Hi,

As Charles Baylis pointed out here:

http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00921.html

The way that we rewrite command lines for big.LITTLE systems
causes bugs where more than one source file is to be used.
The problem fundamentally is that -mcpu never makes it to
the second cc1 invocation.

This patch changes the spec command we use and updates
aarch64-common.c to handle that fact. I confess that the specs
stuff all looks like magic to me, but this approach seems to
make sense. In English, I think I am saying:

"If you find an mcpu= followed by some name, rewrite that to be
 -mcpu followed by the results of passing all other -mcpu values
 we find through aarch64_rewrite_mcpu"

I've regression tested this patch on aarch64-none-elf with no
issues and checked combinations of zero or more -mcpu values with
one or more source files, and things seem to work as expected.

OK?

Thanks,
James

---
2014-01-21  James Greenhalgh  <james.greenha...@arm.com>

        * common/config/aarch64/aarch64-common.c
        (aarch64_rewrite_mcpu): Handle multiple names.
        * config/aarch64/aarch64.h
        (BIG_LITTLE_SPEC): Do not discard mcpu switches.
diff --git a/gcc/common/config/aarch64/aarch64-common.c b/gcc/common/config/aarch64/aarch64-common.c
index 6107007..e44b40a 100644
--- a/gcc/common/config/aarch64/aarch64-common.c
+++ b/gcc/common/config/aarch64/aarch64-common.c
@@ -110,13 +110,15 @@ aarch64_rewrite_selected_cpu (const char *name)
 
 /* Called by the driver to rewrite a name passed to the -mcpu
    argument in preparation to be passed to the assembler.  The
-   name will be in ARGV[0], ARGC should always be 1.  */
+   names passed from the commend line will be in ARGV, we want
+   to use the right-most argument, which should be in
+   ARGV[ARGC - 1].  ARGC should always be greater than 0.  */
 
 const char *
 aarch64_rewrite_mcpu (int argc, const char **argv)
 {
-  gcc_assert (argc == 1);
-  return aarch64_rewrite_selected_cpu (argv[0]);
+  gcc_assert (argc);
+  return aarch64_rewrite_selected_cpu (argv[argc - 1]);
 }
 
 #undef AARCH64_CPU_NAME_LENGTH
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index a08dee0..13c424c 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -857,7 +857,7 @@ extern enum aarch64_code_model aarch64_cmodel;
   (BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 - n : n)
 
 #define BIG_LITTLE_SPEC \
-   " %{mcpu=*:%<mcpu=* -mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}"
+   " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}"
 
 extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
 #define BIG_LITTLE_CPU_SPEC_FUNCTIONS \

Reply via email to