Conversation
|
Note: this adds about 74KB to the WASM module because we're no longer stripping function names (this is something wasm-opt was doing). We can reclaim this space by re-adding wasm-opt, by having cargo strip symbols, or by using llvm-strip or wasm-strip. |
a04036c to
6841591
Compare
| ARG WASM_PACK_VERSION | ||
| # Install wasm-pack for targeting WebAssembly from Rust. | ||
| RUN cargo install wasm-pack --locked --version ${WASM_PACK_VERSION} | ||
|
|
There was a problem hiding this comment.
Should we add some cache warming step here? How bad is it to compile wasm-bindgen-cli every time?
There was a problem hiding this comment.
On my machine it takes 25s for wasm-bindgen-cli to be ready. Priming it is a bit tricky because cargo-bin-run depends on data from Cargo.toml and during docker image creation we don't check out code.
There was a problem hiding this comment.
Echoing what @zmb3 said, we should enable symbol stripping for release builds here (if they're not needed for wasm-bindgen).
There was a problem hiding this comment.
Symbol stripping (as in strip=true in Cargo.toml) gives no improvement in size.
I've added wasm-strip step and it gets some size back. On my machine it shows up as:
wasm-opt (size from current master):
../../../webassets/teleport/app/ironrdp_bg.wasm 436.05 kB │ gzip: 152.91 kB
No wasm-stip (with or without strip in Cargo.toml):
../../../webassets/teleport/app/ironrdp_bg.wasm 558.33 kB │ gzip: 173.94 kB
wasm-strip:
../../../webassets/teleport/app/ironrdp_bg.wasm 483.49 kB │ gzip: 152.40 kB
0b1cef0 to
33c4f4b
Compare
fheinecke
left a comment
There was a problem hiding this comment.
LGTM provided that you test by cutting a dev release after your final set of changes
| #> | ||
|
|
||
| $TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath())" -ChildPath "$([guid]::newguid().Guid)" | ||
| $TempDirectoryPath = Join-Path -Path "$([System.IO.Path]::GetTempPath() )" -ChildPath "$( [guid]::newguid().Guid )" |
There was a problem hiding this comment.
Is this intentional (here and elsewhere)?
| $Env:CARGO_HOME = "$ToolchainDir/cargo" | ||
| & "$ToolchainDir\rustup-init.exe" --profile minimal -y --default-toolchain "$RustVersion-x86_64-pc-windows-gnu" | ||
| Enable-Rust -ToolchainDir $ToolchainDir | ||
| & rustup target add wasm32-unknown-unknown |
There was a problem hiding this comment.
| & rustup target add wasm32-unknown-unknown | |
| rustup target add wasm32-unknown-unknown |
The call operator (&) is not needed here
|
|
||
| # Dockerized builds generate .pnpm-store in the root, so ignore it | ||
| .pnpm-store | ||
| .bin/ |
There was a problem hiding this comment.
Why is this added to .gitignore? Can you add a comment as to why this is here and separate it from .pnmp-store as that description does not seem to apply?
| }, | ||
| "scripts": { | ||
| "build-wasm": "node ../../scripts/clean-up-ironrdp-artifacts.mjs && RUST_MIN_STACK=16777216 wasm-pack build ./libs/ironrdp --target web" | ||
| "build-wasm": "node ../../scripts/clean-up-ironrdp-artifacts.mjs && cd ./libs/ironrdp && cargo build --target wasm32-unknown-unknown --release && cp ../../../../../target/wasm32-unknown-unknown/release/ironrdp.* pkg/ && cargo bin wasm-bindgen pkg/ironrdp.wasm --out-dir pkg --typescript --target web && cargo bin wasm-strip pkg/ironrdp_bg.wasm" |
There was a problem hiding this comment.
This is pretty unwieldy - it is hard to see what is being run and if one part of it fails, it will be hard to tell which of the commands have failed. Is there a way to simplify this with node? If not, can we add a make target and call that?
As someone who has to chase down build failures, long run-on commands like this make life harder.
.PHONY: build-ironrdp-wasm
build-ironrdp-wasm: ironrdp = web/packages/shared/libs/ironrdp
build-ironrdp-wasm:
node web/scripts/clean-up-ironrdp-artifacts.mjs
cd $(ironrdp) && cargo build --target wasm32-unknown-unknown --release
cp target/wasm32-unknown-unknown/release/ironrdp.* $(ironrdp)/pkg
cargo bin wasm-bindgen $(ironrdp)/pkg/ironrdp.wasm --out-dir $(ironrdp)/pkg --typescript --target web
cargo bin wasm-strip $(ironrdp)/pkg/ironrdp_bg.wasm
That will at least print out each commands as it runs so we can see what any failures would be related to. But I don't know if it makes sense to be mixing node package stuff with make stuff like this.
There was a problem hiding this comment.
I dont think this tool belongs in the top-level tool/ directory - that is for the programs we build and release. As a build tool, this belongs in build.assets/tooling or similar.
Can we also have some docs about what this is? It is simply to support the cargo bin ... command as used later? And does it just run a binary that has been put in .bin/?
If so, why do we need a tool for this - can't we just run the tool directly out of .bin/?
|
@probakowski was this superseded by #58618? |
|
Yes. |
This change switches our build process to use
wasm-bindgendirectly sowasm-packis no longer needed