[commit: ghc] wip/angerman/llvmng: Fix binary distributions of cross compilers (9ee3151)

git at git.haskell.org git at git.haskell.org
Fri Oct 20 02:38:15 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/angerman/llvmng
Link       : http://ghc.haskell.org/trac/ghc/changeset/9ee3151537d9fee49bb55e1e918fa62047b58e60/ghc

>---------------------------------------------------------------

commit 9ee3151537d9fee49bb55e1e918fa62047b58e60
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Mon Oct 2 13:47:45 2017 +0800

    Fix binary distributions of cross compilers
    
    Summary:
    - copy over the original settings file
      Otherwise most of the custom cross compiler toolchain will
      be screwed up upon install.  I'd rather have someone complain
      about a proper target-prefixed tool being missing, than getting
      garbaled output and a slew of strange errors because the final
      configure selected tools on the install machine just don't
      match up.
    
    - persist target-prefix. For cross compilers, retain the $target-
      prefix. This allows installing multiple cross compierls targetting
      different targets alongside each other.
    
    Reviewers: austin, hvr, bgamari
    
    Subscribers: rwbarton, trofi, thomie, hvr, bgamari, erikd
    
    Differential Revision: https://phabricator.haskell.org/D4058


>---------------------------------------------------------------

9ee3151537d9fee49bb55e1e918fa62047b58e60
 distrib/configure.ac.in | 20 ++++++++++++++------
 ghc.mk                  | 14 ++++++++++----
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 509e74e..62f6575 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -35,10 +35,9 @@ FPTOOLS_SET_PLATFORM_VARS
 # Requires FPTOOLS_SET_PLATFORM_VARS to be run first.
 FP_FIND_ROOT
 
-# ToDo: if Stage1Only=YES, should be YES
-CrossCompiling=NO
-CrossCompilePrefix=""
-TargetPlatformFull="${target}"
+CrossCompiling=@CrossCompiling@
+CrossCompilePrefix=@CrossCompilePrefix@
+TargetPlatformFull=@TargetPlatformFull@
 
 AC_SUBST(CrossCompiling)
 AC_SUBST(CrossCompilePrefix)
@@ -198,8 +197,17 @@ fi
 
 FP_SETTINGS
 
-#
-AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
+dnl ** Hack tools for cross compilers
+dnl --------------------------------------------------------------
+dnl When building a binary distribution for cross compilers,
+dnl we likely want to retain the target-prefixed tools, and not
+dnl have configure overwrite them with what ever it finds, as
+dnl the found tools likely do not target the target.
+AC_CONFIG_FILES(mk/config.mk mk/install.mk)
+if test "x$CrossCompiling" = "xNO"; then
+AC_CONFIG_FILES(settings)
+fi
+
 AC_OUTPUT
 
 # We get caught by
diff --git a/ghc.mk b/ghc.mk
index f397f7c..66ae00a 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -1060,11 +1060,17 @@ ifneq "$(CLEANING)" "YES"
 # stage0 compiled ghc-cabal into the binary distribution.  As the
 # stage1 compiled ghc-cabal is built for the target, however
 # ghc-cabal is used during 'make install' on the host, when
-# installing the binary distribution.
-ifeq "$(Stage1Only)" "YES"
+# installing the binary distribution. We will also copy the original
+# `settings` file instead of having `configure` compute a new one.
+# We do this because the bindist configure by default picks up
+# the non-target prefixed toolchain; and cross compilers can be
+# very sensitive to the toolchain.
+ifeq "$(Stage1Only) $(CrossCompiling)" "YES YES"
 DIST_GHC_CABAL=utils/ghc-cabal/dist/build/tmp/ghc-cabal
+DIST_SETTINGS=settings
 else
 DIST_GHC_CABAL=utils/ghc-cabal/dist-install/build/tmp/ghc-cabal
+DIST_SETTINGS=settings.in
 endif
 
 $(eval $(call bindist-list,.,\
@@ -1072,7 +1078,7 @@ $(eval $(call bindist-list,.,\
     README \
     INSTALL \
     configure config.sub config.guess install-sh \
-    settings.in \
+    $(DIST_SETTINGS) \
     llvm-targets \
     packages \
     Makefile \
@@ -1133,7 +1139,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
 unix-binary-dist-prep:
 	$(call removeTrees,bindistprep/)
 	"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
-	set -e; for i in packages LICENSE compiler ghc iserv rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in llvm-targets ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
+	set -e; for i in packages LICENSE compiler ghc iserv rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh $(DIST_SETTINGS) llvm-targets ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
 	echo "HADDOCK_DOCS       = $(HADDOCK_DOCS)"       >> $(BIN_DIST_MK)
 	echo "BUILD_SPHINX_HTML  = $(BUILD_SPHINX_HTML)"  >> $(BIN_DIST_MK)
 	echo "BUILD_SPHINX_PDF   = $(BUILD_SPHINX_PDF)"   >> $(BIN_DIST_MK)



More information about the ghc-commits mailing list