Still trying to build unregisterised for FreeBSD/amd64
gwright at comcast.net
Thu Mar 8 11:25:39 EST 2007
I have made some progress in compiling ghc-6.6 unregisterised for
but I am stuck again.
To get the build on the host (freebsd/i386) to go through, I had to
fix up Linker.c so
that it would build. (Linker.c seems to define at least one utility
by the rts, markRootPtrTable.) The instruction on the wiki to,
"Don't worry if the build falls
over in the RTS, we don't need the RTS yet," seems incorrect for
ghc-6.6 at least.
If the build fails in the rts, trying to proceed further just leads
to more errors.
I fixed up Linker.c by replacing the calls to mmap (which will need
fixing up anyway
on FreeBSD/amd64) with MAP_FAILED and copying the definitions of four
types for X86_64 from machine/elf.h on the target into
build on the host complained that R_X86_64_64, R_X86_64_PC32,
and R_X86_64_32S were undefined.)
With this change, the build on the host was able to complete.
Collecting the .hc files
works too, but the Makefile is out of date and references a few files
that no longer
exist. With a little hand editing, this is fixed and I have what I
believe is a good set
of .hc files.
Over on the target, I unpack the fresh ghc-6.6-src.tar.bz2 and drop
the .hc files on top
of it. On FreeBSD, gmp is usually installed by the ports system in /
so I preface invocations of configure in distrib/hc-build by
so that the installed gmp is picked up in the configuration. I also
to add -L/usr/local/lib to HC_LD_BOOT_OPTS, and also add
-lHSregex-compat -lHSregex-posix -lHSregex-base
to HC_BOOT_LIBS. The directories to find the regex libraries also
get added to
I also have to delete cabal-setup from the SUBDIRS in libraries/Cabal/
Otherwise the build fails complaining that there is no rule to make
I also have to change libraries/base/Makefile to not try to build
Prim.hs. It seems
that when booting from .hc files, PrimopWrappers.hs does not in fact
on Prim.hs; instead, PrimopWrappers.hs is not really used since we have
PrimopWrappers.hc copied over from the host. (Without this change
tries to invoke the yet unbuilt genprimopcode program to build Prim.hs.)
With these changes, distrib/hc-build is ready to roll. It chugs
along happily until
it tries to build Linker.c (which I have copied over from the host,
so it has
the changes that I made there) and then ghc-inplace segfaults:
../compiler/ghc-inplace -optc-O -optc-Wall -optc-W -optc-Wstrict-
prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -
optc-Winline -optc-Waggregate-return -optc-Wbad-function-cast -optc-
I../includes -optc-I. -optc-Iparallel -optc-DCOMPILING_RTS -optc-
fomit-frame-pointer -optc-fno-strict-aliasing -H16m -O -optc-O2 -
static -I. -#include HCIncludes.h -fvia-C -dcmm-lint -c Linker.c -
Segmentation fault (core dumped)
gmake: *** [Linker.o] Error 139
gmake: Leaving directory `/tmp/ghc-6.6/rts'
I noticed that a year and a half ago when Wilhelm Kloke was porting
freebsd/amd64 he remarked that Linker.c had to be deleted. If I
from the target, the build just fails earlier, when genapply is being
of missing symbols:
== gmake all -wr;
gcc -x c GenApply.hc -o GenApply.o -c -O -fomit-frame-pointer -fno-
asynchronous-unwind-tables -fno-unit-at-a-time -fno-builtin -DNO_REGS
-DUSE_MINIINTERPRETER -D__GLASGOW_HASKELL__=606 -O -I/tmp/ghc-6.6/
includes -I/tmp/ghc-6.6/libraries/base/include -I/tmp/ghc-6.6/
libraries/unix/include -I/tmp/ghc-6.6/libraries/parsec/include -I/
tmp/ghc-6.6/libraries/readline/include -I. `echo | sed 's/^$/-
gcc -o genapply -fomit-frame-pointer -fno-asynchronous-unwind-tables
-fno-unit-at-a-time -fno-builtin -DNO_REGS -DUSE_MINIINTERPRETER -
D__GLASGOW_HASKELL__=606 -O -I/tmp/ghc-6.6/includes -I/tmp/ghc-6.6/
libraries/base/include -I/tmp/ghc-6.6/libraries/unix/include -I/tmp/
include -L/tmp/ghc-6.6/rts -L/tmp/ghc-6.6/libraries/base -L/tmp/
ghc-6.6/libraries/base/cbits -L/tmp/ghc-6.6/libraries/haskell98 -L/
tmp/ghc-6.6/libraries/parsec -L/tmp/ghc-6.6/libraries/regex-base -L/
posix -L/tmp/ghc-6.6/libraries/Cabal -L/usr/local/lib -L/tmp/ghc-6.6/
libraries/template-haskell -L/tmp/ghc-6.6/libraries/readline -L/tmp/
ghc-6.6/libraries/unix -L/tmp/ghc-6.6/libraries/unix/cbits -u
"GHCziBase_Izh_static_info" -u "GHCziBase_Czh_static_info" -u
"GHCziFloat_Fzh_static_info" -u "GHCziFloat_Dzh_static_info" -u
"GHCziPtr_Ptr_static_info" -u "GHCziWord_Wzh_static_info" -u
"GHCziInt_I8zh_static_info" -u "GHCziInt_I16zh_static_info" -u
"GHCziInt_I32zh_static_info" -u "GHCziInt_I64zh_static_info" -u
"GHCziWord_W8zh_static_info" -u "GHCziWord_W16zh_static_info" -u
"GHCziWord_W32zh_static_info" -u "GHCziWord_W64zh_static_info" -u
"GHCziStable_StablePtr_static_info" -u "GHCziBase_Izh_con_info" -u
"GHCziBase_Czh_con_info" -u "GHCziFloat_Fzh_con_info" -u
"GHCziFloat_Dzh_con_info" -u "GHCziPtr_Ptr_con_info" -u
"GHCziStable_StablePtr_con_info" -u "GHCziBase_False_closure" -u
"GHCziBase_True_closure" -u "GHCziPack_unpackCString_closure" -u
"GHCziWeak_runFinalizzerBatch_closure" -u "__stginit_Prelude"
GenApply.o -lHSreadline -lHStemplate-haskell -lHSunix -
lHSunix_cbits -lHSCabal -lHSregex-compat -lHSregex-posix -lHSregex-
base -lHShaskell98 -lHSrts -lHSbase -lHSbase_cbits -lHSparsec -lgmp -lm
/tmp/ghc-6.6/rts/libHSrts.a(GC.o)(.text+0x779): In function
: undefined reference to `markRootPtrTable'
: undefined reference to `hs_free_stable_ptr'
: undefined reference to `hs_free_stable_ptr'
: undefined reference to `newSpark'
gmake: *** [genapply] Error 1
gmake: *** [all] Error 1
gmake: Leaving directory `/tmp/ghc-6.6/utils'
I am wondering what to try next. Could ghc-inplace on the target be
of differences in say, ptr sizes on the host versus the target?
Could I fool the host build into
using 64 bit pointers by replacing explicit pointers with "long long"
integers? Or should
I try building a set of .hc files on a 64 bit linux host and use
those to bootstrap the freebsd/amd64
Any help would be appreciated. Especially useful would be any
comments on which parts
of the instructions can be trusted and which may be bitrotted and
More information about the Glasgow-haskell-users