Build system: Correctly pass `TARGETPLATFORM` as host
authorNicolas Trangez <ikke@nicolast.be>
Mon, 29 Feb 2016 10:56:33 +0000 (11:56 +0100)
committerBen Gamari <ben@smart-cactus.org>
Mon, 29 Feb 2016 12:42:52 +0000 (13:42 +0100)
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`

Reviewers: thomie, gracjan, austin, erikd, Phyx, hvr, bgamari

Reviewed By: erikd, bgamari

Subscribers: erikd, gracjan

Differential Revision: https://phabricator.haskell.org/D1960

libraries/integer-gmp/gmp/ghc.mk

index 33fab0b..8e52574 100644 (file)
@@ -122,13 +122,16 @@ libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h:
        cat libraries/integer-gmp/gmp/tarball/gmp-5.0.4.patch | { cd libraries/integer-gmp/gmp/gmpbuild && $(PATCH_CMD) -p1 ; }
        chmod +x libraries/integer-gmp/gmp/ln
 
+       # Note: We must pass `TARGETPLATFORM` to the `--host` argument of GMP's
+       #       `./configure`, not `HOSTPLATFORM`: the 'host' on which GMP will
+       #       run is the 'target' platform of the compiler we're building.
        cd libraries/integer-gmp/gmp; (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
            PATH=`pwd`:$$PATH; \
            export PATH; \
            cd gmpbuild && \
            CC=$(CCX) NM=$(NM) AR=$(AR_STAGE1) ./configure \
                  --enable-shared=no \
-                 --host=$(HOSTPLATFORM) --build=$(BUILDPLATFORM)
+                 --host=$(TARGETPLATFORM) --build=$(BUILDPLATFORM)
        $(MAKE) -C libraries/integer-gmp/gmp/gmpbuild MAKEFLAGS=
        $(CP) libraries/integer-gmp/gmp/gmpbuild/gmp.h libraries/integer-gmp/gmp/
        $(CP) libraries/integer-gmp/gmp/gmpbuild/.libs/libgmp.a libraries/integer-gmp/gmp/