diff options
author | Shawn Landden <shawn@git.icu> | 2021-10-15 00:38:08 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 00:38:08 +0400 |
commit | fae8362d4cacc8ebecdbd9b7adf5de853a10ead5 (patch) | |
tree | 0db95c8b7e5e3c14e51e453d232988b7460a5cd3 | |
parent | 3d543c06263744452d099e2b1860052ab061a842 (diff) | |
parent | 850db9eec0d5dd7f47ade8ffca91b679081f6d85 (diff) | |
download | distcc-git-fae8362d4cacc8ebecdbd9b7adf5de853a10ead5.tar.gz |
Merge pull request #427 from asheplyakov/native-compiler-triple-fixup
Improved cross-rewriting on non-x86 systems
Tested on aarch64 (Debian).
-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, "-"); |