Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] building ghc 6.10.1 under amd64 hardened Gentoo



I am looking for help debugging a problem with compiling the latest ghc
6.10.1 on amd64 hardened Gentoo.  I am using the ebuild provided at
code.haskell.org[1].  There are a number of references in the ebuild to
hardened gcc so I presume it has worked for some version of hardened
Gentoo in the past.  The relivant part of the first compile error
message is below.

-----------------------------------------------------------------------------------------------------------------------------
[ebuild     U ] dev-lang/ghc-6.10.1 [6.8.2] USE="-bash-completion
-binary* -doc ghcbootstrap -ghcquickbuild%" 0 kB [0=>1]

./configure --prefix=/usr --host=x86_64-pc-linux-gnu
--mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
--sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64
--build=x86_64-pc-linux-gnu
...
..
checking for nhc98... no
checking for hbc... no
checking for ld... /usr/bin/ld
checking for path to top of build tree...
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/../../../../x86_64-pc-linux-gnu/bin/ld:
pwd.o: relocation R_X86_64_32S against
`ghczmprim_GHCziTypes_ZC_con_info' can not be used when making a shared
object; recompile with -fPIC
pwd.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
./configure: line 3291: utils/pwd/pwd: No such file or directory
configure: error: cannot determine current directory
-----------------------------------------------------------------------------------------------------------------------------

A Google hasn't turned up anything particularly useful, accept
references to possibly related issues with FreeBSD 7.0. with ghc 6.8.2. 
The error appears to be caused by linking object files compiled without
the -fPIC (Position Independent Code[2]) to -fPIC library files.   The
ebuild seems to be filtering the -fPIC flag from the CFLAGS environment
variable, however removing the filter had no effect on the compile failure.

The suggestion I found was to disable the compiling of pwd and use the
system pwd, which the following patch does[3].

-----------------------------------------------------------------------------------------------------------------------------
diff -ur ghc-6.10.1.orig/aclocal.m4 ghc-6.10.1/aclocal.m4
--- ghc-6.10.1.orig/aclocal.m4  2009-01-30 12:56:39.000000000 +0900
+++ ghc-6.10.1/aclocal.m4       2009-01-30 12:57:37.000000000 +0900
@@ -1210,20 +1210,7 @@
 AC_DEFUN([FP_FIND_ROOT],[
 AC_MSG_CHECKING(for path to top of build tree)
 
-dnl This would be
-dnl     make -C utils/pwd clean && make -C utils/pwd
-dnl except we don't want to have to know what make is called. Sigh.
-if test ! -f utils/pwd/pwd && test ! -f utils/pwd/pwd.exe; then
-  cd utils/pwd
-  rm -f *.o
-  rm -f *.hi
-  rm -f pwd
-  rm -f pwd.exe
-  $WithGhc -v0 --make pwd -o pwd
-  cd ../..
-fi
-
-hardtop=`utils/pwd/pwd forwardslash`
+hardtop=`pwd`
-----------------------------------------------------------------------------------------------------------------------------

this got me a bit further but the compile still dies on what looks like
the same error later on

-----------------------------------------------------------------------------------------------------------------------------
cp ifBuildable.hs ifBuildable/
cd ifBuildable && /var/tmp/portage/dev-lang/ghc-6.10.1/work/usr/bin/ghc
-Wall --make ifBuildable -o ifBuildable
[1 of 1] Compiling Main             ( ifBuildable.hs, ifBuildable.o )
Linking ifBuildable ...
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/../../../../x86_64-pc-linux-gnu/bin/ld:
ifBuildable.o: relocation R_X86_64_32S against `stg_CAF_BLACKHOLE_info'
can not be used when making a shared object; recompile with -fPIC
ifBuildable.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [ifBuildable/ifBuildable] Error 1
make[1]: Leaving directory
`/var/tmp/portage/dev-lang/ghc-6.10.1/work/ghc-6.10.1/libraries'
-----------------------------------------------------------------------------------------------------------------------------

I tried with the *ghbootstrap* use flags but got the same result.

The ebuild *binary* use flag worked but that just installs the prebuilt
compiler, which wouldn't run without disabling PAX MPROTECT[4] i.e.

# paxctl -m /usr/lib64/ghc-6.10.1/ghc

Is anyone else running ghc-6.10.1 on a similar system?  This is starting
to look like major build system surgery rather the minor adjustments.

Cheers,

Edward

1. http://code.haskell.org/gentoo/gentoo-haskell/dev-lang/ghc/
2. http://www.gentoo.org/proj/en/hardened/pic-guide.xml
3. it is obviously necessary to also rerun autoconf after patching the
file for the changes to take effect.
4. http://pax.grsecurity.net/docs/mprotect.txt


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links