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

ld linker error: duplicate symbols #529

Closed
GOVYANSONG opened this issue Oct 3, 2022 · 1 comment
Closed

ld linker error: duplicate symbols #529

GOVYANSONG opened this issue Oct 3, 2022 · 1 comment

Comments

@GOVYANSONG
Copy link

I have a binary project that depends on a lib project. they both expose a public function called mainshell(). the compilation worked fine but linking failed due to below error:

note: ld.lld: error: duplicate symbol: mainshell
>>> defined at server_bin.c6e295fc-cgu.12
>>> bazel-out/k8-fastbuild/bin/server_bin.server_bin.c6e295fc-cgu.12.rcgu.o:(mainshell)
>>> defined at uds_lib.b703c14a-cgu.4
>>> uds_lib-1135776745.uds_lib.b703c14a-cgu.4.rcgu.o:(.text.mainshell+0x0) in archive /home/mk8s/.cache/bazel/_bazel_mk8s/9e3db3d0e00a003c34284dea09dfb92b/execroot/hot_restarter/bazel-out/k8-fastbuild/bin/external/raze__uds_pkg__0_1_0/libuds_lib-1135776745.rlib
collect2: error: ld returned 1 exit status

the rustc should have disambiguate these two functions. maybe i am mssing a configuration somewhere. please assist.

@GOVYANSONG
Copy link
Author

Just read about rustc disambuigation. apparently, the issue was caused by putting #[no_mangle] on both functions. after i removed this directive from one fn, the reported linker error disappeared.

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