Bug#807108: ghc: Please add platform detection support for sh4 (patch supplied)

John Paul Adrian Glaubitz glaubitz at physik.fu-berlin.de
Sun Dec 6 16:27:21 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Joachim!

On 12/06/2015 02:01 PM, Joachim Breitner wrote:
>> I am currently preparing a ghc package for Debian's sh4 port.
>> 
>> I have successfully bootstrapped ghc via cross-compilation [1]
>> and I am now building the actual Debian package which I will
>> upload to the 'unreleased' suite later.
> 
> That’s pretty awsome! I did not know that cross-compilation works
> so well these days.

Building a stage1 compiler works almost straight out of the box after
changing the build scripts such that dll-dist is built with the
stage0 compiler. This change has already been implemented upstream.

> https://phabricator.haskell.org/D1430

After the stage1 compiler is built, you can install it onto your
host platform as a cross-compiler. Thus, if you want to provide
a ghc-cross package, that should be almost straight-forward.

In order to build stage2, you basically have to edit mk/build.mk
and set Stage1Only to NO in the section for "quick-cross". After
that, just type "make" again and you will get a stage2 compiler.

Unfortunately, that's were things get a bit tricky as this part
of the build process has some issues. It will get to a point where
the build scripts will try to run the stage2 compiler which, of
course, fails as the stage2 compiler is built for the target
platform. Here's what happened when I cross-compiled for sparc64
today:

"inplace/bin/ghc-stage2" -hisuf hi -osuf  o -hcsuf hc -static
- -optl-Wl,-no-relax    -hide-all-packages -i -iutils/ghctags/.
- -iutils/ghctags/dist-install/build
- -iutils/ghctags/dist-install/build/autogen
- -Iutils/ghctags/dist-install/build
- -Iutils/ghctags/dist-install/build/autogen     -optP-include
- -optPutils/ghctags/dist-install/build/autogen/cabal_macros.h
- -package-key Cabal_1lO1N0pKbwf4zBgHJflENk -package-key
base_2lcyO1PzLwjHA5BlcgluBo -package-key conta_JOLExAcFnznHipKDDX15uc
- -package-key ghc_GBv33sXEm4s0DqgSsvVMUB -XHaskell2010
- -no-user-package-db -rtsopts      -odir
utils/ghctags/dist-install/build -hidir
utils/ghctags/dist-install/build -stubdir
utils/ghctags/dist-install/build   -c utils/ghctags/./Main.hs -o
utils/ghctags/dist-install/build/Main.o
/lib64/ld-linux.so.2: No such file or directory
utils/ghctags/ghc.mk:18: recipe for target
'utils/ghctags/dist-install/build/Main.o' failed
make[1]: *** [utils/ghctags/dist-install/build/Main.o] Error 255
Makefile:71: recipe for target 'all' failed
make: *** [all] Error 2

/lib64/ld-linux.so.2 is the path of the dynamic loader on sparc64
while on amd64 (my host system during the build), it's actually
/lib64/ld-linux-x86-64.so.2. Thus, what I do is copying the whole
build root over to a sparc64 box and just run "make" again which
will finish the build process without any issues. The next problem
occurs then when trying to run "make install" which will install
most of the native sparc64 ghc binaries and packages without a
hitch, but unfortunately will try to run ghc-stage1 at some point
and even the amd64 versions of ghc-cabal and such which are located
in the inplace directory. So, in order to make the installation
finish, these binaries have to be swapped with the sparc64
versions which are in the dist-install sub directories.

> I’m sure the GHC developers would like to hear about it. Would you
> mind writing to the upstream mailing list at 
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs and tell
> them about your experience, i.e. what you did, how you did it, what
> went well and what not so well. This will also be useful 
> information for any further porters to other systems.

Sure, once I have figured out everything and have successfully
bootstrapped on both sh4 and sparc64, I will them and you know. I
will write down a detailed documentation.

>> In order for ghc to actually build on sh4, I had to add sh4 to
>> the list of known architectures in aclocal.m4. Please add the
>> attached patch to the package's Debian patches so the official
>> Debian ghc package supports sh4 as well.
> 
> Will do. This should also go upstream. Do you want to upstream it
> (by opening a ticket at http://hackage.haskell.org/trac/ghc/ and
> attaching it)?

Yeah, will do. My idea was to get it into Debian first to be able to
iron out all the details first and once things are working, I will
upstream everything.

Adrian

- -- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz at debian.org
`. `'   Freie Universitaet Berlin - glaubitz at physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWZGHlAAoJEHQmOzf1tfkTWRcP/Rv11LAnQo+Dp4azk92r2dDS
C3Hzud2rrUl4s8U7IiEj46tJ+aMp0Ex4y4BbevmBh5sD35metZxgf8ytGogMmQBm
w1hVc9DxZsAkHhSLcTAFSes9at3o+qYx8rOAuutJBCqrb1mdNFnA6qQSsgdTnw5w
4g9o+wI/sk1GNCdLYFUEAokzCXuIwlqEG183IcsMnI0K0wa/sXnXTPk4milVVwh6
A3fOECTDY3i6rYGwWzjCD8+F6Sp4Hm9yCDoENq48iZ/apTgtV3vndfg0bKQwh+08
0atMaWJB1SnpiuQOpBUa5Jz39p7MjkGccoF9cRPHG73FQe1fNuF6jiVUM0iSqODG
t12oik3i22zaXWY6TtZjIboicxnBIOCCB3sbT0fi9nfaW3W+7QZda0lPs9/t3HUc
INhrdJXcJ1Hg6Wg4a+t2Vso9msOtial4iejxpkGPopaiMqqa+z1ZIThda5vKoQe+
m4/bzFbQBQu1AUQIcXKfh5c6iDpWPDKXpkShgqHOPsWaGMZ3ZTHCYmTgIKqFg0zG
3JL6RR0RRIuZP4Y4BYle5NdPVui0zOi0w08e0ugAFgq4HzsrFr1aJrHPbCwpR196
C7gZFwvDt7/7hDf6IBHsUZjCHrhbT1OZJ1nXV/vp5pPsyV6YEhv9s6bDwlsdv01O
W+sJ5ZBFxBIyEZNbdYgF
=w+UL
-----END PGP SIGNATURE-----



More information about the Pkg-haskell-maintainers mailing list