From patchwork Mon Aug 4 14:29:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 376340 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 9F0AE14008B for ; Tue, 5 Aug 2014 00:30:59 +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:in-reply-to:references; q=dns; s= default; b=LTpJDX/gkU0RoaD49VPPZRSKw0Itez0njfcprLAGUHEVpahA8kva3 /afkxsbJBNQ8cJ86BGRXqfjg8I4mRQMn+mQbau51lWRGhwRAjnRbd9M3H3563neW m7keKR23Pwsn/pn3bQOEL1j9AZqfT2QLkv7JG4QLZAKG2B8RAokhGQ= 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:in-reply-to:references; s= default; bh=CQGZVoszsMhOkI0VnARlKT8dt9A=; b=OqtEY4eCW9wpZAskw7Ro q/d0xOv7LnQTIDQJl+Mp1NAvy7uD04+k0xNhEbq1NsaqyLNznObmcL95dvcC+vik GxFmptFlwPBGdE3ZNGLhxvXnUF2mzz3MXOSxK8llVQdcLWUR0bI1HbNxU/qj6RoM s5jmhtuVIp+UTkY90ONfkU4= Received: (qmail 9026 invoked by alias); 4 Aug 2014 14:30:41 -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 8910 invoked by uid 89); 4 Aug 2014 14:30:41 -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; Mon, 04 Aug 2014 14:30:39 +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 58B58869B6; Mon, 4 Aug 2014 16:30:34 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id E4AD5A0A4E; Mon, 4 Aug 2014 07:29:52 -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: Mon, 4 Aug 2014 07:29:46 -0700 Message-Id: <1407162587-5210-2-git-send-email-andi@firstfloor.org> In-Reply-To: <1407162587-5210-1-git-send-email-andi@firstfloor.org> References: <1407162587-5210-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. 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..372e087 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)