Build system: Correctly pass `TARGETPLATFORM` as host
ClosedPublic

Authored by NicolasT on Feb 27 2016, 6:04 PM.

Details

Summary

When building the bundled GMP sources, the HOSTPLATFORM value was
passed to the --host flag of the ./configure call. This is
incorrect: when building a cross-compiler, e.g. a compiler targeting
ARM but running on X86, the host on which GMP will run is ARM, i.e.
the target platform of the compiler, and the host platform (i.e. the
platform on which the compiler will run) is X86.

See e.g. [1] for more information about the meaning of and relation
between build, host and target.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Specifying-Target-Triplets.html

Test Plan

Building ARM cross-compiler with integer-gmp

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
NicolasT updated this revision to Diff 6793.Feb 27 2016, 6:04 PM
NicolasT retitled this revision from to Build system: Correctly pass `TARGETPLATFORM` as host.
NicolasT updated this object.
NicolasT edited the test plan for this revision. (Show Details)
NicolasT added reviewers: austin, Phyx, thomie, hvr.
hvr added subscribers: gracjan, erikd.

This makes a lot of sense, but I'd like @erikd or @gracjan who afaik have some experience with GHC cross-compilers to confirm this too

Phyx edited edge metadata.Feb 28 2016, 1:15 AM

I agree that this makes a lot of sense. How were you cross compiling before @erikd ? Or were you only doing the rts?

erikd edited edge metadata.Feb 28 2016, 1:46 AM

By default, cross-compiling uses integer-simple which is written in Haskell and therefore JustWorks (tm). I don't think I've ever tried to cross compile wiyh integer-gmp and I would try that now, but the LLVM backend is currently broken due to https://ghc.haskell.org/trac/ghc/ticket/11649 . I suppose I could test it with before the code before commit 673efccb3b .

erikd accepted this revision.EditedFeb 28 2016, 3:39 AM
erikd edited edge metadata.

To test this, I rolled back to the commit before the LLVM breakage, applied this patch, and then edited mk/flavours/quick-cross.mk to use integer-gmp instead of integer-simple . I then buit an AArch64/Arm64 cross compiler which does indeed produce Arm64 binaries that links against libgmp.

Looks good to me.

This revision is now accepted and ready to land.Feb 28 2016, 3:39 AM
bgamari requested changes to this revision.Feb 28 2016, 10:32 AM
bgamari edited edge metadata.

@NicolasT, thanks for this! Could you add a short comment describing the rationale here? It wasn't obvious to someone in the past; surely it will be just as non-obvious to the next person.

This revision now requires changes to proceed.Feb 28 2016, 10:32 AM
NicolasT updated this revision to Diff 6798.Feb 28 2016, 2:39 PM
NicolasT edited edge metadata.

Add note explaining why GMP's --host is TARGETPLATFORM in ghc.mk

Requested by @bgamari in D1960.

bgamari accepted this revision.Feb 29 2016, 4:50 AM
bgamari edited edge metadata.

Thanks @NicolasT!

This revision is now accepted and ready to land.Feb 29 2016, 4:50 AM
This revision was automatically updated to reflect the committed changes.