Porting the GHC to GNU/Hurd
Thomas Schwinge
schwinge-list-ghc-users at nic-nac-project.de
Mon May 9 12:56:14 EDT 2005
> >> On 10 April 2005 14:20, I wrote:
> >>> Is someone aware of any efforts to port the GHC to GNU/Hurd?
> >>> If not, I'd like to give that a try.
I succeeded. :-)
I did the bootstrap using a ghc-6-4-branch checkout, dated
20050422T204743Z.
On Thu, Apr 21, 2005 at 10:44:18AM +0100, Simon Marlow wrote:
> Just follow the instructions in section 10.2 of the Building Guide:
The rest of this email are my notes of the bootstrapping process and a
few tiny patches. I was following
<URL:http://www.haskell.org/ghc/docs/latest/html/building/sec-porting-ghc.html>
and distrib/hc_build to get the first build done.
I had to patch configure.ac using the attached configure.ac.patch and
regenerate configure to make it recognize the system.
Should HostOS_CPP perhaps be set to 'GNU/Hurd' (or similar) instead of
'gnu'?
host system
#v+
$ make hc-file-bundle Project=Ghc
[...]
echo ghc-6.4/ghc/compiler/main/ParsePkgConf.hs >> hc-files-to-go
echo ghc-6.4/libraries/haskell-src/Language/Haskell/Parser.hs >> hc-files-to-go
tar czf ghc-6.4-i386-unknown-gnu-hc.tar.gz `cat hc-files-to-go`
tar: ghc-6.4/ghc/rts/AutoApply_thr_p.hc: Cannot stat: No such file or directory
tar: ghc-6.4/ghc/rts/AutoApply_thr.hc: Cannot stat: No such file or directory
tar: ghc-6.4/ghc/rts/AutoApply_debug.hc: Cannot stat: No such file or directory
tar: ghc-6.4/libraries/haskell-src/Language/Haskell/Parser.hs: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
make: *** [hc-file-bundle] Error 2
#v-
I continued with the incomplete tarball of .hc files and didn't have any
problems related to that (AFAICT), apart from having to unpack
happy-1.15/happy into the build tree, reconfigure and run
'make -C happy boot all' somewhen later (see below).
target system
#v+
$ make -C ghc boot
[...]
mkdir stage1/iface
mkdir stage1/cmm
Creating main/Config.hs ...
done.
Creating stage1/ghc_boot_platform.h...
Done.
g cmm/CmmLex.x
make[1]: g: Command not found
make[1]: [cmm/CmmLex.hs] Error 127 (ignored)
RTS -K2m -RTS -agc cmm/CmmParse.y
make[1]: RTS: Command not found
make[1]: *** [cmm/CmmParse.hs] Error 127
make: *** [boot] Error 1
make: Leaving directory `/var/tmp/build/ghc/ghc-6.4-branch/ghc'
#v-
I set HAPPY and ALEX to /bin/true in mk/config.mk to work around that.
#v+
$ make -C ghc all
[...]
gcc -o stage1/ghc-6.4 -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -O -I/var/tmp/build/ghc/ghc-6.4-branch/ghc/includes -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/unix/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/parsec/include -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -Iparser -I. -O -D__GLASGOW_HASKELL__=604 -L/var/tmp/build/ghc/ghc-6.4-branch/ghc/rts -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/base -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/cbits -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/haskell98 -u "GHCziBase_Izh_static_info" [...] stage1/utils/OrdList.o stage1/utils/Outputable.o stage1/utils/Panic.o stage1/utils/Pretty.o stage1/utils/PrimPacked.o stage1/utils/StringBuffer.o stage1/utils/UnicodeUtil.o stage1/utils/UniqFM.o stage1/utils/UniqSet.o stage1/utils/Util.o stage1/parser/hschooks.o -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm -ldl
/bin/ld: cannot find -lHSCabal
collect2: ld returned 1 exit status
make[1]: *** [stage1/ghc-6.4] Error 1
make: *** [all] Error 1
#v-
I created the attached mk_bootstrap.mk_HC_BOOT_LIBS.patch to work around
that.
#v+
$ make -C ghc all
[...]
gcc -O -I/var/tmp/build/ghc/ghc-6.4-branch/ghc/includes -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/unix/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/parsec/include -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -c cbits/directory.c -o cbits/directory.o
cbits/directory.c:11:23: directory.h: No such file or directory
make[2]: *** [cbits/directory.o] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1
make: Leaving directory `/var/tmp/build/ghc/ghc-6.4-branch/ghc'
#v-
I created the attached ghc_lib_compat_Makefile_SRC_CC_OPTS.patch to work
around that.
#v+
$ HappyCmd=`pwd`/distrib/fake-happy ./configure --with-ghc=`pwd`/ghc/compiler/ghc-inplace
[...]
checking for ghc-pkg... no
checking for happy... /var/tmp/build/ghc/ghc-6.4-branch/distrib/fake-happy
checking for version of happy... 1.10
checking for haddock... no
checking for alex... no
checking for version of alex... grep: ./alex/mk/version.mk: No such file or directory
configure: error: Alex version 2.0 or later is required to compile GHC.
#v-
I put alex-2.0.1/alex and happy-1.15/happy into my build tree and
reconfigured without having HappyCmd set.
#v+
$ make -C libraries boot
[...]
../../ghc/utils/hsc2hs/hsc2hs-inplace -Iinclude -I. Network/BSD.hsc
BSD.hsc: In function `main':
BSD.hsc:558: error: `PATH_MAX' undeclared (first use in this function)
BSD.hsc:558: error: (Each undeclared identifier is reported only once
BSD.hsc:558: error: for each function it appears in.)
make: *** [Network/BSD.hs] Error 1
make: Leaving directory `/var/tmp/build/ghc/ghc-6.4-branch/libraries'
#v-
... which is correct as the Hurd does not limit the length of paths and
thus doesn't have PATH_MAX defined. Someone writing GHC code also was
aware of that, see ghc/lib/compat/cbits/directory.c and
libraries/base/include/HsBase.h.
The correct solution, however, is not to hard-limit PATH_MAX to 4096 in
that case, but decide / allocate arrays / etc. dynamically where needed.
Unfortunately I'm not able to fix that as I don't know any Haskell, yet.
I created the attached libraries_network_Network_BSD.hsc.patch to work
around that.
The same applies to the attached
libraries_unix_System_Posix_Files.hsc.patch.
Creating the attached ghc_driver_mangler_ghc-asm.lprl.patch, I made the
mangler work (I think, at least).
I rebuilt GHC from clean sources and used that new version to build
darcs <URL:http://darcs.net/>--it's working perfectly.
Regards,
Thomas
-------------- next part --------------
Index: configure.ac
===================================================================
RCS file: /cvs/fptools/configure.ac,v
retrieving revision 1.106.2.4
diff -u -r1.106.2.4 configure.ac
--- configure.ac 8 Mar 2005 09:31:32 -0000 1.106.2.4
+++ configure.ac 25 Apr 2005 17:45:02 -0000
@@ -188,6 +188,15 @@
HostVendor_CPP='unknown'
HostOS_CPP='linux'
;;
+i[[3456]]86-*-gnu*)
+ HostPlatform=i386-unknown-gnu
+ TargetPlatform=i386-unknown-gnu
+ BuildPlatform=i386-unknown-gnu
+ HostPlatform_CPP=i386_unknown_gnu
+ HostArch_CPP=i386
+ HostVendor_CPP=unknown
+ HostOS_CPP=gnu
+ ;;
i[[3456]]86-*-freebsd[[3-9]]*) # FreeBSD 3.0+ uses ELF
HostPlatform=i386-unknown-freebsd # hack again
TargetPlatform=i386-unknown-freebsd
-------------- next part --------------
#v+
gcc -o stage1/ghc-6.4 -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -O -I/var/tmp/build/ghc/ghc-6.4-branch/ghc/includes -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/unix/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/parsec/include -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -Iparser -I. -O -D__GLASGOW_HASKELL__=604 -L/var/tmp/build/ghc/ghc-6.4-branch/ghc/rts -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/base -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/cbits -L/var/tmp/build/ghc/ghc-6.4-branch/libraries/haskell98 -u "GHCziBase_Izh_static_info" [...] stage1/utils/OrdList.o stage1/utils/Outputable.o stage1/utils/Panic.o stage1/utils/Pretty.o stage1/utils/PrimPacked.o stage1/utils/StringBuffer.o stage1/utils/UnicodeUtil.o stage1/utils/UniqFM.o stage1/utils/UniqSet.o stage1/utils/Util.o stage1/parser/hschooks.o -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm -ldl
/bin/ld: cannot find -lHSCabal
collect2: ld returned 1 exit status
make[1]: *** [stage1/ghc-6.4] Error 1
make: *** [all] Error 1
#v-
--- ghc-6.4-branch.orig/mk/bootstrap.mk 2005-01-27 14:00:14.000000000 +0100
+++ ghc-6.4-branch/mk/bootstrap.mk 2005-04-26 07:13:40.000000000 +0200
@@ -97,14 +97,14 @@
$(DASH_L_GHC_RTS_GMP_DIR) \
-L$(FPTOOLS_TOP_ABS)/libraries/base \
-L$(FPTOOLS_TOP_ABS)/libraries/base/cbits \
- -L$(FPTOOLS_TOP_ABS)/libraries/haskell98
+ -L$(FPTOOLS_TOP_ABS)/libraries/haskell98 \
+ -L$(FPTOOLS_TOP_ABS)/libraries/parsec \
+ -L$(FPTOOLS_TOP_ABS)/libraries/Cabal
ifeq "$(GhcWithInterpreter)" "YES"
HC_BOOT_LD_OPTS += \
-L$(FPTOOLS_TOP_ABS)/libraries/template-haskell \
-L$(FPTOOLS_TOP_ABS)/libraries/readline \
- -L$(FPTOOLS_TOP_ABS)/libraries/parsec \
- -L$(FPTOOLS_TOP_ABS)/libraries/Cabal \
-L$(FPTOOLS_TOP_ABS)/libraries/unix \
-L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
endif
-------------- next part --------------
#v+
[...]
../../../glafp-utils/mkdependC/mkdependC -f .depend -I../../includes -- -O
-- cbits/directory.c cbits/rawSystem.c
cbits/directory.c:11:23: directory.h: No such file or directory
cbits/directory.c:11:23: directory.h: No such file or directory
/usr/local/bin/ghc -M -optdep-f -optdep.depend -osuf o -H16m -O -I. -Iinclude -Rghc-timing -I../../../libraries -fglasgow-exts -no-recomp Compat/Directory.hs Compat/RawSystem.hs
[...]
#v-
#v+
[...]
gcc -O -I/var/tmp/build/ghc/ghc-6.4-branch/ghc/includes -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/base/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/unix/include -I/var/tmp/build/ghc/ghc-6.4-branch/libraries/parsec/include -fno-defer-pop -fomit-frame-pointer -DNO_REGS -DUSE_MINIINTERPRETER -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=604 -c cbits/directory.c -o cbits/directory.o
cbits/directory.c:11:23: directory.h: No such file or directory
make[2]: *** [cbits/directory.o] Error 1
make[1]: *** [all] Error 1
make: *** [all] Error 1
make: Leaving directory `/var/tmp/build/ghc/ghc-6.4-branch/ghc'
#v-
--- ghc-6.4-branch.orig/ghc/lib/compat/Makefile 2005-03-21 13:13:37.000000000 +0100
+++ ghc-6.4-branch/ghc/lib/compat/Makefile 2005-04-26 17:25:02.000000000 +0200
@@ -20,6 +20,7 @@
# Needed so that the libraries can #include relative to this directory.
SRC_HC_OPTS += -I. -Iinclude
+SRC_CC_OPTS += -I. -Iinclude
UseGhcForCc = YES
-------------- next part --------------
#v+
[...]
../../ghc/utils/hsc2hs/hsc2hs-inplace -Iinclude -I. Network/BSD.hsc
BSD.hsc: In function `main':
BSD.hsc:558: error: `PATH_MAX' undeclared (first use in this function)
BSD.hsc:558: error: (Each undeclared identifier is reported only once
BSD.hsc:558: error: for each function it appears in.)
make: *** [Network/BSD.hs] Error 1
make: Leaving directory /var/tmp/build/ghc/ghc-6.4-branch/libraries'
#v-
--- ghc-6.4-branch.orig/libraries/network/Network/BSD.hsc 2005-02-07 13:34:44.000000000 +0100
+++ ghc-6.4-branch/libraries/network/Network/BSD.hsc 2005-04-30 16:47:42.000000000 +0200
@@ -25,6 +25,12 @@
-- NOTE: ##, we want this interpreted when compiling the .hs, not by hsc2hs.
##include "../../base/include/Typeable.h"
+#if defined(HAVE_READLINK) && !defined(PATH_MAX)
+-- PATH_MAX is not defined on systems with unlimited path length.
+-- Ugly. Fix this.
+#define PATH_MAX 4096
+#endif
+
module Network.BSD (
-- * Host names
-------------- next part --------------
#v+
[...]
../../ghc/utils/hsc2hs/hsc2hs-inplace -Iinclude -I../../mk/ -I. System/Posix/Files.hsc
Files.hsc: In function `main':
Files.hsc:354: error: `PATH_MAX' undeclared (first use in this function)
Files.hsc:354: error: (Each undeclared identifier is reported only once
Files.hsc:354: error: for each function it appears in.)
make[2]: *** [System/Posix/Files.hs] Error 1
make[1]: *** [boot] Error 1
make[1]: Leaving directory `/var/tmp/build/ghc/ghc-6.4-branch/libraries'
make: *** [build] Error 1
#v-
--- ghc-6.4-branch.orig/libraries/unix/System/Posix/Files.hsc 2005-01-06 12:27:26.000000000 +0100
+++ ghc-6.4-branch/libraries/unix/System/Posix/Files.hsc 2005-05-06 15:50:00.000000000 +0200
@@ -349,6 +349,12 @@
-- ToDo: should really use SYMLINK_MAX, but not everyone supports it yet,
-- and it seems that the intention is that SYMLINK_MAX is no larger than
-- PATH_MAX.
+#if !defined(PATH_MAX)
+-- PATH_MAX is not defined on systems with unlimited path length.
+-- Ugly. Fix this.
+#define PATH_MAX 4096
+#endif
+
readSymbolicLink :: FilePath -> IO FilePath
readSymbolicLink file =
allocaArray0 (#const PATH_MAX) $ \buf -> do
-------------- next part --------------
--- ghc-6.4-branch.orig/ghc/driver/mangler/ghc-asm.lprl 2005-03-08 14:33:14.000000000 +0100
+++ ghc-6.4-branch/ghc/driver/mangler/ghc-asm.lprl 2005-05-02 22:35:06.000000000 +0200
@@ -160,12 +160,12 @@
$T_HDR_vector = "\.text\n\t\.align 2\n"; # NB: requires padding
#--------------------------------------------------------#
- } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd|netbsd|openbsd)$/ ) {
+ } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|gnu|freebsd|netbsd|openbsd)$/ ) {
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
$T_US = ''; # _ if symbols have an underscore on the front
$T_PRE_APP = # regexp that says what comes before APP/NO_APP
- ($TargetPlatform =~ /-(linux|freebsd|netbsd|openbsd)$/) ? '#' : '/' ;
+ ($TargetPlatform =~ /-(linux|gnu|freebsd|netbsd|openbsd)$/) ? '#' : '/' ;
$T_CONST_LBL = '^\.LC(\d+):$'; # regexp for what such a lbl looks like
$T_POST_LBL = ':';
$T_X86_PRE_LLBL_PAT = '\.L';
More information about the Glasgow-haskell-users
mailing list