Skip to content

[SYCL][CMake] Garbage-collect in libsycl linking #18293

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 1 commit into
base: sycl
Choose a base branch
from

Conversation

steffenlarsen
Copy link
Contributor

This commit adds the -Wl,--gc-sections flags to the linking of the SYCL libraries when available. This enables link-time section garbage collection, removing dead code in the binary, potentially reducing the size of it.

This commit adds the -Wl,--gc-sections flags to the linking of the SYCL
libraries when available. This enables link-time section garbage
collection, removing dead code in the binary, potentially reducing the
size of it.

Signed-off-by: Larsen, Steffen <[email protected]>
@steffenlarsen
Copy link
Contributor Author

steffenlarsen commented May 2, 2025

Locally observed libsycl.so size change on Linux: 5401440 -> 5280472

Size difference is even more significant with #16763.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea if/how the same is done on Win?

@aelovikov-intel
Copy link
Contributor

Recording from offline discussion:

From https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html:

In order to do this, it has to work with objects compiled with the following switches passed to the GCC back end: -ffunction-sections -fdata-sections.

Need to ensure that all our object files are compiled with that.

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.

2 participants