diff mbox series

driver: Also prune joined switches with negation

Message ID 20190924184756.13295-1-mattst88@gmail.com
State New
Headers show
Series driver: Also prune joined switches with negation | expand

Commit Message

Matt Turner Sept. 24, 2019, 6:47 p.m. UTC
When -march=native is passed to host_detect_local_cpu to the backend,
it overrides all command lines after it.  That means

$ gcc -march=native -march=armv8-a

is treated as

$ gcc -march=armv8-a -march=native

Prune joined switches with Negative and RejectNegative to allow
-march=armv8-a to override previous -march=native on command-line.

This is the same fix as was applied for i386 in SVN revision 269164 but for
aarch64 and arm.

gcc/

	PR driver/69471
	* config/aarch64/aarch64.opt (march=): Add Negative(march=).
	(mtune=): Add Negative(mtune=). (mcpu=): Add Negative(mcpu=).
	* config/arm/arm.opt: Likewise.
---
 gcc/config/aarch64/aarch64.opt | 6 +++---
 gcc/config/arm/arm.opt         | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Kyrill Tkachov Sept. 25, 2019, 11:10 a.m. UTC | #1
On 9/24/19 7:47 PM, Matt Turner wrote:
> When -march=native is passed to host_detect_local_cpu to the backend,
> it overrides all command lines after it.  That means
>
> $ gcc -march=native -march=armv8-a
>
> is treated as
>
> $ gcc -march=armv8-a -march=native
>
> Prune joined switches with Negative and RejectNegative to allow
> -march=armv8-a to override previous -march=native on command-line.
>
> This is the same fix as was applied for i386 in SVN revision 269164 
> but for
> aarch64 and arm.
>
> gcc/
>
>         PR driver/69471
>         * config/aarch64/aarch64.opt (march=): Add Negative(march=).
>         (mtune=): Add Negative(mtune=). (mcpu=): Add Negative(mcpu=).
>         * config/arm/arm.opt: Likewise.


Thanks.

This is ok for arm. LGTM for aarch64 but you'll need an aarch64 
maintainer to approve.

I've bootstrapped and tested this patch on arm-none-linux-gnueabihf and 
aarch64-none-linux-gnu and there's no fallout.

I can commit it for you once the aarch64 part is

Kyrill


> ---
>  gcc/config/aarch64/aarch64.opt | 6 +++---
>  gcc/config/arm/arm.opt         | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64.opt 
> b/gcc/config/aarch64/aarch64.opt
> index 865b6a6d8ca..fc43428b32a 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -119,15 +119,15 @@ EnumValue
>  Enum(aarch64_tls_size) String(48) Value(48)
>
>  march=
> -Target RejectNegative ToLower Joined Var(aarch64_arch_string)
> +Target RejectNegative Negative(march=) ToLower Joined 
> Var(aarch64_arch_string)
>  Use features of architecture ARCH.
>
>  mcpu=
> -Target RejectNegative ToLower Joined Var(aarch64_cpu_string)
> +Target RejectNegative Negative(mcpu=) ToLower Joined 
> Var(aarch64_cpu_string)
>  Use features of and optimize for CPU.
>
>  mtune=
> -Target RejectNegative ToLower Joined Var(aarch64_tune_string)
> +Target RejectNegative Negative(mtune=) ToLower Joined 
> Var(aarch64_tune_string)
>  Optimize for CPU.
>
>  mabi=
> diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
> index 452f0cf6d67..76c10ab62a2 100644
> --- a/gcc/config/arm/arm.opt
> +++ b/gcc/config/arm/arm.opt
> @@ -82,7 +82,7 @@ mapcs-stack-check
>  Target Report Mask(APCS_STACK) Undocumented
>
>  march=
> -Target RejectNegative ToLower Joined Var(arm_arch_string)
> +Target RejectNegative Negative(march=) ToLower Joined 
> Var(arm_arch_string)
>  Specify the name of the target architecture.
>
>  ; Other arm_arch values are loaded from arm-tables.opt
> @@ -107,7 +107,7 @@ Target Report Mask(CALLER_INTERWORKING)
>  Thumb: Assume function pointers may go to non-Thumb aware code.
>
>  mcpu=
> -Target RejectNegative ToLower Joined Var(arm_cpu_string)
> +Target RejectNegative Negative(mcpu=) ToLower Joined Var(arm_cpu_string)
>  Specify the name of the target CPU.
>
>  mfloat-abi=
> @@ -232,7 +232,7 @@ Target Report Mask(TPCS_LEAF_FRAME)
>  Thumb: Generate (leaf) stack frames even if not needed.
>
>  mtune=
> -Target RejectNegative ToLower Joined Var(arm_tune_string)
> +Target RejectNegative Negative(mtune=) ToLower Joined 
> Var(arm_tune_string)
>  Tune code for the given processor.
>
>  mprint-tune-info
> -- 
> 2.21.0
>
Kyrill Tkachov Sept. 26, 2019, 10:55 a.m. UTC | #2
On 9/25/19 12:10 PM, Kyrill Tkachov wrote:
>
> On 9/24/19 7:47 PM, Matt Turner wrote:
> > When -march=native is passed to host_detect_local_cpu to the backend,
> > it overrides all command lines after it.  That means
> >
> > $ gcc -march=native -march=armv8-a
> >
> > is treated as
> >
> > $ gcc -march=armv8-a -march=native
> >
> > Prune joined switches with Negative and RejectNegative to allow
> > -march=armv8-a to override previous -march=native on command-line.
> >
> > This is the same fix as was applied for i386 in SVN revision 269164
> > but for
> > aarch64 and arm.
> >
> > gcc/
> >
> >         PR driver/69471
> >         * config/aarch64/aarch64.opt (march=): Add Negative(march=).
> >         (mtune=): Add Negative(mtune=). (mcpu=): Add Negative(mcpu=).
> >         * config/arm/arm.opt: Likewise.
>
>
> Thanks.
>
> This is ok for arm. LGTM for aarch64 but you'll need an aarch64
> maintainer to approve.
>
> I've bootstrapped and tested this patch on arm-none-linux-gnueabihf and
> aarch64-none-linux-gnu and there's no fallout.
>
> I can commit it for you once the aarch64 part is
>
I've now committed this to trunk with a slightly adjusted ChangeLog

2019-09-26  Matt Turner  <mattst88@gmail.com>

     PR driver/69471
     * config/aarch64/aarch64.opt (march=): Add Negative(march=).
     (mtune=): Add Negative(mtune=).
     (mcpu=): Add Negative(mcpu=).
     * config/arm/arm.opt: Likewise.

as r276148. Backports will come a bit later after it's had some testing 
on trunk.

I don't think this patch is above the threshold for a copyright 
assignment, but if you intend to write larger patches in the future 
you'll want to get that sorted out.

Thanks!

Kyrill


> Kyrill
>
>
> > ---
> >  gcc/config/aarch64/aarch64.opt | 6 +++---
> >  gcc/config/arm/arm.opt         | 6 +++---
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/gcc/config/aarch64/aarch64.opt
> > b/gcc/config/aarch64/aarch64.opt
> > index 865b6a6d8ca..fc43428b32a 100644
> > --- a/gcc/config/aarch64/aarch64.opt
> > +++ b/gcc/config/aarch64/aarch64.opt
> > @@ -119,15 +119,15 @@ EnumValue
> >  Enum(aarch64_tls_size) String(48) Value(48)
> >
> >  march=
> > -Target RejectNegative ToLower Joined Var(aarch64_arch_string)
> > +Target RejectNegative Negative(march=) ToLower Joined
> > Var(aarch64_arch_string)
> >  Use features of architecture ARCH.
> >
> >  mcpu=
> > -Target RejectNegative ToLower Joined Var(aarch64_cpu_string)
> > +Target RejectNegative Negative(mcpu=) ToLower Joined
> > Var(aarch64_cpu_string)
> >  Use features of and optimize for CPU.
> >
> >  mtune=
> > -Target RejectNegative ToLower Joined Var(aarch64_tune_string)
> > +Target RejectNegative Negative(mtune=) ToLower Joined
> > Var(aarch64_tune_string)
> >  Optimize for CPU.
> >
> >  mabi=
> > diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
> > index 452f0cf6d67..76c10ab62a2 100644
> > --- a/gcc/config/arm/arm.opt
> > +++ b/gcc/config/arm/arm.opt
> > @@ -82,7 +82,7 @@ mapcs-stack-check
> >  Target Report Mask(APCS_STACK) Undocumented
> >
> >  march=
> > -Target RejectNegative ToLower Joined Var(arm_arch_string)
> > +Target RejectNegative Negative(march=) ToLower Joined
> > Var(arm_arch_string)
> >  Specify the name of the target architecture.
> >
> >  ; Other arm_arch values are loaded from arm-tables.opt
> > @@ -107,7 +107,7 @@ Target Report Mask(CALLER_INTERWORKING)
> >  Thumb: Assume function pointers may go to non-Thumb aware code.
> >
> >  mcpu=
> > -Target RejectNegative ToLower Joined Var(arm_cpu_string)
> > +Target RejectNegative Negative(mcpu=) ToLower Joined 
> Var(arm_cpu_string)
> >  Specify the name of the target CPU.
> >
> >  mfloat-abi=
> > @@ -232,7 +232,7 @@ Target Report Mask(TPCS_LEAF_FRAME)
> >  Thumb: Generate (leaf) stack frames even if not needed.
> >
> >  mtune=
> > -Target RejectNegative ToLower Joined Var(arm_tune_string)
> > +Target RejectNegative Negative(mtune=) ToLower Joined
> > Var(arm_tune_string)
> >  Tune code for the given processor.
> >
> >  mprint-tune-info
> > --
> > 2.21.0
> >
diff mbox series

Patch

diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 865b6a6d8ca..fc43428b32a 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -119,15 +119,15 @@  EnumValue
 Enum(aarch64_tls_size) String(48) Value(48)
 
 march=
-Target RejectNegative ToLower Joined Var(aarch64_arch_string)
+Target RejectNegative Negative(march=) ToLower Joined Var(aarch64_arch_string)
 Use features of architecture ARCH.
 
 mcpu=
-Target RejectNegative ToLower Joined Var(aarch64_cpu_string)
+Target RejectNegative Negative(mcpu=) ToLower Joined Var(aarch64_cpu_string)
 Use features of and optimize for CPU.
 
 mtune=
-Target RejectNegative ToLower Joined Var(aarch64_tune_string)
+Target RejectNegative Negative(mtune=) ToLower Joined Var(aarch64_tune_string)
 Optimize for CPU.
 
 mabi=
diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
index 452f0cf6d67..76c10ab62a2 100644
--- a/gcc/config/arm/arm.opt
+++ b/gcc/config/arm/arm.opt
@@ -82,7 +82,7 @@  mapcs-stack-check
 Target Report Mask(APCS_STACK) Undocumented
 
 march=
-Target RejectNegative ToLower Joined Var(arm_arch_string)
+Target RejectNegative Negative(march=) ToLower Joined Var(arm_arch_string)
 Specify the name of the target architecture.
 
 ; Other arm_arch values are loaded from arm-tables.opt
@@ -107,7 +107,7 @@  Target Report Mask(CALLER_INTERWORKING)
 Thumb: Assume function pointers may go to non-Thumb aware code.
 
 mcpu=
-Target RejectNegative ToLower Joined Var(arm_cpu_string)
+Target RejectNegative Negative(mcpu=) ToLower Joined Var(arm_cpu_string)
 Specify the name of the target CPU.
 
 mfloat-abi=
@@ -232,7 +232,7 @@  Target Report Mask(TPCS_LEAF_FRAME)
 Thumb: Generate (leaf) stack frames even if not needed.
 
 mtune=
-Target RejectNegative ToLower Joined Var(arm_tune_string)
+Target RejectNegative Negative(mtune=) ToLower Joined Var(arm_tune_string)
 Tune code for the given processor.
 
 mprint-tune-info