Skip to content
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

fix: load shared libraries from runfiles #297

Merged
merged 1 commit into from
May 10, 2024
Merged

fix: load shared libraries from runfiles #297

merged 1 commit into from
May 10, 2024

Conversation

aherrmann
Copy link
Owner

Adds a RUNPATH to support loading shared libraries from runfiles trees when the entrypoint is executed from outside the runfiles tree, e.g. in genrule build actions.

This issue was previously dormant because the shared library is still available under an alternative RUNPATH in local execution.

Otherwise running dynamically linked binaries fails in remote execution setups with errors of the form:

bazel-out/k8-opt-exec-ST-74b705998179/bin/link-dependencies/shared-library/binary: error while loading shared libraries: libadd.so: cannot open shared object file: No such file or directory

The library libadd.so is part of the action inputs, but only under the runfiles tree next to binary in binary.runfiles/_main/_solib_k8/....

See https://github.com/bazelbuild/bazel/blob/7.0.0/src/main/java/com/google/devtools/build/lib/rules/cpp/LibrariesToLinkCollector.java#L177 for further details on RUNPATHS calculation.
See #296.

Otherwise running dynamically linked binaries fails in remote execution
setups with errors of the form:
```
bazel-out/k8-opt-exec-ST-74b705998179/bin/link-dependencies/shared-library/binary: error while loading shared libraries: libadd.so: cannot open shared object file: No such file or directory
```

The library `libadd.so` is part of the action inputs, but only under the
runfiles tree next to `binary` in `binary.runfiles/_main/_solib_k8/...`.

See https://github.com/bazelbuild/bazel/blob/7.0.0/src/main/java/com/google/devtools/build/lib/rules/cpp/LibrariesToLinkCollector.java#L177
for further details on RUNPATHS calculation.
@aherrmann aherrmann enabled auto-merge May 10, 2024 06:54
@aherrmann aherrmann merged commit 065c22f into main May 10, 2024
27 checks passed
@aherrmann aherrmann deleted the solib-runfiles branch May 10, 2024 07:04
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.

1 participant