From ad35076d072ddf7e98a1e8e5cc18c87d72f4e5f4 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 19 Feb 2024 18:09:34 +0800 Subject: [PATCH] fix(cli,build): build params (#1960) --- cli/src/api/build.ts | 4 ++-- crates/build/src/wasi.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/src/api/build.ts b/cli/src/api/build.ts index 35af94ff..5fd46c83 100644 --- a/cli/src/api/build.ts +++ b/cli/src/api/build.ts @@ -550,11 +550,11 @@ class Builder { this.setEnvIfNotExists('RANLIB', join(WASI_SDK_PATH, 'bin', 'ranlib')) this.setEnvIfNotExists( 'CFLAGS', - `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -I${setjmpInclude}`, + `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -mllvm -wasm-enable-sjlj -I${setjmpInclude}`, ) this.setEnvIfNotExists( 'CXXFLAGS', - `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -I${setjmpInclude}`, + `--target=wasm32-wasi-threads --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -pthread -mllvm -wasm-enable-sjlj -I${setjmpInclude}`, ) this.setEnvIfNotExists( `LDFLAGS`, diff --git a/crates/build/src/wasi.rs b/crates/build/src/wasi.rs index 1e350178..f83ef919 100644 --- a/crates/build/src/wasi.rs +++ b/crates/build/src/wasi.rs @@ -4,12 +4,8 @@ pub fn setup() { let link_dir = env::var("EMNAPI_LINK_DIR").expect("EMNAPI_LINK_DIR must be set"); println!("cargo:rerun-if-env-changed=EMNAPI_LINK_DIR"); println!("cargo:rerun-if-env-changed=WASI_REGISTER_TMP_PATH"); - if let Ok(setjmp_link_dir) = env::var("SETJMP_LINK_DIR") { - println!("cargo:rustc-link-search={link_dir}"); - println!("cargo:rustc-link-search={setjmp_link_dir}"); - } + println!("cargo:rustc-link-search={link_dir}"); println!("cargo:rustc-link-lib=static=emnapi-basic-mt"); - println!("cargo:rustc-link-lib=static=setjmp-mt"); println!("cargo:rustc-link-arg=--export-dynamic"); println!("cargo:rustc-link-arg=--export=malloc"); println!("cargo:rustc-link-arg=--export=free"); @@ -26,4 +22,8 @@ pub fn setup() { // 0x800000 bytes = 8MiB println!("cargo:rustc-link-arg=-zstack-size=0x800000"); println!("cargo:rustc-link-arg=--no-check-features"); + if let Ok(setjmp_link_dir) = env::var("SETJMP_LINK_DIR") { + println!("cargo:rustc-link-search={setjmp_link_dir}"); + println!("cargo:rustc-link-lib=static=setjmp-mt"); + } }