I've compiled GCC 4.01 from Apple's source code:
http://www.opensource.apple.com/darwinsource/10.5/
However that does not include the linker. The linker used on
10.5 is actually from the ld64 project. Which looks to be a complete rewrite of ld from the cctools project. The ld64 source is available from the site linked above and can be easily compiled for debug. That said, the ld from cctools is still available on
10.5 and has the path /usr/bin/ld_classic.
I'm currently swamped with work but have been slowly debugging ld64 to see why it fails to initialize a data member which results in a NULL pointer dereference. Still, the only thing I have of interest is a backtrace. Which isn't enough to tell me if the problem is due to a bug in ld64 or malformed input files. Although I'd argue all crashes are bugs and ld64 should be providing an error message on malformed input.
#0 0x000222ac in ObjectFile::Section::getBaseAddress (this=0x0) at ObjectFile.h:182
182 uint64_t getBaseAddress() { return fBaseAddress; }
(gdb) bt
#0 0x000222ac in ObjectFile::Section::getBaseAddress (this=0x0) at
ObjectFile.h:182
#1 0x000224a0 in ObjectFile::Atom::getAddress (this=0x6decb0) at ObjectFile.h:269
#2 0x000c3a30 in mach_o::executable::Writer<ppc>::addObjectRelocs_powerpc (this=0x6f65a0, atom=0x6dea30, ref=0x6f34a0) at
MachOWriterExecutable.hpp:2742
#3 0x0001309c in mach_o::executable::Writer<ppc>::addObjectRelocs (this=0x6f65a0, atom=0x6dea30, ref=0x6f34a0) at MachOWriterExecutable.hpp:2678
#4 0x001ab3e4 in mach_o::executable::Writer<ppc>::buildObjectFileFixups (this=0x6f65a0) at
MachOWriterExecutable.hpp:3065
#5 0x001be094 in mach_o::executable::Writer<ppc>::buildFixups (this=0x6f65a0) at MachOWriterExecutable.hpp:2398
#6 0x001be108 in mach_o::executable::Writer<ppc>::buildLinkEdit (this=0x6f65a0) at
MachOWriterExecutable.hpp:1834
#7 0x001be238 in mach_o::executable::Writer<ppc>::write (this=0x6f65a0, atoms=@0xbffef940, stabs=@0xbffef9c4, entryPointAtom=0x0, dyldHelperAtom=0x0, createUUID=false, canScatter=false, cpuConstraint=ObjectFile::Reader::kCpuAny, biggerThanTwoGigs=false) at
MachOWriterExecutable.hpp:1814
#8 0x0000fec4 in Linker::writeOutput (this=0xbffef608) at /Users/coconnor/Development/External_projects/Darwin/ld64-77/src/ld.cpp:2700
#9 0x0001f5b0 in Linker::link (this=0xbffef608) at /Users/coconnor/Development/External_projects/Darwin/ld64-77/src/ld.cpp:585
#10 0x0002113c in main (argc=465, argv=0xbffefb88) at /Users/coconnor/Development/External_projects/Darwin/ld64-77/src/ld.cpp:3568
(gdb) up 10
#10 0x0002113c in main (argc=465, argv=0xbffefb88) at /Users/coconnor/Development/External_projects/Darwin/ld64-77/src/ld.cpp:3568
3568 ld.link();
So I decided to try and route around the ld/collect2 problems with ghc-6.8.1 not
working on powerpc OS X 10.5
OS X 10.5 (Leopard) uses XCode 3.0 which has a gcc-4.0 toolchain.
So I try to get another gcc & binutils from macports. This failed. All of
gcc40 gcc41 gcc42 and gcc43 failed to compile successfully with macports.
So I switched to trying fink, which offers gcc-4.2.2 and this did compile and
install. Hooray.
Unfortunately, using ghc-6.6.1 (from when I ran OS 10.4 Tiger) with gcc-4.2.2
does not work when compiling ghc-6.8.1 (at least on this platform).
> ------------------------------------------------------------------------
> == make boot -r;
> in /Users/chrisk/Documents/projects/haskell/build/ghc-6.8.1/ghc-6.8.1/compiler
> ------------------------------------------------------------------------
> ../utils/mkdirhier/mkdirhier stage1
> for i in utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn vectorise specialise simplCore stranal stgSyn simplStg codeGen main profiling parser cprAnalysis ndpFlatten iface cmm nativeGen; do \
> ../utils/mkdirhier/mkdirhier stage1/$i; \
> done
> Creating stage1/ghc_boot_platform.h...
> Done.
> ../utils/genprimopcode/genprimopcode --primop-tag < prelude/primops.txt > primop-tag.hs-incl
> /bin/sh: line 1: 59384 Illegal instruction ../utils/genprimopcode/genprimopcode --primop-tag < prelude/primops.txt > primop-tag.hs-incl
> make[1]: *** [primop-tag.hs-incl] Error 132
> make[1]: *** Deleting file `primop-tag.hs-incl'
> make: *** [stage1] Error 1
Running "../utils/genprimopcode/genprimopcode --primop-tag" produces "Illegal
instruction"
There were other odd messages during the make,such as in this early output:
> ------------------------------------------------------------------------
> == make boot -r;
> in /Users/chrisk/Documents/projects/haskell/build/ghc- 6.8.1/ghc-6.8.1/compat
> ------------------------------------------------------------------------
> ../utils/mkdependC/mkdependC -f .depend -I. -Iinclude -I../includes -- -O -I. -Iinclude -D__GHC_PATCHLEVEL__=1 -I../libraries/base/cbits -I../libraries/base/include -- cbits/directory.c cbits/rawSystem.c cbits/unicode.c
> /usr/local/bin/ghc -M -optdep-f -optdep.depend -osuf o -H16m -O -w -I. -Iinclude -Rghc-timing -ignore-package Cabal -ignore-package filepath -I../libraries -fglasgow-exts -no-recomp Compat/Directory.hs Compat/RawSystem.hs Compat/Unicode.hs Distribution/Compat/Directory.hs Distribution/Compat/Exception.hs Distribution/Compat/Map.hs Distribution/Compat/RawSystem.hs Distribution/Compat/ReadP.hs Distribution/Compat/TempFile.hs Distribution/Compiler.hs Distribution/GetOpt.hs Distribution/InstalledPackageInfo.hs Distribution/License.hs Distribution/Package.hs Distribution/ParseUtils.hs Distribution/Simple/Program.hs Distribution/Simple/Utils.hs Distribution/System.hs Distribution/Verbosity.hs Distribution/Version.hs Language/Haskell/Extension.hs System/FilePath.hs System/FilePath/Posix.hs System/FilePath/Windows.hs Trace/Hpc/Mix.hs Trace/Hpc/Tix.hs Trace/Hpc/Util.hs
> <<ghc: 36490248 bytes, 5 GCs, 130248/130248 avg/max bytes residency (1 samples), 16M in use, 0.01 INIT (0.01 elapsed), 0.22 MUT (4.47 elapsed), 0.06 GC (0.43 elapsed) :ghc>>
> make all
> /usr/local/bin/ghc -H16m -O -w -I. -Iinclude -Rghc-timing -ignore-package Cabal -ignore-package filepath -I../libraries -fglasgow-exts -no-recomp -c System/FilePath/Posix.hs -o System/FilePath/Posix.o -ohi System/FilePath/Posix.hi
> gcc: unrecognized option '-no-cpp-precomp'
>
> /var/folders/CT/CTQA-fMz2RWZwk+BYmhr7U++-Eg/-Tmp-//ghc64877_0/ghc64877_0.s:6606:0:
> section difference relocatable subtraction expression, "_s2tx_0_alt" minus "_s2tx_info" using a symbol at the end of section will not produce an assembly time constant
>
> /var/folders/CT/CTQA-fMz2RWZwk+BYmhr7U++-Eg/-Tmp-//ghc64877_0/ghc64877_0.s:6606:0:
> use a symbol with a constant value created with an assignment instead of the expression, L_const_sym = _s2tx_0_alt - _s2tx_info
The '-no-cpp-precomp' and 'section difference ...' and 'use a symbol ...'
messages repeat often.
I looked at trac, and can only find the closed ticket
http://hackage.haskell.org/trac/ghc/ticket/1427
relating to gcc-4.2 issues.
Does anyone have suggestions? hints? bad jokes?
--
Chris K
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users