Skip to content

Tried to write dynamic symbol definition without a resolution #381

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

Closed
mati865 opened this issue Feb 6, 2025 · 7 comments · Fixed by #440
Closed

Tried to write dynamic symbol definition without a resolution #381

mati865 opened this issue Feb 6, 2025 · 7 comments · Fixed by #440
Assignees

Comments

@mati865
Copy link
Collaborator

mati865 commented Feb 6, 2025

Error:

  Running command: "make libs" in dir: /home/mateusz/projects/rust-rdkafka/target/debug/build/rdkafka-sys-e3110b4b51e6f8c5/out
  Error: Failed copying from <epilogue> to output file

  Caused by:
      Tried to write dynamic symbol definition without a resolution: symbol `_ZTv0_n56_N7RdKafka10HandleImpl8outq_lenEv` (1257 local=239) in file #1536 (6/0) (ProducerImpl.o) defined as 566 in file #1024 (4/0) (HandleImpl.o) (ADDRESS)
  collect2: error: ld returned 255 exit status

Reproduction:

jj git clone https://github.com/fede1024/rust-rdkafka

cd rust-rdkafka

PATH=~/projects/wild:$PATH cargo b

It doesn't reproduce by changing ~/.cargo/config.toml like in the README because [target.<triple>] doesn't apply when linking build scripts.

@marxin
Copy link
Collaborator

marxin commented Feb 8, 2025

I tried to reproduce this, but it does not manifest and I double-checked (by adding a todo!) that Wild linker is used.

@mati865
Copy link
Collaborator Author

mati865 commented Feb 8, 2025

Weird, I had encountered it on Ubuntu VM on the company workstation and then on Arch Linux on my home machine.
I'll see if I can crate Containerfile that is affected.

@marxin
Copy link
Collaborator

marxin commented Feb 8, 2025

Good, now I can reproduce it from an Ubuntu docker image.

@davidlattimore davidlattimore self-assigned this Feb 17, 2025
@davidlattimore
Copy link
Owner

I'm able to reproduce.

It doesn't reproduce by changing ~/.cargo/config.toml like in the README because [target.<triple>] doesn't apply when linking build scripts.

It does affect linking of build scripts, however it doesn't affect what linker might be used when those build scripts invoke GCC or clang.

The problem was because there were multiple weak definitions of the same function and we were trying to export all of them from the shared object, not just the canonical definition. PR coming...

@mati865
Copy link
Collaborator Author

mati865 commented Feb 18, 2025

It does affect linking of build scripts, however it doesn't affect what linker might be used when those build scripts invoke GCC or clang.

I have hit rust-lang/cargo#4423 so many times previously that I think they do not apply. Or at least, not all ways to configure them are applied to build scripts.

Anyway, thanks for the fix. I'll restore the /usr/local/bin/ld symlink to wild and see how it goes.

@davidlattimore
Copy link
Owner

I have hit rust-lang/cargo#4423 so many times previously that I think they do not apply. Or at least, not all ways to configure them are applied to build scripts.

You can check what linker was used (although GNU ld doesn't write a comment, but the other linkers do):

readelf -p .comment target/release/build/ahash-efcdc5043814e943/build_script_build-efcdc5043814e943 | grep Linker
  [    58]  Linker: Wild version 0.3.0

So for me at least, the setting in ~/.cargo/config.toml is sufficient for build scripts to be linked with wild.

Anyway, thanks for the fix. I'll restore the /usr/local/bin/ld symlink to wild and see how it goes.

Another option for overriding the linker is setting PATH. e.g. PATH=$HOME/work/wild/fakes:$PATH.

@mati865
Copy link
Collaborator Author

mati865 commented Feb 18, 2025

You can check what linker was used (although GNU ld doesn't write a comment, but the other linkers do):

Writing a script that would look for binaries in a given path that are not linked with wild would certainly be an option, but I like the nuclear solution: "ld is wild". No build system so far has outsmarted that yet 😉

So for me at least, the setting in ~/.cargo/config.toml is sufficient for build scripts to be linked with wild.

I cannot recall the specific (it wasn't related to wild), but I have learned it hard way to be wary about RUSTFLAGS when linker script are involved.

Another option for overriding the linker is setting PATH. e.g. PATH=$HOME/work/wild/fakes:$PATH.

Yeah, matter of personal preference. For Dockefiles using RUN cargo install --git --locked <wild_repo> && ln -s ... .... is much more convenient.

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

Successfully merging a pull request may close this issue.

3 participants