From 5ad37ffd72b4d128cdae1d78839b9e974e0f4abd Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sun, 12 Nov 2017 02:16:39 -0800 Subject: [PATCH 1/7] New package: distcc --- packages/distcc/Makefile.am.patch | 32 +++++++++++++++++++++++++++++++ packages/distcc/build.sh | 12 ++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 packages/distcc/Makefile.am.patch create mode 100644 packages/distcc/build.sh diff --git a/packages/distcc/Makefile.am.patch b/packages/distcc/Makefile.am.patch new file mode 100644 index 000000000000000..af57da38ae0c493 --- /dev/null +++ b/packages/distcc/Makefile.am.patch @@ -0,0 +1,32 @@ +diff --git a/Makefile.in b/Makefile.in +index 3ea595c..0fb1efd 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -21,7 +21,7 @@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ + POPT_CFLAGS = @POPT_CFLAGS@ + POPT_INCLUDES = @POPT_INCLUDES@ + +-LDFLAGS = @LDFLAGS@ ++LDFLAGS = @LDFLAGS@ -llog -pie + CC = @CC@ + CPP = @CPP@ + # We add a few cppflags. -Isrc is so that config.h can be found in the build +@@ -67,7 +67,7 @@ GNOME_LIBS = @GNOME_LIBS@ + + LIBS = @LIBS@ + +-DESTDIR = ++DESTDIR = /data/data/com.termux/files + + INSTALL = @INSTALL@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -85,7 +85,7 @@ RESTRICTED_PATH = /usr/local/bin:/bin:/usr/bin + # directory names of possible locations for the installation to be + # checked. Change the value of this variable to @bindir@ to check the + # installation at the location determined by 'configure'. +-DISTCC_INSTALLATION = $(RESTRICTED_PATH) ++DISTCC_INSTALLATION = @bindir@ + + dist_files = \ + src/config.h.in \ + diff --git a/packages/distcc/build.sh b/packages/distcc/build.sh new file mode 100644 index 000000000000000..4995757fa4f254f --- /dev/null +++ b/packages/distcc/build.sh @@ -0,0 +1,12 @@ +TERMUX_PKG_HOMEPAGE=http://distcc.org/ +TERMUX_PKG_DESCRIPTION="Distributed C/C++ compiler." +TERMUX_PKG_VERSION=3.2-rc1 +TERMUX_PKG_REVISION=1 +TERMUX_PKG_SHA256=8cf474b9e20f5f3608888c6bff1b5f804a9dfc69ae9704e3d5bdc92f0487760a +TERMUX_PKG_SRCURL=https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/distcc/distcc-3.2rc1.tar.gz +TERMUX_PKG_BUILD_IN_SRC=yes + +termux_step_configure () { + #the configure script checks if $PYTHON is executable + PYTHON=/etc/hosts sh ./configure -disable-Werror --without-libiberty --prefix=/usr --host `dpkg-architecture -q DEB_HOST_GNU_TYPE` +} From ca5ecb31168ec4af1febeca613bf3690b6e0ece1 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sun, 12 Nov 2017 03:46:26 -0800 Subject: [PATCH 2/7] command-not-found for distcc --- packages/command-not-found/commands.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/command-not-found/commands.h b/packages/command-not-found/commands.h index 6fc8975f73cc31e..c298d13f68a3c69 100644 --- a/packages/command-not-found/commands.h +++ b/packages/command-not-found/commands.h @@ -330,6 +330,11 @@ char const* const commands[] = { "dirmngr", " dirmngr", " dirmngr-client", +"distcc" +" distcc", +" distccd", +" distccmon-text", +" lsdistcc", "dnsutils", " dig", " host", From 97659737acf974f4dc847fa6ca5fb2a4b63e0206 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sat, 18 Nov 2017 18:57:55 -0800 Subject: [PATCH 3/7] do not require --allow to distccd (less typing on phone) --- packages/distcc/allow.patch | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/distcc/allow.patch diff --git a/packages/distcc/allow.patch b/packages/distcc/allow.patch new file mode 100644 index 000000000000000..f52f26c6e96b052 --- /dev/null +++ b/packages/distcc/allow.patch @@ -0,0 +1,21 @@ +diff --git a/src/daemon.c b/src/daemon.c +index a1056f8..e11b29e 100644 +--- a/src/daemon.c ++++ b/src/daemon.c +@@ -165,15 +165,6 @@ int main(int argc, char *argv[]) + if (distccd_parse_options(argc, (const char **) argv)) + dcc_exit(EXIT_DISTCC_FAILED); + +- /* check this before redirecting the logs, so that it's really obvious */ +- if (!dcc_should_be_inetd()) +- if (opt_allowed == NULL) { +- rs_log_error("--allow option is now mandatory; " +- "you must specify which clients are allowed to connect"); +- ret = EXIT_BAD_ARGUMENTS; +- goto out; +- } +- + if ((ret = dcc_set_lifetime()) != 0) + dcc_exit(ret); + + From eb4b4884ced1fe87aa027f39e1be2ab1c159fd10 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Mon, 27 Nov 2017 08:41:37 -0800 Subject: [PATCH 4/7] depend on popt doesn't strictly need popt, but if the build environment contains\ popt it will build against it. --- packages/distcc/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/distcc/build.sh b/packages/distcc/build.sh index 4995757fa4f254f..b4f7e9a9bf2c525 100644 --- a/packages/distcc/build.sh +++ b/packages/distcc/build.sh @@ -5,6 +5,7 @@ TERMUX_PKG_REVISION=1 TERMUX_PKG_SHA256=8cf474b9e20f5f3608888c6bff1b5f804a9dfc69ae9704e3d5bdc92f0487760a TERMUX_PKG_SRCURL=https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/distcc/distcc-3.2rc1.tar.gz TERMUX_PKG_BUILD_IN_SRC=yes +TERMUX_PKG_DEPENDS=libpopt termux_step_configure () { #the configure script checks if $PYTHON is executable From e47e7aa325112ff2940006bf8963a6e7c77d78e1 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Mon, 27 Nov 2017 10:40:30 -0800 Subject: [PATCH 5/7] use @TERMUX_PREFIX@ --- packages/distcc/Makefile.am.patch | 2 +- packages/distcc/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/distcc/Makefile.am.patch b/packages/distcc/Makefile.am.patch index af57da38ae0c493..5da11298d72d82a 100644 --- a/packages/distcc/Makefile.am.patch +++ b/packages/distcc/Makefile.am.patch @@ -16,7 +16,7 @@ index 3ea595c..0fb1efd 100644 LIBS = @LIBS@ -DESTDIR = -+DESTDIR = /data/data/com.termux/files ++DESTDIR = @TERMUX_PREFIX@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ diff --git a/packages/distcc/build.sh b/packages/distcc/build.sh index b4f7e9a9bf2c525..7ed0cb31560ee68 100644 --- a/packages/distcc/build.sh +++ b/packages/distcc/build.sh @@ -9,5 +9,5 @@ TERMUX_PKG_DEPENDS=libpopt termux_step_configure () { #the configure script checks if $PYTHON is executable - PYTHON=/etc/hosts sh ./configure -disable-Werror --without-libiberty --prefix=/usr --host `dpkg-architecture -q DEB_HOST_GNU_TYPE` + PYTHON=/etc/hosts sh ./configure -disable-Werror --without-libiberty --prefix=/ --host `dpkg-architecture -q DEB_HOST_GNU_TYPE` } From aae02bc1d8c1981fcc1bdf1162532ee8961624f9 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Mon, 27 Nov 2017 10:52:51 -0800 Subject: [PATCH 6/7] add my patches clang cross-compile --allow-private, better than allowing all --- ...e-option-to-allow-non-Internet-routa.patch | 130 ++++++++++++++++++ .../0002-make-allow-private-the-default.patch | 68 +++++++++ ...0003-clang-cross-compilation-support.patch | 61 ++++++++ packages/distcc/allow.patch | 21 --- 4 files changed, 259 insertions(+), 21 deletions(-) create mode 100644 packages/distcc/0001-new-allow-private-option-to-allow-non-Internet-routa.patch create mode 100644 packages/distcc/0002-make-allow-private-the-default.patch create mode 100644 packages/distcc/0003-clang-cross-compilation-support.patch delete mode 100644 packages/distcc/allow.patch diff --git a/packages/distcc/0001-new-allow-private-option-to-allow-non-Internet-routa.patch b/packages/distcc/0001-new-allow-private-option-to-allow-non-Internet-routa.patch new file mode 100644 index 000000000000000..971807f45372ada --- /dev/null +++ b/packages/distcc/0001-new-allow-private-option-to-allow-non-Internet-routa.patch @@ -0,0 +1,130 @@ +From 4f6fc0cd50dd6987ba72e01dca58361b693bbf13 Mon Sep 17 00:00:00 2001 +From: Shawn Landden +Date: Mon, 6 Nov 2017 17:59:05 -0800 +Subject: [PATCH 1/3] new --allow-private option to allow non-Internet routable + addresses + +--- + man/distccd.1 | 4 ++++ + src/access.h | 2 ++ + src/daemon.c | 6 ++++-- + src/dopt.c | 28 +++++++++++++++++++++++++++- + 4 files changed, 37 insertions(+), 3 deletions(-) + +diff --git a/man/distccd.1 b/man/distccd.1 +index 41596d8..86518eb 100644 +--- a/man/distccd.1 ++++ b/man/distccd.1 +@@ -147,6 +147,10 @@ match in the most significant MASK bits will be allowed. If no + connections are rejected by closing the TCP connection immediately. A + warning is logged on the server but nothing is sent to the client. + .TP ++.B --allow-private ++Allow private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, and ++127.0.0.0/8). ++.TP + .B --job-lifetime SECONDS + Kills a distccd job if it runs for more than SECONDS seconds. This prevents + denial of service from clients that don't properly disconnect and compilers +diff --git a/src/access.h b/src/access.h +index e6bd69c..c1e95ee 100644 +--- a/src/access.h ++++ b/src/access.h +@@ -20,6 +20,8 @@ + * USA. + */ + ++#pragma once ++ + #include + + /* access.c */ +diff --git a/src/daemon.c b/src/daemon.c +index a1056f8..545cb32 100644 +--- a/src/daemon.c ++++ b/src/daemon.c +@@ -168,8 +168,10 @@ int main(int argc, char *argv[]) + /* check this before redirecting the logs, so that it's really obvious */ + if (!dcc_should_be_inetd()) + if (opt_allowed == NULL) { +- rs_log_error("--allow option is now mandatory; " +- "you must specify which clients are allowed to connect"); ++ rs_log_error("--allow or --allow-private option is now mandatory; " ++ "you must specify which clients are allowed to connect." ++ " Use --allow-private to allow non-Internet (globally" ++ " routable) addresses."); + ret = EXIT_BAD_ARGUMENTS; + goto out; + } +diff --git a/src/dopt.c b/src/dopt.c +index 9c36daa..e38c1a3 100644 +--- a/src/dopt.c ++++ b/src/dopt.c +@@ -68,6 +68,8 @@ int arg_port = DISTCC_DEFAULT_PORT; + int arg_stats = DISTCC_DEFAULT_STATS_ENABLED; + int arg_stats_port = DISTCC_DEFAULT_STATS_PORT; + ++int opt_allow_private = 0; ++ + /** If true, serve all requests directly from listening process + without forking. Better for debugging. **/ + int opt_no_fork = 0; +@@ -115,8 +117,16 @@ enum { + int opt_zeroconf = 0; + #endif + ++ ++/*TODO: IPv6*/ ++static const char *dcc_private_networks[] = {"192.168.0.0/16", ++ "10.0.0.0/8", ++ "172.16.0.0/12", ++ "127.0.0.0/8"}; ++ + const struct poptOption options[] = { + { "allow", 'a', POPT_ARG_STRING, 0, 'a', 0, 0 }, ++ { "allow-private", 0,POPT_ARG_STRING, &opt_allow_private, 0, 0, 0 }, + #ifdef HAVE_GSSAPI + { "auth", 0, POPT_ARG_NONE, &opt_auth_enabled, 'A', 0, 0 }, + { "blacklist", 0, POPT_ARG_STRING, &arg_list_file, 'b', 0, 0 }, +@@ -225,6 +235,7 @@ int distccd_parse_options(int argc, const char **argv) + { + poptContext po; + int po_err, exitcode; ++ struct dcc_allow_list *new; + + po = poptGetContext("distccd", argc, argv, options, 0); + +@@ -238,7 +249,6 @@ int distccd_parse_options(int argc, const char **argv) + case 'a': { + /* TODO: Allow this to be a hostname, which is resolved to an address. */ + /* TODO: Split this into a small function. */ +- struct dcc_allow_list *new; + new = malloc(sizeof *new); + if (!new) { + rs_log_crit("malloc failed"); +@@ -367,6 +377,22 @@ int distccd_parse_options(int argc, const char **argv) + } + } + ++ if (opt_allow_private) { ++ int i; ++ for (i = 0;i<3;i++) { ++ new = malloc(sizeof *new); ++ if (!new) { ++ rs_log_crit("malloc failed"); ++ exitcode = EXIT_OUT_OF_MEMORY; ++ goto out_exit; ++ } ++ new->next = opt_allowed; ++ opt_allowed = new; ++ if ((exitcode = dcc_parse_mask(dcc_private_networks[i], &new->addr, &new->mask))) ++ goto out_exit; ++ } ++ } ++ + poptFreeContext(po); + return 0; + +-- +2.14.1 + diff --git a/packages/distcc/0002-make-allow-private-the-default.patch b/packages/distcc/0002-make-allow-private-the-default.patch new file mode 100644 index 000000000000000..768126551f0bcf1 --- /dev/null +++ b/packages/distcc/0002-make-allow-private-the-default.patch @@ -0,0 +1,68 @@ +From 18b9faf205314f5f9329dff9c3f0b5c295384580 Mon Sep 17 00:00:00 2001 +From: Shawn Landden +Date: Sun, 19 Nov 2017 16:31:13 -0800 +Subject: [PATCH 2/3] make --allow-private the default + +--- + src/daemon.c | 8 +++----- + src/dopt.c | 4 ++-- + src/dopt.h | 1 + + 3 files changed, 6 insertions(+), 7 deletions(-) + +diff --git a/src/daemon.c b/src/daemon.c +index 545cb32..b3e269c 100644 +--- a/src/daemon.c ++++ b/src/daemon.c +@@ -168,12 +168,10 @@ int main(int argc, char *argv[]) + /* check this before redirecting the logs, so that it's really obvious */ + if (!dcc_should_be_inetd()) + if (opt_allowed == NULL) { +- rs_log_error("--allow or --allow-private option is now mandatory; " +- "you must specify which clients are allowed to connect." +- " Use --allow-private to allow non-Internet (globally" ++ rs_log_warning("No --allow option specified. Defaulting to --allow-private." ++ " Allowing non-Internet (globally" + " routable) addresses."); +- ret = EXIT_BAD_ARGUMENTS; +- goto out; ++ opt_allow_private = 1; + } + + if ((ret = dcc_set_lifetime()) != 0) +diff --git a/src/dopt.c b/src/dopt.c +index e38c1a3..602b0af 100644 +--- a/src/dopt.c ++++ b/src/dopt.c +@@ -68,8 +68,6 @@ int arg_port = DISTCC_DEFAULT_PORT; + int arg_stats = DISTCC_DEFAULT_STATS_ENABLED; + int arg_stats_port = DISTCC_DEFAULT_STATS_PORT; + +-int opt_allow_private = 0; +- + /** If true, serve all requests directly from listening process + without forking. Better for debugging. **/ + int opt_no_fork = 0; +@@ -83,6 +81,8 @@ char *opt_listen_addr = NULL; + + struct dcc_allow_list *opt_allowed = NULL; + ++int opt_allow_private = 0; ++ + /** + * If true, don't detach from the parent. This is probably necessary + * for use with daemontools or other monitoring programs, and is also +diff --git a/src/dopt.h b/src/dopt.h +index 695bc1e..5064a11 100644 +--- a/src/dopt.h ++++ b/src/dopt.h +@@ -24,6 +24,7 @@ + + /* dopt.c */ + extern struct dcc_allow_list *opt_allowed; ++extern int opt_allow_private; + int distccd_parse_options(int argc, const char *argv[]); + + extern int arg_port; +-- +2.14.1 + diff --git a/packages/distcc/0003-clang-cross-compilation-support.patch b/packages/distcc/0003-clang-cross-compilation-support.patch new file mode 100644 index 000000000000000..4e784d5ae389a94 --- /dev/null +++ b/packages/distcc/0003-clang-cross-compilation-support.patch @@ -0,0 +1,61 @@ +From 6c1dac57785c4ae29de07c32b69256d5a4433658 Mon Sep 17 00:00:00 2001 +From: Shawn Landden +Date: Sat, 25 Nov 2017 23:42:43 -0800 +Subject: [PATCH 3/3] clang cross-compilation support + +--- + src/compile.c | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/src/compile.c b/src/compile.c +index df73e9c..2f78482 100644 +--- a/src/compile.c ++++ b/src/compile.c +@@ -445,6 +445,36 @@ static int dcc_please_send_email_after_investigation( + return dcc_note_discrepancy(discrepancy_filename); + } + ++/* Clang is a native cross-compiler, but needs to be told to what target it is ++ * building. ++ * TODO: actually probe clang with clang --version, instead of trusting ++ * autoheader. ++ */ ++static int dcc_add_clang_target(char **argv) ++{ ++ int i; ++ ++ /* defined by autoheader */ ++ const char *target = GNU_HOST; ++ ++ if (!target) ++ return 0; ++ ++ if (target && strncmp(argv[0], "clang", 5) != 0) ++ return 0; ++ ++ for (i = 0; argv[i]; ++i) { ++ if (strcmp(argv[i], "-target") == 0) { ++ return 0; ++ } ++ } ++ ++ dcc_argv_append(argv, strdup("-target")); ++ dcc_argv_append(argv, strdup(target)); ++ ++ return 0; ++} ++ + /** + * Execute the commands in argv remotely or locally as appropriate. + * +@@ -521,6 +551,7 @@ dcc_build_somewhere(char *argv[], + ret = dcc_scan_args(argv, &input_fname, &output_fname, &new_argv); + dcc_free_argv(argv); + argv = new_argv; ++ dcc_add_clang_target(new_argv); + if (ret != 0) { + /* we need to scan the arguments even if we already know it's + * local, so that we can pick up distcc client options. */ +-- +2.14.1 + diff --git a/packages/distcc/allow.patch b/packages/distcc/allow.patch deleted file mode 100644 index f52f26c6e96b052..000000000000000 --- a/packages/distcc/allow.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/src/daemon.c b/src/daemon.c -index a1056f8..e11b29e 100644 ---- a/src/daemon.c -+++ b/src/daemon.c -@@ -165,15 +165,6 @@ int main(int argc, char *argv[]) - if (distccd_parse_options(argc, (const char **) argv)) - dcc_exit(EXIT_DISTCC_FAILED); - -- /* check this before redirecting the logs, so that it's really obvious */ -- if (!dcc_should_be_inetd()) -- if (opt_allowed == NULL) { -- rs_log_error("--allow option is now mandatory; " -- "you must specify which clients are allowed to connect"); -- ret = EXIT_BAD_ARGUMENTS; -- goto out; -- } -- - if ((ret = dcc_set_lifetime()) != 0) - dcc_exit(ret); - - From 15ab71cd49075d9d04f816ba3ef59f073c0fbd47 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Mon, 27 Nov 2017 12:07:31 -0800 Subject: [PATCH 7/7] more complete cross compile patch --- .../0001-cross-compilation-support.patch | 121 ++++++++++++++++++ ...0003-clang-cross-compilation-support.patch | 61 --------- 2 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 packages/distcc/0001-cross-compilation-support.patch delete mode 100644 packages/distcc/0003-clang-cross-compilation-support.patch diff --git a/packages/distcc/0001-cross-compilation-support.patch b/packages/distcc/0001-cross-compilation-support.patch new file mode 100644 index 000000000000000..a04b8a2994da86b --- /dev/null +++ b/packages/distcc/0001-cross-compilation-support.patch @@ -0,0 +1,121 @@ +From 5eeec8310ba95b9beb3c74903a91e44bcbdc925d Mon Sep 17 00:00:00 2001 +From: Shawn Landden +Date: Sat, 25 Nov 2017 23:42:43 -0800 +Subject: [PATCH] cross-compilation support + +--- + man/distcc.1 | 5 ++++ + src/compile.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 95 insertions(+) + +diff --git a/src/compile.c b/src/compile.c +index df73e9c..936c4b3 100644 +--- a/src/compile.c ++++ b/src/compile.c +@@ -445,6 +445,92 @@ static int dcc_please_send_email_after_investigation( + return dcc_note_discrepancy(discrepancy_filename); + } + ++/* Clang is a native cross-compiler, but needs to be told to what target it is ++ * building. ++ * TODO: actually probe clang with clang --version, instead of trusting ++ * autoheader. ++ */ ++static void dcc_add_clang_target(char **argv) ++{ ++ /* defined by autoheader */ ++ const char *target = GNU_HOST; ++ ++ 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) ++ ; ++ else ++ return; ++ ++ if (dcc_argv_search(argv, "-target")) ++ return; ++ ++ rs_log_info("Adding '-target %s' to support clang cross-compilation.", ++ target); ++ dcc_argv_append(argv, strdup("-target")); ++ dcc_argv_append(argv, strdup(target)); ++} ++ ++/* ++ * Cross compilation for gcc ++*/ ++static int dcc_gcc_rewrite_fqn(char **argv) ++{ ++ /* defined by autoheader */ ++ const char *target_with_vendor = GNU_HOST, *path; ++ char *newcmd, *t; ++ int pathlen = 0; ++ ++ if (strcmp(argv[0], "gcc") == 0 || strncmp(argv[0], "gcc-", strlen("gcc-")) == 0 || ++ strcmp(argv[0], "g++") == 0 || strncmp(argv[0], "g++-", strlen("g++-")) == 0) ++ ; ++ else ++ return -ENOENT; ++ ++ ++ newcmd = malloc(strlen(target_with_vendor) + 1 + strlen(argv[0] + 1)); ++ if (!newcmd) ++ return -ENOMEM; ++ ++ if ((t = strstr(target_with_vendor, "-pc-"))) { ++ strncpy(newcmd, target_with_vendor, t - target_with_vendor); ++ strcat(newcmd, t + strlen("-pc")); ++ } else ++ strcpy(newcmd, target_with_vendor); ++ ++ ++ strcat(newcmd, "-"); ++ strcat(newcmd, argv[0]); ++ ++ /* TODO, is this the right PATH? */ ++ path = getenv("PATH"); ++ do { ++ char *t, *binname = alloca(pathlen + 1 + strlen(newcmd) + 1); ++ int r; ++ ++ /* emulate strchrnul() */ ++ t = strchr(path, ':'); ++ if (!t) ++ t = path + strlen(path); ++ pathlen = t - path; ++ if (*path == '\0') ++ return -ENOENT; ++ strncpy(binname, path, pathlen); ++ binname[pathlen] = '\0'; ++ strcat(binname, "/"); ++ strcat(binname, newcmd); ++ r = access(binname, X_OK); ++ if (r < 0) ++ continue; ++ /* good!, now rewrite */ ++ rs_log_info("Re-writing call to '%s' to '%s' to support cross-compilation.", ++ argv[0], newcmd); ++ free(argv[0]); ++ argv[0] = newcmd; ++ return 0; ++ } while ((path += pathlen + 1)); ++ return -ENOENT; ++} ++ + /** + * Execute the commands in argv remotely or locally as appropriate. + * +@@ -521,6 +607,10 @@ dcc_build_somewhere(char *argv[], + ret = dcc_scan_args(argv, &input_fname, &output_fname, &new_argv); + dcc_free_argv(argv); + argv = new_argv; ++ if (!getenv("DISTCC_NO_REWRITE_CROSS")) { ++ dcc_add_clang_target(new_argv); ++ dcc_gcc_rewrite_fqn(new_argv); ++ } + if (ret != 0) { + /* we need to scan the arguments even if we already know it's + * local, so that we can pick up distcc client options. */ +-- +2.14.1 + diff --git a/packages/distcc/0003-clang-cross-compilation-support.patch b/packages/distcc/0003-clang-cross-compilation-support.patch deleted file mode 100644 index 4e784d5ae389a94..000000000000000 --- a/packages/distcc/0003-clang-cross-compilation-support.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 6c1dac57785c4ae29de07c32b69256d5a4433658 Mon Sep 17 00:00:00 2001 -From: Shawn Landden -Date: Sat, 25 Nov 2017 23:42:43 -0800 -Subject: [PATCH 3/3] clang cross-compilation support - ---- - src/compile.c | 31 +++++++++++++++++++++++++++++++ - 1 file changed, 31 insertions(+) - -diff --git a/src/compile.c b/src/compile.c -index df73e9c..2f78482 100644 ---- a/src/compile.c -+++ b/src/compile.c -@@ -445,6 +445,36 @@ static int dcc_please_send_email_after_investigation( - return dcc_note_discrepancy(discrepancy_filename); - } - -+/* Clang is a native cross-compiler, but needs to be told to what target it is -+ * building. -+ * TODO: actually probe clang with clang --version, instead of trusting -+ * autoheader. -+ */ -+static int dcc_add_clang_target(char **argv) -+{ -+ int i; -+ -+ /* defined by autoheader */ -+ const char *target = GNU_HOST; -+ -+ if (!target) -+ return 0; -+ -+ if (target && strncmp(argv[0], "clang", 5) != 0) -+ return 0; -+ -+ for (i = 0; argv[i]; ++i) { -+ if (strcmp(argv[i], "-target") == 0) { -+ return 0; -+ } -+ } -+ -+ dcc_argv_append(argv, strdup("-target")); -+ dcc_argv_append(argv, strdup(target)); -+ -+ return 0; -+} -+ - /** - * Execute the commands in argv remotely or locally as appropriate. - * -@@ -521,6 +551,7 @@ dcc_build_somewhere(char *argv[], - ret = dcc_scan_args(argv, &input_fname, &output_fname, &new_argv); - dcc_free_argv(argv); - argv = new_argv; -+ dcc_add_clang_target(new_argv); - if (ret != 0) { - /* we need to scan the arguments even if we already know it's - * local, so that we can pick up distcc client options. */ --- -2.14.1 -