Skip to content

Commit 037cb8c

Browse files
committed
Enable wasm_js backend on CI where needed
This enables it through the `RUSTFLAGS` environment vairable, doing so for the `wasm32-unknown-unknown` target only. This is to address: error: The wasm32-unknown-unknown targets are not supported by default; you may need to enable the "wasm_js" configuration flag. Note that enabling the `wasm_js` feature flag alone is insufficient. For more information see: https://docs.rs/getrandom/0.3.3/#webassembly-support --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.3.3/src/backends.rs:168:9 | 168 | / compile_error!(concat!( 169 | | "The wasm32-unknown-unknown targets are not supported by default; \ 170 | | you may need to enable the \"wasm_js\" configuration flag. Note \ 171 | | that enabling the `wasm_js` feature flag alone is insufficient. \ 172 | | For more information see: \ 173 | | https://docs.rs/getrandom/", env!("CARGO_PKG_VERSION"), "/#webassembly-support" 174 | | )); However, it is not necessarily the best way to do it. If we want the `wasm` feature, which is intentionally not a default feature even on WASM targets, to be sufficient to enable this behavior, then it may be necessary to set this up in the build configuration. The documentation at https://docs.rs/getrandom/0.3.3/getrandom suggests doing something like: [target.wasm32-unknown-unknown] rustflags = ['--cfg', 'getrandom_backend="wasm_js"'] However, even assuming we can justifiably and effective do this for `gix-diff`, which is a library crate, it should still only be done when the `wasm` feature of `gix-diff` is enabled. That seems like it might require a `build.rs` file. For now, this change just tests if enabling that backend is sufficient to let the build succeed. For more on backends including the `wasm_js` backend, see: https://docs.rs/getrandom/0.3.3/getrandom/#opt-in-backends
1 parent 06bc85b commit 037cb8c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ jobs:
457457
for feature in progress parallel io-pipe crc32 zlib cache-efficiency-debug; do
458458
cargo build -p gix-features --features "$feature" --target "$TARGET"
459459
done
460+
- name: enable wasm_js backend
461+
if: matrix.target == 'wasm32-unknown-unknown'
462+
run: echo RUSTFLAGS='--cfg getrandom_backend="wasm_js"' >> "$GITHUB_ENV"
460463
- name: crates with 'wasm' feature
461464
run: |
462465
set -x

0 commit comments

Comments
 (0)