Page MenuHomeFreeBSD

lang/rust: add WEBASM (WebAssembly) option
ClosedPublic

Authored by mikael on Feb 12 2020, 6:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 16 2024, 9:54 PM
Unknown Object (File)
Feb 11 2024, 9:18 AM
Unknown Object (File)
Jan 17 2024, 5:00 AM
Unknown Object (File)
Dec 20 2023, 3:06 AM
Unknown Object (File)
Nov 25 2023, 4:46 PM
Unknown Object (File)
Oct 31 2023, 11:01 AM
Unknown Object (File)
Sep 29 2023, 11:03 AM
Unknown Object (File)
Sep 28 2023, 1:07 AM

Details

Reviewers
tobik
Group Reviewers
rust
Commits
rP526265: lang/rust: add the WASM option
Summary

This patch adds the WASM option to build the wasm32-unknown-unknown target, off by default.
web assembly seems popular nowadays and people tries to use it on FreeBSD without success: https://github.com/rust-lang/rustup/issues/1843

I haven't found a better way to transform, say, wasm32-unknown-unknown aarch64-unknown-freebsd to ["wasm32-unknown-unknown","aarch64-unknown-freebsd"]

I would also like to discuss the possibility to have this option enabled by default, it only adds 18MB of disk space (or we can wait for subpackage)

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I would also like to discuss the possibility to have this option enabled by default, it only adds 18MB of disk space

How much longer will the build be? It's already quite long...

lang/rust/Makefile
92–101 ↗(On Diff #68210)
_RUST_TARGETS=  "${_RUST_TARGET}"
.if ${PORT_OPTIONS:MWASM}
_RUST_TARGETS+= "wasm32-unknown-unknown"
.endif
RUST_TARGETS=   [${_RUST_TARGETS:ts,}]

But none of that is needed. See below.

165 ↗(On Diff #68210)

Instead of RUST_TARGETS just add

.if ${PORT_OPTIONS:MWASM}
	@${ECHO_CMD} 'target=["${_RUST_TARGET}","wasm32-unknown-unknown"]' >> ${WRKSRC}/config.toml
.endif

Remove spaces around =.

173 ↗(On Diff #68210)

Why do we need to build the bundled lld?

Remove spaces around =.

lang/rust/Makefile
173 ↗(On Diff #68210)

by default rust uses rust-lld as a linker (I think I was able to use lld from devel/llvm with this invocation "env RUSTFLAGS='-C linker=wasm-ld90'"), it'll be easier for newcomer to not have to search the web for a solution to this error message (as seen in https://github.com/rust-lang/rustup/issues/1843):

error: linker `rust-lld` not found
  |
  = note: No such file or directory (os error 2)

The option will install /usr/local/lib/rustlib/x86_64-unknown-freebsd/bin/rust-lld and rust will manage to pick this linker automatically

I would also like to discuss the possibility to have this option enabled by default, it only adds 18MB of disk space

How much longer will the build be? It's already quite long...

On my ryzen 3900x:
build time: 00:19:47
build time: 00:22:07 (with wasm)

Or we can download upstream version at https://static.rust-lang.org/dist/rust-std-1.33.0-wasm32-unknown-unknown.tar.gz (with the current version instead of 1.33.0), idk.

I think I was able to use lld from devel/llvm with this invocation

I've been using that for embedded (thumbv6m, thumbv7em) as well. Having rust-lld is silly when we have LLD in llvmXX packages. Maybe rustc should auto detect our LLDs..

tobik added a subscriber: manu.

Build time increase seems to be in an acceptable margin. Feel free to commit it after your mentor @manu approves and if lang/rust-nightly also builds with it.

Let's only enable WASM (and SOURCES) by default during the Rust 1.42.0 update.

lang/rust/Makefile
173 ↗(On Diff #68210)

Ok. Only FTR, Rust could probably be patched to use wasm-ld90 or similar in src/librustc_target/spec/wasm32_base.rs.

This revision is now accepted and ready to land.Feb 15 2020, 1:53 PM
This revision was automatically updated to reflect the committed changes.