summaryrefslogtreecommitdiffstats
path: root/debian/patches/fix-wasm-build.patch
blob: d2855dc7d10f18518964a065a3bb25618be03299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Description: fix wasm build
Author: Jérémy Lal <kapouer@melix.org>
Forwarded: not-needed
Reviewed-By: Yadd <yadd@debian.org>
Last-Update: 2022-07-09

--- a/build/wasm.js
+++ b/build/wasm.js
@@ -8,6 +8,7 @@
 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]) {
@@ -44,13 +45,15 @@
 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 +75,16 @@
 )
 
 // 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 \
--- a/llhttp/Makefile
+++ b/llhttp/Makefile
@@ -81,7 +81,7 @@
 	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)
--- a/llhttp/bin/build_wasm.ts
+++ b/llhttp/bin/build_wasm.ts
@@ -25,6 +25,7 @@
     mkdirSync(join(WASM_SRC, 'build'));
     process.exit(0);
   } catch (error) {
+// @ts-ignore
     if (error.code !== 'EEXIST') {
       throw error;
     }
@@ -52,6 +53,7 @@
 try {
   mkdirSync(WASM_OUT);
 } catch (error) {
+// @ts-ignore
   if (error.code !== 'EEXIST') {
     throw error;
   }
@@ -63,12 +65,14 @@
 // 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 \