bazelbuild / bazelbuild/bazel-skylib
native_test and native_binary break shared libraries with remote execution
- Dominant language
- Starlark
- Stars
- 444
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
In many implementation of remote execution services, the [symlink that is created to the executable in native_test](https://github.com/bazelbuild/bazel-skylib/blob/141432789c92e9db2402ef0be58e2a2d2c4dd1fd/rules/native_binary.bzl#L25-L29) is not actually a symlink, and is effectively a copy. For resolving dynamic libraries, bazel uses rpaths relative to `$ORIGIN`. `$ORIGIN` refers to the resolved location of the symlink, and so these relative paths work fine when the executable is a symlink. However, when this file is actually a copy these relative rpaths no longer work. Note that the same thing happens when using the [experimental hermetic linux sandbox](https://github.com/bazelbuild/bazel/pull/13279), since this uses hardlinks and copying instead of symlinks.
I have created [a reproducer](https://github.com/cameron-martin/bazel_native_test_rpaths), using the hermetic linux sandbox.
Contributor guide
Research direction
Start with native_binary.bzl lines 25-29 and the native_test rule, then run the linked bazel_native_test_rpaths reproducer under remote execution and the experimental hermetic Linux sandbox. Compare shared-library resolution when the executable is represented by a symlink versus a copy or hardlink; done means relative $ORIGIN-based libraries resolve in the affected environments.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100