Use non-canocalized triple as cross-compiler prefix
authorSergei Trofimovich <slyfox@gentoo.org>
Thu, 6 Apr 2017 07:51:22 +0000 (08:51 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Thu, 6 Apr 2017 08:30:03 +0000 (09:30 +0100)
I've noticed the problem when tried to install
cross-compiler using following configuration:

    $ ./configure --target=s390x-unknown-linux-gnu
    make install Stage1Only=YES

Instead of expected tool prefix
    's390x-unknown-linux-gnu-'
Result was:
    's390x-ibm-linux-gnu-'

It's problematic as installed binaries appear in
unpredictable location.

The problem is caused by use of ${target} autoconf variable.
${target} contains a canocalized triplet.

Luckily we already have non-canonucalized target triplet
in ${TargetPlatformFull} variable. The change uses that
instead.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
configure.ac

index 3086e03..dd107e5 100644 (file)
@@ -425,12 +425,6 @@ with a cross-compiler.  To cross-compile GHC itself, set TARGET: stage
 GHC.
 ])
 fi
-if test "$CrossCompiling" = "YES"
-then
-  CrossCompilePrefix="${target}-"
-else
-  CrossCompilePrefix=""
-fi
 # Despite its similarity in name to TargetPlatform, TargetPlatformFull is used
 # in calls to subproject configure scripts and thus must be set to the autoconf
 # triple, not the normalized GHC triple that TargetPlatform is set to.
@@ -446,6 +440,8 @@ fi
 # all be taken care of for us if we configured the subprojects using
 # AC_CONFIG_DIR, but unfortunately Cabal needs to be the one to do the
 # configuration.
+#
+# We also use non-canonicalized triple when install stage1 crosscompiler
 if test -z "${target_alias}"
 then
   # --target wasn't given; use result from AC_CANONICAL_TARGET
@@ -453,6 +449,13 @@ then
 else
   TargetPlatformFull="${target_alias}"
 fi
+if test "$CrossCompiling" = "YES"
+then
+  # Use value passed by user from --target=
+  CrossCompilePrefix="${TargetPlatformFull}-"
+else
+  CrossCompilePrefix=""
+fi
 AC_SUBST(CrossCompiling)
 AC_SUBST(CrossCompilePrefix)
 AC_SUBST(TargetPlatformFull)