Skip to content

Deprioritize top level -O2 in CMAKE_CXX_FLAGS_RELEASE #9394

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

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

AdrianLundell
Copy link
Collaborator

@AdrianLundell AdrianLundell commented Mar 19, 2025

By prepending rather than appending to CMAKE_CXX_FLAGS_RELEASE, it allows to specify another optimization level earlier in the build process and still have that take precedence over the -O2.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

@AdrianLundell AdrianLundell added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk topic: not user facing labels Mar 19, 2025
Copy link

pytorch-bot bot commented Mar 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9394

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 1d82e53 with merge base d72ef5b (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 19, 2025
@zingo
Copy link
Collaborator

zingo commented Mar 19, 2025

@digantdesai this changes a global cmake file you might want to test/review this a bit more maybe?

@digantdesai
Copy link
Contributor

I think this is OK. Can we check if "left to right" precedence is generally true beyond gcc, clang, also for msvc for example?

@AdrianLundell
Copy link
Collaborator Author

I think this is OK. Can we check if "left to right" precedence is generally true beyond gcc, clang, also for msvc for example?

This link suggests that it is true for MSVC: https://learn.microsoft.com/en-us/cpp/build/reference/order-of-cl-options?view=msvc-170. Any other important compilers?

A compromise could also be to compile kernels with -O3 and other code with -O2, what do you think about that?

@digantdesai
Copy link
Contributor

I think this is OK. Can we check if "left to right" precedence is generally true beyond gcc, clang, also for msvc for example?

This link suggests that it is true for MSVC: learn.microsoft.com/en-us/cpp/build/reference/order-of-cl-options?view=msvc-170. Any other important compilers?

A compromise could also be to compile kernels with -O3 and other code with -O2, what do you think about that?

Thanks for checking MSVC.

IMO, I guess for a given deployment they should be able to overwrite the default in the CMake.

By prepending rather than appending to CMAKE_CXX_FLAGS_RELEASE,
it allows to specify another optimization level earlier in the
build process and still have that take precedence over the -O2.

Change-Id: I98beba1fb84848fd6c83d55a8e5a9c1cf74e1943
@zingo
Copy link
Collaborator

zingo commented Mar 28, 2025

Got OK to merge from @digantdesai and @swolchok in text form in the commets

@zingo zingo merged commit 65ebabb into pytorch:main Mar 28, 2025
165 checks passed
kirklandsign pushed a commit that referenced this pull request Apr 11, 2025
By prepending rather than appending to CMAKE_CXX_FLAGS_RELEASE, it
allows to specify another optimization level earlier in the build
process and still have that take precedence over the -O2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants