-
Notifications
You must be signed in to change notification settings - Fork 769
[CMake] Set runpath of libsycl.so #15850
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
Problem that this patch fixes: mkdir sycl;
cd sycl;
wget https://github.com/intel/llvm/releases/download/nightly-2024-10-23/sycl_linux.tar.gz;
tar -xzf sycl_linux.tar.gz;
echo "int main() {}" > testfile.cpp;
./bin/clang testfile.cpp -fsycl -o /dev/null; This fails because the rpath of libsycl isn't set in the installed package, so it can't find libur_loader, which causes linking to fail since it can't find a bunch of symbols. See this CI run as well: https://github.com/oneapi-src/unified-runtime/actions/runs/11497879935/job/32002518200?pr=2225 If a better solution is to just pass |
I take it this would be part of the driver's job? Tag @mdtoguchi for comment. |
As the dependency on libur_loader is from the library, I would rather keep it there than have the driver pull it in. If there is a dependency of compiled source on libur_loader we can have the driver do it. |
Similar change has been rejected in the past due to security concerns. @intel/llvm-reviewers-runtime, please, review carefully patches adding rpath to the SYCL runtime library and be aware of associated security risks. |
Thanks for the link, I think this is a different case to The only ways I could see an attacker take advantage of this change is under the following conditions:
I don't think these are likely. And if they were, Of course, happy to have more eyes on this to see if there's anything I've missed or there's a better way of solving this issue. |
@bader @wphuhn-intel Can I get this looked at? As it stands at the moment, the release packages are broken. |
My comments:
My general thought is that this is definitely less egregious than the original |
@wphuhn-intel LD_LIBRARY_PATH=/tmp/sycl/lib ./bin/clang testfile.cpp -fsycl -o /dev/null; (assuming the package is extracted in With regards to packaging, I think it should be fine for them to strip the runpath if they install Thanks for pointing out the rpath vs runpath distinction; I think I just conflated the two. When I get the chance I will check which of the two is being set and update the commit message/comments accordingly. |
It's important to support scenario when we compile an app using one clang, but then use libsycl.so from LD_LIBRARY_PATH of another build (for debugging purposes). Can you please add a test that verifies that behavior somehow? |
@aelovikov-intel Checking that a version of libsycl can run binaries created by an older/newer version of DPCPP feels like it should be covered with ABI testing, which I think is out of scope of this change. |
From what I read in this PR, it's true for RUNPATH but not RPATH (I might have misunderstood), and even if that was true, it wasn't immediately obvious for all the participants here. As such, we need to have a test in tree that will pass after this PR gets merged but would fail if one was to use RPATH over RUNPATH. |
25a773a
to
a64a59d
Compare
Cmake actually sets the runpath, not the rpath, I've updated the commit message and comment to say so. I'll have a look at testing this tomorrow. |
This is already happening and I don't see how presence of
It depends on the way of how SYCL RT is redistributed. For example, it could be bundled alongside a client application aimed for end users: that category of users does not want to tweak
I'm not sure what to do with security checkers, but at least we can make |
@AlexeySachkov IIRC we subsequently found other instances of RUNPATH being used, and we haven't heard any complaints, so that could be overcaution on my end. I would say that as long as we've confirmed that RPATH isn't being used, we should put this to rest. |
Binary information about "installed"
And after this patch:
This change does indeed set RUNPATH rather than RPATH. In regards to testing this, I'm not sure the best way to actually test it. It requires an "install" of dpcpp rather than just a "build", which I don't think is something that our testing infrastructure really uses? Perhaps this makes sense to check for just before the binaries are bundled into the release archive rather than CI? |
@intel/llvm-reviewers-runtime I have updated this and am looking at trying to land it again. Could I get some eyes on this to see if the concerns raised earlier have been resolved? |
libsycl.so depends on libur_loader.so, however it doesn't have an runpath set to find it. This fixes that.
f3cbe21
to
af3d463
Compare
@intel/llvm-reviewers-runtime Can you look at this when you get the chance? |
@intel/llvm-reviewers-runtime Anything blocking this? |
Tag @aelovikov-intel to answer whether he agrees that testing this in CI isn't feasible. |
I'd feel more secure if we'd add a test that performs |
Broadly, speaking the build pipeline works like this:
Cmake only sets the runpath during the install phase, after we've already run our tests.
We can't do these tests as part of the normal Any testing for runpath would have to be done after the install phase, perhaps as a new phase in the CI pipeline or as a script ran by the packager just before it generates packages for distribution. Such a script could probably also check other libraries and binaries for the same issue. I don't disagree with such a thing existing, but I think it's out of scope for this change. |
@intel/llvm-gatekeepers Please merge. I'll create a ticket on Intel's internal Jira about looking into verifying that produced binaries don't use RPATH. |
libsycl.so depends on libur_loader.so, however it doesn't have an rpath
set to find it. This fixes that.