https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116854
--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Anonymous from comment #0) > Summary: GCC enables __haswell__ on certain AMD Excavator CPUs that > '-march=native' resolves to '-march=bdver4 -mno-rdrnd' despite the fact that > RDRND should be checked for and required in order to enable __haswell__. > > While investigating segfaults within Qt, compiled with GCC 13.3.1, it has > been discovered that GCC is attempting to compile for RDRND on bdver4 arch > CPUs. Affected users specify -march=native, which resolves to -march=bdver4. > > Docs state that bdver4 is a superset of Haswell, which implies the presence > of RDRND: > > ~ $ gcc -dM -E -march=bdver4 -xc /dev/null | grep RDRND > #define __RDRND__ 1 > > > To quote from this > [https://bugreports.qt.io/browse/QTBUG-129193?focusedId=825891&page=com. > atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment- > 825891] comment, in the original Qt bug: > > "Ok, so the problem is that this CPU is missing the random number generator > instructions, which all Intel CPU have had since Ivy Bridge (2013). That is > a problem, but not our problem here. Our problem here is that we have a > mismatch between what features are required at compile-time to enable > __haswell__ and which ones are checked at runtime for that CPU." > > It is important to note that the Gentoo tool `resolve-march-native` returns > '-mno-rdrnd' as part of its resolution for an affected machine, however it > seems that even with this being the case, GCC compiles the affected Qt > libraries expecting RDRND as part of the feature set. > > A final quote from the Qt bug: > "Apparently, for AMD Excavator (Bulldozer 4), GCC says that the RDRND ISA > extension is mandatory. That means QtCore assumes it's always present if you > compile with -march=bdver4 and that is likely to crash with SIGILL if you > use that flag." > > NB: Affected users compiled with '-march=native' in all documented cases, > and allowed GCC to resolve the CPU arch and features. -march=native also returns compile flags that fine-tune available ISAs. You can see all flags passed to cc1 by adding -### to the compiler flags, e.g.: gcc -march=native -### hello.c However, -march=bdver4 -mno-rdrnd is what this will show for your target and gcc -march=bdver4 -mno-rdrnd for sure won't define __RDRND__. Does QT enable RDRND instruction based on the definition of __haswell__ or based on the definiotion of __RDRND__?