hermetic_cc_toolchain icon indicating copy to clipboard operation
hermetic_cc_toolchain copied to clipboard

Running bazel test on Linux fails on dynamically linked cc_test targets

Open FabianHahn opened this issue 1 year ago • 3 comments

Running bazel test on cc_test targets that do not specify linkstatic = 1 seems to be broken since v2.1.0. The last working version was v2.0.0.

Minimal reproduction case: https://github.com/FabianHahn/dynamic_test_repro

Example output:

$ bazel test //:dynamic --config=zig_linux --test_output=streamed
INFO: Invocation ID: 24da0913-0973-4b94-b8f7-b978523b237f
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Analyzed target //:dynamic (24 packages loaded, 168 targets configured).
INFO: Found 1 test target...
/home/fabian/.cache/bazel/_bazel_fabian/2cc9cc00e657a7c72ea56ec288228eca/sandbox/linux-sandbox/51/execroot/__main__/bazel-out/k8-fastbuild/bin/dynamic.runfiles/__main__/dynamic: error while loading shared libraries: bazel-out/k8-fastbuild/bin/_solib_k8/liblib_Sliblib.so: cannot open shared object file: No such file or directory
FAIL: //:dynamic (see /home/fabian/.cache/bazel/_bazel_fabian/2cc9cc00e657a7c72ea56ec288228eca/execroot/__main__/bazel-out/k8-fastbuild/testlogs/dynamic/test.log)
Target //:dynamic up-to-date:
  bazel-bin/dynamic
INFO: Elapsed time: 0.371s, Critical Path: 0.20s
INFO: 2 processes: 2 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//:dynamic                                                               FAILED in 0.0s
  /home/fabian/.cache/bazel/_bazel_fabian/2cc9cc00e657a7c72ea56ec288228eca/execroot/__main__/bazel-out/k8-fastbuild/testlogs/dynamic/test.log

Executed 1 out of 1 test: 1 fails locally.

Environment details:

$ lsb_release -ds
Ubuntu 20.04.6 LTS
$ bazel --version
bazel 6.3.0

From the error message, I suspect this is the same issue as #188.

FabianHahn avatar Aug 11 '24 15:08 FabianHahn

Bisecting commits between v2.0.0 and v2.1.0 shows that the breaking commit was 0af71607aa9499677bcf83e3cd616899e0d79d55, which is the merge of the zig 0.11.0 upgrade in #111.

This is somewhat worrying because it didn't follow any change of the rules in this repository, but rather a toolchain upgrade that seems to have changed behavior and is no longer compatible.

FabianHahn avatar Aug 27 '24 13:08 FabianHahn

Filed an upstream bug here: https://github.com/ziglang/zig/issues/21219

FabianHahn avatar Aug 27 '24 15:08 FabianHahn

My Zig PR to fix this: https://github.com/ziglang/zig/pull/19818. Related issue: https://github.com/ziglang/zig/issues/19699.

a-khabarov avatar May 30 '25 16:05 a-khabarov