Skip to content

fix: load shared libraries from runfiles#297

Merged
aherrmann merged 1 commit intomainfrom
solib-runfiles
May 10, 2024
Merged

fix: load shared libraries from runfiles#297
aherrmann merged 1 commit intomainfrom
solib-runfiles

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
@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