From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id B58F83858C39 for ; Fri, 19 Nov 2021 09:21:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B58F83858C39 Received: by mail-wm1-x336.google.com with SMTP id n33-20020a05600c502100b0032fb900951eso9920927wmr.4 for ; Fri, 19 Nov 2021 01:21:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ilzp0sBsEvaKOt1YYd1uIRRCmS1ps7EfGXlRAhCru6Q=; b=UKRjZgEnSftDxes7m9fmkcEWzIIvVuPwOOyxRFuaDlKGHV99Kg1ROmniPOSt8xAvN8 G9hsCAKtt1eFRp74b7GI0tSWyr8MHetbs5IbZBeGByvzGZWB2ds9VemhwqkGTC0jdSoO xi4l0At438KPesZecG5ToBQre6LZmHkdp9ymZ7ws030P8UZ37LqWjTVJcNwLO3m8ThH1 B09VM1UG5iglXHBDg51ZtgBlitvnkqcRcAmT4llckFHofb2184xxjczTYQ6OblikArsu ik5kjeEQ8VivjE/31xQX9p+HAH2j58YQWts0RCKcrhZ/BSDGy6wOKf5XsEwt9Zoyruq3 PjDQ== X-Gm-Message-State: AOAM533uzAUrU56LQNdA+XvRs1RB+CbEbj2Hltdvss3jYdqXsez12GfF VyBbCCOh59zKr0NjaYSIMHI= X-Google-Smtp-Source: ABdhPJyYRtUVLwQ1PtZ5iQtoqOKz7OEhXvCR67lSQylkNemDLvp5ZW0fUaDsx60krmMVI6sbHAAhDg== X-Received: by 2002:a05:600c:501f:: with SMTP id n31mr5074251wmr.101.1637313686486; Fri, 19 Nov 2021 01:21:26 -0800 (PST) Received: from [192.168.1.214] (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id u15sm2677016wmq.13.2021.11.19.01.21.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 01:21:26 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [PATCH] darwin, d: Support outfile substitution for liphobos From: Iain Sandoe In-Reply-To: <20211119083226.3095760-1-ibuclaw@gdcproject.org> Date: Fri, 19 Nov 2021 09:21:25 +0000 Cc: gcc-patches@gcc.gnu.org Content-Transfer-Encoding: quoted-printable Message-Id: <7C82489C-4C47-4501-A59C-D6D7396B545B@gmail.com> References: <20211119083226.3095760-1-ibuclaw@gdcproject.org> To: Iain Buclaw X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 09:21:30 -0000 Hi Iain > On 19 Nov 2021, at 08:32, Iain Buclaw wrote: > This patch fixes a stage2 bootstrap failure in the D front-end on > darwin due to libgphobos being dynamically linked despite > -static-libphobos being on the command line. >=20 > In the gdc driver, this takes the previous fix for the Darwin D > bootstrap, and extends it to the -static-libphobos option as well. > Rather than pushing the -static-libphobos option back onto the command > line, the setting of SKIPOPT is instead conditionally removed. The = same > change has been repeated for -static-libstdc++ so there is now no need > to call generate_option to re-add it. >=20 > In the gcc driver, -static-libphobos has been added as a common = option, > validated, and a new outfile substition added to config/darwin.h to > correctly replace -lgphobos with libgphobos.a. >=20 > Bootstrapped and regression tested on x86_64-linux-gnu and > x86_64-apple-darwin20. >=20 > OK for mainline? This would also be fine for gcc-11 release branch = too, > as well as earlier releases with D support. the Darwin parts are fine, thanks=20 The SKIPOPT in d-spec, presumably means =E2=80=9Cskip removing this = opt=E2=80=9D? otherwise the #ifndef looks odd (because of the = static-libgcc|static-libphobos, darwin.h would do the substitution for -static-libgcc as well, so it=E2=80= =99s not a 100% test). Iain >=20 > Regards, > Iain. >=20 > --- > gcc/ChangeLog: >=20 > * common.opt (static-libphobos): Add option. > * config/darwin.h (LINK_SPEC): Substitute -lgphobos with = libgphobos.a > when linking statically. > * gcc.c (driver_handle_option): Set -static-libphobos as always = valid. >=20 > gcc/d/ChangeLog: >=20 > * d-spec.cc (lang_specific_driver): Set SKIPOPT on = -static-libstdc++ > and -static-libphobos only when target supports = LD_STATIC_DYNAMIC. > Remove generate_option to re-add -static-libstdc++. > --- > gcc/common.opt | 4 ++++ > gcc/config/darwin.h | 1 + > gcc/d/d-spec.cc | 18 +++++++++++------- > gcc/gcc.c | 6 ++++-- > 4 files changed, 20 insertions(+), 9 deletions(-) >=20 > diff --git a/gcc/common.opt b/gcc/common.opt > index db6010e4e20..73c12d933f3 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -3527,6 +3527,10 @@ static-libgfortran > Driver > ; Documented for Fortran, but always accepted by driver. >=20 > +static-libphobos > +Driver > +; Documented for D, but always accepted by driver. > + > static-libstdc++ > Driver >=20 > diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h > index 7ed01efa694..c4ddd623e8b 100644 > --- a/gcc/config/darwin.h > +++ b/gcc/config/darwin.h > @@ -443,6 +443,7 @@ extern GTY(()) int darwin_ms_struct; > %:replace-outfile(-lobjc libobjc-gnu.a%s); \ > :%:replace-outfile(-lobjc -lobjc-gnu )}}\ > = %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran = libgfortran.a%s)}\ > + = %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos = libgphobos.a%s)}\ > = %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfi= le(-lgomp libgomp.a%s)}\ > %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ = libstdc++.a%s)}\ > %{force_cpusubtype_ALL:-arch %(darwin_arch)} \ > diff --git a/gcc/d/d-spec.cc b/gcc/d/d-spec.cc > index b12d28f1047..73ecac3bbf1 100644 > --- a/gcc/d/d-spec.cc > +++ b/gcc/d/d-spec.cc > @@ -253,13 +253,23 @@ lang_specific_driver (cl_decoded_option = **in_decoded_options, >=20 > case OPT_static_libstdc__: > saw_static_libcxx =3D true; > +#ifndef HAVE_LD_STATIC_DYNAMIC > + /* Remove -static-libstdc++ from the command only if target = supports > + LD_STATIC_DYNAMIC. When not supported, it is left in so = that a > + back-end target can use outfile substitution. */ > args[i] |=3D SKIPOPT; > +#endif > break; >=20 > case OPT_static_libphobos: > if (phobos_library !=3D PHOBOS_NOLINK) > phobos_library =3D PHOBOS_STATIC; > +#ifndef HAVE_LD_STATIC_DYNAMIC > + /* Remove -static-libphobos from the command only if target = supports > + LD_STATIC_DYNAMIC. When not supported, it is left in so = that a > + back-end target can use outfile substitution. */ > args[i] |=3D SKIPOPT; > +#endif > break; >=20 > case OPT_shared_libphobos: > @@ -460,7 +470,7 @@ lang_specific_driver (cl_decoded_option = **in_decoded_options, > #endif > } >=20 > - if (saw_libcxx || need_stdcxx) > + if (saw_libcxx || saw_static_libcxx || need_stdcxx) > { > #ifdef HAVE_LD_STATIC_DYNAMIC > if (saw_static_libcxx && !static_link) > @@ -468,12 +478,6 @@ lang_specific_driver (cl_decoded_option = **in_decoded_options, > generate_option (OPT_Wl_, LD_STATIC_OPTION, 1, CL_DRIVER, > &new_decoded_options[j++]); > } > -#else > - /* Push the -static-libstdc++ option back onto the command so = that > - a target without LD_STATIC_DYNAMIC can use outfile = substitution. */ > - if (saw_static_libcxx && !static_link) > - generate_option (OPT_static_libstdc__, NULL, 1, CL_DRIVER, > - &new_decoded_options[j++]); > #endif > if (saw_libcxx) > new_decoded_options[j++] =3D *saw_libcxx; > diff --git a/gcc/gcc.c b/gcc/gcc.c > index 506c2acc282..fea6d049183 100644 > --- a/gcc/gcc.c > +++ b/gcc/gcc.c > @@ -4576,10 +4576,12 @@ driver_handle_option (struct gcc_options = *opts, > case OPT_static_libgcc: > case OPT_shared_libgcc: > case OPT_static_libgfortran: > + case OPT_static_libphobos: > case OPT_static_libstdc__: > /* These are always valid, since gcc.c itself understands the > - first two, gfortranspec.c understands -static-libgfortran and > - g++spec.c understands -static-libstdc++ */ > + first two, gfortranspec.c understands -static-libgfortran, > + d-spec.cc understands -static-libphobos, and g++spec.c > + understands -static-libstdc++ */ > validated =3D true; > break; >=20 > --=20 > 2.30.2 >=20