[PATCH] undefined symbols; mixed architecture build
Machine:
Processor: 3.06 GHz Intel Core 2 Duo
Architecture: x86/x86_64
OS: Mac OS X 10.6.5
Bootstrap GHC Info:
ghc --info
[("Project name","The Glorious Glasgow Haskell Compilation System")
,("Project version","7.0.0.20100924")
,("Booter version","6.12.3")
,("Stage","2")
,("Build platform","i386-apple-darwin")
,("Host platform","i386-apple-darwin")
,("Target platform","i386-apple-darwin")
,("Have interpreter","YES")
,("Object splitting","NO")
,("Have native code generator","YES")
,("Have llvm code generator","YES")
,("Use archives for ghci","True")
,("Support SMP","YES")
,("Unregisterised","NO")
,("Tables next to code","YES")
,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn")
,("Leading underscore","YES")
,("Debug on","False")
,("LibDir","/Library/Frameworks/GHC.framework/Versions/700/usr/lib/ghc-7.0.0.20100924")
,("Global Package DB","/Library/Frameworks/GHC.framework/Versions/700/usr/lib/ghc-7.0.0.20100924/package.conf.d")
]
Configure Info:
$./configure --build=x86_64-apple-darwin --host=x86_64-apple-darwin --target=x86_64-apple-darwin
...
Configure completed successfully.
Building GHC version : 7.1.20101203
Build platform : x86_64-apple-darwin
Host platform : x86_64-apple-darwin
Target platform : x86_64-apple-darwin
Bootstrapping using : /usr/bin/ghc
which is version : 7.0.0.20100924
Using GCC : /usr/bin/gcc
which is version : 4.2.1
ld : /usr/bin/ld
Happy : /usr/local/bin/happy (1.18.5)
Alex : /usr/local/bin/alex (2.3.3)
Python : /usr/bin/python
Perl : /usr/bin/perl
dblatex : /usr/local/bin/dblatex
xsltproc : /usr/bin/xsltproc
HsColour : /Users/x/.cabal/bin/HsColour
Building DocBook HTML documentation : YES
Building DocBook PS documentation : YES
Building DocBook PDF documentation : YES
Error:
"/usr/bin/ghc" -H32m -O -package-conf libraries/bootstrapping.conf -i -iutils/unlit/. -iutils/unlit/dist/build -iutils/unlit/dist/build/autogen -Iutils/unlit/dist/build -Iutils/unlit/dist/build/autogen -no-user-package-conf -rtsopts -c utils/unlit/unlit.c -o utils/unlit/dist/build/unlit.o
"inplace/bin/mkdirhier" utils/unlit/dist/build/tmp//.
"/usr/bin/gcc" -o utils/unlit/dist/build/tmp/unlit -m64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -fno-stack-protector utils/unlit/dist/build/unlit.o
ld: warning: in utils/unlit/dist/build/unlit.o, file was built for i386 which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [utils/unlit/dist/build/tmp/unlit] Error 1
make: *** [all] Error 2
Hypothesis: The bootstrap ghc (previous one I had installed on the machine) was built for the i386 architecture and generates only i386 binaries/objects. By telling configure "--build=x86_64-apple-darwin", it assumes not only that the machine arch is x86_64 (which is true and is what I'd intended), but also that the bootstrap ghc targets x86_64 (which is false and I hadn't realized). This sort of problem seems to stem from the advent of multi-architecture machines, which has blurred the lines of native-compilation and cross-compilation.
Temporary Workaround: Have configure verify that the bootstrap ghc's arch (from ghc --info
) matches the specified build arch, and spit out a sensible error if not. Here's a patch:
--- old-ghc/configure.ac 2010-12-06 01:35:13.000000000 -0500
+++ new-ghc/configure.ac 2010-12-06 01:35:13.000000000 -0500
@@ -227,6 +227,13 @@
GHC_CONVERT_OS([$build_os], [BuildOS])
fi
+# Verify that the installed (bootstrap) GHC is capable of generating code for the requested build platform.
+if test "$build" != "$bootstrap_target"
+then
+ echo "The bootstrap GHC ($bootstrap_target) cannot generate code for the given build platform ($build)"
+ exit 1
+fi
+
if test "$host_alias" = ""
then
if test "${WithGhc}" != ""
Permanent Resolution: Allow ghc to directly target multiple platforms.
Trac metadata
Trac field | Value |
---|---|
Version | 7.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Build System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | william.knop.nospam@gmail.com |
Operating system | |
Architecture |