Skip to content

Commit e5dc593

Browse files
committed
Use shared libraries for dependencies in pyodide
1 parent 33f9617 commit e5dc593

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

bin/pyodide_build_dependencies.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,18 @@ fi
129129
emmake make install
130130

131131
cd ..
132+
133+
134+
# ----------------Build shared libraries from static archives --------------#
135+
136+
137+
emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libgmp.so" \
138+
-Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libgmp.a" -Wl,--no-whole-archive
139+
140+
emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libmpfr.so" \
141+
-Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libmpfr.a" -Wl,--no-whole-archive \
142+
-L"$WASM_LIBRARY_DIR/lib" -lgmp
143+
144+
emcc -shared -sSIDE_MODULE=2 -o "$WASM_LIBRARY_DIR/lib/libflint.so" \
145+
-Wl,--whole-archive "$WASM_LIBRARY_DIR/lib/libflint.a" -Wl,--no-whole-archive \
146+
-L"$WASM_LIBRARY_DIR/lib" -lmpfr -lgmp

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,16 @@ repair-wheel-command = [
179179

180180
[tool.cibuildwheel.pyodide]
181181
before-all = "bin/cibw_before_all_pyodide.sh"
182-
before-build = "pip install wheel"
182+
before-build = "pip install wheel auditwheel_emscripten"
183183

184184
# This needs to be kept in sync with the Pyodide row in
185185
# .github/workflows/buildwheel.yml. The Pyodide version pins both an
186186
# Emscripten version and a CPython minor version. The command
187187
# `pyodide xbuildenv search --all` shows the compatible combinations.
188188
pyodide-version = "0.28.2"
189189

190-
# GMP, MPFR, and FLINT are built as static libraries for Pyodide.
190+
# GMP, MPFR, and FLINT are built as shared libraries for Pyodide and bundled
191+
# into the wheel.
191192
repair-wheel-command = [
192193
"""python bin/cibw_repair_wheel_licenses.py "{wheel}" \
193194
--license LGPL-3.0-or-later \
@@ -198,7 +199,7 @@ repair-wheel-command = [
198199
--license-file 'wasm-library-dir/src/flint-*/COPYING:python-flint.libs/flint-*/COPYING' \
199200
--license-file 'wasm-library-dir/src/flint-*/COPYING.LESSER:python-flint.libs/flint-*/COPYING.LESSER' \
200201
""",
201-
"cp \"{wheel}\" \"{dest_dir}\"",
202+
"pyodide auditwheel repair --libdir wasm-library-dir --output-dir {dest_dir} {wheel}",
202203
]
203204

204205
[tool.cibuildwheel.pyodide.environment]

0 commit comments

Comments
 (0)