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

build go-nvml failed with error "unsupported linker arg: --unresolved-symbols" #186

Open
xuzhenglun opened this issue Jun 21, 2024 · 0 comments

Comments

@xuzhenglun
Copy link

I'm trying to build a project which imported github.com/NVIDIA/go-nvml, which is a C binding to nvida nvml lib.

when I build with hermetic-cc-toolchain, an error was throw: error: unsupported linker arg: --unresolved-symbols. when I switch toolchain to local gcc, it works just fine.

I have tried to alternative --unresolved-symbols with -undefined dynamic_lookup or --allow-shlib-undefined, but it did not work.

Is anybody can help me with this? I will be really appreciate it.


full demo can be found here: https://github.com/xuzhenglun/hermetic-go-nvml

  1. u can build this demo with hermetic_cc_toolchain, and it will fail and throw errors:
# bazel build @com_github_nvidia_go_nvml//examples/devices  --config=linux-amd64
INFO: Analyzed target @@gazelle~~go_deps~com_github_nvidia_go_nvml//examples/devices:devices (88 packages loaded, 15653 targets configured).
ERROR: /data/build/bazel-local-cache/8c12620ae33a989236acb551c5cda37d/external/gazelle~~go_deps~com_github_nvidia_go_nvml/pkg/nvml/BUILD.bazel:3:11: GoCompilePkg external/gazelle~~go_deps~com_github_nvidia_go_nvml/pkg/nvml/nvml.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@gazelle~~go_deps~com_github_nvidia_go_nvml//pkg/nvml:nvml) bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/rules_go~~go_sdk~go_sdk/builder_reset/builder compilepkg -sdk external/rules_go~~go_sdk~go_sdk -installsuffix linux_amd64 -src ... (remaining 75 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: unsupported linker arg: --unresolved-symbols
compilepkg: error running subcommand external/hermetic_cc_toolchain~~toolchains~zig_sdk/tools/x86_64-linux-gnu.2.19/c++: exit status 1
Target @@gazelle~~go_deps~com_github_nvidia_go_nvml//examples/devices:devices failed to build
Use --verbose_failures to see the command lines of failed build steps.
  1. if using un-hermetic cc toolchain, it works fine.
# bazel build @com_github_nvidia_go_nvml//examples/devices
WARNING: Build options --action_env, --extra_toolchains, --features, and 2 more have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target @@gazelle~~go_deps~com_github_nvidia_go_nvml//examples/devices:devices (56 packages loaded, 15671 targets configured).
INFO: Found 1 target...
Target @@gazelle~~go_deps~com_github_nvidia_go_nvml//examples/devices:devices up-to-date:
  bazel-bin/external/gazelle~~go_deps~com_github_nvidia_go_nvml/examples/devices/devices_/devices
INFO: Elapsed time: 15.690s, Critical Path: 14.35s
INFO: 6 processes: 3 internal, 3 linux-sandbox.
INFO: Build completed successfully, 6 total actions

BTW: my build machine info:

# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)

# ls -al /lib/libc*
-rwxr-xr-x 1 root root 2849452 8月  25 2021 /lib/libc-2.28.so
lrwxrwxrwx 1 root root      12 8月  25 2021 /lib/libc.so.6 -> libc-2.28.so
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