View previous topic :: View next topic |
Author |
Message |
leyvi Apprentice

Joined: 08 Sep 2023 Posts: 189
|
Posted: Thu Mar 06, 2025 6:20 pm Post subject: dev-lang/rust fails update: linking with `clang-20` failed |
|
|
Log files: 1.85.0-r1, 1.84.1-r1.
There are two things of interest: Code: | error: linking with `clang-20` failed: exit status: 1 | This appears in both log files, and not that much info is provided.
Code: | note: /usr/bin/x86_64-pc-linux-gnu-ld.bfd: /var/tmp/portage/dev-lang/rust-1.85.0-r1/temp/rustcHelR3r/librustc_codegen_llvm-f93eace2d2279471.rlib: error adding symbols: file format not recognized | This is strange, as I am building with the following environment: Code: | CC=clang
CXX=clang++
LD=ld.lld
AR=llvm-ar
NM=llvm-nm
RANLIB=llvm-ranlib
STRIP=llvm-strip
CFLAGS="-w -march=znver4 -mtune=znver4 -O2 -pipe"
CXXFLAGS=${CFLAGS}
FFLAGS=${CFLAGS}
FCFLAGS=${CFLAGS}
RUSTFLAGS="-C opt-level=2 -C target-cpu=znver4"
LDFLAGS="${FORMER_LDFLAGS} -fuse-ld=lld"
CGO_CFLAGS=${CFLAGS}
CGO_CXXFLAGS=${CXXFLAGS}
CGO_FFLAGS=${FFLAGS}
CGO_LDFLAGS=${LDFLAGS}
GOAMD64=v4
AS=llvm-as | (In case you're wondering, FORMER_LDFLAGS contains the default LDFLAGS for my profile)
Why is it trying to use the BFD linker, when LLD was specified? Isn't Rust tightly integrated with LLVM? If so, why would it be trying to use the GNU toolchain? |
|
Back to top |
|
 |
Sofia Wants Peace N Quiet n00b

Joined: 10 Mar 2025 Posts: 7
|
Posted: Tue Mar 11, 2025 4:09 pm Post subject: |
|
|
My best bet is that rust does not yet support llvm-20, and presumably by extension clang-20. Support for it seems to be merged in master but looks like it will only be available with version 1.87.0.
As to why it's using the bfd linker, I'm unsure, if I remember correctly rust will invoke cc as a linker, and I believe that also applies to itself, at least in my machine my rust projects are linked that way. |
|
Back to top |
|
 |
leyvi Apprentice

Joined: 08 Sep 2023 Posts: 189
|
Posted: Tue Mar 11, 2025 9:55 pm Post subject: |
|
|
Thank you Sofia Wants Peace N Quiet for your response!
Quote: | My best bet is that rust does not yet support llvm-20, and presumably by extension clang-20. Support for it seems to be merged in master but looks like it will only be available with version 1.87.0. | These are the possible values for LLVM_SLOT: Code: | LLVM_SLOT="+16 +17 +18 +19 +20" | So llvm-20 must be supported.
Quote: | As to why it's using the bfd linker, I'm unsure, if I remember correctly rust will invoke cc as a linker, and I believe that also applies to itself, at least in my machine my rust projects are linked that way. | I have my CC set to "clang", with LDFLAGS containing "-fuse-ld=lld", so that wouldn't really be a problem. |
|
Back to top |
|
 |
Sofia Wants Peace N Quiet n00b

Joined: 10 Mar 2025 Posts: 7
|
Posted: Tue Mar 11, 2025 11:50 pm Post subject: |
|
|
leyvi wrote: | Thank you Sofia Wants Peace N Quiet for your response!
Quote: | My best bet is that rust does not yet support llvm-20, and presumably by extension clang-20. Support for it seems to be merged in master but looks like it will only be available with version 1.87.0. | These are the possible values for LLVM_SLOT: Code: | LLVM_SLOT="+16 +17 +18 +19 +20" | So llvm-20 must be supported.
Quote: | As to why it's using the bfd linker, I'm unsure, if I remember correctly rust will invoke cc as a linker, and I believe that also applies to itself, at least in my machine my rust projects are linked that way. | I have my CC set to "clang", with LDFLAGS containing "-fuse-ld=lld", so that wouldn't really be a problem. |
Hmmm, that's very interesting, totally missed the +20 in LLVM_SLOT when looking at the package page, sorry about that.
Also, do you have USE="lto" enabled? It looks like some people have experienced similar problems to this with the bfd linker and lto clang in this rust bug.
Maybe try adding "-C linker=clang -C link-arg=-fuse-ld=lld" to your RUSTFLAGS, as suggested in the comments, this might just be how to tell rust to use lld and clang instead of bfd on the final linking step, not sure :P
Also might be worth checking out this related issue on the rust repo.
Hope this helps! Cheers! :) |
|
Back to top |
|
 |
leyvi Apprentice

Joined: 08 Sep 2023 Posts: 189
|
Posted: Wed Mar 12, 2025 2:06 pm Post subject: |
|
|
While this fixed the original issue, it created another one: Code: | ERROR: Failed to parse '/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/config.toml': expected newline, found an identifier at line 19 column 36
Traceback (most recent call last):
File "/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/./x.py", line 53, in <module>
bootstrap.main()
~~~~~~~~~~~~~~^^
File "/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/src/bootstrap/bootstrap.py", line 1338, in main
bootstrap(args)
~~~~~~~~~^^^^^^
File "/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/src/bootstrap/bootstrap.py", line 1313, in bootstrap
run(args, env=env, verbose=build.verbose, is_bootstrap=True)
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/src/bootstrap/bootstrap.py", line 236, in run
raise RuntimeError(err)
RuntimeError: failed to run: /var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/build/bootstrap/debug/bootstrap build -vvv --config=/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/config.toml -j12 | Full log is available here. |
|
Back to top |
|
 |
Sofia Wants Peace N Quiet n00b

Joined: 10 Mar 2025 Posts: 7
|
Posted: Wed Mar 12, 2025 3:25 pm Post subject: |
|
|
leyvi wrote: | While this fixed the original issue, it created another one |
One build error is never enough it seems :P
I did some searching and found some people experiencing similar issues, but none seem to be failing to parse config.toml, that's very weird indeed.
Could you provide '/var/tmp/portage/dev-lang/rust-1.85.0-r1/work/rustc-1.85.0-src/config.toml'? It looks like it's malformed from what the error is saying.
Both `emerge --info '=dev-lang/rust-1.85.0-r1::gentoo'` and `emerge -pqv '=dev-lang/rust-1.85.0-r1::gentoo'` would also help, if nothing else seems out of place I would probably file a bug report since it's presumably failing to parse a generated file.
I would also try building it without 'USE="lto"', just to see if it works because I've personally have had some weird problems with it and I've seen a lot of different bug reports for rust talking about it. |
|
Back to top |
|
 |
leyvi Apprentice

Joined: 08 Sep 2023 Posts: 189
|
Posted: Wed Mar 12, 2025 4:58 pm Post subject: |
|
|
Found the issue with config.toml: Code: | CMAKE_EXE_LINKER_FLAGS_RELEASE = ""-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -fuse-ld=lld"" | LOL I screwed up my configuration I guess, lemme go see if I can fix this. |
|
Back to top |
|
 |
leyvi Apprentice

Joined: 08 Sep 2023 Posts: 189
|
Posted: Wed Mar 12, 2025 5:22 pm Post subject: |
|
|
Yeah, turns out the second issue wasn't really an issue, just me messing up
Adding `-C link-args=-fuse-ld=lld` to my RUSTFLAGS did the trick.
Thanks so much Sofia Wants Peace N Quiet! |
|
Back to top |
|
 |
Sofia Wants Peace N Quiet n00b

Joined: 10 Mar 2025 Posts: 7
|
Posted: Wed Mar 12, 2025 5:42 pm Post subject: |
|
|
leyvi wrote: | Thanks so much Sofia Wants Peace N Quiet! |
You're welcome! Glad to have helped! :D |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|