Skip to content

Conversation

@uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Nov 3, 2024

Fixes: #15935

Problem
DPC++ shared lib built fails when linking static zstd libraries that are not position-independent. See #15935 for more info.

Proposed Solution
Since zstd is optional to DPC++, we check if zstd static libraries are built with -fPIC flag or not. If not, we disable zstd.

@uditagarwal97 uditagarwal97 self-assigned this Nov 3, 2024
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner November 3, 2024 00:25
@uditagarwal97 uditagarwal97 requested a review from bader November 3, 2024 00:25
@uditagarwal97
Copy link
Contributor Author

Once approved, I'll create a PR to upstream these changes.

set(LLVM_ENABLE_ZSTD ${zstd_FOUND})
# Check if the zstd static library is usable when BUILD_SHARED_LIBS is ON
# Test linking zstd::libzstd_static with a shared library. This is to ensure
# that the static library is built with -fPIC flag.
Copy link
Contributor

Choose a reason for hiding this comment

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

i havent seen this kind of issue before, is that because almost everything is built with -fPIC so it just works?

are there any other examples in llvm or other open source projects of solving it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i havent seen this kind of issue before, is that because almost everything is built with -fPIC so it just works?

This issue was observed when DPC++ is built in shared lib configuration on Ubuntu 24.04. Apparently, the zstd static library that comes with Ubuntu 24.04 was built without the -fPIC flag and thus it gives error when linking to dynamic libraries. I've filed a bug report about the zstd package in Ubuntu 24.04 here: https://bugs.launchpad.net/ubuntu/+source/libzstd/+bug/2086543

We did not observe this error before because the zstd package that we use in CI (Ubuntu 22.04) was built correctly with fPIC flag.

are there any other examples in llvm or other open source projects of solving it this way?

I'm not aware of any. Let me dig around.

Copy link
Contributor

@sarnex sarnex Nov 4, 2024

Choose a reason for hiding this comment

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

yeah my overalll question is i've never seen this kind of issue before so i don't know what the fix should look like so i can't give a good review :)

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2025

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@github-actions github-actions bot added the Stale label May 4, 2025
@github-actions github-actions bot removed the Stale label May 17, 2025
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.

Compiling DPC++ with shared libraries fails with linking error on Ubuntu 24.10

3 participants