Skip to content

Commit aae1349

Browse files
committed
4.0.0bi
1 parent 5ac5707 commit aae1349

File tree

4 files changed

+41
-267
lines changed

4 files changed

+41
-267
lines changed

config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export PYDK_SYSCONFIG_PLATFORM=$(echo -n $PYDK_PYTHON_HOST_PLATFORM|cut -d- -f1)
7070
# ============== wasi sdk ===============
7171

7272
# stable
73-
export WASI_SDK=${WASI_SDK:-24.0}
73+
export WASI_SDK=${WASI_SDK:-25.0}
7474
export WASI_SDK_MAJOR=$(echo ${WASI_SDK}|cut -d. -f1)
7575
export WASI_SDK_MINOR=$(echo ${WASI_SDK}|cut -d. -f2)
7676
export WASI_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_MAJOR}/wasi-sdk-${WASI_SDK}-$(arch)-linux.tar.gz
@@ -89,8 +89,8 @@ NIM_VERSION=nim-2.0.8
8989
NIM_VERSION=nim-2.2.0
9090
NIM_URL=https://nim-lang.org/download/${NIM_VERSION}-linux_x64.tar.xz
9191

92-
NIM_VERSION=nim-git
93-
NIM_URL=https://github.com/nim-lang/Nim
92+
#NIM_VERSION=nim-git
93+
#NIM_URL=https://github.com/nim-lang/Nim
9494

9595
export NIM_VERSION NIM_URL
9696
export NIMSDK=${NIMSDK:-"${SDKROOT}/nimsdk"}

emsdk-cc

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ if not sys.argv[0].endswith(".py"):
2222
else:
2323
EXEC = sys.argv.pop(0)
2424

25-
args = sys.argv
26-
2725

2826
def env(k, default):
2927
if default is false:
@@ -58,6 +56,8 @@ COMMON = arglist(
5856
-Wno-unused-command-line-argument
5957
-Wno-unreachable-code-fallthrough
6058
-Wno-unused-function
59+
-Wno-invalid-noreturn
60+
-Wno-declaration-after-statement
6161
""",
6262
os.environ.get("PYDK_CFLAGS", ""),
6363
)
@@ -102,6 +102,7 @@ if MVP:
102102
-D_FILE_OFFSET_BITS=64
103103
-sSUPPORT_LONGJMP=emscripten
104104
-mno-bulk-memory
105+
-mno-bulk-memory-opt
105106
-mnontrapping-fptoint
106107
-mno-reference-types
107108
-mno-sign-ext
@@ -126,7 +127,7 @@ WASM_EXTRA = env("WASM_EXTRA", "") + " " + env("WASM_OPTS", "")
126127
# the only sane default for now
127128
COPTS = env("COPTS", "-O2 -g3")
128129

129-
SIZEOPT = '-Os' in COPTS
130+
SIZEOPT = "-Os" in COPTS
130131

131132
MAIN_MODULE = LINKING = STATIC = False
132133

@@ -169,7 +170,7 @@ for argc, arg in enumerate(sys.argv):
169170
if arg.find("MAIN_MODULE") > 0:
170171
MAIN_MODULE = True
171172

172-
if arg == '-static':
173+
if arg == "-static":
173174
STATIC = True
174175

175176
if arg.startswith("-sENVIRONMENT"):
@@ -192,6 +193,10 @@ for argc, arg in enumerate(sys.argv):
192193
if arg in ("-g0", "-g1", "-g2", "-g3", "-g4"):
193194
continue
194195

196+
if arg.endswith("/libpq/libpq.so"):
197+
arg = "-lpq"
198+
# for wasm-ld
199+
sys.argv[argc] = arg
195200

196201
if not MAIN_MODULE:
197202
# https://github.com/emscripten-core/emscripten/issues/22742
@@ -252,20 +257,31 @@ for argc, arg in enumerate(sys.argv):
252257
AOUT = sys.argv[out_pos]
253258

254259
elif not STATIC:
255-
if arg.endswith(".so") and arg.startswith("/usr/lib"):
256-
arg = f"-l{arg.rsplit('/',1)[-1][3:-3]}"
257-
if arg in ('-lportmidi','-lporttime'):
258-
continue
259-
elif arg.endswith(".so") or arg == "-shared" or arg.find("SIDE_MODULE") > 0:
260-
IS_SHARED = True
261-
if arg == "-shared":
262-
pass
263-
elif arg.endswith(".so"):
264-
if arg.find("wasm32-emscripten.so") > 0 or arg.find("abi3.so") > 0:
265-
PY_MODULE = true
260+
if arg.endswith(".so"):
261+
if arg.startswith("/usr/lib"):
262+
arg = f"-l{arg.rsplit('/',1)[-1][3:-3]}"
263+
if arg in ("-lportmidi", "-lporttime"):
264+
continue
265+
266+
if arg.find("wasm32-emscripten.so") > 0 or arg.find("abi3.so") > 0:
267+
PY_MODULE = true
266268
SHARED_TARGET = arg
267-
out.append(arg)
268269

270+
# FIX linking .so when it should have been .a for final exe without MAIN_MODULE set
271+
# should be "LINKING" state
272+
# is this arg the -o ? if yes do not even try static
273+
elif out_pos != argc:
274+
# if there is no static version let wasm-ld handle it.
275+
if os.path.isfile(arg[:3] + ".a"):
276+
arg = arg[:3] + ".a"
277+
sys.argv[argc] = arg
278+
elif IS_SHARED:
279+
dbg("WARNING maybe should use static here :", arg)
280+
# raise SystemExit(666)
281+
282+
# TODO check is -shared implies -sSIDE_MODULE=1
283+
elif arg == "-shared":
284+
IS_SHARED = True
269285
SHARED = f"-shared -sASSERTIONS=0 -sSIDE_MODULE=1 -L{os.environ['PREFIX']}/lib"
270286
continue
271287

@@ -278,7 +294,7 @@ for argc, arg in enumerate(sys.argv):
278294
continue
279295

280296
# fix sysroot is not default to PIC
281-
arg = arg.replace("/lib/wasm32-emscripten/lib","/lib/wasm32-emscripten/pic/lib")
297+
arg = arg.replace("/lib/wasm32-emscripten/lib", "/lib/wasm32-emscripten/pic/lib")
282298

283299
out.append(arg)
284300

@@ -363,7 +379,7 @@ else:
363379
try:
364380
with open(AOUT, "w") as file:
365381
file.write("#!/usr/bin/env bash\n")
366-
file.write(os.environ.get('SYS_NODE', '/usr/bin/node')+' $0.cjs "$@"\n')
382+
file.write(os.environ.get("SYS_NODE", "/usr/bin/node") + ' $0.cjs "$@"\n')
367383
except Exception as e:
368384
dbg("ERROR: 306", e)
369385
os.rename(AOUT + ".cjs", AOUT)

scripts/emsdk-fetch.sh

Lines changed: 2 additions & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -255,248 +255,9 @@ unset _EMCC_CCACHE
255255
unset _PYTHON_SYSCONFIGDATA_NAME
256256
unset PYTHONHOME
257257
unset PYTHONPATH
258-
# if \${PYDK_CC:-false}
259-
if true
260-
then
261-
$EMSDK_PYTHON -E $SDKROOT/emsdk-cc \$0.py "\$@"
262-
exit \$?
263-
fi
264-
265-
266-
# -Wwarn-absolute-paths
267-
# --valid-abspath ${SDKROOT}
268-
269-
# COMMON="-Wno-unsupported-floating-point-opt"
270-
COMMON="-Wno-limited-postlink-optimizations -Wno-unused-command-line-argument -Wno-unreachable-code-fallthrough -Wno-unused-function"
271-
SHARED=""
272-
IS_SHARED=false
273-
PY_MODULE=false
274-
MVP=\${MVP:true}
275-
WASM_PURE=\${WASM_PURE:true}
276-
277-
278-
if \$MVP
279-
then
280-
281-
# turn of wasm ex (https://github.com/emscripten-core/emscripten/pull/20536)
282-
# -fno-wasm-exceptions -sEMSCRIPTEN_LONGJMP=0
283-
284-
285-
# -mcpu=generic would activate those https://reviews.llvm.org/D125728
286-
# https://github.com/emscripten-core/emscripten/pull/17689
287-
288-
# -fPIC not allowed with -mno-mutable-globals
289-
# -mno-sign-ext not allowed with pthread
290-
291-
#WASMOPTS="-fno-wasm-exceptions -sSUPPORT_LONGJMP=emscripten"
292-
#CPU="-mnontrapping-fptoint -mno-reference-types -mno-sign-ext -m32"
293-
294-
# -mno-bulk-memory <= this is problematic 2024-10-26
295-
296-
CPU="-D_FILE_OFFSET_BITS=64 -sSUPPORT_LONGJMP=emscripten -mno-bulk-memory -mnontrapping-fptoint -mno-reference-types -mno-sign-ext -m32"
297-
298-
else
299-
CPU="-D_FILE_OFFSET_BITS=64 -mcpu=bleeding-edge -m64"
300-
fi
301-
302-
# try to keep 32 but with 64 iface (bitint)
303-
WASMEXTRA="$WASM_EXTRA \$WASMOPTS"
304-
305-
306-
LINKING=\${LINKING:-false}
307-
308-
if echo "\$@ "|grep -q "\\.so "
309-
then
310-
LINKING=true
311-
fi
312-
313-
314-
declare -A seen=( )
315-
316-
for arg do
317-
shift
318-
319-
if [ "\$arg" = "-v" ]
320-
then
321-
$EMSDK_PYTHON -E \$0.py -v
322-
exit 0
323-
fi
324-
325-
if [ "\$arg" = "--version" ]
326-
then
327-
$EMSDK_PYTHON -E \$0.py --version
328-
exit 0
329-
fi
330-
331-
if \$LINKING
332-
then
333-
# prevent duplicates objects/archives files on cmdline when linking shared
334-
if echo \$arg|grep -q \\\\.o\$
335-
then
336-
[[ \${seen[\$arg]} ]] && continue
337-
fi
338-
if echo \$arg|grep -q \\\\.a\$
339-
then
340-
[[ \${seen[\$arg]} ]] && continue
341-
fi
342-
if echo \$arg|grep -q ^-l
343-
then
344-
[[ \${seen[\$arg]} ]] && continue
345-
fi
346-
seen[\$arg]=1
347-
fi
348-
349-
arg_is_bad=false
350-
351-
for badarg in "-Wl,--as-needed" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,-znow" "-Wl,-zrelro" "-Wl,-zrelro,-znow"
352-
do
353-
if [ "\$arg" = "\$badarg" ]
354-
then
355-
arg_is_bad=true
356-
break
357-
fi
358-
done
359-
360-
if \$arg_is_bad
361-
then
362-
continue
363-
fi
364-
365-
if [ "\$arg" = "-c" ]
366-
then
367-
CPU_EXTRA=\$WASM_EXTRA
368-
fi
369-
370-
if [ "\$arg" = "-o" ]
371-
then
372-
CPU_EXTRA=\$WASM_EXTRA
373-
fi
374-
375-
if [ "\$arg" = "-fallow-argument-mismatch" ]
376-
then
377-
continue
378-
fi
379-
380-
if [ "\$arg" = "-lutil" ]
381-
then
382-
continue
383-
fi
384-
385-
if [ "\$arg" = "-O3" ]
386-
then
387-
continue
388-
fi
389-
390-
if [ "\$arg" = "-g" ]
391-
then
392-
continue
393-
fi
394-
395-
if [ "\$arg" = "-lgcc" ]
396-
then
397-
continue
398-
fi
399-
400-
if [ "\$arg" = "-lgcc_s" ]
401-
then
402-
continue
403-
fi
404-
405-
if [ "\$arg" = "-nomvp" ]
406-
then
407-
MVP=false
408-
continue
409-
fi
410-
411-
if [ "\$arg" = "-pthread" ]
412-
then
413-
if echo \$CPU|grep -q mno-sign-ext
414-
then
415-
continue
416-
fi
417-
fi
418-
419-
420-
# that is for some very bad setup.py behaviour regarding cross compiling.
421-
# should not be needed ..
422-
[ "\$arg" = "-I/usr/include" ] && continue
423-
[ "\$arg" = "-I/usr/include/SDL2" ] && continue
424-
[ "\$arg" = "-L/usr/lib64" ] && continue
425-
[ "\$arg" = "-L/usr/lib" ] && continue
426-
[ "\$arg" = "-latomic" ] && continue
427-
428-
if [ "\$arg" = "-shared" ]
429-
then
430-
IS_SHARED=true
431-
SHARED="\$SHARED -sSIDE_MODULE"
432-
fi
433-
434-
if echo "\$arg"|grep -q wasm32-emscripten.so\$
435-
then
436-
PY_MODULE=true
437-
SHARED_TARGET=\$arg
438-
else
439-
if echo "\$arg"|grep -q abi3.so\$
440-
then
441-
PY_MODULE=true
442-
SHARED_TARGET=\$arg
443-
fi
444-
fi
445-
446-
if \$PY_MODULE
447-
then
448-
if \$IS_SHARED
449-
then
450-
true
451-
else
452-
IS_SHARED=true
453-
SHARED="\$SHARED -shared -sSIDE_MODULE"
454-
fi
455-
else
456-
if \$IS_SHARED
457-
then
458-
if echo "\$arg"|grep \\\\.so\$
459-
then
460-
PY_MODULE=true
461-
SHARED_TARGET=\$arg
462-
SHARED="-sSIDE_MODULE"
463-
fi
464-
fi
465-
fi
466-
467-
set -- "\$@" "\$arg"
468-
done
469-
470-
if \$IS_SHARED
471-
then
472-
# always pass CPU opts when linking
473-
$EMSDK_PYTHON -E \$0.py \$SHARED $COPTS \$CPU \$WASM_EXTRA \$LDFLAGS -sSIDE_MODULE -gsource-map --source-map-base / "\$@" \$COMMON
474-
if \$MVP
475-
then
476-
if \$WASM_PURE
477-
then
478-
SOTMP=\$(mktemp).so
479-
mv \$SHARED_TARGET \$SOTMP
480-
# --memory64-lowering --signext-lowering
481-
$SDKROOT/emsdk/upstream/bin/wasm-emscripten-finalize -mvp \$SOTMP -o \$SHARED_TARGET
482-
[ -f \$SHARED_TARGET.map ] && rm \$SHARED_TARGET.map
483-
rm \$SOTMP
484-
fi
485-
fi
486-
else
487-
# do not pass WASM opts when -c/-o but always PIC
488-
if echo $@|grep -q MAIN_MODULE
489-
then
490-
$EMSDK_PYTHON -E \$0.py $COPTS \$CPU \$CPU_EXTRA \$CPPFLAGS -DBUILD_STATIC "\$@" \$COMMON
491-
else
492-
$EMSDK_PYTHON -E \$0.py $COPTS \$CPU_EXTRA \$CPPFLAGS -DBUILD_STATIC "\$@" \$COMMON
493-
fi
494-
fi
495-
#else
496-
# unset _EMCC_CCACHE
497-
# exec ccache "\$0" "\$@"
498-
#fi
499258
259+
$EMSDK_PYTHON -E $SDKROOT/emsdk-cc \$0.py "\$@"
260+
exit \$?
500261
END
501262

502263
rm emsdk/upstream/emscripten/em++

0 commit comments

Comments
 (0)