Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Trouble building dev-qt/qtbase with Ryzen 9 9950x CC_FLAGS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
paddlaren
Tux's lil' helper
Tux's lil' helper


Joined: 23 Nov 2005
Posts: 127
Location: Hörby, Sweden

PostPosted: Sat Oct 19, 2024 9:28 am    Post subject: Trouble building dev-qt/qtbase with Ryzen 9 9950x CC_FLAGS Reply with quote

I just got an upgrade from Ryzen9 7950x to 9950x and naturally I enable all flags possible. The upgrade (not empty tree though) wen mostly smooth but there was a strange problem with dev-qt/qtbase

My settings in make.conf was derived from resolve-march-native that reported:
Code:
-march=znver4 -mavx512vp2intersect -mavxvnni -mmovdir64b -mmovdiri -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=1024


Thus COMMON_FLAGS in make.conf was:
Code:
CFLAGS="-march=znver4 -mavx512vp2intersect -mavxvnni -mmovdir64b -mmovdiri -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=1024 -O2 -pipe"


(Without the -O2 -pipe media-libs/libvpx-1.14.1 failed to build, which might seem strange as -O2 should be enabled by default from what I read).

GCC is the default:
Code:
gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614


When I built dev-qt/qtbase-6.7.2-r5 I got the following strange errors:

Code:
/usr/bin/x86_64-pc-linux-gnu-g++ -DENABLE_PIXMAN_DRAWHELPERS -DGui_EXPORTS -DMD4C_USE_UTF8 -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_GUI_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x050000 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_LEAN_HEADERS=1 -DQT_MOC_COMPAT -DQT_NO_AS_CONST -DQT_NO_CAST_TO_ASCII -DQT_NO_CONTEXTLESS_CONNECT -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QEXCHANGE -DQT_NO_USING_NAMESPACE -DQT_QPA_DEFAULT_PLATFORM_NAME=\"xcb\" -DQT_USE_QSTRINGBUILDER -DQT_WARN_DEPRECATED_UP_TO=0x070000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/src/gui/Gui_autogen/include -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtGui -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/src/gui -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/../3rdparty/VulkanMemoryAllocator -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/../3rdparty/D3D12MemoryAllocator -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtGui/6.7.2 -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtGui/6.7.2/QtGui -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/../3rdparty/md4c -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtCore -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/mkspecs/linux-g++ -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/src/corelib -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtCore/6.7.2 -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtCore/6.7.2/QtCore -I/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtDBus -isystem /usr/include/harfbuzz -isystem /usr/include/freetype2 -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include  -march=znver4 -mavx512vp2intersect -mavxvnni -mmovdir64b -mmovdiri -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=1024 -O2 -pipe -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fno-exceptions -fPIC -Wsuggest-override -fcf-protection=full -march=haswell -MD -MT src/gui/CMakeFiles/Gui.dir/painting/qdrawhelper_avx2.cpp.o -MF src/gui/CMakeFiles/Gui.dir/painting/qdrawhelper_avx2.cpp.o.d -o src/gui/CMakeFiles/Gui.dir/painting/qdrawhelper_avx2.cpp.o -c /var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/painting/qdrawhelper_avx2.cpp
In file included from /var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2_build/include/QtCore/6.7.2/QtCore/private/qsimd_p.h:1,
                 from /var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/painting/qdrawhelper_p.h:30,
                 from /var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/gui/painting/qdrawhelper_avx2.cpp:5:
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:250:8: error: #error "Please enable all x86-64-v4 extensions; you probably want to use -march=skylake-avx512 or -march=x86-64-v4 instead of -mavx512f"
  250 | #      error "Please enable all x86-64-v4 extensions; you probably want to use -march=skylake-avx512 or -march=x86-64-v4 instead of -mavx512f"
      |        ^~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:247:52: error: ‘__AVX512BW__’ was not declared in this scope
  247 | #  define ARCH_SKX_MACROS           (__AVX512F__ + __AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + __AVX512VL__)
      |                                                    ^~~~~~~~~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:252:15: note: in expansion of macro ‘ARCH_SKX_MACROS’
  252 | static_assert(ARCH_SKX_MACROS, "Undeclared identifiers indicate which features are missing.");
      |               ^~~~~~~~~~~~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:247:67: error: ‘__AVX512CD__’ was not declared in this scope
  247 | #  define ARCH_SKX_MACROS           (__AVX512F__ + __AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + __AVX512VL__)
      |                                                                   ^~~~~~~~~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:252:15: note: in expansion of macro ‘ARCH_SKX_MACROS’
  252 | static_assert(ARCH_SKX_MACROS, "Undeclared identifiers indicate which features are missing.");
      |               ^~~~~~~~~~~~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:247:97: error: ‘__AVX512VL__’ was not declared in this scope
  247 | #  define ARCH_SKX_MACROS           (__AVX512F__ + __AVX512BW__ + __AVX512CD__ + __AVX512DQ__ + __AVX512VL__)
      |                                                                                                 ^~~~~~~~~~~~
/var/tmp/portage/dev-qt/qtbase-6.7.2-r5/work/qtbase-everywhere-src-6.7.2/src/corelib/global/qsimd_p.h:252:15: note: in expansion of macro ‘ARCH_SKX_MACROS’
  252 | static_assert(ARCH_SKX_MACROS, "Undeclared identifiers indicate which features are missing.");
      |               ^~~~~~~~~~~~~~~


I had just no idea where to begin so I verified that those requested flags was compatible with my CPU by checking the CPU-flags from lscpu (lscpu | grep -i AVX512F etc) and it was.

So I tried by chanse to add those specifically to the COMMON_FLAGS:
Code:
CFLAGS="-march=znver4 -mavx512vp2intersect -mavx512f -mavx512bw -mavx512cd -mavx512dq -mavx512vl -mavxvnni -mmovdir64b -mmovdiri -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=48 --param=l2-cache-size=1024 -O2 -pipe"

and qtbase compile just fine.

According to GCC documentation for version 13.3 the problematic flags should be enabled by the -march=znver4:

Quote:
AMD Family 19h core based CPUs with x86-64 instruction set support. (This supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)



What is going on here? Why did I need to add those flags specifically? Aren't gcc and macros picking up those flags automatically with -march=znver4?
This problem is new since the CPU upgrade.

BR
Erik
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2834

PostPosted: Sat Oct 19, 2024 12:15 pm    Post subject: Reply with quote

Meh, we already work around a lot of Qt's pickiness in qt6-build.eclass (by forcing e.g. -march=x86-64-v4) but I hadn't thought it could fail that way.

When it compiles e.g. AVX2-using parts (regardless of what cpu people are using at build time, they're picked at runtime if the cpu supports it), it passes -march=haswell to ensure avx2 is enabled which overrides your znver4 (that's fine in itself, this disables avx512 rather than leave "partial" support), but the -mavx512vp2intersect that you pass re-enable avx512 and without the rest.. and so Qt complains that it's incomplete.

Suppose I could do further checks in qt6-build.eclass, albeit all it'll do is force x86-64-v4. At this point we mostly given up trying to get Qt to improve this.

Edit: to observe what happened:
Code:
Original flags (good on their own, all enabled):
$ gcc -E -march=znver4 -mavx512vp2intersect -mavxvnni -mmovdir64b -mmovdiri -mshstk -x c - <<<"__AVX512F__ __AVX512BW__ __AVX512CD__ __AVX512DQ__ __AVX512VL__" | tail -n 1
1 1 1 1 1

With -march=haswell added (result in incomplete set):
$ gcc -E -march=znver4 -mavx512vp2intersect -mavxvnni -mmovdir64b -mmovdiri -mshstk -march=haswell -x c - <<<"__AVX512F__ __AVX512BW__ __AVX512CD__ __AVX512DQ__ __AVX512VL__" | tail -n 1
1 __AVX512BW__ __AVX512CD__ 1 __AVX512VL__

Like above but without -mavx512vp2intersect (all disabled, which is fine):
$ gcc -E -march=znver4 -mavxvnni -mmovdir64b -mmovdiri -mshstk -march=haswell -x c - <<<"__AVX512F__ __AVX512BW__ __AVX512CD__ __AVX512DQ__ __AVX512VL__" | tail -n 1
__AVX512F__ __AVX512BW__ __AVX512CD__ __AVX512DQ__ __AVX512VL__
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2834

PostPosted: Sat Oct 19, 2024 12:38 pm    Post subject: Reply with quote

Few ways you can work around this anyhow:
1. wait for me to change qt6-build.eclass to force x86-64-v4 with that configuration, albeit if you want your flags to be used it may not be desirable
2. pass the missing -m flags yourself ("-mavx512bw -mavx512cd -mavx512vl", this will enable these even with -march=haswell)
3. drop -mavx512vp2intersect for dev-qt/*:6
4. talk with Qt upstream in my place so this gets improved, could backport fixes
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum