bazelbuild / bazelbuild/rules_rust

cc_common_link doesn't work with -fuse-ld=gold: undefined reference to '__rdl_###'

Open
#2,069 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

A `cc_test` depending on `rust_library` works with cc_common_link only if the linker is lld. Is that expected?

Code: https://github.com/afq984/rules_rust/commit/560e32ec1bb52904ffbbd7026e90267736e27097

gold:

```
bazel test //... --linkopt=-fuse-ld=gold --test_summary=terse
INFO: Invocation ID: e521d30e-dc88-4d0a-949e-3bc6427c6371
INFO: Build option --linkopt has changed, discarding analysis cache.
INFO: Analyzed 28 targets (0 packages loaded, 1678 targets configured).
INFO: Found 15 targets and 13 test targets...
ERROR: /usr/local/google/home/aaronyu/rules_rust/test/cc_common_link/BUILD.bazel:84:8: Linking main_with_rlib failed: (Exit 1): gcc failed: error executing command (from target //:main_with_rlib) /usr/bin/gcc @bazel-out/k8-fastbuild/bin/main_with_rlib-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/k8-fastbuild/bin/_solib_k8/libliballocator_Ulibrary.so: error: undefined reference to '__rdl_oom'
bazel-out/k8-fastbuild/bin/_solib_k8/libliballocator_Ulibrary.so: error: undefined reference to '__rdl_alloc_zeroed'
bazel-out/k8-fastbuild/bin/_solib_k8/libliballocator_Ulibrary.so: error: undefined reference to '__rdl_realloc'
bazel-out/k8-fastbuild/bin/_solib_k8/libliballocator_Ulibrary.so: error: undefined reference to '__rdl_dealloc'
bazel-out/k8-fastbuild/bin/_solib_k8/libliballocator_Ulibrary.so: error: undefined reference to '__rdl_alloc'
collect2: error: ld returned 1 exit status
INFO: Elapsed time: 0.577s, Critical Path: 0.08s
INFO: 22 processes: 3 disk cache hit, 19 internal.
FAILED: Build did NOT complete successfully
//:main_with_rlib FAILED TO BUILD

Executed 0 out of 13 tests: 5 tests pass, 1 fails to build and 7 were skipped.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
```

lld

```
bazel test //... --linkopt=-fuse-ld=lld --test_summary=terse
INFO: Invocation ID: d23e0635-dfef-49e0-9752-e0db9691f3ea
INFO: Analyzed 28 targets (0 packages loaded, 0 targets configured).
INFO: Found 15 targets and 13 test targets...
INFO: Elapsed time: 0.206s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

Executed 0 out of 13 tests: 13 tests pass.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.