Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems the linkage didn't work properly #188

Open
hcoona opened this issue Jun 27, 2024 · 0 comments
Open

Seems the linkage didn't work properly #188

hcoona opened this issue Jun 27, 2024 · 0 comments

Comments

@hcoona
Copy link

hcoona commented Jun 27, 2024

Wrap zig cc manually and build with either Bazel or CMake works fine but failed to run with hermetic_cc_toolchain neither via traditional WORKSPACE nor via bzlmod.

Reproduce steps

git clone https://github.com/google/googletest.git
cd googletest
git checkout 1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2

cat >.bazelrc <<EOF
common --enable_platform_specific_config

build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

build:linux --sandbox_add_mount_pair=/tmp
build:macos --sandbox_add_mount_pair=/var/tmp
build:windows --sandbox_add_mount_pair=C:\Temp
EOF

cat >>MODULE.bazel <<EOF
bazel_dep(
    name = "hermetic_cc_toolchain",
    version = "3.1.0",
)

toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(toolchains, "zig_sdk")

register_toolchains(
    "@zig_sdk//toolchain:linux_amd64_gnu.2.31",
    "@zig_sdk//toolchain:linux_arm64_gnu.2.31",
    "@zig_sdk//toolchain:windows_amd64",
    "@zig_sdk//toolchain:windows_arm64",
)
EOF

bazel test //googletest/test:gtest_skip_test

I can execute bazel-bin/googletest/test/gtest_skip_test directly but failed to run with bazel command. The logs shows:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //googletest/test:gtest_skip_test
-----------------------------------------------------------------------------
/home/shuaiz/.cache/bazel/_bazel_shuaiz/6aeaeb0ed356c77557cf38dba9bcd145/sandbox/linux-sandbox/577/execroot/_main/bazel-out/k8-fastbuild/bin/googletest/test/gtest_skip_test.runfiles/_main/googletest/test/gtest_skip_test: error while loading shared libraries: bazel-out/k8-fastbuild/bin/_solib_k8/liblibgtest_Umain.so: cannot open shared object file: No such file or directory

An initial triage with bazel run //googletest/test:gtest_skip_test --run_under="ldd" shows:

INFO: Running command line: external/bazel_tools/tools/test/test-setup.sh /bin/bash -c '"$@"' /bin/bash ldd googletest/test/gtest_skip_test
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //googletest/test:gtest_skip_test
-----------------------------------------------------------------------------
        linux-vdso.so.1 (0x00007ffce21ca000)
        bazel-out/k8-fastbuild/bin/_solib_k8/liblibgtest_Umain.so => not found
        bazel-out/k8-fastbuild/bin/_solib_k8/liblibgtest.so => not found
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc92ca16000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc92c7ed000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc92ca27000)

A correct version for comparison:

INFO: Running command line: external/bazel_tools/tools/test/test-setup.sh /bin/bash -c '"$@"' /bin/bash ldd googletest/test/gtest_skip_test
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //googletest/test:gtest_skip_test
-----------------------------------------------------------------------------
        linux-vdso.so.1 (0x00007ffd4e1f2000)
        liblibgtest_Umain.so => /home/shuaiz/.cache/bazel/_bazel_shuaiz/6aeaeb0ed356c77557cf38dba9bcd145/execroot/_main/bazel-out/k8-fastbuild/bin/googletest/test/gtest_skip_test.runfiles/_main/googletest/test/../../_solib_k8/liblibgtest_Umain.so (0x00007f9f2e071000)
        liblibgtest.so => /home/shuaiz/.cache/bazel/_bazel_shuaiz/6aeaeb0ed356c77557cf38dba9bcd145/execroot/_main/bazel-out/k8-fastbuild/bin/googletest/test/gtest_skip_test.runfiles/_main/googletest/test/../../_solib_k8/liblibgtest.so (0x00007f9f2deda000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9f2dca4000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9f2dc84000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9f2da59000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9f2d972000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f9f2e081000)
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

No branches or pull requests

1 participant