From patchwork Sat Aug 9 04:05:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 378710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3A6071400D6 for ; Sat, 9 Aug 2014 14:07:16 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ZhcSyOjgMAf7 3gYbtEotSN1zKsrRxO4LK6tytg2YI/bClI97Ew5eFKvzoETbq9+lm8XGSKO2iRpl uBFUuut+BuzHp605XeeNxzP3GASyif/9LPRv2H4EOIuHESjlWxAlB084wQdNB+qj UkOVossNVRqq4QBxgWkEQ+T9lCA5Z0s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=bb38sm7Z5daNLRX4kn OYiwxBOG8=; b=mCS6ypry4kooUcB32QMBwXGc8lQZRFhe6KSwqTduSAUdD8OID9 hzFudRI+LuaVY0smQAwpMclK0dS66mV9ZdXWBO5Caz9fTEj/riuQG92GV7NszOpa 8pkdcgNHSJh5y6xsplkIJvGt/Okfx9fUMXKig3gMvdR90JBgXsCoNbTPo= Received: (qmail 21908 invoked by alias); 9 Aug 2014 04:07:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21887 invoked by uid 89); 9 Aug 2014 04:07:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 09 Aug 2014 04:07:06 +0000 Received: from basil.firstfloor.org (184-100-237-164.ptld.qwest.net [184.100.237.164]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 632A28677B; Sat, 9 Aug 2014 06:07:01 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 15817A1883; Fri, 8 Aug 2014 21:06:02 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 1/2] Add -B support to gcc-ar/ranlib/nm Date: Fri, 8 Aug 2014 21:05:55 -0700 Message-Id: <1407557156-12737-1-git-send-email-andi@firstfloor.org> From: Andi Kleen To use gcc-{ar,ranlib} for boot strap we need to add a -B option to the tool. Since ar has weird and unusual argument conventions implement the code by hand instead of using any libraries. v2: Fix typo gcc/: 2014-08-04 Andi Kleen * gcc-ar.c (main): Support -B option. --- gcc/gcc-ar.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c index aebaa92..70bf222 100644 --- a/gcc/gcc-ar.c +++ b/gcc/gcc-ar.c @@ -132,9 +132,50 @@ main (int ac, char **av) const char **nargv; bool is_ar = !strcmp (PERSONALITY, "ar"); int exit_code = FATAL_EXIT_CODE; + int i; setup_prefixes (av[0]); + /* Not using getopt for now. */ + for (i = 0; i < ac; i++) + if (!strncmp (av[i], "-B", 2)) + { + const char *arg = av[i] + 2; + const char *end; + + memmove (av + i, av + i + 1, sizeof (char *) * ((ac + 1) - i)); + ac--; + if (*arg == 0) + { + arg = av[i + 1]; + if (!arg) + { + fprintf (stderr, "Usage: gcc-ar [-B prefix] ar arguments ...\n"); + exit (EXIT_FAILURE); + } + memmove (av + i, av + i + 1, sizeof (char *) * ((ac + 1) - i)); + ac--; + i++; + } + + for (end = arg; *end; end++) + ; + end--; + if (end > arg && *end != '/') + { + char *newarg = (char *)xmalloc (strlen(arg) + 2); + + strcpy (newarg, arg); + strcat (newarg, "/"); + arg = newarg; + } + + add_prefix (&path, arg); + add_prefix (&target_path, arg); + break; + } + + /* Find the GCC LTO plugin */ plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK); if (!plugin)