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

Make -march=native configurable. #2292

Merged

Conversation

mserajnik
Copy link
Contributor

@mserajnik mserajnik commented Nov 17, 2023

🍰 Pullrequest

-march=native tells the compiler to specifically optimize for the host CPU which makes it unlikely that the resulting executable will run on other CPU models. This is obviously not suitable for builds that are supposed to be portable/distributable.

This PR introduces a new CMake option called BUILD_FOR_HOST_CPU that allows to control the usage of the -march=native flag. The default is that it does build with the flag so that it doesn't change the current behavior.

Example use case: I provide prebuilt Docker images and currently have to patch out the -march=native flag.

Proof

  • None

Issues

How2Test

  • Make a build with -DBUILD_FOR_HOST_CPU=0 and observe that the -march=native flag is not used

Todo / Checklist

  • None

This allows for portable builds by not targeting the local CPU specifically
when the introduced `BUILD_FOR_HOST_CPU` option is turned off.
@ratkosrb ratkosrb merged commit 5b256d7 into vmangos:development Nov 25, 2023
3 checks passed
@mserajnik mserajnik deleted the allow-non-native-cmake-builds branch November 27, 2023 09:30
Benjaminmnoer pushed a commit to Benjaminmnoer/vmangoscore that referenced this pull request Dec 18, 2023
This allows for portable builds by not targeting the local CPU specifically
when the introduced `BUILD_FOR_HOST_CPU` option is turned off.
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.

🐛 [Bug] Cross-compiling & -march=native
2 participants