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

git at git.haskell.org git at git.haskell.org
Tue Oct 3 01:23:45 UTC 2017


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

On branch  : wip/angerman/llvmng
Link       : http://ghc.haskell.org/trac/ghc/changeset/67ab675cfbe1f7e6846accd07e3626b6cb3c2a79/ghc

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

commit 67ab675cfbe1f7e6846accd07e3626b6cb3c2a79
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


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

67ab675cfbe1f7e6846accd07e3626b6cb3c2a79
 distrib/configure.ac.in | 19 ++++++++++++++-----
 ghc.mk                  | 22 ++++++++++++++++++++--
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 509e74e..7e0aef1 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -36,9 +36,9 @@ FPTOOLS_SET_PLATFORM_VARS
 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 +198,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 c3edc5e..012bffa 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -1056,12 +1056,30 @@ ifneq "$(CLEANING)" "YES"
 # This rule seems to hold some files open on Windows which prevents
 # cleaning, perhaps due to the $(wildcard).
 
+# when building stage1only (a cross-compiler), we need to put the
+# 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. We will also copy the original
+# `settings` file instead of having `configure` compute a new one
+# when runningt `./configure && make install`.  We do this because
+# configure at install by default picks up the non-target prefixed
+# toolchain; and cross compilers can be very sensitive to
+# the toolchain.
+ifeq "$(Stage1Only)" "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,.,\
     LICENSE \
     README \
     INSTALL \
     configure config.sub config.guess install-sh \
-    settings.in \
+    $(DIST_SETTINGS) \
     llvm-targets \
     packages \
     Makefile \
@@ -1122,7 +1140,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