if you create an alpha toolchain with the target alphaev68-unknown-linux-gnu,
gcc will use the -mcpu=ev67 by default when compiling. some software packages
(like gmp) will use this target info to decided that it can freely use
assembly code that targets ev67+. the trouble comes in when trying to compile
that pure assembly code.
while gcc will use -mcpu=ev67 just fine, it will invoke gas without an -mev67
option, so the assembler will default to the lowest common denominator -- ev4
in this case. inline assembly in C code is normally just peachy because gcc's
assembler output will start with ".arch <cpu>" and the assembler will accept
that. but if the hand coded assembly code lacks that .arch, you easily end up
with errors like so: opcode `cttz' not supported for target <all>
while the assembly code could/should be fixed to explicitly output the .arch
directive, i think it's reasonable to expect this to work:
echo 'cttz $20,$21' | gcc -x assembler -c - -o /dev/null -mcpu=ev67
this simple patch implements that, although i guess it is a bit redundant in
the default case where gcc outputs .arch. perhaps that should all be shunted
in favor of a specs-only approach. considering gas respects .arch in the code
over the command line, it should also make things more natural. the command
line is processed in the standard/expected way -- gcc defaults the -m option
while user's custom -mcpu/-Wa,-m options come after, and the guy writing the
assembly code is free to use .arch to override everything else.
2009-11-07 Mike Frysinger <
vapier@...>
* gcc/config/alpha/elf.h (ASM_SPEC): Add %{mcpu=*:-m%*}.
--- trunk/gcc/config/alpha/elf.h (revision 153992)
+++ trunk/gcc/config/alpha/elf.h (working copy)
@@ -46,7 +46,7 @@ along with GCC; see the file COPYING3.
#define CC1_SPEC "%{G*}"
#undef ASM_SPEC
-#define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
+#define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug} %{mcpu=*:-m%*}"
#undef IDENT_ASM_OP
#define IDENT_ASM_OP "\t.ident\t"
-mike