Skip to content

Commit 8cf554a

Browse files
authored
build: optimize pipeline take two (#6078)
* Reapply "build: aggressively optimize wasm build, improve pipeline (#6053)" This reverts commit 82a8f15. * build(rust): napi-cross prevents dependency on flagship libc Rust creates a dependency on glibc 2.34, whereas the napi binary only depends on glibc 2.14 * build: explicitly use clang on some targets * ci: leverage new gha runners to run full test suite on aarch64 * ci: add architecture to cache key, exclude win/node18
1 parent c9e96c2 commit 8cf554a

File tree

11 files changed

+135
-157
lines changed

11 files changed

+135
-157
lines changed

.github/workflows/build-and-tests.yml

Lines changed: 78 additions & 127 deletions
Large diffs are not rendered by default.

.github/workflows/performance-report.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: dtolnay/rust-toolchain@stable
3737
with:
3838
toolchain: nightly-2025-07-25
39-
targets: x86_64-unknown-linux-gnu
39+
components: rust-src
4040
- name: Restore Cargo cache
4141
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
4242
with:
@@ -59,7 +59,7 @@ jobs:
5959
path: |
6060
node_modules
6161
~/.npm
62-
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
62+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
6363
- name: Install Node dependencies
6464
if: steps.cache-node-modules.outputs.cache-hit != 'true'
6565
run: npm install --ignore-scripts
@@ -87,7 +87,7 @@ jobs:
8787
uses: dtolnay/rust-toolchain@stable
8888
with:
8989
toolchain: nightly-2025-07-25
90-
targets: x86_64-unknown-linux-gnu
90+
components: rust-src
9191
- name: Restore Cargo cache
9292
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
9393
with:
@@ -110,7 +110,7 @@ jobs:
110110
path: |
111111
node_modules
112112
~/.npm
113-
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
113+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
114114
- name: Install dependencies
115115
if: steps.cache-node-modules.outputs.cache-hit != 'true'
116116
run: npm ci --ignore-scripts

.github/workflows/repl-artefacts.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: dtolnay/rust-toolchain@stable
3232
with:
3333
toolchain: nightly-2025-07-25
34-
targets: wasm32-unknown-unknown
34+
components: rust-src
3535
- name: Restore Cargo cache
3636
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
3737
with:
@@ -54,8 +54,8 @@ jobs:
5454
path: |
5555
node_modules
5656
~/.npm
57-
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
58-
restore-keys: node-modules-${{ runner.os }}
57+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
58+
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
5959
- name: Install Node dependencies
6060
if: steps.cache-node-modules.outputs.cache-hit != 'true'
6161
run: npm install --ignore-scripts

CONTRIBUTING.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,18 @@ Working on your first Pull Request? You can learn how from this _free_ course, [
2020

2121
Rollup now includes some Rust code. To compile it, you need to set up the Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.
2222

23-
Make sure you use the same toolchain version as specified in the `/rust/rust-toolchain.toml` file. For example, if the file contains the following:
24-
25-
```toml
26-
[toolchain]
27-
profile = "default"
28-
channel = "nightly-2025-07-25"
29-
```
30-
31-
You should be able to install it with the following commands:
23+
Make sure you use the same toolchain version as specified in the `/rust-toolchain.toml` file. It should automatically be handled, as well as acquiring the required targets. Should you want to do it manually, use the following commands:
3224

3325
```shell
34-
rustup toolchain install nightly-2025-07-25
35-
rustup default nightly-2025-07-25
26+
# Look at the rust-toolchain.toml file for the precise toolchain used by Rollup
27+
rustup toolchain install nightly
28+
rustup default nightly
3629
```
3730

38-
You should also install the `wasm32-unknown-unknown` target:
31+
You should also install the `rust-src` component:
3932

4033
```shell
41-
rustup target add wasm32-unknown-unknown
34+
rustup component add rust-src
4235
```
4336

4437
In the end, run

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"scripts": {
3838
"build": "concurrently -c green,blue \"npm run build:wasm\" \"npm:build:ast-converters\" && concurrently -c green,blue \"npm run build:napi -- --release\" \"npm:build:js\" && npm run build:copy-native",
3939
"build:quick": "concurrently -c green,blue 'npm:build:napi' 'npm:build:cjs' && npm run build:copy-native",
40-
"build:napi": "napi build --platform --dts native.d.ts --no-js --output-dir . --manifest-path rust/bindings_napi/Cargo.toml",
41-
"build:wasm": "cross-env RUSTFLAGS=\"-C opt-level=z\" wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack && shx rm wasm/.gitignore",
40+
"build:napi": "napi build --cwd rust/bindings_napi --platform --dts ../../native.d.ts --no-js --output-dir ../.. --package-json-path ../../package.json",
41+
"build:wasm": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack && shx rm wasm/.gitignore",
4242
"build:wasm:node": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm-node --target nodejs --no-pack && shx rm wasm-node/.gitignore",
4343
"update:napi": "npm run build:napi && npm run build:copy-native",
4444
"build:js": "rollup --config rollup.config.ts --configPlugin typescript --forceExit",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[toolchain]
22
profile = "default"
33
channel = "nightly-2025-07-25"
4+
components = ["rust-src"]

rust/Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[profile.release]
2-
lto = true
3-
strip = true
4-
51
[workspace]
62
resolver = "2"
73
members = [
@@ -10,3 +6,9 @@ members = [
106
"parse_ast",
117
"xxhash"
128
]
9+
10+
[profile.release]
11+
strip = true
12+
lto = true
13+
opt-level = 3
14+
codegen-units = 1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build]
2+
rustflags = "-Z location-detail=none"
3+
4+
[unstable]
5+
build-std = ["std", "core", "alloc", "panic_unwind"]
6+
build-std-features = ["panic-unwind"]
7+
8+
[target.loongarch64-unknown-linux-gnu]
9+
linker = "loongarch64-linux-gnu-gcc"
10+
11+
[target.aarch64-unknown-linux-gnu]
12+
linker = "aarch64-linux-gnu-gcc"
13+
14+
[target.armv7-unknown-linux-gnueabihf]
15+
linker = "arm-linux-gnueabihf-gcc"

rust/bindings_napi/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ impl<'task> ScopedTask<'task> for ParseTask {
3636
}
3737

3838
#[napi]
39-
pub fn parse(
40-
env: &Env,
39+
pub fn parse<'env>(
40+
env: &'env Env,
4141
code: String,
4242
allow_return_outside_function: bool,
4343
jsx: bool,
44-
) -> Result<BufferSlice<'_>> {
44+
) -> Result<BufferSlice<'env>> {
4545
BufferSlice::from_data(env, parse_ast(code, allow_return_outside_function, jsx))
4646
}
4747

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build]
2+
rustflags = "-C opt-level=z -Z location-detail=none"
3+
4+
[unstable]
5+
build-std = ["std", "core", "alloc", "panic_abort"]
6+
build-std-features = ["panic_immediate_abort", "optimize_for_size"]

0 commit comments

Comments
 (0)