Wrong cc toolchain solib path in rpath for external repos with sibling layout #16956
Labels
help wanted
Someone outside the Bazel team could own this
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-Rules-CPP
Issues for C++ rules
type: bug
Description of the bug:
We are setting up bazel for Android Emulator. The cc toolchain we've setup:
static_link_cpp_runtimes
feature and feeds libc++ to the(dynamic | static)_runtime_lib
attributes of thecc_toolchain
rule.And due to the layout of the source tree (a top-level "external" directory), we have to pass
--experimental_sibling_repository_layout
to solve the conflict with external repositories.With this setup, we find that we are unable to correctly build dynamically linked binaries in external repositories. The rpath for
dynamic_runtime_lib
(libc++) is set incorrectly. Sincecc_test
is always linked dynamically, this is prohibiting us to run any cc_test in external repos.e.g., with the following setup:
@//toolchains/cc:linux_clang_x64
@zlib//:zlib_test
k8
The following rpaths are set by bazel:
However, what bazel generates in the execroot file tree is:
Form the execroot tree, it seems that the correct rpath to find libc++ should be either:
$ORIGIN/../../../k8-fastbuild/bin/_solib__toolchains_Scc_Clinux_Uclang_Ux64
, or$ORIGIN/zlib_test.runfiles/__main__/_solib__toolchains_Scc_Clinux_Uclang_Ux64
However bazel generates:
$ORIGIN/_solib__toolchains_Scc_Clinux_Uclang_Ux64
$ORIGIN/zlib_test.runfiles/zlib/_solib__toolchains_Scc_Clinux_Uclang_Ux64
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
dynamic_runtime_lib
attribute, and enable featurestatic_link_cpp_runtimes
.--experimental_sibling_repository_layout
flag and build the targetWhich operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 7.0.0-pre.20221111.3
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No.
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: