|
| 1 | +set -ex |
| 2 | + |
| 3 | +LLVM_PKG_URL="https://github.com/IsabelParedes/llvm-project/releases/download/v20.1.7_emscripten-wasm32/llvm_emscripten-wasm32-20.1.7-h2e33cc4_5.tar.bz2" |
| 4 | +LLVM_PKG="llvm.tar.bz2" |
| 5 | +export LLVM_DIR=$HOME/llvm |
| 6 | + |
| 7 | +if [ ! -d "$LLVM_DIR" ]; then |
| 8 | + wget -O "$LLVM_PKG" "$LLVM_PKG_URL" |
| 9 | + mkdir -p $LLVM_DIR |
| 10 | + tar -xjvf $LLVM_PKG -C $LLVM_DIR --exclude='info/*' --exclude='share/*' --exclude='libexec/*' |
| 11 | +fi |
| 12 | + |
| 13 | +export EM_LLVM_ROOT=$LLVM_DIR |
| 14 | + |
| 15 | +echo "LLVM installation complete." |
| 16 | + |
| 17 | +# https://github.com/mesonbuild/meson/blob/e542901af6e30865715d3c3c18f703910a096ec0/mesonbuild/backend/ninjabackend.py#L94 |
| 18 | +# Prevent from using response file. The response file that meson generates is not compatible to pyodide-build |
| 19 | +export MESON_RSP_THRESHOLD=131072 |
| 20 | + |
| 21 | +export CFLAGS="-I$PREFIX/include/python3.13 $CFLAGS" |
| 22 | +export CXXFLAGS="-I$PREFIX/include/python3.13 $CXXFLAGS" |
| 23 | + |
| 24 | +# Patch mesonbuild/linkers/linkers.py - not sure what version we are patching? |
| 25 | +# meson 1.9.1 conda-forge, meson-python 0.18.0 conda-forge |
| 26 | +cp $RECIPE_DIR/meson_linkers.py $BUILD_PREFIX/lib/python3.13/site-packages/mesonbuild/linkers/linkers.py |
| 27 | + |
| 28 | +# Remove whitespace after '-s' in LDFLAGS |
| 29 | +export LDFLAGS="$(echo "${LDFLAGS}" | sed -E 's/-s +/-s/g')" |
| 30 | + |
| 31 | +# Use local flang-new-wrapper that does some arg mangling. |
| 32 | +cp $RECIPE_DIR/flang-new-wrapper $LLVM_DIR/bin/flang-new-wrapper |
| 33 | + |
| 34 | +export FC=$LLVM_DIR/bin/flang-new-wrapper |
| 35 | +export FFLAGS="-g --target=wasm32-unknown-emscripten -fPIC" |
| 36 | +export FCLIBS="-lFortranRuntime" |
| 37 | + |
| 38 | +export CFLAGS="$CFLAGS -fwasm-exceptions -sSUPPORT_LONGJMP=wasm" |
| 39 | +export CXXFLAGS="$CXXFLAGS -fwasm-exceptions -sSUPPORT_LONGJMP=wasm" |
| 40 | + |
| 41 | +# Note bracket after function name is important or 'sgesv' will also match 'sgesvd' |
| 42 | +cat void_to_int_return.txt | xargs -i sed -i -r 's/^void ({})\(/int \1(/g' scipy/linalg/cython_lapack_signatures.txt |
| 43 | +# Underscore after name is important |
| 44 | +cat void_to_int_return.txt | xargs -i sed -i -r 's/^void ({})_/int \1_/g' scipy/linalg/_matfuncs_expm.h |
| 45 | + |
| 46 | +# Add -Wl,--fatal-warnings to flags - this does not work |
| 47 | +export LDFLAGS="$LDFLAGS -Wl,--no-fatal-warnings" |
| 48 | + |
| 49 | +${PYTHON} -m pip install . ${PIP_ARGS} --no-build-isolation \ |
| 50 | + -Csetup-args="--cross-file=$RECIPE_DIR/emscripten.meson.cross" \ |
| 51 | + -Csetup-args="-Dfortran_std=none" \ |
| 52 | + -Csetup-args="-Duse-pythran=false" \ |
| 53 | + -Cbuild-dir="_build" \ |
| 54 | + -Ccompile-args="--verbose" |
0 commit comments