Skip to content

Commit 760d8b0

Browse files
committed
force pic in host static lib
1 parent 2c660e7 commit 760d8b0

File tree

5 files changed

+43
-21
lines changed

5 files changed

+43
-21
lines changed

python-wasm-sdk.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22
reset
3+
4+
# TODO: check how dbg tools work with default settings
5+
# https://developer.chrome.com/blog/wasm-debugging-2020/
6+
7+
38
. /etc/lsb-release
49
DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}"
510

@@ -15,8 +20,11 @@ sudo chmod 777 ${SDKDIR}
1520

1621
ORIGIN=$(pwd)
1722

23+
# 3.12 3.11 3.10
24+
25+
BUILDS=${BUILDS:-3.12 3.11 3.10}
1826

19-
for PYBUILD in 3.12 3.11 3.10
27+
for PYBUILD in $BUILDS
2028
do
2129
cd "$ORIGIN"
2230

scripts/cpython-build-emsdk-deps.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ then
157157
popd
158158
fi
159159

160-
[ -f ../devices/emsdk/usr/lib/libncursesw.a ]
161-
if true
160+
161+
if [ -f ../devices/emsdk/usr/lib/libncursesw.a ]
162162
then
163163
echo "
164164
* ncursesw already built

scripts/cpython-build-emsdk.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ else
121121

122122
# --with-tzpath="/usr/share/zoneinfo" \
123123

124-
export EMCC_CFLAGS="$CPOPTS"
124+
export EMCC_CFLAGS="$CPOPTS -I$PREFIX/include/ncursesw -sUSE_ZLIB -sUSE_BZIP2"
125125

126126
CPPFLAGS="$CPPFLAGS -I$PREFIX/include/ncursesw"
127127
CFLAGS="$CPPFLAGS -I$PREFIX/include/ncursesw"
@@ -150,15 +150,13 @@ _decimal
150150
END
151151

152152

153-
if EMCC_CFLAGS="-sUSE_ZLIB -sUSE_BZIP2" \
154-
emmake make -j$NPROC WASM_ASSETS_DIR=$(realpath ${PYTHONPYCACHEPREFIX}/empty)@/
153+
if emmake make -j$NPROC WASM_ASSETS_DIR=$(realpath ${PYTHONPYCACHEPREFIX}/empty)@/
155154
then
156-
EMCC_CFLAGS="-sUSE_ZLIB -sUSE_BZIP2" \
157155
emmake make WASM_ASSETS_DIR=$(realpath ${PYTHONPYCACHEPREFIX}/empty)@/ install
158156
else
159157
echo " **** cpython wasm build failed ***
160158
161-
EMCC_CFLAGS="-sUSE_ZLIB -sUSE_BZIP2" emmake make WASM_ASSETS_DIR=$(realpath ${PYTHONPYCACHEPREFIX}/empty)@/ install
159+
emmake make WASM_ASSETS_DIR=$(realpath ${PYTHONPYCACHEPREFIX}/empty)@/ install
162160
163161
" 1>&2
164162

@@ -180,7 +178,11 @@ EMCC_CFLAGS="-sUSE_ZLIB -sUSE_BZIP2" emmake make WASM_ASSETS_DIR=$(realpath ${PY
180178
# specific platform support
181179
cp -Rfv $ROOT/support/__EMSCRIPTEN__.patches/${PYBUILD}/. $HOST_PREFIX/lib/python${PYBUILD}/
182180

183-
cp -vf build/cpython-wasm/libpython3.*.a prebuilt/emsdk/
181+
cp -vf build/cpython-wasm/libpython${PYBUILD}.a prebuilt/emsdk/
182+
if [ -f build/cpython-wasm/Modules/expat/libexpat.a ]
183+
then
184+
cp build/cpython-wasm/Modules/expat/libexpat.a prebuilt/emsdk/libexpat${PYBUILD}.a
185+
fi
184186
rmdir $PREFIX/lib/python${PYBUILD}/lib-dynload
185187
fi
186188
fi
@@ -301,15 +303,19 @@ export PYTHONSTARTUP=$ROOT/support/__EMSCRIPTEN__.py
301303
# so include dirs are good
302304
export PYTHONHOME=$PREFIX
303305
306+
# so pip does not think everything in ~/.local is useable
307+
export HOME=${PYTHONPYCACHEPREFIX}
308+
309+
304310
# find sysconfig ( tweaked )
305311
# but still can load dynload and setuptools
306312
PYTHONPATH=$(echo -n ${HOST_PREFIX}/lib/python/\${PYBUILD}/site-packages):\$PYTHONPATH
307313
export PYTHONPATH=$PYTHONPYCACHEPREFIX/sysconfig:$(echo -n ${HOST_PREFIX}/lib/python\${PYBUILD}/lib-dynload):\$PYTHONPATH
308314
309315
310-
#probably useless
316+
# just in case
311317
export _PYTHON_HOST_PLATFORM=${PYDK_PYTHON_HOST_PLATFORM}
312-
export PYTHON_FOR_BUILD=${PYTHON_FOR_BUILD}
318+
export PYTHON_FOR_BUILD=${HOST_PREFIX}/bin/python\${PYBUILD}
313319
314320
${HOST_PREFIX}/bin/python\${PYBUILD} -u -B \$@
315321
END

scripts/cpython-build-host-deps.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ do
3535
fi
3636
done
3737

38+
if [ -f $HPFX/site-packages/distutils-precedence.pth ]
39+
then
40+
mv $HPFX/site-packages/distutils-precedence.pth $HPFX/
41+
fi
42+
43+
3844

3945
# https://github.com/aroberge/ideas, for code transformation
4046
$PIP install token-utils

scripts/cpython-build-host.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ END
5656
5757
END
5858

59-
60-
61-
# Prevent freezing bytecode with a different magic
62-
rm -f $HOST_PREFIX/bin/python3*
63-
64-
if command -v python3.${PYMINOR}
59+
if echo $PYBUILD|grep -q 3.12$
6560
then
66-
echo "
61+
# Prevent freezing bytecode with a different magic
62+
rm -f $HOST_PREFIX/bin/python3 $HOST_PREFIX/bin/python${PYBUILD}
63+
64+
if command -v python3.${PYMINOR}
65+
then
66+
echo "
6767
6868
===================================================================================
6969
@@ -73,14 +73,16 @@ END
7373
7474
===================================================================================
7575
76-
" 1>&2
77-
sleep 6
76+
" 1>&2
77+
sleep 6
78+
fi
7879
fi
7980

81+
8082
# OPT="$OPT"
8183
# CFLAGS="-DHAVE_FFI_PREP_CIF_VAR=1 -DHAVE_FFI_PREP_CLOSURE_LOC=1 -DHAVE_FFI_CLOSURE_ALLOC=1"
8284
if \
83-
CC=clang CXX=clang++ \
85+
CC=clang CXX=clang++ CFLAGS="-fPIC" CPPFLAGS="-fPIC" \
8486
${ROOT}/src/cpython/configure \
8587
--prefix=$HOST_PREFIX $PYOPTS
8688
then

0 commit comments

Comments
 (0)