How to determine what is default x86-64 -march= value for a given release of gcc?
Segher Boessenkool
segher@kernel.crashing.org
Tue Sep 24 16:25:01 GMT 2024
On Mon, Sep 23, 2024 at 03:26:59PM -0400, Bradley Lucier via Gcc-help wrote:
> On 9/23/24 15:14, Jonathan Wakely wrote:
> >
> >On Mon, 23 Sept 2024 at 19:21, Bradley Lucier via Gcc-help
> ><gcc-help@gcc.gnu.org> wrote:
> >>
> >>On 9/23/24 13:51, Alexander Monakov wrote:
> >>>
> >>>On Mon, 23 Sep 2024, Bradley Lucier via Gcc-help wrote:
> >>>
> >>
> >>#ifdef ___CPU_x86
> >>#if __has_builtin(__builtin_ia32_rdtscp)
> >
> >This will always be true on x86_64, even for an -march that doesn't
> >support the instruction. What __has_builtin tells you is that GCC
> >knows that built-in function, not that the instruction is available in
> >the current instruction set selected by -march.
>
> Thank you for that explanation (and the ones below).
>
> Is there a way to test in the C source whether the architecture you're
> compiling for has a specific instruction?
>
> >>#undef ___USE___builtin_ia32_rdtscp
> >>#define ___USE___builtin_ia32_rdtscp
> >
> >This is a reserved name, unless your library is part of the kernel or
> >the C library or the C compiler, you should not be defining names
> >starting with double underscores.
>
> These names start with three underscores. I suppose that means they
> also start with two underscores, but otherwise I don't know what
> difference that makes. This part is not my code.
Yes, anything that starts with three underscores starts with two
unbderscores :-) Same as any name that starts with an underscore and
a capital letter.
The kernel really should not use such names either, but it has since
forever, and this doesn't often cause problems (mostly because they
don't use any external libraries). And when it does it just gives the
kernel people another excuse to blame the compiler people (for their own
mistakes!)
Segher
More information about the Gcc-help
mailing list