Bug 1222752 - ugrep: build results depend on CPU
Summary: ugrep: build results depend on CPU
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Other (show other bugs)
Version: Current
Hardware: Other All
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Andreas Stieger
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 1100677
  Show dependency treegraph
 
Reported: 2024-04-14 03:10 UTC by Bernhard Wiedemann
Modified: 2024-04-14 18:04 UTC (History)
0 users

See Also:
Found By: Development
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Wiedemann 2024-04-14 03:10:29 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
Comment 1 Andreas Stieger 2024-04-14 06:34:59 UTC
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?
Comment 2 Bernhard Wiedemann 2024-04-14 18:04:51 UTC
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.