Opened 14 months ago

Last modified 5 months ago

#8910 infoneeded task

cross compiling for x86_64 solaris2

Reported by: maeder Owned by:
Priority: normal Milestone: 7.12.1
Component: Compiler Version: 7.8.1-rc2
Keywords: Cc: kgardas
Operating System: Solaris Architecture: x86_64 (amd64)
Type of failure: Runtime crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

using a "gcc -m64" and a working ghc-7.8.0.20140228-i386-unknown-solaris2 I was able to create a 64Bit ghc-stage2 compiler that can compile a simple hello world program but may create binaries from larger sources that seg-fault. In particular "ghc-stage2 --interactive" seg-faults:

[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
[New LWP    2        ]
[New LWP    3        ]
[New LWP    4        ]
GHCi, version 7.8.0.20140228: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-simple ... linking ... done.
Loading package base ... linking ... 
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x00000000041ea4c0 in ?? ()
(gdb) bt
#0  0x00000000041ea4c0 in ?? ()
#1  0x000000000369cf92 in resolveObjs ()
#2  0x000000000206de99 in cplU_info ()
#3  0x000000000000000c in ?? ()
#4  0x0000000003d0fe09 in base_GHCziEventziManager_zdLr88clvl8_closure ()
#5  0x0000000000000000 in ?? ()

The content of my mk/build.mk is just

INTEGER_LIBRARY = integer-simple

Creating a binary-dist also worked, but unpacking and "gmake install" failed at first because old-time, haskell98 and haskell2010 libraries were missing due to "CrossCompiling" in ghc.mk and the second time with:

Reading package info from "rts/dist/package.conf.install" ... done.
"utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" register libraries/ghc-prim dist-install "/local/home/maeder/haskell/ghc-7.8-x64-static/lib/ghc-7.8.0.20140228/bin/ghc" "/local/home/maeder/haskell/ghc-7.8-x64-static/lib/ghc-7.8.0.20140228/bin/ghc-pkg" "/local/home/maeder/haskell/ghc-7.8-x64-static/lib/ghc-7.8.0.20140228" '' '/local/home/maeder/haskell/ghc-7.8-x64-static' '/local/home/maeder/haskell/ghc-7.8-x64-static/lib/ghc-7.8.0.20140228' '/local/home/maeder/haskell/ghc-7.8-x64-static/share/doc/ghc/html/libraries' NO  
ghc-cabal: Bad interface file: dist-install/build/GHC/CString.hi
magic number mismatch: old/corrupt interface file? (wanted 129742, got
33214052)
gmake[1]: *** [install_packages] Fehler 1

What am I doing wrong for cross compiling? There is also #8378 using a different build host. #8713 also seem to use x86_64 solaris2 libs.

Change History (14)

comment:1 Changed 14 months ago by maeder

The "magic number mismatch" is gone when I use my 64bit-gcc --with-gcc= during configure.
Is there a better way to pass the "-m64" flag to gcc? (Currently, I'm using a separate shell script.)

comment:2 Changed 14 months ago by maeder

I could install my (half-working) ghc-stage2 compiler and tried to bootstrap ghc-7.8.0.20140228.
However, the program

inplace/bin/genprimopcode --data-decl < compiler/stage1/build/primops.txt

seg-faults:

[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x000000000049fb4f in Syntax_getzuattribzuname_info ()
(gdb) bt
#0  0x000000000049fb4f in Syntax_getzuattribzuname_info ()
#1  0x0000000000000000 in ?? ()

comment:3 Changed 14 months ago by kgardas

Well, I've also got that far IIRC in the past and then was blocked by segfaults everywhere. Anyway, back in my head one idea started to appear and that is. Perhaps we don't have ABI right in RTS? Have a look into rts/StgCRun.c -- scroll to x86_64 part and you will see different regs being pushed/poped for MinGW (so Windows). I would seriously suggest to check Solaris AMD64 ABI and check that StgCRun.c is written in correct way for it. If not, then fix it first there.
Also if it's over your head now, perhaps you can at least give a try to testsuite. You can run testsuite with stage1 compiler with IIRC:

make stage=1

and let's see if you get at least few tests passing. See http://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Running for more information about running the testsuite.

Version 0, edited 14 months ago by kgardas (next)

comment:4 Changed 14 months ago by maeder

Obviously, I can create a stage1 cross-compiler showing

 ,("Build platform","i386-unknown-solaris2")
 ,("Host platform","i386-unknown-solaris2")
 ,("Target platform","x86_64-unknown-solaris2")

However, "inplace/bin/ghc-stage2 --info" shows

 ,("Build platform","i386-unknown-solaris2")
 ,("Host platform","x86_64-unknown-solaris2")
 ,("Target platform","x86_64-unknown-solaris2")

which looks wrong, since build and host should be equal.
The problem is that the auto-detected build platform always remains i386-unknown-solaris2.

comment:5 Changed 14 months ago by kgardas

Have you built just stage1 and then configure another ghc tree with this ghc-stage1 passed to --with-ghc param?

comment:6 Changed 14 months ago by maeder

I'm just trying to use the stage1 cross compiler that I installed using "gmake install" (and adding properly named links) to compile another ghc tree. However, if my "gcc -m64" gcc-script is in the path ./configure shows the following, which cannot really work:

checking build system type... x86_64-pc-solaris2.10
checking host system type... x86_64-pc-solaris2.10
checking target system type... x86_64-pc-solaris2.10
Build platform inferred as: i386-unknown-solaris2
Host platform inferred as: i386-unknown-solaris2
Target platform inferred as: i386-unknown-solaris2
GHC build  : i386-unknown-solaris2
GHC host   : i386-unknown-solaris2
GHC target : i386-unknown-solaris2

x86_64-pc-solaris2.10 is canonicalized to i386-unknown-solaris2.

comment:7 Changed 14 months ago by maeder

Even if I add "--build=x86_64-pc-solaris2 --target=x86_64-pc-solaris2 --host=x86_64-pc-solaris2", configure complains:

checking build system type... x86_64-pc-solaris2
checking host system type... x86_64-pc-solaris2
checking target system type... x86_64-pc-solaris2
GHC build  : x86_64-unknown-solaris2
GHC host   : x86_64-unknown-solaris2
GHC target : x86_64-unknown-solaris2
This GHC (/local/home/maeder/haskell/ghc-7.8-x64/bin/ghc) does not generate code for the build platform
   GHC target platform    : i386-unknown-solaris2
   Desired build platform : x86_64-unknown-solaris2

comment:8 Changed 14 months ago by maeder

Running the testsuite with the stage1 cross-compiler fails directly with:

mk/boilerplate.mk:127: *** Cannot find hp2ps ...

comment:9 Changed 10 months ago by kgardas

  • Status changed from new to infoneeded

Could you be so kind and retest with latest HEAD? The commit 6da603213b097a267418d8c14cbfaf0021ac2b2c should solve the issue of x86_64-solaris2 platform but I'm not sure if also with cross-compiling since I used native compilation using SmartOS buildbot binaries.

comment:10 Changed 10 months ago by thoughtpolice

  • Milestone set to 7.10.1

Moving to 7.10.1.

comment:11 Changed 10 months ago by maeder

Ok, I've tried again as follows:

git clone git://git.haskell.org/ghc.git
cd ghc
./sync-all --no-dph get  ## did not work as expected!
rm -rf libraries/dph/
echo "INTEGER_LIBRARY = integer-simple" > mk/build.mk
perl boot
./configure --target=x86_64-pc-solaris2 --with-ld=/usr/ccs/bin/ld --with-nm=/usr/ccs/bin/nm --with-ar=/usr/ccs/bin/ar --with-ranlib=/usr/ccs/bin/ranlib --prefix=/local/home/maeder/haskell/ghc-7.9-x64
gmake
gmake install

After setting some additional links:

-bash-3.2$ ls -l /local/home/maeder/haskell/ghc-7.9-x64/bin
Gesamt 127
lrwxrwxrwx   1 maeder   wimi          35 Jul 15 16:08 ghc -> x86_64-pc-solaris2-ghc-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          35 Jul 15 16:09 ghc-7.9.20140715 -> x86_64-pc-solaris2-ghc-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          39 Jul 15 16:09 ghc-pkg -> x86_64-pc-solaris2-ghc-pkg-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          39 Jul 15 16:10 ghc-pkg-7.9.20140715 -> x86_64-pc-solaris2-ghc-pkg-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          17 Jul 15 16:02 ghci -> ghci-7.9.20140715
-rwxr-xr-x   1 maeder   wimi         103 Jul 15 16:02 ghci-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          24 Jul 15 16:02 haddock -> haddock-ghc-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          25 Jul 15 16:10 hsc2hs -> x86_64-pc-solaris2-hsc2hs
lrwxrwxrwx   1 maeder   wimi          19 Jul 15 16:02 runghc -> runghc-7.9.20140715
lrwxrwxrwx   1 maeder   wimi           6 Jul 15 16:02 runhaskell -> runghc
lrwxrwxrwx   1 maeder   wimi          35 Jul 15 16:02 x86_64-pc-solaris2-ghc -> x86_64-pc-solaris2-ghc-7.9.20140715
-rwxr-xr-x   1 maeder   wimi         428 Jul 15 16:02 x86_64-pc-solaris2-ghc-7.9.20140715
lrwxrwxrwx   1 maeder   wimi          39 Jul 15 16:02 x86_64-pc-solaris2-ghc-pkg -> x86_64-pc-solaris2-ghc-pkg-7.9.20140715
-rwxr-xr-x   1 maeder   wimi         460 Jul 15 16:02 x86_64-pc-solaris2-ghc-pkg-7.9.20140715
-rwxr-xr-x   1 maeder   wimi         419 Jul 15 16:02 x86_64-pc-solaris2-haddock-ghc-7.9.20140715
-rwxr-xr-x   1 maeder   wimi       50192 Jul 15 16:04 x86_64-pc-solaris2-hp2ps
-rwxr-xr-x   1 maeder   wimi         390 Jul 15 16:02 x86_64-pc-solaris2-hpc
-rwxr-xr-x   1 maeder   wimi        1169 Jul 15 16:02 x86_64-pc-solaris2-hsc2hs
-rwxr-xr-x   1 maeder   wimi         411 Jul 15 16:02 x86_64-pc-solaris2-runghc-7.9.20140715

The 64Bit compiler was usable (and fully dynamically linked):

-bash-3.2$ ghc --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","/local/home/maeder/haskell/ghc64bin/gcc")
 ,("C compiler flags"," -fno-stack-protector")
 ,("C compiler link flags","")
 ,("Haskell CPP command","/local/home/maeder/haskell/ghc64bin/gcc")
 ,("Haskell CPP flags","-E -undef -traditional ")
 ,("ld command","/usr/ccs/bin/ld")
 ,("ld flags","")
 ,("ld supports compact unwind","NO")
 ,("ld supports build-id","NO")
 ,("ld supports filelist","NO")
 ,("ld is GNU ld","NO")
 ,("ar command","/usr/ccs/bin/ar")
 ,("ar flags","clqs")
 ,("ar supports at file","no")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("libtool command","libtool")
 ,("perl command","/usr/bin/perl")
 ,("target os","OSSolaris2")
 ,("target arch","ArchX86_64")
 ,("target word size","8")
 ,("target has GNU nonexec stack","True")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("Unregisterised","NO")
 ,("LLVM llc command","llc")
 ,("LLVM opt command","opt")
 ,("Project version","7.9.20140715")
 ,("Booter version","7.8.2")
 ,("Stage","2")
 ,("Build platform","i386-unknown-solaris2")
 ,("Host platform","x86_64-unknown-solaris2")
 ,("Target platform","x86_64-unknown-solaris2")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn")
 ,("Support dynamic-too","YES")
 ,("Support parallel --make","YES")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","YES")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","/local/home/maeder/haskell/ghc-7.9-x64/lib/x86_64-pc-solaris2-ghc-7.9.20140715")
 ,("Global Package DB","/local/home/maeder/haskell/ghc-7.9-x64/lib/x86_64-pc-solaris2-ghc-7.9.20140715/package.conf.d")
 ]

With this compiler I tried to bootstrap from scratch:

git clone git://git.haskell.org/ghc.git
cd ghc
./sync-all
perl boot
./configure --enable-bootstrap-with-devel-snapshot
gmake

However, this step failed again with a core dump that is already described in comment:2:

"inplace/bin/genprimopcode" --data-decl          < compiler/stage1/build/primops.txt > compiler/stage1/build/primop-data-decl.hs-incl
/bin/bash: line 1: 17544 Segmentierungsfehler    (core dumped) "inplace/bin/genprimopcode" --data-decl < compiler/stage1/build/primops.txt > compiler/stage1/build/primop-data-decl.hs-incl

comment:12 Changed 10 months ago by maeder

P.S. Trying to build just a stage1 (32bit) cross compiler (https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling) by putting "Stage1Only = YES" into mk/build.mk did not work at all. It failed because something tried to use a missing "inplace/bin/ghc-stage2".

comment:13 Changed 10 months ago by maeder

the binary-dist of the cross-compiler (created by "gmake binary-dist") does not contain a configure file. http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/pc-solaris/ghcs/ghc-7.9.20140715-x86_64-unknown-solaris2.tar.bz2

(Luckily, "gmake install" produced something usuable.)

comment:14 Changed 5 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

Note: See TracTickets for help on using tickets.