Skip to content

Commit 10b2672

Browse files
authored
fix(rust): use prebuilt std when it is available (#6109)
* fix(rust): enable compiler-builtins-c for build-std in napi build * fix(rust): try to fix android builds part 2 * fix(rust): fix android builds part 3 * fix(rust): silly command line hiccups * fix(rust): fix compiler-rt path * fix(rust): use prebuilt std when it is available * fix(rust): target does matter again * fix(rust): properly define toolchain action * fix(rust): actually get the syntax right * fix(rust): misc tweaks to ci pipeline
1 parent 69b5dd3 commit 10b2672

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ jobs:
141141
- host: ubuntu-latest
142142
target: armv7-linux-androideabi
143143
cross: napi
144-
# There are compile issues when using the cache with Android
145-
cache-cargo: false
146144
- host: ubuntu-latest
147145
target: aarch64-linux-android
148146
cross: napi
@@ -169,6 +167,8 @@ jobs:
169167
-C link-args=-L/sysroot-riscv64/usr/lib
170168
-C linker=riscv64-alpine-linux-musl-ld
171169
" &&
170+
rustup default nightly-2025-07-25 &&
171+
rustup target add riscv64gc-unknown-linux-musl &&
172172
npm run build:napi -- --release --target riscv64gc-unknown-linux-musl
173173
- host: ubuntu-latest
174174
target: powerpc64le-unknown-linux-gnu
@@ -208,9 +208,11 @@ jobs:
208208
- host: ubuntu-latest
209209
target: x86_64-unknown-freebsd
210210
cross: cross
211+
build-std: true
211212
- host: ubuntu-latest
212213
target: aarch64-unknown-freebsd
213214
cross: cross
215+
build-std: true
214216

215217
name: Build ${{ matrix.settings.name || matrix.settings.target }}
216218
runs-on: ${{ matrix.settings.host }}
@@ -241,7 +243,8 @@ jobs:
241243
if: ${{ !matrix.settings.docker }}
242244
with:
243245
toolchain: nightly-2025-07-25
244-
components: rust-src
246+
components: ${{ matrix.settings.build-std && 'rust-src' || '' }}
247+
targets: ${{ !matrix.settings.build-std && matrix.settings.target || '' }}
245248
- name: Setup OpenHarmony SDK
246249
if: ${{ contains(matrix.settings.target, 'ohos') }}
247250
uses: openharmony-rs/setup-ohos-sdk@3c181b3244cec76aaec289ab84fb00f55f2fce3f # v0.2.4
@@ -296,7 +299,7 @@ jobs:
296299
if: ${{ !matrix.settings.docker && matrix.settings.build && matrix.settings.target != 'x86_64-pc-windows-gnu' }}
297300
- name: Build (Classic)
298301
env: ${{ matrix.settings.env || fromJSON('{}') }}
299-
run: npm run build:napi -- --release --target ${{ matrix.settings.target }} ${{ matrix.settings.cross == 'zig' && '-x' || matrix.settings.cross == 'napi' && '--use-napi-cross' || matrix.settings.cross == 'cross' && '--use-cross' || '' }}
302+
run: npm run build:napi -- --release --target ${{ matrix.settings.target }} ${{ matrix.settings.cross == 'zig' && '-x' || matrix.settings.cross == 'napi' && '--use-napi-cross' || matrix.settings.cross == 'cross' && '--use-cross' || '' }} -- ${{ matrix.settings.build-std && '-Zbuild-std=std,core,alloc,panic_unwind -Zbuild-std-features=panic-unwind' || '' }}
300303
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
301304
shell: bash
302305
- name: Save Cargo cache

rust/bindings_napi/.cargo/config.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
[build]
22
rustflags = "-Z location-detail=none"
33

4-
[unstable]
5-
build-std = ["std", "core", "alloc", "panic_unwind"]
6-
build-std-features = ["panic-unwind"]
7-
84
[target.loongarch64-unknown-linux-gnu]
95
linker = "loongarch64-linux-gnu-gcc"
106

0 commit comments

Comments
 (0)