public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding
@ 2022-11-05  6:15 Alexandre Oliva
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2022-11-05  6:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6b1a2474f9e422ef746f7ea13014b288850bb68a

commit 6b1a2474f9e422ef746f7ea13014b288850bb68a
Author: Alexandre Oliva <oliva@adacore.com>
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=.} %<fdump-final-insns",
-  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS
+  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS,
+  /* 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"
 };
 
 #ifndef OPTION_DEFAULT_SPECS
diff --git a/gcc/opts.cc b/gcc/opts.cc
index ae079fcd20e..3797784c865 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3248,6 +3248,10 @@ common_handle_option (struct gcc_options *opts,
       dc->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.  */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding
@ 2022-05-20 14:39 Alexandre Oliva
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2022-05-20 14:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:909a0c48d1ad9da130191cf934885bc7146c7e90

commit 909a0c48d1ad9da130191cf934885bc7146c7e90
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu May 19 06:45:57 2022 -0300

    Support multilib-aware target lib flags self-specs overriding
    
    This patch introduces -multiflags, 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.
    
    I realize -m is reserved for machine-specific flags, which this option
    sort-of isn't, but its intended use is indeed to stand for
    machine-specific flags, so it's kind of ok.  But that's just my
    official excuse, the reason I couldn't help picking it up is that it
    is a portmanteau of multi[lib] and TFLAGS.
    
    
    for  gcc/ChangeLog
    
            * common.opt (multiflags): 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 8a0dafc522d..73b69ba3118 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1786,6 +1786,10 @@ fif-conversion2
 Common Var(flag_if_conversion2) Optimization
 Perform conversion of conditional jumps to conditional execution.
 
+multiflags
+Common Driver
+Building block for specs-based multilib-aware TFLAGS.
+
 fstack-reuse=
 Common Joined RejectNegative Enum(stack_reuse_level) Var(flag_stack_reuse) Init(SR_ALL) Optimization
 -fstack-reuse=[all|named_vars|none]	Set stack reuse level for local variables.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 98a543ae06f..032f8d45c27 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -727,7 +727,7 @@ Objective-C and Objective-C++ Dialects}.
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose @gol
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details @gol
 -fvar-tracking-assignments-toggle  -gtoggle @gol
--print-file-name=@var{library}  -print-libgcc-file-name @gol
+-multiflags  -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
 -print-sysroot  -print-sysroot-headers-suffix @gol
@@ -18870,6 +18870,34 @@ For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
 eleventh invocation.
 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
 
+@item -multiflags
+@opindex multiflags
+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=-multiflags}, after configuring
+@samp{--with-specs=%@{multiflags:...@}}.
+
+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
+@samp{--with-specs='%@{!multiflags:%emissing TFLAGS@}'} and building the
+compiler and target libraries.
+
 @item -print-file-name=@var{library}
 @opindex print-file-name
 Print the full absolute name of the library file @var{library} that
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 299e09c4f54..fd9523c48f1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -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",
-  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS
+  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS,
+  /* This discards -multiflags 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.  */
+  "%<multiflags"
 };
 
 #ifndef OPTION_DEFAULT_SPECS
diff --git a/gcc/opts.cc b/gcc/opts.cc
index f0c5c4db955..f0cf6ded55f 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3203,6 +3203,10 @@ common_handle_option (struct gcc_options *opts,
       dc->report_bug = value;
       break;
 
+    case OPT_multiflags:
+      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.  */


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding
@ 2022-05-19 10:36 Alexandre Oliva
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2022-05-19 10:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7513dac9a34a20b1ce3433a3b65c1d10a24c6892

commit 7513dac9a34a20b1ce3433a3b65c1d10a24c6892
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu May 19 06:45:57 2022 -0300

    Support multilib-aware target lib flags self-specs overriding
    
    This patch introduces -multiflags, 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.
    
    I realize -m is reserved for machine-specific flags, which this option
    sort-of isn't, but its intended use is indeed to stand for
    machine-specific flags, so it's kind of ok.  But that's just my
    official excuse, the reason I couldn't help picking it up is that it
    is a portmanteau of multi[lib] and TFLAGS.
    
    
    for  gcc/ChangeLog
    
            * common.opt (multiflags): 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 8a0dafc522d..73b69ba3118 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1786,6 +1786,10 @@ fif-conversion2
 Common Var(flag_if_conversion2) Optimization
 Perform conversion of conditional jumps to conditional execution.
 
+multiflags
+Common Driver
+Building block for specs-based multilib-aware TFLAGS.
+
 fstack-reuse=
 Common Joined RejectNegative Enum(stack_reuse_level) Var(flag_stack_reuse) Init(SR_ALL) Optimization
 -fstack-reuse=[all|named_vars|none]	Set stack reuse level for local variables.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 98a543ae06f..467f067806f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -727,7 +727,7 @@ Objective-C and Objective-C++ Dialects}.
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose @gol
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details @gol
 -fvar-tracking-assignments-toggle  -gtoggle @gol
--print-file-name=@var{library}  -print-libgcc-file-name @gol
+-multiflags  -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
 -print-sysroot  -print-sysroot-headers-suffix @gol
@@ -18870,6 +18870,34 @@ For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
 eleventh invocation.
 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
 
+@item -multiflags
+@opindex multiflags
+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=-multiflags}, after configuring
+@samp{--with-specs=%@{multiflags:...@}}.
+
+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 cross compiler
+@samp{--with-specs=%@{!multiflags:%@{!fself-test=*:%emissing TFLAGS@}@}}
+and building the compiler and target libraries.
+
 @item -print-file-name=@var{library}
 @opindex print-file-name
 Print the full absolute name of the library file @var{library} that
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 299e09c4f54..fd9523c48f1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -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",
-  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS
+  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS,
+  /* This discards -multiflags 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.  */
+  "%<multiflags"
 };
 
 #ifndef OPTION_DEFAULT_SPECS
diff --git a/gcc/opts.cc b/gcc/opts.cc
index f0c5c4db955..f0cf6ded55f 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3203,6 +3203,10 @@ common_handle_option (struct gcc_options *opts,
       dc->report_bug = value;
       break;
 
+    case OPT_multiflags:
+      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.  */


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding
@ 2022-05-19 10:15 Alexandre Oliva
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2022-05-19 10:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fbdfe1293c24bb97324c4b28b0083f783b026830

commit fbdfe1293c24bb97324c4b28b0083f783b026830
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu May 19 06:45:57 2022 -0300

    Support multilib-aware target lib flags self-specs overriding
    
    This patch introduces -multiflags, 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.
    
    I realize -m is reserved for machine-specific flags, which this option
    sort-of isn't, but its intended use is indeed to stand for
    machine-specific flags, so it's kind of ok.  But that's just my
    official excuse, the reason I couldn't help picking it up is that it
    is a portmanteau of multi[lib] and TFLAGS.
    
    
    for  gcc/ChangeLog
    
            * common.opt (multiflags): 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 | 31 ++++++++++++++++++++++++++++++-
 gcc/gcc.cc          |  6 +++++-
 gcc/opts.cc         |  4 ++++
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 8a0dafc522d..73b69ba3118 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1786,6 +1786,10 @@ fif-conversion2
 Common Var(flag_if_conversion2) Optimization
 Perform conversion of conditional jumps to conditional execution.
 
+multiflags
+Common Driver
+Building block for specs-based multilib-aware TFLAGS.
+
 fstack-reuse=
 Common Joined RejectNegative Enum(stack_reuse_level) Var(flag_stack_reuse) Init(SR_ALL) Optimization
 -fstack-reuse=[all|named_vars|none]	Set stack reuse level for local variables.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 98a543ae06f..7405cac7633 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -727,7 +727,7 @@ Objective-C and Objective-C++ Dialects}.
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose @gol
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details @gol
 -fvar-tracking-assignments-toggle  -gtoggle @gol
--print-file-name=@var{library}  -print-libgcc-file-name @gol
+-multiflags  -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
 -print-sysroot  -print-sysroot-headers-suffix @gol
@@ -18870,6 +18870,35 @@ For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
 eleventh invocation.
 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
 
+@item -multiflags
+@opindex multiflags
+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=-multiflags}, after configuring
+@samp{--with-specs=%@{multiflags:...@}}.
+
+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, in a non-bootstrap configuration, by configuring
+the compiler
+@samp{--with-specs=%@{!multiflags:%@{!fself-test=*:%emissing TFLAGS@}@}}
+and building the compiler and target libraries.
+
 @item -print-file-name=@var{library}
 @opindex print-file-name
 Print the full absolute name of the library file @var{library} that
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 299e09c4f54..fd9523c48f1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -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",
-  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS
+  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS,
+  /* This discards -multiflags 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.  */
+  "%<multiflags"
 };
 
 #ifndef OPTION_DEFAULT_SPECS
diff --git a/gcc/opts.cc b/gcc/opts.cc
index f0c5c4db955..f0cf6ded55f 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3203,6 +3203,10 @@ common_handle_option (struct gcc_options *opts,
       dc->report_bug = value;
       break;
 
+    case OPT_multiflags:
+      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.  */


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding
@ 2022-05-19  9:47 Alexandre Oliva
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2022-05-19  9:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:273f851aa568ef762fd35f95ec7599b063bbbddb

commit 273f851aa568ef762fd35f95ec7599b063bbbddb
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu May 19 06:45:57 2022 -0300

    Support multilib-aware target lib flags self-specs overriding
    
    This patch introduces -multiflags, 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.
    
    I realize -m is reserved for machine-specific flags, which this option
    sort-of isn't, but its intended use is indeed to stand for
    machine-specific flags, so it's kind of ok.  But that's just my
    official excuse, the reason I couldn't help picking it up is that it
    is a portmanteau of multi[lib] and TFLAGS.
    
    
    for  gcc/ChangeLog
    
            * common.opt (multiflags): 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 8a0dafc522d..73b69ba3118 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1786,6 +1786,10 @@ fif-conversion2
 Common Var(flag_if_conversion2) Optimization
 Perform conversion of conditional jumps to conditional execution.
 
+multiflags
+Common Driver
+Building block for specs-based multilib-aware TFLAGS.
+
 fstack-reuse=
 Common Joined RejectNegative Enum(stack_reuse_level) Var(flag_stack_reuse) Init(SR_ALL) Optimization
 -fstack-reuse=[all|named_vars|none]	Set stack reuse level for local variables.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 98a543ae06f..b4556134eb0 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -727,7 +727,7 @@ Objective-C and Objective-C++ Dialects}.
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose @gol
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details @gol
 -fvar-tracking-assignments-toggle  -gtoggle @gol
--print-file-name=@var{library}  -print-libgcc-file-name @gol
+-multiflags  -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
 -print-sysroot  -print-sysroot-headers-suffix @gol
@@ -18870,6 +18870,34 @@ For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
 eleventh invocation.
 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
 
+@item -multiflags
+@opindex multiflags
+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=-multiflags}, after configuring
+@samp{--with-specs=%@{multiflags:...@}}.
+
+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, in a non-bootstrap configuration, by configuring
+the compiler @samp{--with-specs=%@{!multiflags:%emissing TFLAGS@}} and
+building the compiler and target libraries.
+
 @item -print-file-name=@var{library}
 @opindex print-file-name
 Print the full absolute name of the library file @var{library} that
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 299e09c4f54..fd9523c48f1 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -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",
-  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS
+  DRIVER_SELF_SPECS, CONFIGURE_SPECS, GOMP_SELF_SPECS, GTM_SELF_SPECS,
+  /* This discards -multiflags 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.  */
+  "%<multiflags"
 };
 
 #ifndef OPTION_DEFAULT_SPECS
diff --git a/gcc/opts.cc b/gcc/opts.cc
index f0c5c4db955..f0cf6ded55f 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3203,6 +3203,10 @@ common_handle_option (struct gcc_options *opts,
       dc->report_bug = value;
       break;
 
+    case OPT_multiflags:
+      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.  */


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-05  6:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05  6:15 [gcc(refs/users/aoliva/heads/testme)] Support multilib-aware target lib flags self-specs overriding Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2022-05-20 14:39 Alexandre Oliva
2022-05-19 10:36 Alexandre Oliva
2022-05-19 10:15 Alexandre Oliva
2022-05-19  9:47 Alexandre Oliva

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).