Petr made it. Great!
So I installed debootstrap with aptitude and run:
# cd /srv/chroot # mkdir kfreebsd-i386 # debootstrap --arch=kfreebsd-i386 --include=ghc6 --variant=minbase sid \ kfreebsd-i386/ http://10.0.2.2:9999/debian/
It worked fine. So I mounted /root (where the ghc tree will be) in /srv/chroot/kfreebsd-i386/root with nullfs:
# mount_nullfs /root /srv/chroot/kfreebsd-i386/root
So I changed my sources.list to contain the sid binaries and the source from experimental, so I can grab the latest ghc6:
deb http://10.0.2.2:9999/debian/ sid main deb-src http://10.0.2.2:9999/debian/ experimental main
I tried to download the source from ghc6, but the dpkg-dev package is missing, to extract the source (dpkg-source -x).
# apt-get source ghc6
So I upgraded the system to sid, and installed dpkg-dev.
# dpkg-source -x ghc6_6.12.1-4.dsc
Just noticed that ghc6-6.12.1-4 built on kfreebsd-i386, so I'll try to build from it instead.
# chroot /srv/chroot/kfreebsd-i386 # cat > /etc/apt/sources.list deb http://10.0.2.2:9999/debian sid main deb http://10.0.2.2:9999/debian experimental main # apt-get update # apt-get install aptitude install ghc6/experimental
Trying to build hello world:
# cat 'main = putStrLn "Hello world"' > hello.hs # ghc --make hello.hs
It's giving an error of missing crt1.o. It seems to be a bug in ghc on kfreebsd-i386 of missing dependency on libc0.1-dev. I'll report it latter.
I also need to create the ghc binaries in kfreebsd-amd64. So I wrote /usr/bin/chroot-kfreebsd-i386:
#!/bin/sh chroot /srv/chroot/kfreebsd-i386/ $0 $@
And created the symlinks for all ghc6 binaries:
# for i in ghc ghc-pkg `chroot /srv/chroot/kfreebsd-i386 dpkg -L ghc6 | grep \ ^/usr/bin`; do ln -s /usr/bin/chroot-kfreebsd-i386 $i; done
To build, I'll first install the build-deps.
I used a improved version of the script to install them:
# aptitude install `grep Build-Depends:\ debian/control | cut -d: -f2- | sed \ 's/ghc6,//;s/([^)]*)//g;s/|[^,]*,//g;s/,//g;s/\[[^]]*\]//g'`
pejo@#email@example.com suggested me using the binaries of GHC 6.10.4 available to FreeBSD to build GHC, if they can be run at kfreebsd-amd64. I asked about this in #firstname.lastname@example.org and they said that this would be possible only if the GHC binary is static, or using a chroot. It's not static, so I'll have to use a chroot.
I haven't found any documentation about creating a FreeBSD chroot, but I've found a link about installing FreeBSD on a USB stick, which may have the information I need.
I started mounting the cdrom:
# cd /media # mkdir cdrom # mount -t iso9660 /dev/cdrom cdrom/
Notice that the second time I tried this, the last command gave me:
mount: /dev/cdrom: No such device
So I tried with:
# mount_cd9660 /dev/cdrom cdrom/
And it worked.
Then I created the dir where the chroot will be:
# mkdir -p /srv/chroot/freebsd/
So I started the installation:
# cd cdrom/7.2-RELEASE/base # DESTDIR=/srv/chroot/freebsd ./install.sh
This exits with an error, but the installation works well enough.
To chroot to it, I need to pass /bin/sh as a parameter, since /bin/bash is not available in FreeBSD.
# chroot /srv/chroot/freebsd /bin/sh
Actually, it's better to use tcsh instead of sh, because it has more features, such as tab-completion.
So I'll copy GHC 6.10.4 binaries to the chroot and tried to run it:
Which gave me an error of missing libiconv.so.3.
# pkg_add -r libiconv
This gave me an error:
Error: FTP Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/Latest/libiconv.tbz: Syntax error, command unrecognized pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.2-release/Latest/libiconv.tbz' by URL
which I thought was DNS. So I added the DNS IP to /etc/resolv.conf, from NET, which I'm using:
# cat > /etc/resolv.conf nameserver 220.127.116.11
I got the same error, so I don't think this was the problem. So I searched for the error message and found that I should set FTP_PASSIVE_MDOE variable under a NAT.
So, finally, pkg_add worked.
So I tried to run ghc again, and it gave another error that libgmp.so.8 was missing. So I did as I was supposed:
# pkg_add -r libgmp
But it still complained about libgmp. So I inspected what version of libgmp was installed:
# cd / # find . -name libgmp\*
Notice that the . is needed, since this is not GNU find. The installed version was libgmp.so.7, which is not the needed one.
# pkg_delete libgmp\*
So, as suggested, I set PACKAGESITE to the next version, and got the correct libgmp:
# setenv PACKAGESITE \ ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8-stable/Latest/ # find . -name
And the correct libgmp was there.
Still, when I run ghc, I got the problem:
# ghc-6.10.4-boot/ghc/dist-stage2/build/ghc/ghc --make hello.hs ghc: missing -B<dir> option
I decided to try to install it instead of running from the directory it came:
# ./configure /dev/null: ./configure:: not found checking build system type... amd64-unknown-freebsd7.2 checking host system type... amd64-unknown-freebsd7.2 checking target system type... amd64-unknown-freebsd7.2 Unrecognised platform: amd64-unknown-freebsd7.2
Looking at configure.ac, I notice that the right platform is x86_64-unknown-freebsd. I guess the first one showed is the platform of Debian/kFreeBSD, I'll check for it latter.
So I passed –build, –host and –target as parameters:
# ./configure --host=x86_64-unknown-freebsd --build=x86_64-unknown-freebsd --target=x86_64-unknown-freebsd
And I got an error of missing perl.
As I didn't want to get perl from freebsd8, I unset PACKAGESITE:
# unsetenv PACKAGESITE
And then got perl:
# pkg_add -r perl
After that ./configure worked. But make install gave me the errors:
# make install "Makefile", line 2: Could not find Makefile-vars Unknown modifier '$' "Makefile", line 50: Need an operator "Makefile", line 53: Need an operator make: fatal errors encountered -- cannot continue
I think this is happening because FreeBSD doesn't use GNU make. I'll install it:
# pkg_add -r gmake
But the same error was going, and there was no gmake in the PATH. So I searched for the pkg_info manpage and notice that -L list the files in a package:
# pkg_info -L gmake\*
And got that the binary is in /usr/local/bin. So I did:
# /usr/local/bin/gmake install
Make seems to be working, but I got a problem with swap_pager_getswapspace. So I searched for i in Google and found out that I should have more swap space. So I searched in Google about it and added more swap space.
# dd if=/dev/zero of=/usr/swap0 bs=1024k count=64
It gave me an error, since there's no /dev/zero. I'll do it on the Debian/kFreeBSD:
# dd if=/dev/zero of=/usr/swap0 bs=1024k count=64 # chmod 0600 /usr/swap0
As there was no /etc/rc.conf I just skipped this step.
# mdconfig -a -t vnode -f /usr/swap0 -u 0 # swapon /dev/md0
I got the same problem. So I tried to flush the swap, turning it off and on again, inside the chroot.
# swapoff -a
But it complain of no fstab. So I copied fstab:
# cp /etc/fstab /srv/chroot/etc
# swapoff -a
And it complained about no /dev/ad0s5. So I mounted mounted devfs:
# mount_devfs devfs /srv/chroot/freebsd/dev
Now it worked:
# swapoff -a # swapon -a
But I got the same problems.
I tried also running make install from Debian/kFreeBSD, but it was not possible, since there're some FreeBSD binaries that are run in the process, namely utils/mkdirhier/mkdirhier.
I notice I'm out of free space on disk, so this may be the problem. I think I'll have to re-start the process, since there's no way to grow a qemu image. I'll try to make as much free space as I can first. Ok, I don't think I'll make enought space, so I'll reinstall it and redo the whole process.
I've created a kfreebsd image of 10G. Hope this will be enough. I'll put it in a lvm partition destinated to qemu images.
The current status is described in this bug report. Notice that, in the supplied patch, there's no need to change:
#define _GNU_SOURCE 1
I've set the variable, and copied pwd with success:
$ export CFLAGS=-m64 $ cp /bin/pwd utils/ghc-pwd/ghc-pwd
And I got a problem running:
$ sh boot
The problem was the autoreconf was not found. So I installed autoconf. At this point I remembered of installing ghc6 build-deps, excluding ghc6 itself:
$ aptitude install `grep Build-Depends:\ control | cut -d: -f2- | cut -d, -f1-3,5- | cut -d[ -f1 | sed 's/([^)]*)//g;s/|[^,]*,/,/g;s/,//g'`
So I tried running sh boot again, and it failed because it was missing aclocal. I installed it, and ran sh boot again and now it worked.
kfreebsd-i386 and s390. These had a good build in ghc6 6.10.4, and an error only in 6.12.1.
kfreebsd-i386 was already solved by Petr. Great.
utils/haddock/src/Haddock/Interface/AttachInstances.hs:28:19: Module `TcRnDriver' does not export `tcRnGetInfo'
The related line in utils/haddock/src/Haddock/Interface/AttachInstances.hs is:
import TcRnDriver (tcRnGetInfo)
This function is used only once, in:
-- | Like GHC's getInfo but doesn't cut things out depending on the -- interative context, which we don't set sufficiently anyway. getAllInfo :: GhcMonad m => Name -> m (Maybe (TyThing,Fixity,[Instance])) getAllInfo name = withSession $ \hsc_env -> ioMsg $ tcRnGetInfo hsc_env name
The problem is that this function is only exported by compiler/typecheck/TcRnDriver if GHCI is available:
module TcRnDriver ( #ifdef GHCI tcRnStmt, tcRnExpr, tcRnType, tcRnLookupRdrName, tcRnLookupName, tcRnGetInfo, getModuleExports, #endif