From 367b528d4ae2aab9a3e91e261ea1943c63bc301e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Fri, 12 Apr 2024 12:05:59 +0200 Subject: [PATCH] fix wasm build Forwarded: not-needed Reviewed-By: Yadd Last-Update: 2024-04-05 Gbp-Pq: Name fix-wasm-build.patch --- build/wasm.js | 21 +++++++++------------ llhttp/Makefile | 2 +- llhttp/bin/build_wasm.ts | 6 +++++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/build/wasm.js b/build/wasm.js index fd90ac2..eded00a 100644 --- a/build/wasm.js +++ b/build/wasm.js @@ -8,6 +8,7 @@ const ROOT = resolve(__dirname, '../') const WASM_SRC = resolve(__dirname, '../deps/llhttp') const WASM_OUT = resolve(__dirname, '../lib/llhttp') const DOCKERFILE = resolve(__dirname, './Dockerfile') +const { CLANG } = process.env let platform = process.env.WASM_PLATFORM if (!platform && process.argv[2]) { @@ -35,22 +36,16 @@ if (process.argv[2] === '--docker') { process.exit(0) } -// Gather information about the tools used for the build -const buildInfo = execSync('apk info -v').toString() -if (!buildInfo.includes('wasi-sdk')) { - console.log('Failed to generate build environment information') - process.exit(-1) -} -writeFileSync(join(WASM_OUT, 'wasm_build_env.txt'), buildInfo) - // Build wasm binary -execSync(`clang \ - --sysroot=/usr/share/wasi-sysroot \ +execSync(`${CLANG} \ + -nodefaultlibs \ + --sysroot=/usr \ -target wasm32-unknown-wasi \ -Ofast \ -fno-exceptions \ -fvisibility=hidden \ -mexec-model=reactor \ + -Wl,-lc \ -Wl,-error-limit=0 \ -Wl,-O3 \ -Wl,--lto-O3 \ @@ -72,14 +67,16 @@ writeFileSync( ) // Build wasm simd binary -execSync(`clang \ - --sysroot=/usr/share/wasi-sysroot \ +execSync(`${CLANG} \ + -nodefaultlibs \ + --sysroot=/usr \ -target wasm32-unknown-wasi \ -msimd128 \ -Ofast \ -fno-exceptions \ -fvisibility=hidden \ -mexec-model=reactor \ + -Wl,-lc \ -Wl,-error-limit=0 \ -Wl,-O3 \ -Wl,--lto-O3 \ diff --git a/llhttp/Makefile b/llhttp/Makefile index d9c6d35..f3afeba 100644 --- a/llhttp/Makefile +++ b/llhttp/Makefile @@ -81,7 +81,7 @@ postversion: release git checkout main generate: - npx ts-node bin/generate.ts + ts-node bin/generate.ts install: build/libllhttp.a build/libllhttp.so $(INSTALL) -d $(DESTDIR)$(INCLUDEDIR) diff --git a/llhttp/bin/build_wasm.ts b/llhttp/bin/build_wasm.ts index 95c1ced..d6183b5 100644 --- a/llhttp/bin/build_wasm.ts +++ b/llhttp/bin/build_wasm.ts @@ -25,6 +25,7 @@ if (process.argv[2] === '--setup') { mkdirSync(join(WASM_SRC, 'build')); process.exit(0); } catch (error: unknown) { +// @ts-ignore if (isErrorWithCode(error) && error.code !== 'EEXIST') { throw error; } @@ -52,6 +53,7 @@ if (process.argv[2] === '--docker') { try { mkdirSync(WASM_OUT); } catch (error: unknown) { +// @ts-ignore if (isErrorWithCode(error) && error.code !== 'EEXIST') { throw error; } @@ -63,12 +65,14 @@ execSync('npm run build', { cwd: WASM_SRC, stdio: 'inherit' }); // Build wasm binary execSync( `clang \ - --sysroot=/usr/share/wasi-sysroot \ + -nodefaultlibs \ + --sysroot=/usr \ -target wasm32-unknown-wasi \ -Ofast \ -fno-exceptions \ -fvisibility=hidden \ -mexec-model=reactor \ + -Wl,-lc \ -Wl,-error-limit=0 \ -Wl,-O3 \ -Wl,--lto-O3 \ -- 2.30.2