Scenario:
- We would like to build our sources by an external / hermetic toolchain so all includes, libs and tools from the host are ignored
- To do so, a new toolchain is introduced to Bazel-Configuration. >>> working well
- Using
-Wl,-rpath=$ORIGIN/%{runtime_library_search_directories}/...
the relative path from the binary to the libs that should be loaded on runtime gets defined >>> works quite well - When doing
bazel run
the Binary is executed but the host's LD is beeing used - To get rid of this a wrapper (written in Bash) is injected using
--run_under
. >>> dirty workaround
Problem:
--run_under
could only be used once. We also need this option to execute tests within a specific environment and so this option is not the way of choice for us. IMHO it's also a bit dirty workaround.
We also tried to use -Wl,--dynamic-linker=<<PATH_TO_LD>>
. But we were not able to get neither a relative nor an absolute path to LD when linking the executable.
Questions:
Is there ...
- ... any way to get the absolute/relative path to LD when linking?
- ... any other way of running a binary on Host using a toolchain?
- ... a possibility to do sandboxing/chroot so the correct LD of the toolchain is being used automatically?
Sidenotes:
- Bazel 1.1.0 is used
- the toolchain is GCC8 build from sources
- the host is an Ubuntu 18.04.1 image running in docker