Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 715348 - dev-lang/rust [wasm]: error: linker `rust-lld` not found
Summary: dev-lang/rust [wasm]: error: linker `rust-lld` not found
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Georgy Yakovlev
URL: https://github.com/rust-lang/rust/iss...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-29 19:51 UTC by deso
Modified: 2020-06-19 22:31 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
wasm test project (wasm-test.tar.bz2,767 bytes, application/x-bzip)
2020-03-29 19:51 UTC, deso
Details
equery uses rust (equery-uses-rust.log,2.00 KB, text/x-log)
2020-03-29 19:55 UTC, deso
Details
unrelated patch I have applied for the rust ebuild (rust-1.42.0.ebuild.patch,1.46 KB, patch)
2020-03-30 14:51 UTC, deso
Details | Diff
builds logs (dev-lang:rust-1.42.0:20200330.log.tar.bz2,143.90 KB, application/x-bzip)
2020-03-30 15:41 UTC, deso
Details

Note You need to log in before you can comment on or make changes to this bug.
Description deso 2020-03-29 19:51:21 UTC
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
Comment 1 deso 2020-03-29 19:55:23 UTC
Created attachment 627020 [details]
equery uses rust
Comment 2 Georgy Yakovlev gentoo-dev 2020-03-30 05:31:59 UTC
question
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
    [target.wasm32-unknown-unknown]
    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?
Comment 3 deso 2020-03-30 14:39:49 UTC
(In reply to Georgy Yakovlev from comment #2)
> question
> 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.

LLVM_DEPEND="
	|| (
		sys-devel/llvm:9[${LLVM_TARGET_USEDEPS// /,}]
		wasm? ( =sys-devel/lld-9* )
	)
	<sys-devel/llvm-10:=
"

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?

Will do.
Comment 4 deso 2020-03-30 14:51:37 UTC
Created attachment 627328 [details, diff]
unrelated patch I have applied for the rust ebuild
Comment 5 deso 2020-03-30 15:41:43 UTC
Created attachment 627474 [details]
builds logs
Comment 6 deso 2020-03-30 15:43:13 UTC
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.
Comment 7 deso 2020-03-30 16:22:29 UTC
(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
> difference.

Sorry no, not true. Nothing has changed. I tested with the non-wasm target...

Still getting the same error with --target=wasm32-unknown-unknown.
Comment 8 Georgy Yakovlev gentoo-dev 2020-03-30 18:31:56 UTC
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.
Comment 9 Georgy Yakovlev gentoo-dev 2020-03-30 19:49:35 UTC
rustc -Z unstable-options --target=wasm32-unknown-unknown --print target-spec-json
{
  "arch": "wasm32",
  "data-layout": "e-m:e-p:32:32-i64:64-n32:64-S128",
  "default-hidden-visibility": true,
  "dll-prefix": "",
  "dll-suffix": ".wasm",
  "dynamic-linking": true,
  "emit-debug-gdb-scripts": false,
  "env": "",
  "exe-suffix": ".wasm",
  "executables": true,
  "has-elf-tls": true,
  "is-builtin": true,
  "limit-rdylib-exports": false,
  "linker": "rust-lld",
  "linker-flavor": "wasm-ld",
  "lld-flavor": "wasm",
  "llvm-target": "wasm32-unknown-unknown",
  "max-atomic-width": 64,
  "only-cdylib": true,
  "os": "unknown",
  "panic-strategy": "abort",
  "pre-link-args": {
    "gcc": [
      "-Wl,--no-threads",
      "-Wl,-z",
      "-Wl,stack-size=1048576",
      "-Wl,--stack-first",
      "-Wl,--allow-undefined",
      "-Wl,--fatal-warnings",
      "-Wl,--no-demangle",
      "-Wl,--export-dynamic",
      "--target=wasm32-unknown-unknown",
      "-nostdlib",
      "-Wl,--no-entry"
    ],
    "wasm-ld": [
      "--no-threads",
      "-z",
      "stack-size=1048576",
      "--stack-first",
      "--allow-undefined",
      "--fatal-warnings",
      "--no-demangle",
      "--export-dynamic",
      "--no-entry"
    ]
  },
  "relocation-model": "static",
  "simd-types-indirect": false,
  "singlethread": true,
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-pointer-width": "32",
  "tls-model": "local-exec",
  "vendor": "unknown"
}

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
Comment 10 Georgy Yakovlev gentoo-dev 2020-03-30 19:56:29 UTC
another tip, you can set
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER=wasm-ld

and it will use linker just for this target, not for all of them
Comment 11 deso 2020-06-10 15:54:50 UTC
Seems the Rust team doesn't see an issue on their side. What's the stance here?
Comment 12 Georgy Yakovlev gentoo-dev 2020-06-11 09:12:17 UTC
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.
Comment 13 Larry the Git Cow gentoo-dev 2020-06-18 23:53:08 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4c22a8c26d3eba78f2bb5835645c34dcb9def55

commit a4c22a8c26d3eba78f2bb5835645c34dcb9def55
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2020-06-18 22:43:14 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2020-06-18 23:50:11 +0000

    dev-lang/rust: un-hardcode wasm linker if system-llvm is used
    
    Bug: https://bugs.gentoo.org/715348
    Package-Manager: Portage-2.3.101, Repoman-2.3.22
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/rust-1.44.1.ebuild | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Comment 14 Georgy Yakovlev gentoo-dev 2020-06-18 23:53:57 UTC
please test and let me know if it works
Comment 15 deso 2020-06-19 20:39:58 UTC
(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!
Comment 16 Georgy Yakovlev gentoo-dev 2020-06-19 22:31:40 UTC
thanks for testing!

not going to backport it, because easy workaround exists and I don't want to force rebuilds for users.
closing.