From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56258 invoked by alias); 7 Sep 2015 18:24:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 56248 invoked by uid 89); 7 Sep 2015 18:24:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Sep 2015 18:24:52 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZZ160-0001Nh-Lx from Iain_Sandoe@mentor.com ; Mon, 07 Sep 2015 11:24:49 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 7 Sep 2015 19:24:47 +0100 From: Iain Sandoe Content-Type: multipart/mixed; boundary="Apple-Mail=_FA62A89B-1028-45B5-B8F6-9DAADAD9EA64" Subject: [PATCH, Darwin] Some driver TLC (improve support for the '-arch' flag). Date: Mon, 07 Sep 2015 18:28:00 -0000 Message-ID: CC: Mike Stump To: gcc-patches List MIME-Version: 1.0 (Apple Message framework v1283) X-SW-Source: 2015-09/txt/msg00454.txt.bz2 --Apple-Mail=_FA62A89B-1028-45B5-B8F6-9DAADAD9EA64 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" Content-length: 934 Hi, For some Darwin compilers, "-arch xxxx" can be used (a) in place of, but to= indicate the same as, a multilib flag like "-m32" and (b) multiple times t= o indicate that the User wants a FAT object with multiple arch slices. It's helpful to support this, as far as possible, to minimise build system = changes between compilers. --- This patch improves the uniformity of support for (a) - provides support for PPC - produces warnings where such flags conflict with each other and/or with = any multilib options given. We don't support (b), at present, so the patch produces warnings if the Use= r attempts to add multiple (different) instances of -arch. OK for trunk? Iain gcc/ Iain Sandoe * config/darwin-driver.c (darwin_driver_init): Handle '-arch' for PPC, det= ect conflicts between -arch and multilib settings. Detect and warn about conflicts betw= een multiple -arch definitions. --Apple-Mail=_FA62A89B-1028-45B5-B8F6-9DAADAD9EA64 Content-Disposition: attachment; filename="darwin-driver-arch-tidy.txt" Content-Type: text/plain; name="darwin-driver-arch-tidy.txt" Content-Transfer-Encoding: quoted-printable Content-length: 4668 =46rom 9a9a4ef8b032e333b6b56be19ea093e0e8b84b2a Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Mon, 7 Sep 2015 09:52:15 +0100 Subject: [PATCH] [Darwin, driver] Improve support for the '-arch' flag. Support the flag for X86 and PPC, also check and warn for conflicts of settings of the flag with multi-lib flags or other instances of the '-arch' flag. --- gcc/config/darwin-driver.c | 98 ++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 868cb8d..727ea53 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -179,21 +179,55 @@ darwin_driver_init (unsigned int *decoded_options_cou= nt, struct cl_decoded_option **decoded_options) { unsigned int i; + bool seenX86 =3D false; + bool seenX86_64 =3D false; + bool seenPPC =3D false; + bool seenPPC64 =3D false; + bool seenM32 =3D false; + bool seenM64 =3D false; + bool appendM32 =3D false; + bool appendM64 =3D false; =20 for (i =3D 1; i < *decoded_options_count; i++) { if ((*decoded_options)[i].errors & CL_ERR_MISSING_ARG) continue; + switch ((*decoded_options)[i].opt_index) { -#if DARWIN_X86 case OPT_arch: + /* Support provision of a single -arch xxxx flag as a means of + specifying the sub-target/multi-lib. Translate this into -m32/64 + as appropriate. */=20=20 if (!strcmp ((*decoded_options)[i].arg, "i386")) - generate_option (OPT_m32, NULL, 1, CL_DRIVER, &(*decoded_options)[i]); + seenX86 =3D true; else if (!strcmp ((*decoded_options)[i].arg, "x86_64")) - generate_option (OPT_m64, NULL, 1, CL_DRIVER, &(*decoded_options)[i]); + seenX86_64 =3D true; + else if (!strcmp ((*decoded_options)[i].arg, "ppc")) + seenPPC =3D true; + else if (!strcmp ((*decoded_options)[i].arg, "ppc64")) + seenPPC64 =3D true; + else + error ("this compiler does not support %s", + (*decoded_options)[i].arg); + /* Now we've examined it, drop the -arch arg. */ + if (*decoded_options_count > i) { + memmove (*decoded_options + i, + *decoded_options + i + 1, + ((*decoded_options_count - i) + * sizeof (struct cl_decoded_option))); + } + --i; + --*decoded_options_count;=20 + break; + + case OPT_m32: + seenM32 =3D true; + break; + + case OPT_m64: + seenM64 =3D true; break; -#endif =20 case OPT_filelist: case OPT_framework: @@ -218,4 +252,60 @@ darwin_driver_init (unsigned int *decoded_options_coun= t, } =20 darwin_default_min_version (decoded_options_count, decoded_options); + /* Turn -arch xxxx into the appropriate -m32/-m64 flag. + If the User tried to specify multiple arch flags (which is possible w= ith + some Darwin compilers) warn that this mode is not supported by this + compiler (and ignore the arch flags, which means that the default mul= ti- + lib will be generated). */ + /* TODO: determine if these warnings would better be errors. */ +#if DARWIN_X86 + if (seenPPC || seenPPC64) + warning (0, "this compiler does not support PowerPC (arch flags ignore= d)"); + if (seenX86) + { + if (seenX86_64 || seenM64) + warning (0, "%s conflicts with i386 (arch flags ignored)", + (seenX86_64? "x86_64": "m64")); + else if (! seenM32) /* Add -m32 if the User didn't. */ + appendM32 =3D true; + } + else if (seenX86_64) + { + if (seenX86 || seenM32) + warning (0, "%s conflicts with x86_64 (arch flags ignored)", + (seenX86? "i386": "m32")); + else if (! seenM64) /* Add -m64 if the User didn't. */ + appendM64 =3D true; + }=20=20 +#elif DARWIN_PPC + if (seenX86 || seenX86_64) + warning (0, "this compiler does not support X86 (arch flags ignored)"); + if (seenPPC) + { + if (seenPPC64 || seenM64) + warning (0, "%s conflicts with ppc (arch flags ignored)", + (seenPPC64? "ppc64": "m64")); + else if (! seenM32) /* Add -m32 if the User didn't. */ + appendM32 =3D true; + } + else if (seenPPC64) + { + if (seenPPC || seenM32) + warning (0, "%s conflicts with ppc64 (arch flags ignored)", + (seenPPC? "ppc": "m32")); + else if (! seenM64) /* Add -m64 if the User didn't. */ + appendM64 =3D true; + } +#endif + + if (appendM32 || appendM64) + { + ++*decoded_options_count; + *decoded_options =3D XRESIZEVEC (struct cl_decoded_option, + *decoded_options, + *decoded_options_count); + generate_option (appendM32 ? OPT_m32 : OPT_m64, NULL, 1, CL_DRIVER, + &(*decoded_options)[*decoded_options_count - 1]); + } + } --=20 2.2.1 --Apple-Mail=_FA62A89B-1028-45B5-B8F6-9DAADAD9EA64--