Opened 6 years ago

Closed 6 years ago

#5033 closed bug (worksforme)

GHC 7.0.2 does not build on OS X 10.5.

Reported by: nominolo Owned by:
Priority: normal Milestone:
Component: Build System Version: 7.0.2
Keywords: Cc: pho@…
Operating System: MacOS X Architecture: x86
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Since the binary release of 7.0.2 for OS X doesn't work on 10.5, I tried building it from source, which fails with this:

"inplace/bin/ghc-stage1" -optc-I/Users/nominolo/code/ghc/7.0.2/libraries/integer-gmp/gmp -optc-Ilibraries/integer-gmp/. -optc-I"/Users/nominolo/code/ghc/7.0.2/includes" -optc-I"/Users/nominolo/code/ghc/7.0.2/libffi/dist-install/build" -fPIC -dynamic  -H32m -O    -package-name integer-gmp- -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/.    -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-  -package-name integer-gmp -XCPP -XMagicHash -XUnboxedTuples -XNoImplicitPrelude -XForeignFunctionInterface -XUnliftedFFITypes -no-user-package-conf -rtsopts -O2 -XGenerics     -c libraries/integer-gmp/cbits/cbits.c -o libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o
"inplace/bin/ghc-stage1" libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o  libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o    libraries/integer-gmp/gmp/objs/*.o `/usr/bin/find libraries/integer-gmp/dist-install/build -name "*_stub.dyn_o" -print` -shared -dynamic -dynload deploy -dylib-install-name /Users/nominolo/local/lib/ghc-7.0.2/`basename "libraries/integer-gmp/dist-install/build/libHSinteger-gmp-" | sed 's/^libHS//;s/[-]ghc.*//'`/`basename "libraries/integer-gmp/dist-install/build/libHSinteger-gmp-"` -no-auto-link-packages -package ghc-prim- -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-
ld: absolute addressing (perhaps -mdynamic-no-pic) used in ___gmpn_add_nc from libraries/integer-gmp/gmp/objs/add_n.o not allowed in slidable image
collect2: ld returned 1 exit status
make[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-] Error 1
make: *** [all] Error 2

Change History (3)

comment:1 Changed 6 years ago by PHO

Cc: pho@… added

comment:2 Changed 6 years ago by nominolo

Okay, it seems like the GMP C library is not compilled with PIC defined. Here is part of the hand-coded assembly for add:

	subl	%eax,%edx		C ... enter the loop
	shrl	$2,%eax			C restore previous value

	C Calculate start address in loop for PIC.  Due to limitations in
	C old gas, LF(M4_function_n,oop)-L(0a)-3 cannot be put into the leal
	call	L(0a)
L(0a):	leal	(%eax,%eax,8),%eax
	addl	(%esp),%eax
	addl	$L(oop)-L(0a)-3,%eax
	addl	$4,%esp
	C Calculate start address in loop for non-PIC.
	leal	L(oop)-3(%eax,%eax,8),%eax

	C These lines initialize carry from the 5th parameter.  Should be
	C possible to simplify.
	pushl	%ebp		FRAME_pushl()
	movl	PARAM_CARRY,%ebp

If we now look at the output from otool -tv add_n.o we see that it apparently uses the code for non-PIC:

00000026	subl	%eax,%edx
00000028	shrl	$0x02,%eax

0000002b	leal	0x0000007d(%eax,%eax,8),%eax

00000032	pushl	%ebp
00000033	movl	0x20(%esp),%ebp

comment:3 Changed 6 years ago by nominolo

Resolution: worksforme
Status: newclosed

Upgrading to XCode 3.1.4 (from 3.0 it seems) fixed it. (XCode version reported at the top of the file /Developer/About\ Xcode\ Tools.pdf. Closing as worksforme.

Note: See TracTickets for help on using tickets.