Skip to content

Commit 8f1173d

Browse files
committed
Enable wasm_js backend on CI where needed
This enables it through the `RUSTFLAGS` environment variable, 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 we might not be able to use `getrandom` 0.3. The documentation at https://docs.rs/getrandom/0.3.3/getrandom suggests doing something like this in `.cargo/config.toml`: [target.wasm32-unknown-unknown] rustflags = ['--cfg', 'getrandom_backend="wasm_js"'] However, this would be done in the crate that uses `gix-diff`. Doing it here would not alleviate those using `gix-diff` of the need to do so. It could be done here for WASM tests, but we don't currently run tests on WASM. It could be done for the checks that WASM builds that are done in the `wasm` job on CI, but we probably shouldn't do that, because the current approach there of setting `RUSTFLAGS` is more granular; we would want to find out if more crates start needing this functionality in order to build. 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 8f1173d

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)