From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id C5D9F3858C2D; Sat, 5 Nov 2022 09:25:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5D9F3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667640325; bh=u37mcwtnOyg3siyjK6sXNXjMUHJuEgXWKOUSRv8qLJQ=; h=From:To:Subject:Date:From; b=H1WxYhMvkTTM34PrmOeoDZz1ZhJXdsknaB/ai3SE91xU28T3cZnl5sSXxm5q9aq2x 1daz/77fE4tbZfl8+/0vbJtWxHlib7Ej7VjewBgnGuCXOD74OQigPPlyVcN2H6Qdxe OJjmQ/c2pjX1xcLCPk+9EnmrIVT4sh15H4URom0g= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3693] Support multilib-aware target lib flags self-specs overriding X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/heads/master X-Git-Oldrev: 95ba31bc4f88a0a2ff9f0ed41f3478cafcb9e040 X-Git-Newrev: 6b1a2474f9e422ef746f7ea13014b288850bb68a Message-Id: <20221105092525.C5D9F3858C2D@sourceware.org> Date: Sat, 5 Nov 2022 09:25:25 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6b1a2474f9e422ef746f7ea13014b288850bb68a commit r13-3693-g6b1a2474f9e422ef746f7ea13014b288850bb68a Author: Alexandre Oliva Date: Sat Nov 5 03:14:33 2022 -0300 Support multilib-aware target lib flags self-specs overriding This patch introduces -fmultiflags, short for multilib TFLAGS, as an option that does nothing by default, but that can be added to TFLAGS and mapped to useful options by driver self-specs. for gcc/ChangeLog * common.opt (fmultiflags): New. * doc/invoke.texi: Document it. * gcc.cc (driver_self_specs): Discard it. * opts.cc (common_handle_option): Ignore it in the driver. Diff: --- gcc/common.opt | 4 ++++ gcc/doc/invoke.texi | 30 +++++++++++++++++++++++++++++- gcc/gcc.cc | 6 +++++- gcc/opts.cc | 4 ++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index bce3e514f65..26e9d1cc4e7 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2174,6 +2174,10 @@ fmove-loop-stores Common Var(flag_move_loop_stores) Optimization Move stores out of loops. +fmultiflags +Common Driver +Building block for specs-based multilib-aware TFLAGS. + fdce Common Var(flag_dce) Init(1) Optimization Use the RTL dead code elimination pass. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e9207a3a255..5077cd7d242 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -738,7 +738,7 @@ Objective-C and Objective-C++ Dialects}. -flto-report -flto-report-wpa -fmem-report-wpa @gol -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol --fprofile-report @gol +-fmultiflags -fprofile-report @gol -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol -fstats -fstack-usage -ftime-report -ftime-report-details @gol @@ -19344,6 +19344,34 @@ allocation for the WPA phase only. Makes the compiler print some statistics about permanent memory allocation before or after interprocedural optimization. +@item -fmultiflags +@opindex fmultiflags +This option enables multilib-aware @code{TFLAGS} to be used to build +target libraries with options different from those the compiler is +configured to use by default, through the use of specs (@xref{Spec +Files}) set up by compiler internals, by the target, or by builders at +configure time. + +Like @code{TFLAGS}, this allows the target libraries to be built for +portable baseline environments, while the compiler defaults to more +demanding ones. That's useful because users can easily override the +defaults the compiler is configured to use to build their own programs, +if the defaults are not ideal for their target environment, whereas +rebuilding the runtime libraries is usually not as easy or desirable. + +Unlike @code{TFLAGS}, the use of specs enables different flags to be +selected for different multilibs. The way to accomplish that is to +build with @samp{make TFLAGS=-fmultiflags}, after configuring +@samp{--with-specs=%@{fmultiflags:...@}}. + +This option is discarded by the driver once it's done processing driver +self spec. + +It is also useful to check that @code{TFLAGS} are being used to build +all target libraries, by configuring a non-bootstrap compiler +@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building +the compiler and target libraries. + @item -fprofile-report @opindex fprofile-report Makes the compiler print some statistics about consistency of the diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 98a239c8531..830ab88701f 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -1327,7 +1327,11 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS; static const char *const driver_self_specs[] = { "%{fdump-final-insns:-fdump-final-insns=.} %report_bug = value; break; + case OPT_fmultiflags: + gcc_checking_assert (lang_mask == CL_DRIVER); + break; + default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */