Bugzilla – Bug 1222752
ugrep: build results depend on CPU
Last modified: 2024-04-14 18:04:51 UTC
While working on reproducible builds for openSUSE, I found that our ugrep binaries depend on the build machine CPU again. It seems SR 1166721 reverted my previous SR 818786 related: https://github.com/Genivia/ugrep/pull/50 CPU march=native ; partial fix The buildroot diff shows +++ /home/abuild/rpmbuild/BUILD.unsorted/ugrep-5.1.4/Makefile @@ -327,9 +327,9 @@ SED = /usr/bin/sed SET_MAKE = SHELL = /usr/bin/bash -SIMD_AVX2_FLAGS = -mavx2 +SIMD_AVX2_FLAGS = SIMD_AVX512BW_FLAGS = -SIMD_FLAGS = -msse2 -DHAVE_AVX2 +SIMD_FLAGS = -msse2 -DHAVE_SSE2 There are multiple ways to solve that: - never use AVX2 (as before) - always use AVX2 - detect AVX2 at runtime instead of compile-time
I was under the impression that upstream implemented run-time detection correctly. Do you know where binary differences are? The following are supposed to be selected at run-time: lib/matcher.cpp lib/matcher_avx2.cpp lib/matcher_avx512bw.cpp Also is the following constraint not forcing the correct CPU so that the binary result is always the same? > #!BuildConstraint: hardware:cpu:flag x86-64-v3 Does the binary differ even when taking that into account?
I test these outside of OBS with osc build --vm-type=kvm --build-opt=--vm-custom-opt="-cpu kvm64" which seems to ignore the BuildConstraint. However, there is still some build-time detection going on. Especially the part in configure.ac line 113 still depends on if the build machine CPU has AVX512 or not. If there is indeed runtime-detection, you just need to add a force-avx configure option.