On Fri, Feb 8, 2019 at 3:02 PM H.J. Lu <hjl.to...@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.
From a5a453e48f8560955cfa2e2db3b8f4f22b9cf9b1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@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