@@ -17,7 +17,7 @@ PREFIX = Path(os.environ.get("PREFIX", "/opt/python-wasm-sdk/devices/emsdk/usr")
1717sys .argv .pop (0 )
1818
1919# point to emscripten cc
20- if not sys .argv [0 ].endswith (' .py' ):
20+ if not sys .argv [0 ].endswith (" .py" ):
2121 EXEC = f"{ EMSDK } /upstream/emscripten/emcc.py"
2222else :
2323 EXEC = sys .argv .pop (0 )
@@ -93,6 +93,8 @@ if MVP:
9393 # bulk and main/side
9494 # https://github.com/emscripten-core/emscripten/issues/22161
9595
96+ # -mno-bulk-memory
97+
9698 CPU = arglist (
9799 """
98100 -m32
@@ -140,6 +142,16 @@ RUSTC = False
140142
141143
142144out = []
145+
146+ # fix rust calling
147+ for argc , arg in enumerate (sys .argv ):
148+ if arg in ("-l" , "-L" , "-I" ):
149+ sys .argv [argc ] += sys .argv [argc + 1 ]
150+ sys .argv [argc + 1 ] = ""
151+
152+ while "" in sys .argv :
153+ sys .argv .remove ("" )
154+
143155for argc , arg in enumerate (sys .argv ):
144156 if arg in ("-v" , "--version" ):
145157 SKIP = True
@@ -168,7 +180,6 @@ for argc, arg in enumerate(sys.argv):
168180 if arg in ("-Wl,--as-needed" , "-Wl,--eh-frame-hdr" , "-Wl,-znoexecstack" , "-Wl,-znow" , "-Wl,-zrelro" , "-Wl,-zrelro,-znow" ):
169181 continue
170182
171-
172183 if arg in ("-lgcc" , "-lgcc_s" , "-fallow-argument-mismatch" ):
173184 continue
174185
@@ -179,44 +190,31 @@ for argc, arg in enumerate(sys.argv):
179190 if arg in ("-O1" , "-O2" , "-O3" , "-Os" , "-Oz" ):
180191 continue
181192
182- if arg in ("-g" , "- g0" , "-g1" , "-g2" , "-g3" , "-g4" ):
193+ if arg in ("-g0" , "-g1" , "-g2" , "-g3" , "-g4" ):
183194 continue
184195
185-
186196 # FAILSAFE
187197 # that is for some very bad known setup.py behaviour regarding cross compiling and some old codebases.
188198 # should not be needed ..
189199 if arg .startswith ("-I/" ):
190200 if arg .startswith ("-I/usr/" ):
191201 continue
192- # remove dups
193- if arg in out :
194- continue
195202
196203 if arg .startswith ("-L/" ):
197204 if arg .startswith ("-L/usr/" ):
198205 continue
199- # remove dups
200- if arg in out :
201- continue
202-
203206
204- # https://github.com/emscripten-core/emscripten/issues/22742
205- # https://github.com/hoodmane/emscripten/commit/34144634026c91a73bd3e1db85627132d3a37a6d
207+ # https://github.com/emscripten-core/emscripten/issues/22742
208+ # https://github.com/hoodmane/emscripten/commit/34144634026c91a73bd3e1db85627132d3a37a6d
209+ if arg == "-lc" :
210+ continue
206211
207212 if arg .find ("ASSERTIONS" ) > 0 :
208213 continue
209214
210-
211- if IS_SHARED :
212- if arg == '-lc' :
213- #continue
214- pass
215-
216-
217215 # rustc has an habit of "-l" "c" instead of "-lc"
218216 if arg .startswith ("-l" ):
219- if len (arg )> 2 :
217+ if len (arg ) > 2 :
220218 LINKING = True
221219 # prevent duplicate lib when linking
222220 if arg in out :
@@ -250,7 +248,6 @@ for argc, arg in enumerate(sys.argv):
250248 SHARED = f"-shared -sSIDE_MODULE=1 -L{ os .environ ['PREFIX' ]} /lib"
251249 continue
252250
253-
254251 # duplicates can happen on cmake/rustc but they are expected to be here for a reason so skip them
255252 if not (CMAKE or RUSTC ):
256253 # prevent duplicates objects/archives files on cmdline when linking
@@ -436,7 +433,7 @@ if EMCC_TRACE:
436433 with open ("conftest.c" , "r" ) as file :
437434 if file .read ().find (DEBUG_PATTERN ) > 0 :
438435 dump ()
439- if DEBUG_PATTERN == "*" :
436+ if DEBUG_PATTERN == "*" :
440437 dump ()
441438
442439else :
0 commit comments