←back to thread

383 points hkalbasi | 1 comments | | HN request time: 0.216s | source
Show context
shmerl ◴[] No.42816069[source]
That looks promising. In Rust to begin with and with the goal of being fast and support incremental linking.

To use it with Rust, this can probbaly also work using gcc as linker driver.

In project's .cargo/config.toml:

    [target.x86_64-unknown-linux-gnu]
    rustflags = ["-C", "link-arg=-fuse-ld=wild"]
Side note, but why does Rust need to plug into gcc or clang for that? Some missing functionality?
replies(2): >>42816486 #>>42817056 #
davidlattimore ◴[] No.42817056[source]
Unfortunately gcc doesn't accept arbitrary linkers via the `-fuse-ld=` flag. The only linkers it accepts are bfd, gold lld and mold. It is possible to use gcc to invoke wild as the linker, but currently to do that, you need to create a directory containing the wild linker and rename the binary (or a symlink) to "ld", then pass `-B/path/to/directory/containing/wild` to gcc.

As for why Rust uses gcc or clang to invoke the linker rather than invoking the linker directly - it's because the C compiler knows what linker flags are needed on the current platform in order to link against libc and the C runtime. Things like `Scrt1.o`, `crti.o`, `crtbeginS.o`, `crtendS.o` and `crtn.o`.

replies(2): >>42817154 #>>42818920 #
1. shmerl ◴[] No.42817154[source]
Ah, good to know, thanks!

May be it's worth filing a feature request for gcc to have parity with clang for arbitrary linkers?