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

linker error with mold #1183

Open
folkertdev opened this issue Dec 4, 2024 · 3 comments
Open

linker error with mold #1183

folkertdev opened this issue Dec 4, 2024 · 3 comments

Comments

@folkertdev
Copy link
Contributor

I get a linker error when trying to build c2rust using mold. I've configured the mold linker as my default because it is much faster.

> LLVM_CONFIG_PATH=llvm-config-19 cargo build --release
...
  = note: mold: fatal: failed to load plugin : /usr/bin/mold: undefined symbol: onload
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Mold is configured like so

# .cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"]

and is the latest version

> mold --version
mold 2.34.1 (de65f6bd75b93eeb9f3775fc136ee79683ff35f1; compatible with GNU ld)

When I comment out the rustflags line there (i.e. the default linker is picked) the build does succeed. When I explicitly pick ld.lld from the llvm that I'm using that also works (you still need the linker = "clang" bit of config for this):

LLVM_CONFIG_PATH=llvm-config-19 RUSTFLAGS="-C link-arg=-fuse-ld=/usr/bin/ld.lld-19" cargo build --release

Not a huge problem, and maybe even a limitation in mold, but it does add a bit of friction and might indicate an issue somewhere in the c2rust build pipeline?

@kkysen
Copy link
Contributor

kkysen commented Dec 5, 2024

That's odd, I use mold, too.

@folkertdev
Copy link
Contributor Author

A particular version? And there isn't some sneaky .cargo/config.toml overriding it? (any rustflags anywhere will override that global toml config I believe)

@kkysen
Copy link
Contributor

kkysen commented Dec 6, 2024

I have this in my ~/.cargo/config.toml:

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/home/kkysen/.linuxbrew/bin/mold"]

with these versions:

~/.linuxbrew/bin/mold --version
mold 2.34.1 (compatible with GNU ld)
❯ llvm-config --version
19.1.4
❯ strings target/debug/c2rust | rg mold
mold 2.34.1 (compatible with GNU ld)
❯ strings target/release/c2rust | rg mold
mold 2.34.1 (compatible with GNU ld)

So I'm not sure what's different.

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

2 participants