From 2b0e74624615b067b023b613260f3962a706507a Mon Sep 17 00:00:00 2001 From: pmp-p Date: Mon, 16 Dec 2024 10:18:47 +0100 Subject: [PATCH] 3.1.74.0pre --- .github/workflows/ci.yml | 2 +- config | 9 ++-- emsdk-cc | 2 +- python-wasi-sdk.sh | 29 +++++++---- python-wasm-sdk.sh | 29 +++++++---- scripts/cpython-build-emsdk.sh | 4 +- scripts/cpython-build-host.sh | 2 +- scripts/cpython-fetch.sh | 8 +-- scripts/emsdk-fetch.sh | 11 +++- sources.extra/1000-glib.sh | 7 ++- sources.wasm/9000-uuid-ossp.sh | 91 ++++++++++++++++++++++++++-------- 11 files changed, 138 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88b713a..d460890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: gosdk: false rustsdk: false nimsdk: false - COPTS: -Os -g3 + COPTS: -Os -g0 steps: - uses: actions/checkout@v3.3.0 diff --git a/config b/config index dc8b257..8f1c56b 100644 --- a/config +++ b/config @@ -27,16 +27,13 @@ export XDG_DATA_HOME=${HOME}/build/share export XDG_CACHE_HOME=${HOME}/build/cache export XDG_CONFIG_HOME=${HOME}/build/config export XDG_DATA_DIRS=${HOME}/build/share - mkdir -p $XDG_DATA_HOME $XDG_CACHE_HOME $XDG_CONFIG_HOME +export PIP_ROOT_USER_ACTION=ignore +export PIP_NO_CACHE_DIR=1 export HPY=${HOST_PREFIX}/bin/python${PYBUILD} export HPIP="${HPY} -mpip" -# cpython build opts -export CPOPTS="-Os -g0 -fPIC" - - # base wasm features pure is "mvp" , "bi" is bigint if [ -f /mvp ] @@ -154,7 +151,7 @@ done # this is python used for emsdk : ${SYS_PYTHON} -> ${EMSDK_PYTHON} # sane default -export SYS_PYTHON=$(command -v python${PYMAJOR}) +export SYS_PYTHON=python${PYMAJOR} for py in 10 9 8 do if command -v python${PYMAJOR}.${py} >/dev/null diff --git a/emsdk-cc b/emsdk-cc index 02b104f..8d1eb17 100644 --- a/emsdk-cc +++ b/emsdk-cc @@ -358,7 +358,7 @@ else: try: with open(AOUT, "w") as file: file.write("#!/usr/bin/env bash\n") - file.write('node $0.cjs "$@"\n') + file.write(os.environ.get('SYS_NODE', '/usr/bin/node')+' $0.cjs "$@"\n') except Exception as e: dbg("ERROR: 306", e) os.rename(AOUT + ".cjs", AOUT) diff --git a/python-wasi-sdk.sh b/python-wasi-sdk.sh index 1724cf8..2b493f9 100755 --- a/python-wasi-sdk.sh +++ b/python-wasi-sdk.sh @@ -4,14 +4,25 @@ reset # TODO: check how dbg tools work with default settings # https://developer.chrome.com/blog/wasm-debugging-2020/ -if command -v python3 +mkdir -p /tmp/sdk-bin +export PATH=/tmp/sdk-bin:$PATH + +which command || cat > /tmp/sdk-bin/command << END +#!/bin/bash +shift +which $1 +END +chmod +x /tmp/sdk-bin/command + + +if which python3 then - SYS_PYTHON=$(command -v python3) + SYS_PYTHON=$(which python3) else - SYS_PYTHON=$(command -v python) + SYS_PYTHON=$(which python) fi -DISTRIB_RELEASE="any" +DISTRIB_RELEASE=${DISTRIB_RELEASE:-any} # is it linux enough ? if [ -f /etc/lsb-release ] @@ -20,10 +31,10 @@ then export PLATFORM=linux else # or not - export DISTRIB_ID=$($SYS_PYTHON -E -c "print(__import__('sys').platform)") - echo no /etc/lsb-release found, please identify platform '$DISTRIB_ID' - DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}" - exit 1 + export DISTRIB_ID=$($SYS_PYTHON -E -c "print(__import__('sysconfig').get_config_var('HOST_GNU_TYPE'))") + export PLATFORM=$($SYS_PYTHON -E -c "print(__import__('sys').platform)") + echo no /etc/lsb-release found, please identify platform $PLATFORM : \"${DISTRIB_ID}-${DISTRIB_RELEASE}\" or hit enter to continue + read fi export DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}" @@ -60,7 +71,7 @@ do fi done -if [ -d ${SDKROOT} ] +if mkdir -p ${SDKROOT} then echo "Assuming destination $SDKROOT is ready" else diff --git a/python-wasm-sdk.sh b/python-wasm-sdk.sh index 1724cf8..2b493f9 100755 --- a/python-wasm-sdk.sh +++ b/python-wasm-sdk.sh @@ -4,14 +4,25 @@ reset # TODO: check how dbg tools work with default settings # https://developer.chrome.com/blog/wasm-debugging-2020/ -if command -v python3 +mkdir -p /tmp/sdk-bin +export PATH=/tmp/sdk-bin:$PATH + +which command || cat > /tmp/sdk-bin/command << END +#!/bin/bash +shift +which $1 +END +chmod +x /tmp/sdk-bin/command + + +if which python3 then - SYS_PYTHON=$(command -v python3) + SYS_PYTHON=$(which python3) else - SYS_PYTHON=$(command -v python) + SYS_PYTHON=$(which python) fi -DISTRIB_RELEASE="any" +DISTRIB_RELEASE=${DISTRIB_RELEASE:-any} # is it linux enough ? if [ -f /etc/lsb-release ] @@ -20,10 +31,10 @@ then export PLATFORM=linux else # or not - export DISTRIB_ID=$($SYS_PYTHON -E -c "print(__import__('sys').platform)") - echo no /etc/lsb-release found, please identify platform '$DISTRIB_ID' - DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}" - exit 1 + export DISTRIB_ID=$($SYS_PYTHON -E -c "print(__import__('sysconfig').get_config_var('HOST_GNU_TYPE'))") + export PLATFORM=$($SYS_PYTHON -E -c "print(__import__('sys').platform)") + echo no /etc/lsb-release found, please identify platform $PLATFORM : \"${DISTRIB_ID}-${DISTRIB_RELEASE}\" or hit enter to continue + read fi export DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}" @@ -60,7 +71,7 @@ do fi done -if [ -d ${SDKROOT} ] +if mkdir -p ${SDKROOT} then echo "Assuming destination $SDKROOT is ready" else diff --git a/scripts/cpython-build-emsdk.sh b/scripts/cpython-build-emsdk.sh index 7df659a..b570f5f 100755 --- a/scripts/cpython-build-emsdk.sh +++ b/scripts/cpython-build-emsdk.sh @@ -67,7 +67,7 @@ else - EMCC_CFLAGS="-O0 -g0 -fPIC" CFLAGS="-O0 -g0 -fPIC" CC=${SDKROOT}/emsdk/upstream/emscripten/emcc \ + CC=${SDKROOT}/emsdk/upstream/emscripten/emcc \ emconfigure $ROOT/src/libffi/configure --host=wasm32-bi-emscripten \ --prefix=$PREFIX --enable-static --disable-shared --disable-dependency-tracking\ --disable-builddir --disable-multi-os-directory --disable-raw-api --disable-docs @@ -147,7 +147,7 @@ else # --with-tzpath="/usr/share/zoneinfo" \ - export EMCC_CFLAGS="$CPOPTS -D_XOPEN_SOURCE_EXTENDED=1 -I$PREFIX/include/ncursesw -sUSE_ZLIB -sUSE_BZIP2" + export EMCC_CFLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -I$PREFIX/include/ncursesw -sUSE_ZLIB -sUSE_BZIP2" CPPFLAGS="$CPPFLAGS -I$PREFIX/include/ncursesw" CFLAGS="$CPPFLAGS -I$PREFIX/include/ncursesw" diff --git a/scripts/cpython-build-host.sh b/scripts/cpython-build-host.sh index 6712365..b3d7c0c 100755 --- a/scripts/cpython-build-host.sh +++ b/scripts/cpython-build-host.sh @@ -102,7 +102,7 @@ END CNF="${ROOT}/src/cpython${PYBUILD}/configure \ --prefix=$HOST_PREFIX $PYOPTS $GIL" - if CC="clang" CXX="clang++" CCSHARED="-fPIC" $CNF + if CC="clang" CXX="clang++" CCSHARED="-fPIC" EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" $CNF then if make -j$(nproc) diff --git a/scripts/cpython-fetch.sh b/scripts/cpython-fetch.sh index 9ed047e..e967157 100755 --- a/scripts/cpython-fetch.sh +++ b/scripts/cpython-fetch.sh @@ -79,9 +79,11 @@ fi if echo $PYBUILD |grep -q 13$ then - wget -q -c https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tar.xz - tar xf Python-3.13.0.tar.xz - ln -s Python-3.13.0 cpython${PYBUILD} + wget -q -c https://www.python.org/ftp/python/3.13.1/Python-3.13.1.tar.xz + tar xf Python-3.13.1.tar.xz + ln -s Python-3.13.1 cpython${PYBUILD} + + sed -i 's|ProcessPoolExecutor = None|return True|g' cpython3.13/Lib/compileall.py mkdir $ROOT/devices/emsdk/usr/lib $ROOT/devices/$(arch)/usr/lib -p diff --git a/scripts/emsdk-fetch.sh b/scripts/emsdk-fetch.sh index 6e8268e..9574839 100755 --- a/scripts/emsdk-fetch.sh +++ b/scripts/emsdk-fetch.sh @@ -208,7 +208,14 @@ END curl -fsSL https://bun.sh/install | bash - npm install --prefix $ROOT/emsdk/node/??.??.* -g pnpm@^9.0.0 + # emsdk shipped node cannot run on alpine + if [ -f /alpine ] + then + cp -vf /usr/bin/node $ROOT/emsdk/node/??.??.*/bin/node + fi + + export PATH=$(echo -n ${SDKROOT}/emsdk/node/??.??.*/bin):$PATH + $ROOT/emsdk/node/??.??.*/bin/npm install --prefix $ROOT/emsdk/node/??.??.* -g pnpm@^9.0.0 # maybe rewrite that in python and move it to emcc.py @@ -523,7 +530,7 @@ END # emsdk env does not set it, but it's required for eg sdl2-config echo -n else - export PATH=$EMSDK/upstream/emscripten/system/bin:$EMSDK/upstream/emscripten:$PATH + export PATH=$(echo -n ${EMSDK}/node/??.??.*/bin):$EMSDK/upstream/emscripten/system/bin:$EMSDK/upstream/emscripten:$PATH fi #ln $EMSDK/upstream/emscripten/emstrip $EMSDK/upstream/emscripten/strip diff --git a/sources.extra/1000-glib.sh b/sources.extra/1000-glib.sh index 2742f94..968d83d 100755 --- a/sources.extra/1000-glib.sh +++ b/sources.extra/1000-glib.sh @@ -118,8 +118,9 @@ c = 'emcc' cpp = 'em++' ar = 'emar' ranlib = 'emranlib' -pkgconfig = ['pkg-config', '--static'] +pkg-config = ['pkg-config', '--static'] # https://docs.gtk.org/glib/cross-compiling.html#cross-properties + [properties] growing_stack = true have_c99_vsnprintf = true @@ -136,6 +137,10 @@ system = 'emscripten' cpu_family = 'wasm32' cpu = 'wasm32' endian = 'little' + +[ninja] +backend_max_links = 1 + END meson setup _build --prefix=$PREFIX --cross-file=emscripten-crossfile.meson --default-library=static --buildtype=release \ diff --git a/sources.wasm/9000-uuid-ossp.sh b/sources.wasm/9000-uuid-ossp.sh index a725d46..8f02f25 100755 --- a/sources.wasm/9000-uuid-ossp.sh +++ b/sources.wasm/9000-uuid-ossp.sh @@ -2,19 +2,39 @@ . ${CONFIG:-config} -. scripts/emsdk-fetch.sh -cd ${ROOT}/src -if [ -d uuid-1.6.2 ] +pushd ${ROOT}/src + +if [ -d libuuid ] then - echo ok + echo "using local source tree" else - #wget -c http://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz - #tar xfz uuid-1.6.2.tar.gz - git clone https://github.com/pygame-web/ossp-uuid uuid-1.6.2 + #wget -c http://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/libuuid.tar.gz + #tar xfz libuuid.tar.gz + + #wget -c http://deb.debian.org/debian/pool/main/o/ossp-uuid/ossp-uuid_1.6.4.orig.tar.gz + #tar xvfz ossp-uuid_1.6.4.orig.tar.gz + #mv ossp-uuid-UUID_1_6_4 libuuid + + git clone https://github.com/pygame-web/ossp-uuid libuuid + + #tar xfp /data/git/python-wasm-sdk/libuuid.tar + + pushd libuuid + # libtoolize && aclocal && autoheader && autoconf && autoreconf && automake --add-missing + #cp -vf /data/git/python-wasm-sdk/{libtool,shtool} ./ + cp -vf /data/git/python-wasm-sdk/shtool ./ + chmod u-w+x libtool shtool + popd + fi +popd + + +. scripts/emsdk-fetch.sh + INCDIR=$EMSDK/upstream/emscripten/cache/sysroot/include LIBDIR=$EMSDK/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten @@ -27,7 +47,7 @@ else mkdir -p $ROOT/build/libuuid - for mode in "--without-pic" "--with-pic" + for mode in "--without-pic" "--with-pic" do rm -rf $ROOT/build/libuuid/* pushd $ROOT/build/libuuid @@ -38,32 +58,61 @@ END ln -sf /bin/true bin/strip export PATH=$(pwd)/bin:$PATH - if CONFIG_SIZE=$(pwd)/config.site emconfigure ../../src/uuid-1.6.2/configure --with-gnu-ld $mode --disable-shared --prefix=$PREFIX + cp -vf /data/git/python-wasm-sdk/{libtool,shtool} /tmp/ + cp -vf /data/git/python-wasm-sdk/libtool ./ + chmod u-w+x /tmp/libtool /tmp/shtool libtool + + if PATH=/tmp:$PATH CONFIG_SIZE=$(pwd)/config.site emconfigure ../../src/libuuid/configure --with-gnu-ld $mode --disable-shared --prefix=$PREFIX then - emmake make - sed -i 's|luuid|lossp-uuid|g' uuid.pc - cp uuid.pc ../../src/uuid-1.6.2/ - echo "------ installing uuid ---------" - emmake make install - mkdir -p ${INCDIR}/ossp - mv $PREFIX/include/uuid.h ${INCDIR}/ossp/ + cp -vf /data/git/python-wasm-sdk/{libtool,shtool} /tmp/ + cp -vf /data/git/python-wasm-sdk/libtool ./ + chmod u-w+x /tmp/libtool /tmp/shtool libtool - cp -r ${INCDIR}/ossp $PREFIX/include/ + PATH=/tmp:$PATH emmake make +# LIBTOOL="'bash ${ROOT}/src/libuuid/libtool'" SHTOOL="'bash ${ROOT}/src/libuuid/shtool'" + sed -i 's|luuid|lossp-uuid|g' uuid.pc + cp uuid.pc ../../src/libuuid/ if echo $mode | grep -q with-pic then - mv $PREFIX/lib/libuuid.a $LIBDIR/pic/libossp-uuid.a + TARGETLIB=$LIBDIR/pic/libossp-uuid.a + else + TARGETLIB=$LIBDIR/libossp-uuid.a + fi + + + echo "------ installing uuid to $TARGETLIB ---------" + + if PATH=/tmp:$PATH emmake make install + then + mkdir -p ${INCDIR}/ossp + cp $PREFIX/include/uuid.h ${INCDIR}/ossp/ + cp -r ${INCDIR}/ossp $PREFIX/include/ + mv $PREFIX/lib/libuuid.a $TARGETLIB + rm $PREFIX/lib/libuuid.la + else + echo "FIXME: libtool wasm" + fi + + if [ -f $TARGETLIB ] + then + echo "normal build sucess" else - mv $PREFIX/lib/libuuid.a $LIBDIR/libossp-uuid.a + echo "TODO: fix uuid ossp for alpine" + mkdir -p ${INCDIR}/ossp + cp $PREFIX/include/uuid.h ${INCDIR}/ossp/ + cp -r ${INCDIR}/ossp $PREFIX/include/ + emar cr libuuid.a *.o + mv libuuid.a $TARGETLIB fi - rm $PREFIX/lib/libuuid.la + else echo " failed to build uuid-ossp " - exit 44 + exit 115 fi popd done