From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 41F933858C60 for ; Wed, 1 Dec 2021 14:12:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 41F933858C60 Received: by mail-ed1-x531.google.com with SMTP id r25so36902497edq.7 for ; Wed, 01 Dec 2021 06:12:17 -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:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=axwcXvnCIwqnVHH2c+vLEXz4glxd5Ysn9oRP9Gr72Uo=; b=2BMN+xdSLeqgGUAmDImXrsa75ChxNQvpjI/42vezHq4tx/sPGzPc0vQMnq8ZUlzSNd uwDp4a2RzxC0hNFLIZKWhRWPit4cSBljX4KL4kJ4P3Ug/aRQZu15hPdugTlMIUyglI9y lnTfCmqDlwWoNgRfU7wvYvgemtTFfIVtY/ksRlBmO07u/PBUo3zFIq5jMj5rlc2Gy4Jj jHJJGena20GICvrVWGFZDivD0Yd6K1bWF4NvJUzRwR5iXPUEWtsjECNIrlpvacR5VETZ nvF+TAOpDkjUJNlBzmMjrCCR5qmuGvtJoa353eUqyqM6/6H7wNt1e5d7pC2mRCOGgsDJ tunA== X-Gm-Message-State: AOAM5313e6EZyPOEdPIYNQ/gBcfANE6zwcGxT5K7jmIBPZ0iFnARgNWT D1kCSeiekmkuoNJNpZP+uyaVEL7+LDsk4tuFmk8= X-Google-Smtp-Source: ABdhPJzinzITlMocbhjjmjhxKTZerNGMVxijfOygyOt+EJep6/sgvM34RAyzW0t9Lc4N5NjW6xoZVoosmTMMZNZ8bJo= X-Received: by 2002:aa7:c313:: with SMTP id l19mr8732575edq.209.1638367936187; Wed, 01 Dec 2021 06:12:16 -0800 (PST) MIME-Version: 1.0 References: <20211119083226.3095760-1-ibuclaw@gdcproject.org> <7C82489C-4C47-4501-A59C-D6D7396B545B@gmail.com> <1637930910.aba2ohsbq9.astroid@galago.none> <1638291693.aqa5rbc1j0.astroid@galago.none> In-Reply-To: <1638291693.aqa5rbc1j0.astroid@galago.none> From: Richard Biener Date: Wed, 1 Dec 2021 15:12:05 +0100 Message-ID: Subject: Re: [PING, PATCH] darwin, d: Support outfile substitution for liphobos To: Iain Buclaw Cc: GCC Patches , Iain Sandoe , "Joseph S. Myers" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.5 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: Wed, 01 Dec 2021 14:12:19 -0000 On Tue, Nov 30, 2021 at 6:04 PM Iain Buclaw via Gcc-patches wrote: > > Ping. > > Are the common gcc parts OK (also for backporting)? Yes, OK for backporting as well after a short burn in period. Richard, > Iain. > > Excerpts from Iain Buclaw's message of November 26, 2021 1:51 pm: > > Excerpts from Iain Sandoe's message of November 19, 2021 10:21 am: > >> 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. > >>> > >>> 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 comman= d > >>> line, the setting of SKIPOPT is instead conditionally removed. The s= ame > >>> change has been repeated for -static-libstdc++ so there is now no nee= d > >>> to call generate_option to re-add it. > >>> > >>> In the gcc driver, -static-libphobos has been added as a common optio= n, > >>> validated, and a new outfile substition added to config/darwin.h to > >>> correctly replace -lgphobos with libgphobos.a. > >>> > >>> Bootstrapped and regression tested on x86_64-linux-gnu and > >>> x86_64-apple-darwin20. > >>> > >>> OK for mainline? This would also be fine for gcc-11 release branch t= oo, > >>> as well as earlier releases with D support. > >> > >> the Darwin parts are fine, thanks > >> > >> The SKIPOPT in d-spec, presumably means =E2=80=9Cskip removing this op= t=E2=80=9D? > >> otherwise the #ifndef looks odd (because of the static-libgcc|static-l= ibphobos, > >> darwin.h would do the substitution for -static-libgcc as well, so it= =E2=80=99s not a 100% > >> test). > >> > > > > I've only just realised what you meant. Yes you are of course right, > > and it should have been #ifdef, attaching a fixed-up patch. > > > > Iain. > > > > --- > > gcc/ChangeLog: > > > > * common.opt (static-libphobos): Add option. > > * config/darwin.h (LINK_SPEC): Substitute -lgphobos with li= bgphobos.a > > when linking statically. > > * gcc.c (driver_handle_option): Set -static-libphobos as al= ways valid. > > > > gcc/d/ChangeLog: > > > > * d-spec.cc (lang_specific_driver): Set SKIPOPT on -static-= libstdc++ > > and -static-libphobos only when target supports LD_STATIC_D= YNAMIC. > > Remove generate_option to re-add -static-libstdc++. > > > > libphobos/ChangeLog: > > > > * testsuite/testsuite_flags.in: Add libphobos library direc= tory as > > search path to --gdcldflags. > > > > 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. > > > > +static-libphobos > > +Driver > > +; Documented for D, but always accepted by driver. > > + > > static-libstdc++ > > Driver > > > > 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(-lgfort= ran libgfortran.a%s)}\ > > + %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos= libgphobos.a%s)}\ > > %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replac= e-outfile(-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..1304126a675 100644 > > --- a/gcc/d/d-spec.cc > > +++ b/gcc/d/d-spec.cc > > @@ -253,13 +253,23 @@ lang_specific_driver (cl_decoded_option **in_deco= ded_options, > > > > case OPT_static_libstdc__: > > saw_static_libcxx =3D true; > > +#ifdef HAVE_LD_STATIC_DYNAMIC > > + /* Remove -static-libstdc++ from the command only if target sup= ports > > + LD_STATIC_DYNAMIC. When not supported, it is left in so tha= t a > > + back-end target can use outfile substitution. */ > > args[i] |=3D SKIPOPT; > > +#endif > > break; > > > > case OPT_static_libphobos: > > if (phobos_library !=3D PHOBOS_NOLINK) > > phobos_library =3D PHOBOS_STATIC; > > +#ifdef HAVE_LD_STATIC_DYNAMIC > > + /* Remove -static-libphobos from the command only if target sup= ports > > + LD_STATIC_DYNAMIC. When not supported, it is left in so tha= t a > > + back-end target can use outfile substitution. */ > > args[i] |=3D SKIPOPT; > > +#endif > > break; > > > > case OPT_shared_libphobos: > > @@ -460,7 +470,7 @@ lang_specific_driver (cl_decoded_option **in_decode= d_options, > > #endif > > } > > > > - 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_decod= ed_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 th= at > > - 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; > > > > diff --git a/libphobos/testsuite/testsuite_flags.in b/libphobos/testsui= te/testsuite_flags.in > > index bafd5ad4502..8e2f1eefd5b 100755 > > --- a/libphobos/testsuite/testsuite_flags.in > > +++ b/libphobos/testsuite/testsuite_flags.in > > @@ -46,6 +46,7 @@ case ${query} in > > --gdcldflags) > > GDCLDFLAGS=3D"-B${BUILD_DIR}/src > > -B${BUILD_DIR}/libdruntime/gcc > > + -B${BUILD_DIR}/src/.libs > > -L${BUILD_DIR}/src/.libs" > > echo ${GDCLDFLAGS} > > ;; > >