diff options
author | Alexey Sheplyakov <asheplyakov@altlinux.org> | 2021-07-11 18:57:00 +0400 |
---|---|---|
committer | Alexey Sheplyakov <asheplyakov@altlinux.org> | 2021-09-30 17:05:18 +0400 |
commit | 850db9eec0d5dd7f47ade8ffca91b679081f6d85 (patch) | |
tree | 0db95c8b7e5e3c14e51e453d232988b7460a5cd3 | |
parent | 3d543c06263744452d099e2b1860052ab061a842 (diff) | |
download | distcc-git-850db9eec0d5dd7f47ade8ffca91b679081f6d85.tar.gz |
Improved cross-rewriting on non-x86 systems
Unfortunately autoconf and GCC don't agree on the system name:
- On arm (aarch64): `GNU_HOST` is `aarch64-unknown-linux-gnu`,
and GCC triple is `aarch64-linux-gnu` instead.
- On rpm-based x86_64 distros: `GNU_HOST` is `x86_64-pc-linux-gnu`,
and GCC triple is `x86_64-redhat-linux`
Therefore ask the compiler (when running distcc configure script)
how to correctly identify it.
Closes: #440
ALTBUG: 40425
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | src/compile.c | 10 |
2 files changed, 19 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index 4d709e0..007efb8 100644 --- a/configure.ac +++ b/configure.ac @@ -547,6 +547,22 @@ AC_SUBST(CPPFLAGS) AC_SUBST(POPT_INCLUDES) AC_SUBST(BUILD_POPT) AC_SUBST(GNOME_BIN) + + +# Sometimes canonical triples as used by configure differ from GCC ones +# x86: configure: x86_64-pc-linux-gnu, GCC: x86_64-linux-gnu +# ALT Linux: configure: ${arch}-alt-linux-gnu, GCC: ${arch}-alt-linux +# Therefore ask the compiler for its triple +if test "x${GCC}" = xyes ; then + native_compiler_triple=`$CC -dumpmachine` +fi +if test "x$native_compiler_triple" = "x"; then + native_compiler_triple="$host" +fi +AC_MSG_NOTICE([Native compiler triple: $native_compiler_triple]) + +AC_DEFINE_UNQUOTED(NATIVE_COMPILER_TRIPLE, ["$native_compiler_triple"], [Native compiler triple]) + AC_DEFINE_UNQUOTED(GNU_HOST, ["$host"], [Your gnu-style host triple]) # The '.stamp-conf' files force creation of the containing directories in the # build tree. diff --git a/src/compile.c b/src/compile.c index 1b2b080..e6ef9b9 100644 --- a/src/compile.c +++ b/src/compile.c @@ -549,7 +549,7 @@ static void dcc_rewrite_generic_compiler(char **argv) static void dcc_add_clang_target(char **argv) { /* defined by autoheader */ - const char *target = GNU_HOST; + const char *target = NATIVE_COMPILER_TRIPLE; if (strcmp(argv[0], "clang") == 0 || strncmp(argv[0], "clang-", strlen("clang-")) == 0 || strcmp(argv[0], "clang++") == 0 || strncmp(argv[0], "clang++-", strlen("clang++-")) == 0) @@ -577,7 +577,7 @@ static void dcc_add_clang_target(char **argv) static int dcc_gcc_rewrite_fqn(char **argv) { /* defined by autoheader */ - const char *target_with_vendor = GNU_HOST; + const char *target_with_vendor = NATIVE_COMPILER_TRIPLE; char *newcmd, *t, *path; int pathlen = 0; int newcmd_len = 0; @@ -595,11 +595,7 @@ static int dcc_gcc_rewrite_fqn(char **argv) return -ENOMEM; memset(newcmd, 0, newcmd_len); - if ((t = strstr(target_with_vendor, "-pc-"))) { - memcpy(newcmd, target_with_vendor, t - target_with_vendor); - strcat(newcmd, t + strlen("-pc")); - } else - strcpy(newcmd, target_with_vendor); + strcpy(newcmd, target_with_vendor); strcat(newcmd, "-"); |