2525 wget https://patch-diff.githubusercontent.com/raw/emscripten-core/emscripten/pull/17956.diff
2626 patch -p1 < 17956.diff
2727 popd
28+
29+ wget https://raw.githubusercontent.com/paradust7/minetest-wasm/main/emsdk_emcc.patch
30+ patch -p1 < emsdk_emcc.patch
31+
32+ # https://github.com/paradust7/minetest-wasm/blob/main/emsdk_dirperms.patch
33+ patch -p1 << END
34+ --- emsdk-orig/upstream/emscripten/system/lib/wasmfs/wasmfs.cpp 2022-07-29 17:22:28.000000000 +0000
35+ +++ emsdk/upstream/emscripten/system/lib/wasmfs/wasmfs.cpp 2022-08-06 02:07:24.098196400 +0000
36+ @@ -141,7 +141,7 @@
37+ }
38+
39+ auto inserted =
40+ - lockedParentDir.insertDirectory(childName, S_IRUGO | S_IXUGO);
41+ + lockedParentDir.insertDirectory(childName, S_IRUGO | S_IWUGO | S_IXUGO);
42+ assert(inserted && "TODO: handle preload insertion errors");
43+ }
44+ END
45+ # https://raw.githubusercontent.com/paradust7/minetest-wasm/main/emsdk_file_packager.patch
46+ patch -p1 << END
47+ --- emsdk1/upstream/emscripten/tools/file_packager.py 2022-03-24 19:45:39.000000000 +0000
48+ +++ emsdk2/upstream/emscripten/tools/file_packager.py 2022-03-22 10:13:11.332849695 +0000
49+ @@ -686,8 +686,12 @@
50+ use_data = '''// Reuse the bytearray from the XHR as the source for file reads.
51+ DataRequest.prototype.byteArray = byteArray;
52+ var files = metadata['files'];
53+ + function make_callback(i) {
54+ + var req = DataRequest.prototype.requests[files[i].filename];
55+ + return () => {req.onload()};
56+ + }
57+ for (var i = 0; i < files.length; ++i) {
58+ - DataRequest.prototype.requests[files[i].filename].onload();
59+ + setTimeout(make_callback(i));
60+ }'''
61+ use_data += (" Module['removeRunDependency']('datafile_%s');\n"
62+ % js_manipulation.escape_for_js_string(data_target))
63+ END
64+ # https://raw.githubusercontent.com/paradust7/minetest-wasm/main/emsdk_setlk.patch
65+ patch -p1 << END
66+ --- emsdk-orig/upstream/emscripten/system/lib/wasmfs/syscalls.cpp 2022-07-29 17:22:28.000000000 +0000
67+ +++ emsdk/upstream/emscripten/system/lib/wasmfs/syscalls.cpp 2022-08-06 05:05:17.014502697 +0000
68+ @@ -1419,7 +1419,7 @@
69+ static_assert(F_SETLK == F_SETLK64);
70+ static_assert(F_SETLKW == F_SETLKW64);
71+ // Always error for now, until we implement byte-range locks.
72+ - return -EACCES;
73+ + return 0; //-EACCES;
74+ }
75+ case F_GETOWN_EX:
76+ case F_SETOWN:
77+ END
78+
79+
80+
2881 popd
2982 fi
3083 fi
84137 cat > emsdk/upstream/emscripten/emcc << END
85138#!/bin/bash
86139
140+ EMCC_TRACE=\$ {EMCC_TRACE:-false}
141+ if \$ EMCC_TRACE
142+ then
143+ echo "
144+ $@ " >> $SDKROOT /emcc.log
145+
146+ fi
147+
87148unset _EMCC_CCACHE
88149
89150#if [ -z "\$ _EMCC_CCACHE" ]
@@ -100,7 +161,16 @@ COMMON="-Wno-unsupported-floating-point-opt -Wno-unused-command-line-argument -W
100161SHARED=""
101162IS_SHARED=false
102163PY_MODULE=false
103- MVP=true
164+ MVP=\$ {MVP:true}
165+ LINKING=\$ {LINKING:-false}
166+
167+ if echo "\$ @ "|grep -q "\\ .so "
168+ then
169+ LINKING=true
170+ fi
171+
172+
173+ declare -A seen=( )
104174
105175for arg do
106176 shift
@@ -117,23 +187,68 @@ for arg do
117187 exit 0
118188 fi
119189
190+ if \$ LINKING
191+ then
192+ # prevent duplicates objects/archives files on cmdline when linking shared
193+ if echo \$ arg|grep -q \\\\ .o\$
194+ then
195+ [[ \$ {seen[\$ arg]} ]] && continue
196+ fi
197+ if echo \$ arg|grep -q \\\\ .a\$
198+ then
199+ [[ \$ {seen[\$ arg]} ]] && continue
200+ fi
201+ if echo \$ arg|grep -q ^-l
202+ then
203+ [[ \$ {seen[\$ arg]} ]] && continue
204+ fi
205+ seen[\$ arg]=1
206+ fi
207+
208+ arg_is_bad=false
209+
210+ for badarg in "-Wl,--as-needed" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,-znow" "-Wl,-zrelro" "-Wl,-zrelro,-znow"
211+ do
212+ if [ "\$ arg" = "\$ badarg" ]
213+ then
214+ arg_is_bad=true
215+ break
216+ fi
217+ done
218+
219+ if \$ arg_is_bad
220+ then
221+ continue
222+ fi
223+
120224 if [ "\$ arg" = "-fallow-argument-mismatch" ]
121225 then
122226 continue
123227 fi
124228
229+ if [ "\$ arg" = "-lutil" ]
230+ then
231+ continue
232+ fi
233+
125234 if [ "\$ arg" = "-lgcc" ]
126235 then
127236 continue
128237 fi
129238
239+ if [ "\$ arg" = "-lgcc_s" ]
240+ then
241+ continue
242+ fi
243+
130244 if [ "\$ arg" = "-nomvp" ]
131245 then
132246 MVP=false
133247 continue
134248 fi
135249
136- # that is for some very bad setup.py behaviour regarding cross compiling. should not be needed ..
250+ # that is for some very bad setup.py behaviour regarding cross compiling.
251+ # should not be needed ..
137252 [ "\$ arg" = "-I/usr/include" ] && continue
138253 [ "\$ arg" = "-I/usr/include/SDL2" ] && continue
139254 [ "\$ arg" = "-L/usr/lib64" ] && continue
0 commit comments