-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][CMAKE] Switch back to _FORTIFY_SOURCE=2 #19268
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
base: sycl
Are you sure you want to change the base?
[SYCL][CMAKE] Switch back to _FORTIFY_SOURCE=2 #19268
Conversation
The problem here is that the macro is actually handled by glibc and value `3` isn't supported with older compiler/glibc combinations, causing warnings about the macro redefinition. We still have to support older compilers/glibc and therefore as a temporary solution, reverting `_FORTIFY_SOURCE` back to `2` to avoid build issues with `-Werror`.
@@ -167,18 +167,18 @@ macro(append_common_extra_security_flags) | |||
if(LLVM_ON_UNIX) | |||
# Fortify Source (strongly recommended): | |||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | |||
message(WARNING "-D_FORTIFY_SOURCE=3 can only be used with optimization.") | |||
message(WARNING "-D_FORTIFY_SOURCE=3 is not supported.") | |||
message(WARNING "-D_FORTIFY_SOURCE=2 can only be used with optimization.") |
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.
Is there a way we can detect what compiler we can use 3
on and use that and use 2
otherwise?
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.
Is there a way we can detect what compiler we can use
3
on and use that and use2
otherwise?
Theoretically, but it is not clear which exact versions are "good" and which ones are "bad". It seems like gcc 12 is the first "good" (link), but I'm not sure about clang
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.
The doc says There has been compiler support for this builtin in [Clang](https://clang.llvm.org/) for some time
so maybe we can just ignore it/check for some really old version?
If 3
has some benefit IMO we should try to add a check to see if we can use it if it's not too complicated
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.
075da8c introduces the check. I also had to uplift _FORTIFY_SOURCE
in the Unified Runtime to avoid macro redefinition. We set it globally, but UR also sets it locally, because it is intended to buildable standalone.
I tried to uplift _FORTIFY_SOURCE
in UR in #19236 and this is how I detected the issue with "bad" gcc, so we will see now if the suggested check works.
The problem here is that the macro is actually handled by glibc and value
3
isn't supported with older compiler/glibc combinations, causing warnings about the macro redefinition.We still have to support older compilers/glibc and therefore as a temporary solution, reverting
_FORTIFY_SOURCE
back to2
to avoid build issues with-Werror
.