File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4141 EMSDK_VERSION : " 4.0.9"
4242 # hugrverse-env target used to fetch the pre-built tket-c-api WebAssembly library.
4343 HUGRVERSE_WASM_TARGET : " emscripten_4_0_9_wasm32"
44+ # Rust nightly version used to build the WebAssembly wheels.
45+ RUST_NIGHTLY_VERSION : " nightly-2026-08-20"
4446
4547jobs :
4648 # Check if the tag matches the package name,
@@ -276,12 +278,12 @@ jobs:
276278 - name : Install nightly Rust toolchain
277279 uses : dtolnay/rust-toolchain@master
278280 with :
279- toolchain : " nightly "
281+ toolchain : ${{ env.RUST_NIGHTLY_VERSION }}
280282 - name : Add required rust targets and components
281283 run : |
282- rustup override set nightly
284+ rustup override set ${{ env.RUST_NIGHTLY_VERSION }}
283285 rustup target add wasm32-unknown-emscripten
284- rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
286+ rustup component add rust-src --toolchain ${{ env.RUST_NIGHTLY_VERSION }}
285287 - name : Install Node.js for emsdk
286288 uses : actions/setup-node@v6
287289 with :
Original file line number Diff line number Diff line change @@ -96,9 +96,18 @@ fn main() {
9696 println ! ( "cargo:rustc-link-lib=stdc++" ) ;
9797 }
9898
99- // Generate bindings using bindgen
100- let bindings = bindgen:: Builder :: default ( )
101- . header ( header_path. to_str ( ) . unwrap ( ) )
99+ // Generate bindings using bindgen. The C API only contains opaque pointers
100+ // and target-independent scalar types, so parsing it for the host produces
101+ // bindings that are also valid for Emscripten. This avoids libclang
102+ // dropping function declarations when using its Emscripten target.
103+ let mut bindings_builder = bindgen:: Builder :: default ( ) . header ( header_path. to_str ( ) . unwrap ( ) ) ;
104+ if target == Some ( SupportedPlatform :: Emscripten ) {
105+ println ! ( "cargo:rerun-if-env-changed=HOST" ) ;
106+ let host = env:: var ( "HOST" ) . expect ( "Cargo should set HOST for build scripts" ) ;
107+ bindings_builder = bindings_builder. clang_arg ( format ! ( "--target={host}" ) ) ;
108+ }
109+
110+ let bindings = bindings_builder
102111 . generate ( )
103112 . expect ( "Unable to generate bindings" ) ;
104113
You can’t perform that action at this time.
0 commit comments