Skip to content

[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

Open
wants to merge 3 commits into
base: sycl
Choose a base branch
from

Conversation

AlexeySachkov
Copy link
Contributor

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.

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`.
@AlexeySachkov AlexeySachkov requested a review from a team as a code owner July 2, 2025 14:24
@@ -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.")
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

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.

3 participants