-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
compiler_flags: Change optimization_fast from '-Ofast' to '-O3' #87495
base: main
Are you sure you want to change the base?
Conversation
There are other possibilities here, such as disable the warning for However, it seems like we want the meaning of this flag to be the same across all compilers, so I think it makes sense for whatever we do to be consistent. If we want to keep the unsafe optimizations, it might be good to rename it to something like |
@@ -21,7 +21,7 @@ endif() | |||
set_compiler_property(PROPERTY optimization_speed -O2) | |||
set_compiler_property(PROPERTY optimization_size -Os) | |||
set_compiler_property(PROPERTY optimization_size_aggressive -Oz) | |||
set_compiler_property(PROPERTY optimization_fast -Ofast) | |||
set_compiler_property(PROPERTY optimization_fast -O3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we choose to make this change, I'll add a context comment here so it doesn't accidentally get changed back in the future.
9919c29
to
a52b9d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR says changing for clang but is changing for gcc, clang changes should go in the clang file as per https://github.com/zephyrproject-rtos/zephyr/blob/a52b9d4084133edbdf547f308f5cb349a764fcc3/cmake/compiler/clang/compiler_flags.cmake#L1-L4]
GCC has no plans to deprecate this flag https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115990
'-Ofast' enables optimizations that are not standards compliant, which can produce unexpected results unless used carefully. When building with clang 19 and newer, it warns: clang: error: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior, or '-O3' to enable only conforming optimizations [-Werror,-Wdeprecated-ofast] Relevant discussion: * llvm/llvm-project#98736 * https://discourse.llvm.org/t/rfc-deprecate-ofast/78687/109 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115990 Signed-off-by: Tom Hughes <[email protected]>
a52b9d4
to
e42bd38
Compare
I think we want to be consistent on this on all compilers.
|
'-Ofast' enables optimizations that are not standards compliant, which can
produce unexpected results unless used carefully.
When building with clang 19 and newer, it warns:
clang: error: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for
the same behavior, or '-O3' to enable only conforming optimizations
[-Werror,-Wdeprecated-ofast]
Relevant discussion:
-Ofast
driver option llvm/llvm-project#98736