From 9fbb2972eb26dbeb262f9fc737bc4c0a11535420 Mon Sep 17 00:00:00 2001 From: Gyeongjae Choi Date: Mon, 4 Jul 2022 16:11:55 +0900 Subject: [PATCH] Remove freetype and png from the main module (#2813) --- Makefile.envs | 3 +-- packages/Pillow/meta.yaml | 6 ++++-- packages/libwebp/meta.yaml | 14 +++++++++++++- packages/matplotlib/meta.yaml | 9 +++++++-- packages/opencv-python/meta.yaml | 4 ++-- pyodide-build/pyodide_build/pywasmcross.py | 3 +-- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Makefile.envs b/Makefile.envs index 67edb9eca..891300a95 100644 --- a/Makefile.envs +++ b/Makefile.envs @@ -100,8 +100,7 @@ export MAIN_MODULE_LDFLAGS= $(LDFLAGS_BASE) \ -s EXPORT_NAME="'_createPyodideModule'" \ -s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules'] \ -s DEMANGLE_SUPPORT=1 \ - -s USE_FREETYPE=1 \ - -s USE_LIBPNG=1 \ + -s USE_ZLIB=1 \ -s FORCE_FILESYSTEM=1 \ -s TOTAL_MEMORY=20971520 \ -s ALLOW_MEMORY_GROWTH=1 \ diff --git a/packages/Pillow/meta.yaml b/packages/Pillow/meta.yaml index b86dc0aeb..37f580658 100644 --- a/packages/Pillow/meta.yaml +++ b/packages/Pillow/meta.yaml @@ -10,11 +10,13 @@ source: - - src/setup.cfg - ./setup.cfg build: + # RELOCATABLE flag is required because if affects how emscripten build ports. cflags: | + -s RELOCATABLE=1 -s USE_ZLIB=1 - -s USE_LIBJPEG=1 -s USE_FREETYPE=1 - -s SIDE_MODULE=1 + -s USE_LIBPNG=1 + -s USE_LIBJPEG=1 ldflags: | -ljpeg diff --git a/packages/libwebp/meta.yaml b/packages/libwebp/meta.yaml index 1786746f3..21bab81ae 100644 --- a/packages/libwebp/meta.yaml +++ b/packages/libwebp/meta.yaml @@ -9,6 +9,18 @@ source: build: library: true script: | - mkdir build && cd build && emcmake cmake -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX=${WASM_LIBRARY_DIR} ../ + mkdir build && cd build && emcmake cmake \ + -DCMAKE_C_FLAGS="-fPIC" \ + -DCMAKE_INSTALL_PREFIX=${WASM_LIBRARY_DIR} \ + -DWEBP_BUILD_CWEBP=OFF \ + -DWEBP_BUILD_DWEBP=OFF \ + -DWEBP_BUILD_VWEBP=OFF \ + -DWEBP_BUILD_GIF2WEBP=OFF \ + -DWEBP_BUILD_IMG2WEBP=OFF \ + -DWEBP_BUILD_WEBPINFO=OFF \ + -DWEBP_BUILD_WEBPINFO=OFF \ + -DWEBP_BUILD_WEBPMUX=OFF \ + -DWEBP_BUILD_EXTRAS=OFF \ + ../ emmake make -j ${PYODIDE_JOBS:-3} emmake make install diff --git a/packages/matplotlib/meta.yaml b/packages/matplotlib/meta.yaml index 88aeee596..6f2709536 100644 --- a/packages/matplotlib/meta.yaml +++ b/packages/matplotlib/meta.yaml @@ -22,8 +22,13 @@ source: - ./mplsetup.cfg build: - cflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1 - ldflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1 + # RELOCATABLE flag is required because if affects how emscripten build ports. + cflags: | + -s RELOCATABLE=1 + -s USE_FREETYPE=1 + -s USE_LIBPNG=1 + -s USE_ZLIB=1 + -fno-lto script: export SETUPTOOLS_SCM_PRETEND_VERSION=$PKG_VERSION post: | cd build/matplotlib-$PKG_VERSION/dist/matplotlib-$PKG_VERSION/ diff --git a/packages/opencv-python/meta.yaml b/packages/opencv-python/meta.yaml index 4055abc6c..caae9e8c3 100644 --- a/packages/opencv-python/meta.yaml +++ b/packages/opencv-python/meta.yaml @@ -25,12 +25,12 @@ requirements: - libwebp - libtiff build: + # RELOCATABLE flag is required because if affects how emscripten build ports. cxxflags: | - -fPIC + -s RELOCATABLE=1 -s USE_ZLIB=1 -s USE_LIBJPEG=1 -s USE_LIBPNG=1 - -s SIDE_MODULE=1 ldflags: | -ljpeg -lz diff --git a/pyodide-build/pyodide_build/pywasmcross.py b/pyodide-build/pyodide_build/pywasmcross.py index 4f12f73d2..2217553de 100755 --- a/pyodide-build/pyodide_build/pywasmcross.py +++ b/pyodide-build/pyodide_build/pywasmcross.py @@ -241,8 +241,7 @@ def replay_genargs_handle_dashl(arg: str, used_libs: set[str]) -> str | None: if arg == "-lffi": return None - # See https://github.com/emscripten-core/emscripten/issues/8650 - if arg in ["-lfreetype", "-lz", "-lpng", "-lgfortran"]: + if arg == "-lgfortran": return None # WASM link doesn't like libraries being included twice