From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 51C0E13888F for ; Sat, 3 Jan 2015 14:54:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A6CD5E0794; Sat, 3 Jan 2015 14:54:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 02ECEE0794 for ; Sat, 3 Jan 2015 14:54:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2497D34059D for ; Sat, 3 Jan 2015 14:54:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B9E14EC7D for ; Sat, 3 Jan 2015 14:54:08 +0000 (UTC) From: "Andrew Savchenko" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Savchenko" Message-ID: <1420296750.a1605b450c17bfc0b459750e4fc49561bdb39401.bircoph@gentoo> Subject: [gentoo-commits] dev/bircoph:master commit in: sys-devel/distcc/, sys-devel/distcc/files/ X-VCS-Repository: dev/bircoph X-VCS-Files: sys-devel/distcc/Manifest sys-devel/distcc/distcc-3.2_rc1-r2.ebuild sys-devel/distcc/files/distcc-3.2_rc1-native.patch X-VCS-Directories: sys-devel/distcc/ sys-devel/distcc/files/ X-VCS-Committer: bircoph X-VCS-Committer-Name: Andrew Savchenko X-VCS-Revision: a1605b450c17bfc0b459750e4fc49561bdb39401 X-VCS-Branch: master Date: Sat, 3 Jan 2015 14:54:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6dcd8648-1163-4a1a-8404-42e5dcd95f91 X-Archives-Hash: ab08ebdc992709fbeb2bfc31828486e0 commit: a1605b450c17bfc0b459750e4fc49561bdb39401 Author: Andrew Savchenko gmail com> AuthorDate: Sat Jan 3 14:52:30 2015 +0000 Commit: Andrew Savchenko gmail com> CommitDate: Sat Jan 3 14:52:30 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=dev/bircoph.git;a=commit;h=a1605b45 distcc: sync fix python and QA Fix variables to match python-r1.eclass. Move large patch to dev.gentoo.org's public_html. --- sys-devel/distcc/Manifest | 4 +- sys-devel/distcc/distcc-3.2_rc1-r2.ebuild | 7 +- sys-devel/distcc/files/distcc-3.2_rc1-native.patch | 924 --------------------- 3 files changed, 6 insertions(+), 929 deletions(-) diff --git a/sys-devel/distcc/Manifest b/sys-devel/distcc/Manifest index 1335727..a832d2e 100644 --- a/sys-devel/distcc/Manifest +++ b/sys-devel/distcc/Manifest @@ -14,13 +14,13 @@ AUX distcc-3.1-argc-fix.patch 480 SHA256 e576553f27c7fabc2dcd3f361a98e2db70fef9f AUX distcc-3.2_rc1-crosscompile.patch 5029 SHA256 98f878fec98e19011505a4d43ee4719e615a76863af8d0e15c19784c9cd43fef SHA512 e97ab66999859812c77cd077aa2220d49d39998748c368476193acd6e8276af4e58bb1ae54dfd848ba6cb67ae23a6d5776fc488d21aa518a0cfa22834805f517 WHIRLPOOL 711c438c78797df03bb9dc09ffc812f65766621a351121b34e695e73783a785b0488254bfde4e4e9e8e7916563c6b41b36b593773df548c4fae80eaf45aea4ae AUX distcc-3.2_rc1-freedesktop.patch 3140 SHA256 7ead1174fc170cee5c32ac183edf0c15ae35df56bedbbf6bc24c0099fe23b7f6 SHA512 fe953e1884b498da9cbb83ca90af9e49b554ad56fef8a8f55b9e6b46e5904f7376e5e58a9123f4acb474e16577fb6c9371a12eddc29c07c5d488be847f4ed2ef WHIRLPOOL b073d4c775493a2976dc430f949269d6328178254c2080ca1f8c71be3b935cdfcc5e3135e2504e87267059df243f744d2f7f90a517aefebeaed5f55e40607eb1 AUX distcc-3.2_rc1-gssapi.patch 1638 SHA256 2693fbf5b76ab64874e0a4bc1540067f402799dfabde5202a89ec045f1d88ea0 SHA512 c804189f87068f82e7cb18de4e8d30cc67db7cc7fbcb13872d44e3f6fb006b3c779adf9c6068ae50831ef649da718ddb33c0efc4354636aacc9a7217b3c9a348 WHIRLPOOL fd0afc3bcdc176aec7f2f2e9d990578573628c66a23da60ba8e34663c86835ca138f48a2feb4f02dd8cfa2c28442f65338ea531994a09db38bbdf62bfdfcbe4d -AUX distcc-3.2_rc1-native.patch 29735 SHA256 65c0a6761be1299920e4d4c57ea9c8fa60710311c0a99acd9bb241d4b60d1d73 SHA512 cf2d7c1042c757281b300967fdcd6f7a83dc10444a2779e2678977cf507bdac06508917ada5e320ffb0cb0f5254bccf267a253407bcdf39a0067cda44fd9c798 WHIRLPOOL 682ba316ecdffafd4ec22fef7fefb5a58bd724b7f244f9dd8a03cb9fa33e27c92095fa58c5181b8638b5434734554ffd6ebd9139f622fc9e99f27a90fa28103f AUX distcc-3.2_rc1-python.patch 10592 SHA256 935328943efe26f20bfb94952bc8bcb7f8536465db72411d81e6f3d1ade37989 SHA512 513c2fb9aa8f222a0f6062795fac1f855d67467d796b406c6b685e345554ce09a96ab9e594d6a05aad6c5a0f8c7906700529cfb562f2dd7c498d9078219b3d6b WHIRLPOOL 0ec9deafa00b161a29ead3ff7791262a189501d2ca69d03d46eb5838ca3effa8e1de7878b72917634cb261ee2cf68401f2b8ca70048345d4bfddc6db82fa56aa AUX distcc-config-3.2_rc1-v2 7983 SHA256 70763dd6f53cfbe373dc54ab68fc1cda8eeda0db5241166f3da2d9655314193d SHA512 6a1b40c578d8e46a9dfffee3a5186b5d4c68cdc1266f37395fc8c25c9c519af30069912934dd34004b65bfa8c554e691ea8182d28a26af024fe32d372de8c984 WHIRLPOOL 94f142c15d2c0858afd1ffc8882676faed86b993f1292293946272b7220266bdd057b8bdc7f0fe057dbcabfc199aa7d662b91cd8bb6c3295c1a08e2d7a4c322f AUX distcc-hardened.patch 1084 SHA256 dcf63f201cb7f4bf13eeb1485a5056c64370b9239d28e4acc77a47046dcda6cf SHA512 d1150dc83bf89c332f8c0bd01e15f52f95d71868733bd2e5430a5377f1a4aaa2b5b6e0cd488d33d9b94ce18b0eeeadf4af719db536b001b50e4d482b35c7e057 WHIRLPOOL 5faa97711f48d3bb41c6362d9467dab28546d01015de1b76eaaf847d633711bf56af16d1e3484b9bf9215cdf5436fcc6837bc870287cce02553b9ff756215111 AUX distccd.confd 1292 SHA256 95c1118098be6e6594442ee841a0b58c1aa72d0059d91c10001bd449336fba2b SHA512 996b5e021e61abe121a220c764da21d9f19c3bff8e1ebfbc48958d230a41f0d7673e0eb7ca2d419248ee5ea97b02218c51630f2754f9da1418888cc2d09bd3ce WHIRLPOOL a6567d09456bcc79a8f273051eef5fc41da7672eb06a4ef132cb222cf21a2696dac2893b0999b5657492b84f30db7fba6897aab96ba67a1a232d9b827538f101 AUX distccd.initd 832 SHA256 cc2f9cfb51a3889167f5270442251f713d4774ec468f1e428cff3ac22aa75320 SHA512 645dcbff5a27455f9dda9d7c9696aec9f436ebf6c9363c16ea5411230bbf3b05f5f20ee760ebd062c41c28fdabe3c59a20e883c07fd79462a678d5046cf52e0e WHIRLPOOL be05eb81faa68b1ceb9d441ba99d983e54aa1fbb065d46774f9b3520abd8760fb99e3ab906f61f2605643db6030150e2b79890b0e7ef2f3e10fafef38a12e29a +DIST distcc-3.2_rc1-native.patch.xz 8000 SHA256 b83991c029982316ab283b2dc9646fbbed844a9190c223f8cfc996f930c66cda SHA512 29418160902996d38a9a8619cf07b60b1303b1e508831a706addae9fcbbbe61855cd489e97cab878f26fd4f0d3f8ac21164462b5befbbb15cf341dd73b539cc9 WHIRLPOOL cbb7a34c6642fc738abb8f671c9884dbd7d053aedc7371e85cba00a569ea14229291c74b22494d0ebe16d854b47998f00f518e5716ad74d433278f47f4427c6b DIST distcc-3.2rc1.tar.bz2 609904 SHA256 311671e844625d7fdb18dd3d096cd855751cfe8de13827682bcb7beff9133b30 SHA512 98b2e8423d724bbb6a615d946d170441a8e293310785f867d7a277b318c043a37b0af39ae8ed1f7a0667803de9db1d1925199bad85130cf9bd9cb347635125ee WHIRLPOOL d366abb05d10aa5a458acf7b57f5bf52fd4f5ff46c68494e28140eb944524e66d729ebef60190acb1d9b33a0fb8faea6b909509de67294c29dbebcf01d500a36 -EBUILD distcc-3.2_rc1-r2.ebuild 7837 SHA256 f0f8f7eefce33133eadf37fc320af51f53dd5de3d87a34deaa5d9721cf2cfe4f SHA512 92feb61338fb949556c2fe0ef8879ba1d9466a3d0fc134fa58235b700922a13e9a730aadc6df5ed8adf9c6349e77e5140a60a43b29154462c44530c995d31faa WHIRLPOOL 1d34d8cb5b54925793588e84cf22384faec54e10b53e513ccd0ec8fdce1b0be1d201235adb97bd6e9130b6654e117c2d7170a84e1aec49b5e77684d916bbb6c6 +EBUILD distcc-3.2_rc1-r2.ebuild 7887 SHA256 7fef1fc762167ba5415fffad96a9592eb059dfec73a5ac5929cb7e370bdc8f52 SHA512 5cedda57453ea7364855606d2cc99711ce51315238738622f635a2368754215af4376c2ff80b051b809b0b20b3d8c5bb1b0ebe525112b3ea90d3fcc8f964794d WHIRLPOOL b614e439e3d92b228752aebf606afc4da62c2f10119bd9a71a98adff027c37b41e5d3ff91bc001919b4ca26c2e1f5ccd699ce7f2bcc27ab691e94820af3e437e MISC ChangeLog 42654 SHA256 a8b548a16dc870630092eb94f21abad5b01e461bc47887ae407150a3a6d0678b SHA512 8011702bafe58a1dd6044e988d5424bea1bbc9791d87f7d674a2eeeaeff913a4109bcab5eb07bad3432705867065a6b1e0d04154c7413aa1f4c7f3a53b482eb0 WHIRLPOOL f77ac79af511ba7aa2f9433dee67807d8655b7e5ddcaa3cd50c8da3e859056f3355e49dec819474816117cb05ff73025b81a0e29bab5cfa62bef0c476a22d464 MISC metadata.xml 881 SHA256 d65af84bc59b5847e7a126d69160714fd49ef0d01838af2f6e60accb8d4a99fb SHA512 39d69d8c86cc5befc4409dc132fb4daa8c49f07f91dc13b127fd782915aed88300b98dfad10c53ac225acf0db5e4be5c9972e667fd777c5b856a3c472a7f4993 WHIRLPOOL ecb2b558e7813de05847356d64996f5344c3a89aa8aaf2cf8054a2de84f76b5843b11ec92063f9566fe27edd78b76595cde58f74587786ef7356292618287784 diff --git a/sys-devel/distcc/distcc-3.2_rc1-r2.ebuild b/sys-devel/distcc/distcc-3.2_rc1-r2.ebuild index 3845ed8..3d37971 100644 --- a/sys-devel/distcc/distcc-3.2_rc1-r2.ebuild +++ b/sys-devel/distcc/distcc-3.2_rc1-r2.ebuild @@ -11,7 +11,8 @@ inherit autotools eutils fdo-mime flag-o-matic multilib python-single-r1 toolcha MY_P="${P/_}" DESCRIPTION="Distribute compilation of C code across several machines on a network" HOMEPAGE="http://distcc.org/" -SRC_URI="http://distcc.googlecode.com/files/${MY_P}.tar.bz2" +SRC_URI="http://distcc.googlecode.com/files/${MY_P}.tar.bz2 + http://dev.gentoo.org/~bircoph/patches/${P}-native.patch.xz" LICENSE="GPL-2" SLOT="0" @@ -79,14 +80,14 @@ src_prepare() { # for cross-compiling epatch "${FILESDIR}/${P}-crosscompile.patch" # to support native arguments - epatch "${FILESDIR}/${P}-native.patch" + epatch "${WORKDIR}/${P}-native.patch" # Bugs #120001, #167844 and probably more. See patch for description. use hardened && epatch "${FILESDIR}/distcc-hardened.patch" sed -i \ -e "/PATH/s:\$distcc_location:${EPREFIX}${DCCC_PATH}:" \ - -e "s:@PYTHON@:${EPREFIX}$(PYTHON -a):" \ + -e "s:@PYTHON@:${EPYTHON}:" \ pump.in || die "sed failed" sed \ diff --git a/sys-devel/distcc/files/distcc-3.2_rc1-native.patch b/sys-devel/distcc/files/distcc-3.2_rc1-native.patch deleted file mode 100644 index 27ff261..0000000 --- a/sys-devel/distcc/files/distcc-3.2_rc1-native.patch +++ /dev/null @@ -1,924 +0,0 @@ -diff -Naurd -x '*.swp' -x '*.o' -x '*.d' -x config.h distcc-3.2rc1.orig/src/arg.c distcc-3.2rc1/src/arg.c ---- distcc-3.2rc1.orig/src/arg.c 2008-12-03 00:50:24.000000000 +0300 -+++ distcc-3.2rc1/src/arg.c 2013-06-17 05:23:22.575994582 +0400 -@@ -4,6 +4,7 @@ - * - * Copyright (C) 2002, 2003, 2004 by Martin Pool - * Copyright 2007 Google Inc. -+ * Copyright 2013 Andrew Savchenko - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License -@@ -134,6 +135,8 @@ - int i; - char *a; - int ret; -+ int arg_native = 0; -+ int input_idx, output_idx; // indices of input and output arguments - - /* allow for -o foo.o */ - if ((ret = dcc_copy_argv(argv, ret_newargv, 2)) != 0) -@@ -182,13 +185,11 @@ - rs_trace("%s implies -E (maybe) and must be local", a); - return EXIT_DISTCC_FAILED; - } else if (!strcmp(a, "-march=native")) { -- rs_trace("-march=native generates code for local machine; " -- "must be local"); -- return EXIT_DISTCC_FAILED; -+ arg_native |= DCC_ARG_MARCH; - } else if (!strcmp(a, "-mtune=native")) { -- rs_trace("-mtune=native optimizes for local machine; " -- "must be local"); -- return EXIT_DISTCC_FAILED; -+ arg_native |= DCC_ARG_MTUNE; -+ } else if (!strcmp(a, "-mcpu=native")) { -+ arg_native |= DCC_ARG_MCPU; - } else if (str_startswith("-Wa,", a)) { - /* Look for assembler options that would produce output - * files and must be local. -@@ -236,6 +237,7 @@ - return EXIT_DISTCC_FAILED; - } - *input_file = a; -+ input_idx = i; - } else if (str_endswith(".o", a)) { - GOT_OUTPUT: - rs_trace("found object/output file \"%s\"", a); -@@ -244,6 +246,7 @@ - return EXIT_DISTCC_FAILED; - } - *output_file = a; -+ output_idx = i; - } - } - } -@@ -265,6 +268,14 @@ - if (dcc_source_needs_local(*input_file)) - return EXIT_DISTCC_FAILED; - -+ /* Expand -m$arg=native using local compiler */ -+ if (arg_native && (ret = dcc_expand_native(ret_newargv, arg_native, -+ &input_idx, &output_idx))) -+ return ret; -+ // correct input filename index -+ argv = *ret_newargv; -+ *input_file = argv[input_idx]; -+ - if (!*output_file) { - /* This is a commandline like "gcc -c hello.c". They want - * hello.o, but they don't say so. For example, the Ethereal -@@ -293,6 +304,9 @@ - dcc_argv_append(argv, strdup("-o")); - dcc_argv_append(argv, ofile); - *output_file = ofile; -+ } else { -+ // correct output filename index -+ *output_file = argv[output_idx]; - } - - dcc_note_compiled(*input_file, *output_file); -diff -Naurd -x '*.swp' -x '*.o' -x '*.d' -x config.h distcc-3.2rc1.orig/src/arg_native.c distcc-3.2rc1/src/arg_native.c ---- distcc-3.2rc1.orig/src/arg_native.c 1970-01-01 03:00:00.000000000 +0300 -+++ distcc-3.2rc1/src/arg_native.c 2013-06-18 02:10:22.688183653 +0400 -@@ -0,0 +1,705 @@ -+/* -*- c-file-style: "java"; indent-tabs-mode: nil; tab-width: 4; fill-column: 78 -*- -+ * -+ * distcc -- A simple distributed compiler system -+ * -+ * Copyright 2013 Andrew Savchenko -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -+ * USA. -+ */ -+ -+ -+ /* The chief enemy of creativity is "good" sense -+ * -- Picasso */ -+ -+ -+/** -+ * @file -+ * -+ * Functions for -m$arg=native argument expansion. -+ * -+ * Instead of compiling -march=native locally (as well as -mtune=native and -+ * -mcpu=native) we can extract expansion of native parameter from -+ * gcc output in a way similar to: -+ * $ gcc -march=native -E -v - < /dev/null 2>&1 | egrep "\-E -quiet -v" | -+ * sed 's/.*-E -quiet -v - //' -+ * -+ * Results are per-compiler cached. Compiler is identified by mtime -+ * and size. -+ * -+ * -march supersedes -mcpu and -mcpu supersedes -mtune, so all args -+ * should be parsed before actual expansion. -+ **/ -+ -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include "distcc.h" -+#include "trace.h" -+#include "exitcode.h" -+#include "snprintf.h" -+ -+/** -+ * Search compiler based on its basename. -+ * -+ * First try to get PATH. If it is undefined or emphy, try to get -+ * system defaults from confstr(). -+ * -+ * @param name Compiler base name. -+ * @param fullname Returned found full name. -+ * -+ * @return dcc standard exit code -+ **/ -+static int -+dcc_search_compiler_in_path(const char *name, char **fullname) -+{ -+ char *envpath; -+ char *token, *saveptr, *str; -+ int envpath_size = 256; -+ int ret; -+ int need4free = 0; // do we need to free envpath? -+ // it can't be touched after getenv, but must -+ // be after confstr -+ -+ /* Look for PATH */ -+ if (!(envpath = getenv("PATH")) || !strlen(envpath)) { -+ // Strange, but legal: we have PATH undefined or empty -+ rs_trace("PATH seems to be not defined"); -+ -+ // try to get from standard configuration, -+ // will result in something like "/bin:/usr/bin" -+ envpath = malloc(envpath_size * sizeof(char)); -+ if (!(envpath = malloc(envpath_size * sizeof(char)))) { -+ rs_log_error("failed to allocate PATH buffer"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ need4free = 1; -+ -+ ret = confstr(_CS_PATH, envpath, envpath_size); -+ if (ret > envpath_size) { -+ // Strange, but legal: too long default PATH -+ if (!(envpath = realloc(envpath, ret * sizeof(char)))) { -+ rs_log_error("failed to reallocate PATH buffer"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ envpath_size = ret; -+ // Recall with full path -+ confstr(_CS_PATH, envpath, envpath_size); -+ } -+ if (!(confstr(_CS_PATH, envpath, ret))) { -+ rs_log_error("confstr() says PATH have no value"); -+ return EXIT_COMPILER_MISSING; -+ } -+ } -+ -+ /* Parse PATH string */ -+ ret = EXIT_COMPILER_MISSING; -+ str = strdup(envpath); // copy as will need to modify -+ while ((token = strtok_r(str, ":", &saveptr))) { -+ // construct full name to check -+ if (asprintf(fullname, "%s/%s", token, name) == -1) { -+ rs_log_error("asprintf failed for compiler fullname"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ -+ if (!access(*fullname, X_OK)) { -+ // found it! -+ rs_trace("compiler found: %s", *fullname); -+ ret = 0; -+ break; -+ } -+ str = NULL; -+ } -+ -+ if (need4free) -+ free(envpath); -+ return ret; -+} -+ -+/** -+ * Search compiler and get its ID: size, mtime in form of a hash -+ * string. This should be reliable enough for compiler change -+ * detection. -+ * -+ * @param name Compiler name. -+ * @param hash Found hash value. Must be freed by caller. -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_get_compiler_id(const char *name, char **hash) -+{ -+ char *fullname; -+ int ret; -+ int need4free = 1; // do we need to free fullname? -+ struct stat statbuf; -+ -+ /* Look for full name first */ -+ if (name[0] == '/') { -+ if (!access(name, X_OK)) { -+ fullname = (char*)name; -+ need4free = 0; -+ } else { -+ rs_log_warning("compiler is not accessible by its full name '%s' : %s", -+ name, strerror(errno)); -+ // If compiler is not found by a full name, it may be -+ // somewhere else, so try PATH as fallback. -+ // Strip dirname before proceed further. -+ if (( ret = dcc_search_compiler_in_path(basename(name), &fullname) )) -+ return ret; -+ } -+ } else { -+ if (( ret = dcc_search_compiler_in_path(name, &fullname) )) -+ return ret; -+ } -+ -+ /* Get ID data */ -+ if (stat(fullname, &statbuf) == -1) { -+ rs_log_error("failed to stat compiler '%s': %s", fullname, strerror(errno)); -+ return EXIT_COMPILER_MISSING; -+ } -+ -+ /* Generate compiler hash: hex(size, mtime)*/ -+ if (asprintf(hash, "%lx%lx", statbuf.st_size, statbuf.st_mtime) == -1) { -+ rs_log_error("can't generate compiler's hash"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ rs_trace("compiler is %s, hash is %s", fullname, *hash); -+ -+ if (need4free) -+ free(fullname); -+ return 0; -+} -+ -+/** -+ * Generate cache path and file name based on compiler's hash and -+ * native type. -+ * -+ * Cache is stored at $DISTCC_DIR/cache/$hash-$type , -+ * where type is a charfield "act" corresponding to -march, -mcpu -+ * and -mtune options present (with native argument). -+ * -+ * @note -+ * A complicate thing here is that on different architectures -+ * different combinations of these options may provide different -+ * non-additive results. E.g. expanded options from -march, -mcpu -+ * and -march -mcpu (together) may yield three different results - -+ * that's why we need to cache them separately. Though order of -+ * options doesn't matter, thus we have seven cases left :) -+ * -+ * @param ret_hash Compiler hash. Full hash name is returned by this -+ * variable too. -+ * @param type Bitmask of requested native type. -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_get_hash_filename(char **ret_hash, const int type) -+{ -+ int hash_len, ret; -+ char *hash = *ret_hash; -+ char *cachedir; -+ char *hashname; -+ -+ // Grow hash array to adapt the longest possible extension: -+ // "-act" -+ hash_len = strlen(hash); -+ // 4 bytes for extension + 1 for '\0' -+ if (!(hash = realloc(hash, (hash_len + 5) * sizeof(char)))) { -+ rs_log_error("failed to reallocate PATH buffer"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ -+ /* Add hash name extension based on its type. */ -+ hash[hash_len++] = '-'; -+ if (type & DCC_ARG_MARCH) -+ hash[hash_len++] = 'a'; -+ if (type & DCC_ARG_MCPU) -+ hash[hash_len++] = 'c'; -+ if (type & DCC_ARG_MTUNE) -+ hash[hash_len++] = 't'; -+ hash[hash_len++] = '\0'; -+ -+ /* Get cache directory */ -+ if (dcc_get_cache_dir(&cachedir)) { -+ rs_log_error("can't get cache directory"); -+ *ret_hash = hash; -+ return EXIT_IO_ERROR; -+ } -+ -+ // construct full hash name -+ if (asprintf(&hashname, "%s/%s", cachedir, hash) == -1) { -+ rs_log_error("asprintf failed for hash full name"); -+ *ret_hash = hash; -+ ret = EXIT_OUT_OF_MEMORY; -+ } else { -+ free(hash); -+ *ret_hash = hashname; -+ ret = 0; -+ } -+ -+ free(cachedir); -+ -+ return ret; -+} -+ -+/** -+ * Split string into argv array. -+ * -+ * @param str String to split -+ * @param ret_argv Pointer to argv array -+ * @param ret_argc Pointer to argv size (not including last NULL -+ * element) -+ * -+ * @return dcc standard exit code -+ * Error is also returned if no elements were found, -+ * argv is cleared in this case. -+ **/ -+static int -+dcc_str_to_argv(char *str, char ***ret_argv, int *ret_argc) -+{ -+ const char *delim = " \t\v\n\r"; // possible field delimitors -+ char *saveptr, *token; -+ int argv_size = 64; // memory allocation size for argv, may be larger argc -+ char **argv; -+ int argc; -+ -+ argc = 0; -+ // allocate initial argv buffer -+ if (!(argv = malloc(sizeof(char*) * argv_size))) { -+ rs_log_error("failed to allocate argv buffer"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ -+ /* Convert string to argv array */ -+ for (argc = 0; (token = strtok_r(str, delim, &saveptr)); argc++, str = NULL) { -+ // grow array as needed -+ if (argc + 2 > argv_size) { -+ argv_size *= 2; -+ if (!(argv = realloc(argv, sizeof(char*) * argv_size))) { -+ rs_log_error("failed to reallocate argv buffer"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ } -+ // record new element -+ argv[argc] = strdup(token); -+ } -+ argv[argc] = NULL; -+ -+ /* If list is empty, emit an error */ -+ if (!argc) { -+ rs_log_error("argv string is empty!"); -+ dcc_free_argv(argv); -+ argv = NULL; -+ return EXIT_DISTCC_FAILED; -+ } -+ -+ // return values -+ *ret_argv = argv; -+ *ret_argc = argc; -+ -+ return 0; -+} -+ -+/** -+ * Look for a cache file for present compiler and flag type. -+ * -+ * This function errors should be non-fatal for further proceeding. -+ * Cache miss is OK. -+ * -+ * @param hash Compiler hash -+ * @param argv Where to write argv -+ * @param argc Where to write argc, terminating NULL is not -+ * counted. -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_cache_query(const char *hashname, char ***argv, int *argc) -+{ -+ int ret; -+ FILE *cache ; -+ char *buf = NULL; -+ size_t buf_size; -+ -+ if (!(cache = fopen(hashname, "r"))) { -+ // File is not readable (or absent) -+ rs_trace("can't open cache file %s : %s", hashname, strerror(errno)); -+ return EXIT_NO_SUCH_FILE; -+ } -+ -+ // Get cache string -+ if (getline(&buf, &buf_size, cache) == -1) { -+ rs_log_error("cache %s is empty!", hashname); -+ ret = EXIT_DISTCC_FAILED; -+ } else { -+ // split parameter list into argv array -+ rs_log_info("cache found : %s", hashname); -+ ret = dcc_str_to_argv(buf, argv, argc); -+ } -+ -+ // cleanup -+ if (fclose(cache)) -+ rs_log_error("can't close cache file %s : %s", hashname, strerror(errno)); -+ free(buf); -+ -+ return ret; -+} -+ -+/** -+ * Child process intended to run compiler sample in order to -+ * extract -m expansion. -+ * -+ * @param name Compiler name -+ * @param type -m type -+ * @param pipefd pipe descriptors -+ * -+ * @return never -+ **/ -+static void NORETURN -+dcc_compiler_query_child(const char *name, const int type, const int pipefd[]) -+{ -+ const char *args[8] = {NULL, "-E", "-v", "-", NULL, NULL, NULL, NULL}; -+ const char *args_m[3] = {"-march=native", "-mcpu=native", "-mtune=native"}; -+ int argsidx; -+ int devnull; -+ -+ // do not read from pipe -+ if (close(pipefd[0])) { -+ rs_log_error("can't close child's pipe: %s", strerror(errno)); -+ exit(EXIT_IO_ERROR); -+ } -+ -+ // redirect stdin and stdout to /dev/null -+ if ((devnull = open("/dev/null", O_RDWR)) == -1) { -+ rs_log_error("can't open /dev/null: %s", strerror(errno)); -+ exit(EXIT_IO_ERROR); -+ } -+ if (dup2(devnull, 0) == -1) { -+ rs_log_error("can't redirect /dev/null to stdin: %s", strerror(errno)); -+ exit(EXIT_IO_ERROR); -+ } -+ if (dup2(devnull, 1) == -1) { -+ rs_log_error("can't redirect stdout to /dev/null: %s", strerror(errno)); -+ exit(EXIT_IO_ERROR); -+ } -+ -+ /* Prepare compiler args */ -+ args[0] = basename(name); -+ argsidx = 4; // first empty slot; -+ if (type & DCC_ARG_MARCH) -+ args[argsidx++] = args_m[0]; -+ if (type & DCC_ARG_MCPU) -+ args[argsidx++] = args_m[1]; -+ if (type & DCC_ARG_MTUNE) -+ args[argsidx++] = args_m[2]; -+ -+ if (rs_trace_level >= RS_LOG_INFO) -+ rs_log_info("running compiler query: %s %s", name, dcc_argv_tostr((char**)args)); -+ -+ // write stderr to pipe -+ if (dup2(pipefd[1], 2) == -1) { -+ rs_log_error("can't dup2() stderr: %s", strerror(errno)); -+ exit(EXIT_IO_ERROR); -+ } -+ -+ /* Run compiler */ -+ execvp(name, (char *const *)args); -+ // We've failed. Try based on basename. -+ execvp(args[0], (char *const *)args); -+ exit(EXIT_COMPILER_MISSING); -+} -+ -+/** -+ * Get -m=native expansion from compiler output alike: -+ * $ gcc -E -v - -march=native < /dev/null 2>&1 -+ * We need to parse stderr. -+ * -+ * @param name Compiler name -+ * @param argv argv storage -+ * @param argc argv size -+ * @param type Type of query to perform (march, mtune, mcpu) -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_compiler_query(const char *name, char ***argv, int *argc, const int type) -+{ -+ int pipefd[2]; // pipe for gcc stderr -+ pid_t cpid; // child pid -+ -+ FILE *out; // stderr output data from gcc -+ char *buf = NULL; // stderr buffer -+ size_t buf_size; -+ char *match; -+ int ret; -+ -+ // prepare pipe to get stderr -+ if (pipe(pipefd) == -1) { -+ rs_log_error("failed to create pipe for compiler: %s", strerror(errno)); -+ return EXIT_IO_ERROR; -+ } -+ -+ // here we go.. -+ if ((cpid = fork()) == -1) { -+ rs_log_error("failed to fork for compiler: %s", strerror(errno)); -+ return EXIT_DISTCC_FAILED; -+ } -+ -+ if (!cpid) { -+ /* Child is here */ -+ dcc_compiler_query_child(name, type, pipefd); -+ } else { -+ /* Parent is here */ -+ -+ // do not write to pipe -+ if (close(pipefd[1])) { -+ rs_log_error("can't close parent's pipe: %s", strerror(errno)); -+ return EXIT_IO_ERROR; -+ } -+ -+ // open pipe from child -+ if (!(out = fdopen(pipefd[0], "r"))) { -+ rs_trace("can't open pipe from child : %s", strerror(errno)); -+ return EXIT_NO_SUCH_FILE; -+ } -+ -+ /* Parse GCC output */ -+ ret = EXIT_DISTCC_FAILED; // in case we'll found nothing -+ while (getline(&buf, &buf_size, out) != -1) { -+ // grep for unique pattern -+ if (!(match = strstr(buf, " - "))) -+ continue; -+ // convert to argv -+ ret = dcc_str_to_argv(match + 3, argv, argc); -+ break; -+ } -+ -+ // cleanup -+ if (fclose(out)) -+ rs_log_error("can't close pipe : %s", strerror(errno)); -+ free(buf); -+ -+ if (wait(NULL) == -1) -+ rs_log_error("wait failed : %s", strerror(errno)); -+ } -+ -+ return ret; -+} -+ -+/** -+ * Save expanded "native" arguments to cache -+ * -+ * @param hash Filename to save hash to -+ * @param argv argv array to save -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_cache_write(const char *hash, const char **argv) -+{ -+ FILE *cache; -+ char *astr; -+ int ret = 0; -+ -+ if (!(cache = fopen(hash, "w"))) { -+ rs_trace("unable to create cache file %s : %s", hash, strerror(errno)); -+ return EXIT_IO_ERROR; -+ } -+ -+ // write data to the file -+ astr = dcc_argv_tostr((char**)argv); -+ if (fputs(astr, cache) == EOF) { -+ rs_log_error("can't write to cache file %s : %s", hash, strerror(errno)); -+ ret = EXIT_IO_ERROR; -+ } -+ -+ if (fclose(cache)) { -+ rs_log_error("can't close cache file %s : %s", hash, strerror(errno)); -+ ret = EXIT_IO_ERROR; -+ } -+ free(astr); -+ -+ if (!ret) -+ rs_log_info("cache %s saved", hash); -+ -+ return ret; -+} -+ -+/** -+ * Insert native expansion into argv instead of first occurrence of -+ * native flags, remove all other native encounters. -+ * -+ * A special pain here is that input and output filename indices in -+ * the argv will be changed and must be recalculated. -+ * -+ * @param argv Original list of arguments, must be freed by the caller. -+ * @param exp_argv Expanded list of arguments. -+ * @param exp_argc Size of exp_argv array. -+ * @param input_idx index of input file name in the argv -+ * @param output_idx index of output file name in the argv -+ * -+ * @return dcc standard exit code -+ **/ -+static inline int -+dcc_insert_expansion(char ***argv, char ***ret_exp_argv, const int exp_argc, -+ int *input_idx, int *output_idx) -+{ -+ char **new_argv; // buffer for new argv -+ char **old_argv; // pointer to old argv -+ char **exp_argv; // pointer to old argv -+ char *astr; -+ char *a; -+ int inserted = 0; // flag is set if expansion data is already inserted -+ int i, j, k; -+ -+ // new array length <= old - 1(at least) + exp + 1 -+ if (!(new_argv = malloc((dcc_argv_len(*argv) + exp_argc) * sizeof(char*)))) { -+ rs_log_error("failed to allocate argv for native expansion"); -+ return EXIT_OUT_OF_MEMORY; -+ } -+ -+ // generate new argv -+ old_argv = *argv; -+ exp_argv = *ret_exp_argv; -+ for (i = j = 0; (a = old_argv[i]); i++) { -+ if (!strcmp(a, "-march=native") || -+ !strcmp(a, "-mtune=native") || -+ !strcmp(a, "-mcpu=native")) { -+ // insert expansion only once -+ if (!inserted) { -+ for (k = 0; k < exp_argc; k++) { -+ // insert expansion in place of native arg -+ new_argv[j++] = exp_argv[k]; -+ } -+ inserted = 1; -+ -+ // recalculate indices -+ if (*input_idx > i) -+ *input_idx += exp_argc - 1; -+ if (*output_idx > i) -+ *output_idx += exp_argc - 1; -+ } else { -+ // skip argument -+ free(a); -+ // recalculate indices -+ if (*input_idx > i) -+ (*input_idx)--; -+ if (*output_idx > i) -+ (*output_idx)--; -+ -+ continue; -+ } -+ } else { -+ // copy all other args untouched -+ new_argv[j++] = a; -+ } -+ } -+ // terminate new argv by NULL element -+ new_argv[j] = NULL; -+ -+ free(*argv); // clean old arrays, but not their elements -+ free(exp_argv); // as they are put into new array; -+ *ret_exp_argv = NULL; // avoid double free later -+ *argv = new_argv; -+ -+ // check for log level to avoid useless string manipulations -+ if (rs_trace_level >= RS_LOG_INFO) { -+ astr = dcc_argv_tostr(*argv); -+ rs_log_info("argv after native expansion: %s", astr); -+ free(astr); -+ } -+ -+ return 0; -+} -+ -+/** -+ * Replace -m=native flag by its expansion string from -+ * local compiler output or cache from previous queries, if -+ * available. -+ * -+ * Supported args are: -march, -mcpu, -mtune. The former flag -+ * supersedes the latter. -+ * -+ * All -m$arg=native arguments are removed from argv and the first -+ * one is replaced by expansion of the highest priority flag found. -+ * -+ * A special pain here is that input and output filename indices in -+ * the argv will be changed and must be recalculated. -+ * -+ * @param argv argv, must be freed by the caller -+ * @param type denotes type of native argument (bitfield) -+ * @param input_idx index of input file name in the argv -+ * @param output_idx index of output file name in the argv -+ * -+ * @return dcc standard exit code -+ **/ -+int -+dcc_expand_native(char ***argv, const int type, -+ int *input_idx, int *output_idx) -+{ -+ char **exp_argv = NULL; // buffer for expanded native data -+ int exp_argc = 0; // length of expanded data -+ char *compiler_name, *hash; -+ int ret; -+ -+ // Lookup compiler ID (size + mtime) -+ compiler_name = (*argv)[0]; -+ if ((ret = dcc_get_compiler_id(compiler_name, &hash))) { -+ rs_log_error("failed to get compiler ID"); -+ return ret; -+ } -+ -+ // Construct hash filename -+ if ((ret = dcc_get_hash_filename(&hash, type))) { -+ rs_log_error("failed to supply hash filename"); -+ goto cleanup; -+ } -+ -+ /* Query expanded arguments from cache */ -+ if (dcc_cache_query(hash, &exp_argv, &exp_argc)) { -+ // If cache is not available, grep compiler's output -+ if (!(ret = dcc_compiler_query(compiler_name, &exp_argv, &exp_argc, type))) { -+ // If grep is successful, record results to cache -+ if (dcc_cache_write(hash, (const char**)exp_argv)) { -+ rs_log_warning("can't save cache for compiler %s", compiler_name); -+ } -+ } else { -+ rs_log_error("failed to expand native argument using compiler"); -+ goto cleanup; -+ } -+ } -+ -+ // Replace native args by found expansion -+ ret = dcc_insert_expansion(argv, &exp_argv, exp_argc, input_idx, output_idx); -+ -+cleanup: -+ free(hash); -+ if (exp_argv) -+ dcc_free_argv(exp_argv); -+ -+ return ret; -+} -diff -Naurd -x '*.swp' -x '*.o' -x '*.d' -x config.h distcc-3.2rc1.orig/src/distcc.h distcc-3.2rc1/src/distcc.h ---- distcc-3.2rc1.orig/src/distcc.h 2011-04-05 22:58:58.000000000 +0400 -+++ distcc-3.2rc1/src/distcc.h 2013-06-16 22:11:06.768761656 +0400 -@@ -4,6 +4,7 @@ - * - * Copyright (C) 2002, 2003, 2004 by Martin Pool - * Copyright 2007 Google Inc. -+ * Copyright 2013 Andrew Savchenko - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License -@@ -256,6 +257,14 @@ - char **orig_i, char ***ret_newargv); - int dcc_expand_preprocessor_options(char ***argv_ptr); - -+/* arg_native.c */ -+/* Type of "native" param expansion */ -+#define DCC_ARG_MTUNE (1 << 0) -+#define DCC_ARG_MCPU (1 << 1) -+#define DCC_ARG_MARCH (1 << 2) -+int dcc_expand_native(char ***argv, const int type, -+ int *input_idx, int *output_idx); -+ - /* argutil.c */ - unsigned int dcc_argv_len(char **a); - int dcc_argv_search(char **a, const char *); -@@ -272,6 +281,7 @@ - int dcc_mkdir(const char *path); - int dcc_get_subdir(const char *name, char **path_ret) WARN_UNUSED; - -+int dcc_get_cache_dir(char **path_ret) WARN_UNUSED; - int dcc_get_lock_dir(char **path_ret) WARN_UNUSED; - int dcc_get_state_dir(char **path_ret) WARN_UNUSED; - int dcc_get_top_dir(char **path_ret) WARN_UNUSED; -diff -Naurd -x '*.swp' -x '*.o' -x '*.d' -x config.h distcc-3.2rc1.orig/src/tempfile.c distcc-3.2rc1/src/tempfile.c ---- distcc-3.2rc1.orig/src/tempfile.c 2008-12-03 00:50:24.000000000 +0300 -+++ distcc-3.2rc1/src/tempfile.c 2013-06-16 03:37:21.807183537 +0400 -@@ -4,6 +4,7 @@ - * - * Copyright (C) 2002, 2003, 2004 by Martin Pool - * Copyright 2007 Google Inc. -+ * Copyright 2013 Andrew Savchenko - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License -@@ -333,39 +334,26 @@ - return dcc_mkdir(*dir_ret); - } - --int dcc_get_lock_dir(char **dir_ret) --{ -- static char *cached; -- int ret; -- -- if (cached) { -- *dir_ret = cached; -- return 0; -- } else { -- ret = dcc_get_subdir("lock", dir_ret); -- if (ret == 0) -- cached = *dir_ret; -- return ret; -- } --} -- --int dcc_get_state_dir(char **dir_ret) --{ -- static char *cached; -- int ret; -- -- if (cached) { -- *dir_ret = cached; -- return 0; -- } else { -- ret = dcc_get_subdir("state", dir_ret); -- if (ret == 0) -- cached = *dir_ret; -- return ret; -- } -+#define DCC_GET_DIR(NAME) \ -+int dcc_get_## NAME ##_dir(char **dir_ret) \ -+{ \ -+ static char *cached; \ -+ int ret; \ -+\ -+ if (cached) { \ -+ *dir_ret = cached; \ -+ return 0; \ -+ } else { \ -+ ret = dcc_get_subdir(#NAME, dir_ret); \ -+ if (ret == 0) \ -+ cached = *dir_ret; \ -+ return ret; \ -+ } \ - } - -- -+DCC_GET_DIR(cache) -+DCC_GET_DIR(lock) -+DCC_GET_DIR(state) - - /** - * Create a file inside the temporary directory and register it for ---- distcc-3.2rc1.orig/Makefile.in 2011-10-26 06:07:15.000000000 +0400 -+++ distcc-3.2rc1/Makefile.in 2013-06-15 18:54:50.254612420 +0400 -@@ -227,7 +227,7 @@ - rpm_glob_pattern = "$(PACKAGE)"*[-_.]"$(VERSION)"[-_.]*.deb - deb_glob_pattern = "$(PACKAGE)"*[-_.]"$(VERSION)"[-_.]*.rpm - --common_obj = src/arg.o src/argutil.o \ -+common_obj = src/arg.o src/arg_native.o src/argutil.o \ - src/cleanup.o src/compress.o \ - src/trace.o src/util.o src/io.o src/exec.o \ - src/rpc.o src/tempfile.o src/bulk.o src/help.o src/filename.o \ -@@ -309,7 +309,7 @@ - - # All source files, for the purposes of building the distribution - SRC = src/stats.c \ -- src/access.c src/arg.c src/argutil.c \ -+ src/access.c src/arg.c src/arg_native.c src/argutil.c \ - src/auth_common.c src/auth_distcc.c src/auth_distccd.c \ - src/backoff.c src/bulk.c \ - src/cleanup.c \ -diff -Naurd distcc-3.2rc1.orig/man/distcc.1 distcc-3.2rc1/man/distcc.1 ---- distcc-3.2rc1.orig/man/distcc.1 2011-10-25 03:36:12.000000000 +0400 -+++ distcc-3.2rc1/man/distcc.1 2013-06-16 04:03:36.087697023 +0400 -@@ -789,7 +789,8 @@ - recompile that file locally. - .TP - .B "DISTCC_DIR" --Per-user configuration directory to store lock files and state files. -+Per-user configuration directory to store lock files, state files -+and cache files. - By default - .B ~/.distcc/ - is used.