Skip to content

Commit

Permalink
Use webassembly exception handling
Browse files Browse the repository at this point in the history
It's a bit hard to make the rust compiler play along, see the upstream
PR for the rust difficulties pyodide/pyodide-build#81
  • Loading branch information
hoodmane committed Jan 15, 2025
1 parent bcbeac9 commit 275f76f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile.envs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export MAIN_MODULE_LDFLAGS= $(LDFLAGS_BASE) \
-s LZ4=1 \
-s EXPORT_NAME="'_createPyodideModule'" \
-s EXPORT_EXCEPTION_HANDLING_HELPERS \
-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \
-fwasm-exceptions \
-sEXPORTED_RUNTIME_METHODS='wasmTable,ERRNO_CODES' \
-s USE_ZLIB \
-s USE_BZIP2 \
Expand Down
8 changes: 4 additions & 4 deletions packages/RobotRaconteur/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ requirements:
- numpy

build:
cxxflags: -fexceptions -fPIC -DBOOST_SP_DISABLE_THREADS=1 -O2
ldflags: -fexceptions
cxxflags: -fwasm-exceptions -fPIC -DBOOST_SP_DISABLE_THREADS=1 -O2
ldflags: -fwasm-exceptions
script: |
export INSTALL_DIR=${WASM_LIBRARY_DIR}
Expand All @@ -26,7 +26,7 @@ build:
-DNUMPY_INCLUDE_DIR=$HOSTINSTALLDIR/lib/python$PYMAJOR.$PYMINOR/site-packages/numpy/_core/include/ \
-DPYTHON3_INCLUDE_DIR=$PYTHONINCLUDE -DPYTHON3_EXECUTABLE=python$PYMAJOR.$PYMINOR \
-DPYTHON3_LIBRARY=$HOSTINSTALLDIR/lib/python$PYMAJOR.$PYMINOR.a \
-DCMAKE_CXX_FLAGS="-fPIC -fexceptions -DBOOST_AP_DISABLE_THREADS=1 -O2 -DBOOST_BIND_GLOBAL_PLACEHOLDERS=1 -Wno-enum-constexpr-conversion" \
-DCMAKE_CXX_FLAGS="-fPIC -fwasm-exceptions -DBOOST_AP_DISABLE_THREADS=1 -O2 -DBOOST_BIND_GLOBAL_PLACEHOLDERS=1 -Wno-enum-constexpr-conversion" \
-DBoost_INCLUDE_DIR=$WASM_LIBRARY_DIR/include -DBoost_LIBRARY_DIR=$WASM_LIBRARY_DIR/lib \
-DBoost_DATE_TIME_LIBRARY_RELEASE=$WASM_LIBRARY_DIR/lib/libboost_date_time.a \
-DBoost_DATE_TIME_LIBRARY_DEBUG=$WASM_LIBRARY_DIR/lib/libboost_date_time.a \
Expand All @@ -48,7 +48,7 @@ build:
-DUSE_PREGENERATED_SOURCE=ON \
.
emmake make -j ${PYODIDE_JOBS:-3}
emcc ${SIDE_MODULE_LDFLAGS} -fexceptions out/lib/libRobotRaconteurCore.a \
emcc ${SIDE_MODULE_LDFLAGS} -fwasm-exceptions out/lib/libRobotRaconteurCore.a \
out/Python3/RobotRaconteur/_RobotRaconteurPython.a \
$WASM_LIBRARY_DIR/lib/libboost_chrono.a \
$WASM_LIBRARY_DIR/lib/libboost_date_time.a \
Expand Down
4 changes: 2 additions & 2 deletions packages/boost-cpp/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ build:
./b2 variant=release toolset=clang-emscripten link=static threading=single \
--with-date_time --with-filesystem \
--with-system --with-regex --with-chrono --with-random --with-program_options --disable-icu \
cxxflags="$SIDE_MODULE_CXXFLAGS -fexceptions -DBOOST_SP_DISABLE_THREADS=1" \
cflags="$SIDE_MODULE_CFLAGS -fexceptions -DBOOST_SP_DISABLE_THREADS=1" \
cxxflags="$SIDE_MODULE_CXXFLAGS -fwasm-exceptions -DBOOST_SP_DISABLE_THREADS=1" \
cflags="$SIDE_MODULE_CFLAGS -fwasm-exceptions -DBOOST_SP_DISABLE_THREADS=1" \
linkflags="-fpic $SIDE_MODULE_LDFLAGS" \
--layout=system -j"${PYODIDE_JOBS:-3}" --prefix=${INSTALL_DIR} \
install
Expand Down
6 changes: 3 additions & 3 deletions packages/casadi/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ requirements:
build:
exports: requested
cflags: |
-fexceptions -frtti
-fwasm-exceptions -frtti
cxxflags: |
-fexceptions -frtti
-fwasm-exceptions -frtti
ldflags: |
-fexceptions
-fwasm-exceptions
about:
home: http://casadi.org
PyPI: https://pypi.org/project/casadi
Expand Down
6 changes: 3 additions & 3 deletions packages/coolprop/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ source:
- ./pyproject.toml

build:
cflags: -fexceptions
cxxflags: -fexceptions
ldflags: -fexceptions
cflags: -fwasm-exceptions
cxxflags: -fwasm-exceptions
ldflags: -fwasm-exceptions

requirements:
run:
Expand Down
8 changes: 4 additions & 4 deletions packages/cpp-exceptions-test/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ source:
build:
type: shared_library
script: |
em++ ${SIDE_MODULE_CFLAGS} -fexceptions -I${PYTHONINCLUDE} -flto -fno-lto -std=c++20 -c throw.cpp -o throw.o
em++ ${SIDE_MODULE_CFLAGS} -fexceptions -I${PYTHONINCLUDE} -flto -fno-lto -std=c++20 -c catch.cpp -o catch.o -mreference-types
em++ ${SIDE_MODULE_LDFLAGS} -fexceptions -o ${DISTDIR}/cpp-exceptions-test-throw.so throw.o
em++ ${SIDE_MODULE_LDFLAGS} -fexceptions -o ${DISTDIR}/cpp-exceptions-test-catch.so catch.o
em++ ${SIDE_MODULE_CFLAGS} -fwasm-exceptions -I${PYTHONINCLUDE} -flto -fno-lto -std=c++20 -c throw.cpp -o throw.o
em++ ${SIDE_MODULE_CFLAGS} -fwasm-exceptions -I${PYTHONINCLUDE} -flto -fno-lto -std=c++20 -c catch.cpp -o catch.o -mreference-types
em++ ${SIDE_MODULE_LDFLAGS} -fwasm-exceptions -o ${DISTDIR}/cpp-exceptions-test-throw.so throw.o
em++ ${SIDE_MODULE_LDFLAGS} -fwasm-exceptions -o ${DISTDIR}/cpp-exceptions-test-catch.so catch.o
about:
license: MPL-2.0
4 changes: 2 additions & 2 deletions packages/cpp-exceptions-test2/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package:
source:
path: src
build:
cxxflags: -fexceptions
ldflags: -fexceptions
cxxflags: -fwasm-exceptions
ldflags: -fwasm-exceptions
about:
license: MPL-2.0
6 changes: 3 additions & 3 deletions packages/matplotlib/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ build:
-s USE_FREETYPE=1
-s USE_LIBPNG=1
-s USE_ZLIB=1
-fexceptions
-fwasm-exceptions
-fno-lto
cxxflags: |
-std=c++14
-fexceptions
-fwasm-exceptions
ldflags: |
-fexceptions
-fwasm-exceptions
script: export SETUPTOOLS_SCM_PRETEND_VERSION=$PKG_VERSION
post: |
rm -rf matplotlib/backends/qt_editor
Expand Down
4 changes: 2 additions & 2 deletions packages/scipy/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ build:
-DUNDERSCORE_G77
-fvisibility=default
cxxflags: |
-fexceptions
-fwasm-exceptions
-fvisibility=default
ldflags: |
-L$(NUMPY_LIB)/core/lib/
-L$(NUMPY_LIB)/random/lib/
-fexceptions
-fwasm-exceptions
# Exclude tests via Meson's install tags functionality.
unvendor-tests: true
Expand Down
4 changes: 2 additions & 2 deletions packages/shapely/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ build:
script: |
export GEOS_CONFIG=${WASM_LIBRARY_DIR}/bin/geos-config
cxxflags: |
-fexceptions
-fwasm-exceptions
ldflags: |
-fexceptions
-fwasm-exceptions
requirements:
run:
- numpy
Expand Down
2 changes: 1 addition & 1 deletion pyodide-build

0 comments on commit 275f76f

Please sign in to comment.