Skip to content

[SYCL][CMAKE] Refactor -fPIE handling #19235

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

Conversation

AlexeySachkov
Copy link
Contributor

@AlexeySachkov AlexeySachkov commented Jul 1, 2025

CMake is capable of setting -fPIE correctly and we don't need to intervene with that.

Without the patch, I see the following errors:

FAILED: lib/libze_trace_collector.so
: && /usr/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite
-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor
 -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra 
-fcf-protection=full -Wformat -Wformat-security -fPIC -fPIE -Wno-covered-switch-default -Wall -Wextra -Werror -O2 -g -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -pie -shared -Wl,-soname,libze_
trace_collector.so -o lib/libze_trace_collector.so tools/sycl/tools/sycl-trace/CMakeFiles/ze_trace_collector.dir/ze_trace_collector.cpp.o  -Wl,-rpath,build/lib:  lib/libxptifw.so  -ldl && :
clang++: error: argument unused during compilation: '-pie' [-Werror,-Wunused-command-line-argument]

CMake is capable of setting `-fPIE` correctly and we don't need to
intervene with that.
@AlexeySachkov AlexeySachkov requested a review from a team as a code owner July 1, 2025 10:19
@AlexeySachkov
Copy link
Contributor Author

Windows failures are known (#18576) and corresponding tests have been already disabled

@AlexeySachkov AlexeySachkov merged commit 42c6ffc into intel:sycl Jul 2, 2025
24 of 25 checks passed
@AlexeySachkov AlexeySachkov deleted the private/asachkov/refactor-fpie-flag-handling branch July 2, 2025 09:08
AlexeySachkov added a commit that referenced this pull request Jul 11, 2025
CMake is capable of setting `-fPIE` correctly and we don't need to
intervene with that.

Without the patch, I see the following errors:

```
FAILED: lib/libze_trace_collector.so
: && /usr/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite
-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor
 -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra 
-fcf-protection=full -Wformat -Wformat-security -fPIC -fPIE -Wno-covered-switch-default -Wall -Wextra -Werror -O2 -g -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -pie -shared -Wl,-soname,libze_
trace_collector.so -o lib/libze_trace_collector.so tools/sycl/tools/sycl-trace/CMakeFiles/ze_trace_collector.dir/ze_trace_collector.cpp.o  -Wl,-rpath,build/lib:  lib/libxptifw.so  -ldl && :
clang++: error: argument unused during compilation: '-pie' [-Werror,-Wunused-command-line-argument]
```
AlexeySachkov added a commit that referenced this pull request Jul 16, 2025
This PR contains several cherry-picks and some unique changes which have
not been applied to the `sycl` branch yet.

The intent of this PR is to enable as much (quickly) possible hardening
flags to be in better compliance with our SDL requirements.
The main thing this PR is after are things like immediate bindings,
fortify source, stack protection and `relro`.
The thing that this PR is **not** after are extra warning flags - some
of them we can't apply globally because LLVM itself isn't warning free,
some of them we can't apply even locally to SYCL RT because we haven't
fixed corresponding warnings yet.

Patches which were cherry-picked from the `sycl` branch:

- [SYCL] Fix AddSecurityFlags having no side effects
(#17690)
  - Patch-By: Alexey Sachkov <[email protected]>
- [SYCL] Refresh hardening flags applied to the project
(#18398)
  - Patch-By: Nikita Kornev <[email protected]>
- [SYCL][CMAKE] Refactor -fPIE handling
(#19235)
  - Patch-By: Alexey Sachkov <[email protected]>
- [SYCL][CMAKE] Drop nodlopen from hardening flags
(#19357)
  - Patch-By: Alexey Sachkov <[email protected]>
- [SYCL][CMAKE] Fix _FORTIFY_SOURCE=3
(#19268)
  - Patch-By: Alexey Sachkov <[email protected]>
- [SYCL][CMake] Properly enable -pie hardening flag
(#19447)
  - Patch-By: Alexey Sachkov <[email protected]>

Additional changes which have **not** been applied to the `sycl` branch:
- Adjusted `configure.py` to the new way of `-fPIE` handling
- Dropped `/sdl` flag because LLVM isn't warning-free
  - it will be applied locally to SYCL RT in a separate PR against the `sycl` branch for future releases
- Dropped `/analyze` flag because SYCL RT isn't warning-free 
  - it will be applied locally to SYCL RT in a separate PR against the `sycl` branch for future releases
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