Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable march=native for SSE2 #50

Merged
merged 1 commit into from Jul 5, 2020
Merged

Conversation

bmwiedemann
Copy link
Contributor

@bmwiedemann bmwiedemann commented Jul 4, 2020

Without this patch, the code would only build binaries with SSE2,
if the build machine CPU supported SSE2.

And through the -march=native flag, it would then use more CPU features
available on the build CPU that might not be available
on the target machine CPU. That can cause an illegal instruction
exception on the target machine.

This patch changes behaviour so that only configure options determine the
result of the build, regarding SSE2.

See https://reproducible-builds.org/ for why this is good.

This PR was done while working on reproducible builds for openSUSE.

note that there are similar issues around AVX and neon extensions, but they are more tricky to resolve. e.g. the AVX test needs -avx2 for some reason and maybe avx512 should be decoupled.
Maybe an option for compile-time detection is wanted there by some users?

Without this patch, the code would only build binaries with SSE2,
if the build machine CPU supported SSE2.

And through the -march=native flag, it would then use more CPU features
available on the build CPU that might not be available
on the target machine CPU. That can cause an illegal instruction
exception on the target machine.

This patch changes behaviour so that only configure options determine the
result of the build, regarding SSE2.

See https://reproducible-builds.org/ for why this is good.

This PR was done while working on reproducible builds for openSUSE.
@genivia-inc
Copy link
Member

Thank you for your contribution. This is important and useful.

Looks good for SSE2.

Frankly, I faced trouble getting the right sets of extended instructions to be recognized on some combinations of platforms with the GCC and clang compilers. Indeed, I don't like using -march=native but in some cases it would only appear to build properly with -march=native for AVX, even though it should have worked without this option according to the compiler documentation.

@genivia-inc genivia-inc merged commit 03cfbd8 into Genivia:master Jul 5, 2020
@bmwiedemann bmwiedemann deleted the sse2 branch July 6, 2020 06:31
@bmwiedemann
Copy link
Contributor Author

I must admit that I only tested this on openSUSE Tumbleweed with gcc10. Hope it still works out with other setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants