Created attachment 627018 [details]
wasm test project
I am seeing the following error when compiling a webassembly project using dev-lang/rust-1.42.0 (emerged with 'wasm' USE flag):
> $ cargo build --release --target=wasm32-unknown-unknown
> error: linker `rust-lld` not found
> = note: No such file or directory (os error 2)
> error: aborting due to previous error
I know for sure that this worked in the past with a different version of Rust, but I don't recall which.
Only related bug report I've found: https://github.com/rust-lang/rustup/issues/1843
Managed to get it working using rust-lld from a nightly rust-bin installation I happen to have lying around, like so:
RUSTFLAGS="-C linker=/opt/rust-bin-20200218/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld" cargo build --target=wasm32-unknown-unknown
Also seemingly working, after manual installation of sys-devel/lld:
RUSTFLAGS="-C linker=/usr/bin/lld" cargo build --release --target=wasm32-unknown-unknown
Created attachment 627020 [details]
equery uses rust
how did you end up needing to manually install lld?
we have a dependency on it, so it should have been pulled with system-llvm.
wasm? ( =sys-devel/lld-9* )
and we pass
if use wasm; then
linker = "$(usex system-llvm lld rust-lld)"
so you should already have lld linker set for wasm32-unknown-unknown target
to me it looks like you've build rust without wasm enabled, because it's still looking for rust-lld and not lld, which we set explicitly.
you have 2 symptoms of wasm being disabled: missing deps, missing linker setting.
did you do any manual ebuild installations (with ebuild and not emerge?)
the only other reason for failure I see is that we don't set llvm-config path in wasm target. I'll investigate that.
can you rebuild, upload build log and try again?
(In reply to Georgy Yakovlev from comment #2)
> how did you end up needing to manually install lld?
> we have a dependency on it, so it should have been pulled with system-llvm.
> wasm? ( =sys-devel/lld-9* )
Well, I looked at the ebuild before and I concluded that I don't understand the syntax enough to determine whether it is doing the right thing.
wasm? ( =sys-devel/lld-9* )
Why is there what appears to be an OR? And what does the additional conditional 'wasm?' mean *in this context*? If there is llvm:9, does it still matter whether 'wasm` is set? Does not seem to be the case as lld is definitely not a dependency here. If I do an emerge depclean the sys-devel/lld package is slated for removal, despite 'wasm' USE flag being set and present for dev-lang/rust.
> did you do any manual ebuild installations (with ebuild and not emerge?)
No. Didn't even know that was possible. I do have a slightly modified ebuild, but the modifications don't affect any of that.
> the only other reason for failure I see is that we don't set llvm-config
> path in wasm target. I'll investigate that.
> can you rebuild, upload build log and try again?
Created attachment 627328 [details, diff]
unrelated patch I have applied for the rust ebuild
Created attachment 627474 [details]
It seems that after a re-emerge things are working without problems. I did have lld installed during the emerge, though, not sure if that could make a difference.
(In reply to deso from comment #6)
> It seems that after a re-emerge things are working without problems. I did
> have lld installed during the emerge, though, not sure if that could make a
Sorry no, not true. Nothing has changed. I tested with the non-wasm target...
Still getting the same error with --target=wasm32-unknown-unknown.
actually, you are absolutely right, dependency is incorrectly written.
it's here from times when rust ebuild supported multiple llvm versions and not locked just to a single one. it should totally move outside of || block.
thanks for catching it.
doing a build with wasm currently to test the project, thanks for providing testcase.
rustc -Z unstable-options --target=wasm32-unknown-unknown --print target-spec-json
for some reason linker is still set to rust-lld
I'll dig into that. at least you have a workaround for now with RUSTFLAGS
another tip, you can set
and it will use linker just for this target, not for all of them
Seems the Rust team doesn't see an issue on their side. What's the stance here?
Very convenient workaround exists, I could just print a postinst message with instructions.
Or maybe we can sed target specification at configure time if wasm and system llvm is enabled to force specific linker. Lld path seems to be stable.
The bug has been referenced in the following commit(s):
Author: Georgy Yakovlev <email@example.com>
AuthorDate: 2020-06-18 22:43:14 +0000
Commit: Georgy Yakovlev <firstname.lastname@example.org>
CommitDate: 2020-06-18 23:50:11 +0000
dev-lang/rust: un-hardcode wasm linker if system-llvm is used
Package-Manager: Portage-2.3.101, Repoman-2.3.22
Signed-off-by: Georgy Yakovlev <email@example.com>
dev-lang/rust/rust-1.44.1.ebuild | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
please test and let me know if it works
(In reply to Georgy Yakovlev from comment #14)
> please test and let me know if it works
The fix seems to work for me. Thanks!
thanks for testing!
not going to backport it, because easy workaround exists and I don't want to force rebuilds for users.