public inbox for
 help / color / mirror / Atom feed
From: Alexandre Oliva <>
To: Hans-Peter Nilsson <>
Subject: Re: [PATCH] Support multilib-aware target lib flags self-specs overriding
Date: Tue, 28 Jun 2022 10:32:54 -0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Alexandre Oliva's message of "Fri, 03 Jun 2022 04:15:15 -0300")

On Jun  3, 2022, Alexandre Oliva <> wrote:

> On Jun  1, 2022, Hans-Peter Nilsson <> wrote:

>> -fmultiflags?

> That works for me.  I favored -multiflags slightly, because the intended
> use is for it to stand for other -m flags, but --multiflags AKA
> -fmultiflags will do as well.

> Now, is there interest in this feature?  (As in, does it any make sense
> for me to post a revised patch, or should I keep it downstream?)

FTR, here's the patch I ended up with, adjusted to use -fmultiflags.

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.

Regstrapped on x86_64-linux-gnu.  Posted mainly FTR, but...  I wouldn't
mind putting it in, so...  Ok to install?  ;-)

for  gcc/ChangeLog

	* common.opt (fmultiflags): New.
	* doc/invoke.texi: Document it.
	* (driver_self_specs): Discard it.
	* (common_handle_option): Ignore it in the driver.
 gcc/common.opt      |    4 ++++
 gcc/doc/invoke.texi |   30 +++++++++++++++++++++++++++++-
 gcc/          |    6 +++++-
 gcc/         |    4 ++++
 4 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index e7a51e882bade..814966c4562fe 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2177,6 +2177,10 @@ fmove-loop-stores
 Common Var(flag_move_loop_stores) Optimization
 Move stores out of loops.
+Common Driver
+Building block for specs-based multilib-aware TFLAGS.
 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 bde59ff047249..f9c53df37b28b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -725,7 +725,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
@@ -18927,6 +18927,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
+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/ b/gcc/
index 5cbb38560b266..24d3544e68140 100644
--- a/gcc/
+++ b/gcc/
@@ -1347,7 +1347,11 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS;
 static const char *const driver_self_specs[] = {
   "%{fdump-final-insns:-fdump-final-insns=.} %<fdump-final-insns",
+  /* This discards -fmultiflags at the end of self specs processing in the
+     driver, so that it is effectively Ignored, without actually marking it as
+     Ignored, which would get it discarded before self specs could remap it.  */
+  "%<fmultiflags"
diff --git a/gcc/ b/gcc/
index fe0293e4283df..1ac9554a341c6 100644
--- a/gcc/
+++ b/gcc/
@@ -3257,6 +3257,10 @@ common_handle_option (struct gcc_options *opts,
       dc->report_bug = value;
+    case OPT_fmultiflags:
+      gcc_checking_assert (lang_mask == CL_DRIVER);
+      break;
       /* If the flag was handled in a standard way, assume the lack of
 	 processing here is intentional.  */

Alexandre Oliva, happy hacker      
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <>

  reply	other threads:[~2022-06-28 13:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 19:13 Alexandre Oliva
2022-05-28  7:02 ` Alexandre Oliva
2022-06-01 22:00 ` Hans-Peter Nilsson
2022-06-03  7:15   ` Alexandre Oliva
2022-06-28 13:32     ` Alexandre Oliva [this message]
2022-10-06  8:24       ` Alexandre Oliva
2022-11-05  9:23         ` Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).