* [PATCH] driver: Also prune joined switches with negation
@ 2019-09-24 4:04 Matt Turner
2019-09-24 8:24 ` Kyrill Tkachov
2019-09-24 18:48 ` Matt Turner
0 siblings, 2 replies; 8+ messages in thread
From: Matt Turner @ 2019-09-24 4:04 UTC (permalink / raw)
To: gcc-patches
Cc: James Greenhalgh, Kyrylo Tkachov, Marcus Shawcroft, Nick Clifton,
Ramana Radhakrishnan, Richard Earnshaw, Matt Turner
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=).
* config/arm/arm.opt: Likewise.
---
gcc/config/aarch64/aarch64.opt | 5 +++--
gcc/config/arm/arm.opt | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 865b6a6d8ca..908dca23b3c 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -119,7 +119,8 @@ 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=
@@ -127,7 +128,7 @@ Target RejectNegative 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..e3ead5c95d1 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
@@ -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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] driver: Also prune joined switches with negation
2019-09-24 4:04 [PATCH] driver: Also prune joined switches with negation Matt Turner
@ 2019-09-24 8:24 ` Kyrill Tkachov
2019-09-24 18:57 ` Matt Turner
2019-09-24 18:48 ` Matt Turner
1 sibling, 1 reply; 8+ messages in thread
From: Kyrill Tkachov @ 2019-09-24 8:24 UTC (permalink / raw)
To: Matt Turner, gcc-patches
Cc: James Greenhalgh, Marcus Shawcroft, nickc, Ramana Radhakrishnan,
Richard Earnshaw
Hi Matt,
On 9/24/19 5:04 AM, 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.
>
The fix is ok for arm and LGTM for aarch64 FWIW.
How has this been tested?
However...
> gcc/
>
> Â Â Â Â Â Â Â PR driver/69471
> Â Â Â Â Â Â Â * config/aarch64/aarch64.opt (march=): Add Negative(march=).
> Â Â Â Â Â Â Â (mtune=): Add Negative(mtune=).
> Â Â Â Â Â Â Â * config/arm/arm.opt: Likewise.
> ---
> Â gcc/config/aarch64/aarch64.opt | 5 +++--
>  gcc/config/arm/arm.opt        | 4 ++--
> Â 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64.opt
> b/gcc/config/aarch64/aarch64.opt
> index 865b6a6d8ca..908dca23b3c 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -119,7 +119,8 @@ 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=
... Looks like we'll need something similar for -mcpu. On arm and
aarch64 the -mcpu is the most commonly used option and that can also
take a "native" value that would suffer from the same issue I presume.
Thanks,
Kyrill
> @@ -127,7 +128,7 @@ Target RejectNegative 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..e3ead5c95d1 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
> @@ -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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] driver: Also prune joined switches with negation
2019-09-24 8:24 ` Kyrill Tkachov
@ 2019-09-24 18:57 ` Matt Turner
0 siblings, 0 replies; 8+ messages in thread
From: Matt Turner @ 2019-09-24 18:57 UTC (permalink / raw)
To: Kyrill Tkachov
Cc: gcc-patches, James Greenhalgh, Marcus Shawcroft, nickc,
Ramana Radhakrishnan, Richard Earnshaw
On Tue, Sep 24, 2019 at 1:24 AM Kyrill Tkachov
<kyrylo.tkachov@foss.arm.com> wrote:
>
> Hi Matt,
>
> On 9/24/19 5:04 AM, 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.
> >
> The fix is ok for arm and LGTM for aarch64 FWIW.
Thanks!
> How has this been tested?
The problem was noticed in this bug report:
https://bugs.gentoo.org/693522
I remembered seeing the i386 fix and I separately encountered the
problem on ARM when building the pixman library which has iwMMXt code
which requires march=iwmmxt (Could I bribe someone into fixing that by
giving gcc an -miwmmxt flag?)
I verified the fix works by patching gcc and seeing that nss (the
package from the Gentoo bug report) successfully builds with
CFLAGS="-march=native -O2 -pipe"
SVN revision 269164 also added some tests to the gcc test suite, but I
am not sufficiently familiar with building gcc and running the test
suite to verify that any test I speculatively add actually works.
> However...
>
>
> > gcc/
> >
> > PR driver/69471
> > * config/aarch64/aarch64.opt (march=): Add Negative(march=).
> > (mtune=): Add Negative(mtune=).
> > * config/arm/arm.opt: Likewise.
> > ---
> > gcc/config/aarch64/aarch64.opt | 5 +++--
> > gcc/config/arm/arm.opt | 4 ++--
> > 2 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/gcc/config/aarch64/aarch64.opt
> > b/gcc/config/aarch64/aarch64.opt
> > index 865b6a6d8ca..908dca23b3c 100644
> > --- a/gcc/config/aarch64/aarch64.opt
> > +++ b/gcc/config/aarch64/aarch64.opt
> > @@ -119,7 +119,8 @@ 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=
>
>
> ... Looks like we'll need something similar for -mcpu. On arm and
> aarch64 the -mcpu is the most commonly used option and that can also
> take a "native" value that would suffer from the same issue I presume.
Thank you. I've sent a second version with this addressed in reply to
my initial patch.
If the patch is okay, I think we'd appreciate it if it were backported
to the gcc-8 branch as well.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] driver: Also prune joined switches with negation
2019-09-24 4:04 [PATCH] driver: Also prune joined switches with negation Matt Turner
2019-09-24 8:24 ` Kyrill Tkachov
@ 2019-09-24 18:48 ` Matt Turner
2019-09-25 11:10 ` Kyrill Tkachov
1 sibling, 1 reply; 8+ messages in thread
From: Matt Turner @ 2019-09-24 18:48 UTC (permalink / raw)
To: gcc-patches
Cc: James Greenhalgh, Kyrylo Tkachov, Marcus Shawcroft, Nick Clifton,
Ramana Radhakrishnan, Richard Earnshaw, Matt Turner
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(-)
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] driver: Also prune joined switches with negation
2019-09-24 18:48 ` Matt Turner
@ 2019-09-25 11:10 ` Kyrill Tkachov
2019-09-26 10:55 ` Kyrill Tkachov
0 siblings, 1 reply; 8+ messages in thread
From: Kyrill Tkachov @ 2019-09-25 11:10 UTC (permalink / raw)
To: Matt Turner, gcc-patches
Cc: James Greenhalgh, Marcus Shawcroft, nickc, Ramana Radhakrishnan,
Richard Earnshaw
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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] driver: Also prune joined switches with negation
2019-09-25 11:10 ` Kyrill Tkachov
@ 2019-09-26 10:55 ` Kyrill Tkachov
0 siblings, 0 replies; 8+ messages in thread
From: Kyrill Tkachov @ 2019-09-26 10:55 UTC (permalink / raw)
To: Matt Turner, gcc-patches
Cc: James Greenhalgh, Marcus Shawcroft, nickc, Ramana Radhakrishnan,
Richard Earnshaw
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
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] driver: Also prune joined switches with negation
@ 2019-02-08 23:02 H.J. Lu
2019-02-08 23:10 ` H.J. Lu
0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2019-02-08 23:02 UTC (permalink / raw)
To: gcc-patches; +Cc: Joseph Myers
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=skylake-avx512
is the treated as
$ gcc -march=skylake-avx512 -march=native
Prune joined switches with negation to allow -march=skylake-avx512 to
override previous -march=native on command-line.
PR driver/69471
* opts-common.c (prune_options): Also prune joined switches
with negation.
* config/i386/i386.opt (march=): Add Negative(march=).
(mtune=): Add Negative(mtune=).
---
gcc/config/i386/i386.opt | 4 ++--
gcc/opts-common.c | 7 ++++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 9b93241f790..b7998ee7363 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -253,7 +253,7 @@ EnumValue
Enum(ix86_align_data) String(cacheline) Value(ix86_align_data_type_cacheline)
march=
-Target RejectNegative Joined Var(ix86_arch_string)
+Target RejectNegative Negative(march=) Joined Var(ix86_arch_string)
Generate code for given CPU.
masm=
@@ -510,7 +510,7 @@ Target Report Mask(TLS_DIRECT_SEG_REFS)
Use direct references against %gs when accessing tls data.
mtune=
-Target RejectNegative Joined Var(ix86_tune_string)
+Target RejectNegative Negative(mtune=) Joined Var(ix86_tune_string)
Schedule code for given CPU.
mtune-ctrl=
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index ee8898b22ec..ba9eb144078 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1014,8 +1014,8 @@ prune_options (struct cl_decoded_option **decoded_options,
if (option->neg_index < 0)
goto keep;
- /* Skip joined switches. */
- if ((option->flags & CL_JOINED))
+ /* Skip joined switches if there is no negation. */
+ if ((option->flags & CL_JOINED) && option->neg_index < 0)
goto keep;
for (j = i + 1; j < old_decoded_options_count; j++)
@@ -1027,7 +1027,8 @@ prune_options (struct cl_decoded_option **decoded_options,
continue;
if (cl_options[next_opt_idx].neg_index < 0)
continue;
- if ((cl_options[next_opt_idx].flags & CL_JOINED))
+ if ((cl_options[next_opt_idx].flags & CL_JOINED)
+ && cl_options[next_opt_idx].neg_index < 0)
continue;
if (cancel_option (opt_idx, next_opt_idx, next_opt_idx))
break;
--
2.20.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] driver: Also prune joined switches with negation
2019-02-08 23:02 H.J. Lu
@ 2019-02-08 23:10 ` H.J. Lu
0 siblings, 0 replies; 8+ messages in thread
From: H.J. Lu @ 2019-02-08 23:10 UTC (permalink / raw)
To: GCC Patches; +Cc: Joseph Myers
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
On Fri, Feb 8, 2019 at 3:02 PM H.J. Lu <hjl.tools@gmail.com> 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=skylake-avx512
>
> is the treated as
>
> $ gcc -march=skylake-avx512 -march=native
>
> Prune joined switches with negation to allow -march=skylake-avx512 to
> override previous -march=native on command-line.
>
> PR driver/69471
> * opts-common.c (prune_options): Also prune joined switches
> with negation.
> * config/i386/i386.opt (march=): Add Negative(march=).
> (mtune=): Add Negative(mtune=).
Here is the updated patch.
--
H.J.
[-- Attachment #2: 0001-driver-Also-prune-joined-switches-with-negation.patch --]
[-- Type: text/x-patch, Size: 2425 bytes --]
From a5a453e48f8560955cfa2e2db3b8f4f22b9cf9b1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 8 Feb 2019 14:52:57 -0800
Subject: [PATCH] driver: Also prune joined switches with negation
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=skylake-avx512
is the treated as
$ gcc -march=skylake-avx512 -march=native
Prune joined switches with negation to allow -march=skylake-avx512 to
override previous -march=native on command-line.
PR driver/69471
* opts-common.c (prune_options): Also prune joined switches
with negation.
* config/i386/i386.opt (march=): Add Negative(march=).
(mtune=): Add Negative(mtune=).
---
gcc/config/i386/i386.opt | 4 ++--
gcc/opts-common.c | 6 ------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 9b93241f790..b7998ee7363 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -253,7 +253,7 @@ EnumValue
Enum(ix86_align_data) String(cacheline) Value(ix86_align_data_type_cacheline)
march=
-Target RejectNegative Joined Var(ix86_arch_string)
+Target RejectNegative Negative(march=) Joined Var(ix86_arch_string)
Generate code for given CPU.
masm=
@@ -510,7 +510,7 @@ Target Report Mask(TLS_DIRECT_SEG_REFS)
Use direct references against %gs when accessing tls data.
mtune=
-Target RejectNegative Joined Var(ix86_tune_string)
+Target RejectNegative Negative(mtune=) Joined Var(ix86_tune_string)
Schedule code for given CPU.
mtune-ctrl=
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index ee8898b22ec..7204bb5a8fa 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1014,10 +1014,6 @@ prune_options (struct cl_decoded_option **decoded_options,
if (option->neg_index < 0)
goto keep;
- /* Skip joined switches. */
- if ((option->flags & CL_JOINED))
- goto keep;
-
for (j = i + 1; j < old_decoded_options_count; j++)
{
if (old_decoded_options[j].errors & ~CL_ERR_WRONG_LANG)
@@ -1027,8 +1023,6 @@ prune_options (struct cl_decoded_option **decoded_options,
continue;
if (cl_options[next_opt_idx].neg_index < 0)
continue;
- if ((cl_options[next_opt_idx].flags & CL_JOINED))
- continue;
if (cancel_option (opt_idx, next_opt_idx, next_opt_idx))
break;
}
--
2.20.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-09-26 10:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 4:04 [PATCH] driver: Also prune joined switches with negation Matt Turner
2019-09-24 8:24 ` Kyrill Tkachov
2019-09-24 18:57 ` Matt Turner
2019-09-24 18:48 ` Matt Turner
2019-09-25 11:10 ` Kyrill Tkachov
2019-09-26 10:55 ` Kyrill Tkachov
-- strict thread matches above, loose matches on Subject: below --
2019-02-08 23:02 H.J. Lu
2019-02-08 23:10 ` H.J. Lu
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).