Which -march option to use for a generic 64-bit cpu?
Erik Leunissen
e.leunissen@hccnet.nl
Sat Jan 21 17:31:00 GMT 2012
On 21/01/12 16:33, Jonathan Wakely wrote:
> On 21/01/2012, Erik Leunissen wrote:
>> L.S.
>>
>> I'd like to generate code that runs on a selection of common 64-bit
>> cpu's, both Intel and AMD[*].
>>
>> [*] Aside: I'm not yet entirely sure yet about the final selection
>> of architectures, but in any case I would like to support core2, atom,
>> athlon64 (not yet sure about opteron and AMD multicore cpu's).
>>
>> To that end, I've been looking in the list of "-march" options to gcc
>> for a specific option that indicates such a common set of architectures
>> (much like "-march=i686" for 32-bit architectures).
>>
>> I remain confused about how to do this for 64-bit cpu's. I found several
>> options indicating specific cpu's that I'd like to run my code on.
>> However, I guess that I'm clueless about "backward compatibility" of
>> (closely) related 64-bit cpu types (like i386 code being supported by
>> i686 with 32-bit cpu's). Also, I'm unsure about the differences between
>> AMD and Intel in this regard.
>>
>> - Do options indicating such a generic 64-bit cpu exist?, or
>
> Why do you think you need to use any -march option?
Well, for all I knew, absence of any option could mean that gcc
generates code for the machine where I run the compile command, and not
for others.
Following that logic, I expected to need a -march option.
Apparently this is just one part where I was confused/ignorant, as
predicted.
> If do don't use one you'll get code that runs on any x86_64 machine.
>
I simply didn't know this. It's just what I need.
>> - Can I specifiy multiple -march options in one compile command?, or
>
> No.
>
>> - Do I need to compile separately for each 64-bit architecture?, or
>> - ... ?
>>
>> I'd appreciate very much any directions about how to proceed.
>
> Just compile without any -march, unless you're sure your code will
> always run on chips that support more specific features. Each -march
> option lists the features it enables, so you should be able to work
> out what options will work for all the machines you want to use. e.g.
> don't use -march=core2 if you want to support chips without SSSE3.
>
OK
> You can always use -mtune=generic to generate code that is tuned for
> common chips, but still runs on older ones.
>
OK, thanks for clearing up my confusion/ignorance.
Erik.
More information about the Gcc-help
mailing list