https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116854

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Anonymous from comment #8)
> (In reply to Thiago Macieira from comment #5)
> 
> > This has nothing to do with -march=native. In fact, for the Gentoo people
> > who are using -march=native, everything is fine because __RDRND__ is *not*
> > defined (I think; I don't have such a CPU to check, but on my TGL,
> > -march=native and -march=tigerlake differ).
> 
> I have to disagree. I specifically stated in the Qt bug that affected users
> were using -march=native and that was being resolved to -march=bdver4, so

What does "being resolved to -march=bdver4" mean?

Could you please provide the output of the command shown in comment 1?

gcc -march=native -### hello.c

That will resolve to a specific -march option **and** zero or more -m options
for specific instructions. If -march=native resolves to **only** -march=bdver4
on your machine (as you seem to be suggesting) then that's a problem.

But if it resolves to -march=bdver4 -mno-rdrnd then GCC is behaving correctly.


> everything is not fine when using -march=native. You are correct that with
> -march=native on an affected CPU, __RDRND__ is not defined,

Well then that suggests -march=native includes -mno-rdrnd and so GCC is
behaving correctly.

> but that's what
> I used to build Qt libraries that segfaulted. I only got working libraries
> by supplying -march=x86-64-v2 or omitting -march entirely.
> 
> This is why I was asking in the Qt bug about the lack of definition for
> __RDRND__ when GCC is supplied with -march=native, and whether the
> explanation about __haswell__ still worked - because nobody involved is
> supplying -march=bdver4 as a compiler argument, everyone is using
> -march=native and trusting gcc to make a decision on the correct environment.

Which contradicts what Thiago said above.

We really need some clarity here to do anything.

Please run the -### command to give some concrete facts about what GCC is
actually doing on a machine with the relevant CPU.

Then please also provide the output of:

gcc -march=native -E -dM -x c /dev/null | grep -E -i '__tune_|rdrnd'

Reply via email to