From 5fe352afb879731f035569039f9dffe4a3699876 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Fri, 27 Nov 2026 11:39:00 +0100 Subject: [PATCH 01/10] Add petsc - PETSc 3.26.1 for emscripten-wasm32/wasm64, serial static build - Bundles PETSc's C f2cblaslapack (no Fortran, no flang runtime) - Drops PETSC_HAVE_SYS_PROCFS_H (batch-mode false positive) - Defines PETSC_DIR in .pc files for strict pkg-config 0.29.2 --- recipes/recipes_wasm/petsc/build.sh | 61 ++++++++++++++++++++ recipes/recipes_wasm/petsc/recipe.yaml | 71 ++++++++++++++++++++++++ recipes/recipes_wasm/petsc/test_petsc.c | 70 +++++++++++++++++++++++ recipes/recipes_wasm/petsc/test_petsc.sh | 12 ++++ 4 files changed, 214 insertions(+) create mode 100755 recipes/recipes_wasm/petsc/build.sh create mode 100644 recipes/recipes_wasm/petsc/recipe.yaml create mode 100644 recipes/recipes_wasm/petsc/test_petsc.c create mode 100755 recipes/recipes_wasm/petsc/test_petsc.sh diff --git a/recipes/recipes_wasm/petsc/build.sh b/recipes/recipes_wasm/petsc/build.sh new file mode 100755 index 00000000000..1d9097c1c9c --- /dev/null +++ b/recipes/recipes_wasm/petsc/build.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -eux + +export PYTHON=${PYTHON:-$(command -v python3)} +export PETSC_DIR=$SRC_DIR +export PETSC_ARCH=arch-emscripten + +# 1. Build PETSc's C BLAS/LAPACK (second source, extracted to +# $SRC_DIR/f2cblaslapack with its own top dir flattened). Its makefile pulls +# PETSc's *build-time* conf, which does not exist yet; drop that include and +# drive the compilers directly. +cd "$SRC_DIR/f2cblaslapack" +sed -i '/^include \${PETSC_DIR}/d' makefile +make -j"${CPU_COUNT}" CC=emcc AR=emar RANLIB=emranlib COPTFLAGS="-O2" \ + blas_lib lapack_lib +mkdir -p "$PREFIX/lib" +cp libf2cblas.a libf2clapack.a "$PREFIX/lib/" + +# 2. Configure PETSc in batch (cross-compile) mode against those archives. +cd "$PETSC_DIR" +"$PYTHON" ./configure \ + --with-cc=emcc \ + --with-cxx=0 \ + --with-fc=0 \ + --with-ar=emar \ + --with-ranlib=emranlib \ + --with-batch \ + --with-mpi=0 \ + --with-x=0 \ + --with-shared-libraries=0 \ + --with-debugging=0 \ + COPTFLAGS="-O2" \ + --with-blas-lib="[$PREFIX/lib/libf2cblas.a]" \ + --with-lapack-lib="[$PREFIX/lib/libf2clapack.a]" \ + --prefix="$PREFIX" + +# 3. Batch mode probes headers with the preprocessor only, so it "finds" +# , which exists in emscripten's sysroot but is unusable +# (undeclared elf_gregset_t) and breaks src/sys/memory/mem.c. +sed -i '/PETSC_HAVE_SYS_PROCFS_H/d' "$PETSC_ARCH/include/petscconf.h" + +# 4. Build and install (install-lib skips ~60 MB of examples/data). +make -j"${CPU_COUNT}" all +make install-lib + +# 5. Strip build-env tool paths; keep the tool names so they resolve on PATH. +for f in $(grep -rl "$BUILD_PREFIX/bin/" "$PREFIX/lib/petsc" 2>/dev/null); do + sed -i "s|$BUILD_PREFIX/bin/||g" "$f" +done + +# 6. PETSc's .pc files expand ${PETSC_DIR} without defining it; strict +# pkg-config (0.29.2, as opposed to 3.x) then rejects the file outright. +for pc in "$PREFIX"/lib/pkgconfig/petsc.pc "$PREFIX"/lib/pkgconfig/PETSc.pc; do + sed -i '/^prefix=/a PETSC_DIR=${prefix}' "$pc" +done + +# 7. Drop build-only leftovers. +rm -f "$PREFIX"/lib/petsc/conf/configure-hash \ + "$PREFIX"/lib/petsc/conf/pkg.conf.f2cblaslapack +rm -rf "$PREFIX"/share/petsc/examples/src +find "$PREFIX" -name '*.pyc' -delete diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml new file mode 100644 index 00000000000..6e21bc15aa8 --- /dev/null +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -0,0 +1,71 @@ +context: + name: petsc + version: 3.26.1 + f2c_version: 3.8.0.q2 + +package: + name: ${{ name }} + version: ${{ version }} + +source: +- url: https://pypi.io/packages/source/p/petsc/petsc-${{ version }}.tar.gz + sha256: a4dc46c1b4403545ac2274741ce10801366c4a9a7b2683b678d18f6663b93496 +- url: https://web.cels.anl.gov/projects/petsc/download/externalpackages/f2cblaslapack-${{ f2c_version }}.tar.gz + sha256: 12fa8d5001e313aeeea22eb2054883f59e3e3c656f11129f31abb02ddbf8ad60 + target_directory: f2cblaslapack + +build: + number: 0 + script: build.sh + +requirements: + build: + - ${{ compiler('c') }} + - make + - python + - cmake + - pkg-config + run_exports: + - ${{ pin_subpackage('petsc', upper_bound='x.x') }} + +tests: +- package_contents: + files: + - include/petsc.h + - include/petscconf.h + - lib/libpetsc.a + - lib/libf2cblas.a + - lib/libf2clapack.a + - lib/pkgconfig/PETSc.pc +- script: test_petsc.sh + files: + recipe: + - test_petsc.c + - test_petsc.sh + requirements: + build: + - ${{ compiler('c') }} + - nodejs + - pkg-config +- script: generic-testing --allow-pthread + requirements: + build: + - generic-testing + +about: + homepage: https://petsc.org/ + repository: https://gitlab.com/petsc/petsc + license: BSD-2-Clause + license_file: LICENSE + summary: Portable, Extensible Toolkit for Scientific Computation + description: | + PETSc is a suite of data structures and routines for the scalable solution of + scientific applications modeled by partial differential equations. This + WebAssembly build is serial (PETSc MPIUNI) and static, and bundles PETSc's C + translation of BLAS/LAPACK (f2cblaslapack), so consumers need no Fortran + compiler and no flang runtime. + documentation: https://petsc.org/release/ + +extra: + recipe-maintainers: + - Copilot diff --git a/recipes/recipes_wasm/petsc/test_petsc.c b/recipes/recipes_wasm/petsc/test_petsc.c new file mode 100644 index 00000000000..1e4a0c15066 --- /dev/null +++ b/recipes/recipes_wasm/petsc/test_petsc.c @@ -0,0 +1,70 @@ +#include + +static char help[] = "PETSc smoke test: dense LU solve (LAPACK) and MatMult (BLAS).\n"; + +int main(int argc, char **argv) +{ + Mat A; + Vec x, b, u, u2, b2; + KSP ksp; + PetscReal norm; + PetscInt n = 4, i, its; + + PetscFunctionBeginUser; + PetscCall(PetscInitialize(&argc, &argv, NULL, help)); + + /* 1. LAPACK path: dense LU factorization + solve (PC LU -> dgetrf/dgetrs). */ + PetscCall(MatCreateSeqDense(PETSC_COMM_SELF, n, n, NULL, &A)); + for (i = 0; i < n; i++) { + PetscCall(MatSetValue(A, i, i, (PetscScalar)(2 + i), INSERT_VALUES)); + if (i + 1 < n) PetscCall(MatSetValue(A, i, i + 1, (PetscScalar)-1, INSERT_VALUES)); + if (i > 0) PetscCall(MatSetValue(A, i, i - 1, (PetscScalar)-1, INSERT_VALUES)); + } + PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY)); + PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY)); + + PetscCall(VecCreateSeq(PETSC_COMM_SELF, n, &u)); + PetscCall(VecDuplicate(u, &b)); + PetscCall(VecDuplicate(u, &x)); + PetscCall(VecSet(u, 1.0)); + PetscCall(MatMult(A, u, b)); + + PetscCall(KSPCreate(PETSC_COMM_SELF, &ksp)); + PetscCall(KSPSetType(ksp, KSPPREONLY)); + PetscCall(KSPSetOperators(ksp, A, A)); + PetscCall(KSPSetFromOptions(ksp)); + PetscCall(KSPSolve(ksp, b, x)); + PetscCall(VecAXPY(x, -1.0, u)); + PetscCall(VecNorm(x, NORM_2, &norm)); + PetscCall(KSPGetIterationNumber(ksp, &its)); + PetscCheck(norm < 1e-10, PETSC_COMM_SELF, PETSC_ERR_PLIB, "LU residual %g too large", (double)norm); + PetscCall(PetscPrintf(PETSC_COMM_SELF, "dense LU residual=%.3e its=%" PetscInt_FMT "\n", (double)norm, its)); + PetscCall(KSPDestroy(&ksp)); + PetscCall(VecDestroy(&x)); + PetscCall(VecDestroy(&b)); + PetscCall(VecDestroy(&u)); + PetscCall(MatDestroy(&A)); + + /* 2. BLAS path: dense MatMult (dgemv) on a 2x2 system; ||[3,4]|| = 5. */ + PetscCall(MatCreateSeqDense(PETSC_COMM_SELF, 2, 2, NULL, &A)); + PetscCall(MatSetValue(A, 0, 0, (PetscScalar)2.0, INSERT_VALUES)); + PetscCall(MatSetValue(A, 0, 1, (PetscScalar)1.0, INSERT_VALUES)); + PetscCall(MatSetValue(A, 1, 0, (PetscScalar)1.0, INSERT_VALUES)); + PetscCall(MatSetValue(A, 1, 1, (PetscScalar)3.0, INSERT_VALUES)); + PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY)); + PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY)); + + PetscCall(VecCreateSeq(PETSC_COMM_SELF, 2, &u2)); + PetscCall(VecDuplicate(u2, &b2)); + PetscCall(VecSet(u2, 1.0)); + PetscCall(MatMult(A, u2, b2)); + PetscCall(VecNorm(b2, NORM_2, &norm)); + PetscCheck(PetscAbsReal(norm - 5.0) < 1e-12, PETSC_COMM_SELF, PETSC_ERR_PLIB, "MatMult norm %g", (double)norm); + PetscCall(PetscPrintf(PETSC_COMM_SELF, "BLAS MatMult norm=%g\n", (double)norm)); + PetscCall(VecDestroy(&b2)); + PetscCall(VecDestroy(&u2)); + PetscCall(MatDestroy(&A)); + + PetscCall(PetscFinalize()); + return 0; +} diff --git a/recipes/recipes_wasm/petsc/test_petsc.sh b/recipes/recipes_wasm/petsc/test_petsc.sh new file mode 100755 index 00000000000..3cfb8a9690d --- /dev/null +++ b/recipes/recipes_wasm/petsc/test_petsc.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eux + +export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" +emcc test_petsc.c -o test_petsc.js \ + -sEXIT_RUNTIME=1 \ + -sALLOW_MEMORY_GROWTH=1 \ + $(pkg-config --cflags PETSc) \ + $(pkg-config --static --libs PETSc) + +node test_petsc.js -pc_type lu +node test_petsc.js -ksp_type gmres -pc_type jacobi -ksp_rtol 1e-13 From 545b38fb809e80c83dd26a6dcd7ae083f2130af7 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:51:03 +0100 Subject: [PATCH 02/10] Add petsc4py to the petsc recipe - Second output builds petsc4py from the tree in the PETSc sdist - Patch skips rpath flags: wasm-ld rejects --enable-new-dtags, and sys.platform is 'unknown' under cross-python so upstream's guard misses - prefix_detection.ignore: conda's ELF-style binary prefix rewrite corrupts wasm side modules (build.dynamic_linking is ignored by rattler-build) - Verified: wasm32 + wasm64, dense LU residual 0, petsc4py solve on all three pytester backends --- recipes/recipes_wasm/petsc/build_petsc4py.sh | 13 ++ .../0001-skip-rpath-for-static-petsc.patch | 38 ++++ recipes/recipes_wasm/petsc/recipe.yaml | 163 ++++++++++++++---- recipes/recipes_wasm/petsc/test_petsc4py.py | 35 ++++ 4 files changed, 215 insertions(+), 34 deletions(-) create mode 100755 recipes/recipes_wasm/petsc/build_petsc4py.sh create mode 100644 recipes/recipes_wasm/petsc/patches/0001-skip-rpath-for-static-petsc.patch create mode 100644 recipes/recipes_wasm/petsc/test_petsc4py.py diff --git a/recipes/recipes_wasm/petsc/build_petsc4py.sh b/recipes/recipes_wasm/petsc/build_petsc4py.sh new file mode 100755 index 00000000000..4be8e1335f5 --- /dev/null +++ b/recipes/recipes_wasm/petsc/build_petsc4py.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -eux + +# petsc4py lives in the PETSc sdist and builds against the installed PETSc. +export PETSC_DIR="$PREFIX" +unset PETSC_ARCH + +# numpy is a wasm wheel, so it cannot be imported by the build interpreter; +# petsc4py takes the include dir from this variable instead of numpy.get_include(). +export NUMPY_INCLUDE="$PREFIX/lib/python${PY_VER}/site-packages/numpy/_core/include" + +cd "$SRC_DIR/src/binding/petsc4py" +"$PYTHON" -m pip install . --no-deps --no-build-isolation -vv diff --git a/recipes/recipes_wasm/petsc/patches/0001-skip-rpath-for-static-petsc.patch b/recipes/recipes_wasm/petsc/patches/0001-skip-rpath-for-static-petsc.patch new file mode 100644 index 00000000000..973f393c9b0 --- /dev/null +++ b/recipes/recipes_wasm/petsc/patches/0001-skip-rpath-for-static-petsc.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: omp +Date: Fri, 28 Nov 2026 10:00:00 +0100 +Subject: [PATCH] Skip rpath flags for static PETSc + +distutils turns ``runtime_library_dirs`` into ``-Wl,--enable-new-dtags +-Wl,-rpath,``. Under emscripten the compiler is ``emcc`` and the +linker step is ``wasm-ld``, which rejects ``--enable-new-dtags``: + + wasm-ld: error: unknown argument: --enable-new-dtags + +The guard upstream uses is ``sys.platform != 'win32'``, but under +cross-python ``sys.platform`` is ``unknown`` (the host interpreter reports +the build machine), so it does not trigger. ``sysconfig.get_platform()`` +here is ``unknown-wasm32``, and there is no ``sys.platform`` value for +emscripten at all. + +An rpath is meaningless for this build anyway: PETSc is installed static +(``BUILDSHAREDLIB = no``) and the extension modules are emscripten side +modules, which do not resolve libraries through the dynamic loader. So +gate the rpath block on PETSc actually being shared, which is also correct +for the non-emscripten static case. + +--- a/src/binding/petsc4py/conf/confpetsc.py ++++ b/src/binding/petsc4py/conf/confpetsc.py +@@ -317,8 +317,10 @@ + '-L{} {}'.format(self['PETSC_LIB_DIR'], self['PETSC_LIB_BASIC']), + ) + petsc_lib = flaglist(lib_flags) +- # runtime_library_dirs is not supported on Windows +- if sys.platform != 'win32': ++ # runtime_library_dirs is not supported on Windows, and it is ++ # pointless for static PETSc: distutils would pass ++ # -Wl,--enable-new-dtags, which wasm-ld rejects. ++ if sys.platform != 'win32' and self['BUILDSHAREDLIB'] == 'yes': + # if DESTDIR is set, then we're building against PETSc in a staging + # directory, but rpath needs to point to final install directory. + rpath = [strip_prefix(self.DESTDIR, self['PETSC_LIB_DIR'])] diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index 6e21bc15aa8..bca5a0fd3b5 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -3,54 +3,151 @@ context: version: 3.26.1 f2c_version: 3.8.0.q2 -package: - name: ${{ name }} - version: ${{ version }} - source: - url: https://pypi.io/packages/source/p/petsc/petsc-${{ version }}.tar.gz sha256: a4dc46c1b4403545ac2274741ce10801366c4a9a7b2683b678d18f6663b93496 + patches: + - patches/0001-skip-rpath-for-static-petsc.patch - url: https://web.cels.anl.gov/projects/petsc/download/externalpackages/f2cblaslapack-${{ f2c_version }}.tar.gz sha256: 12fa8d5001e313aeeea22eb2054883f59e3e3c656f11129f31abb02ddbf8ad60 target_directory: f2cblaslapack build: number: 0 - script: build.sh -requirements: +outputs: +# PETSc itself: serial, static, with PETSc's own C BLAS/LAPACK. +- package: + name: ${{ name }} + version: ${{ version }} + build: - - ${{ compiler('c') }} - - make - - python - - cmake - - pkg-config - run_exports: - - ${{ pin_subpackage('petsc', upper_bound='x.x') }} + script: build.sh -tests: -- package_contents: - files: - - include/petsc.h - - include/petscconf.h - - lib/libpetsc.a - - lib/libf2cblas.a - - lib/libf2clapack.a - - lib/pkgconfig/PETSc.pc -- script: test_petsc.sh - files: - recipe: - - test_petsc.c - - test_petsc.sh requirements: build: - ${{ compiler('c') }} - - nodejs + - make + - python + - cmake - pkg-config -- script: generic-testing --allow-pthread + run_exports: + - ${{ pin_subpackage('petsc', upper_bound='x.x') }} + + tests: + - package_contents: + files: + - include/petsc.h + - include/petscconf.h + - lib/libpetsc.a + - lib/libf2cblas.a + - lib/libf2clapack.a + - lib/pkgconfig/PETSc.pc + - script: test_petsc.sh + files: + recipe: + - test_petsc.c + - test_petsc.sh + requirements: + build: + - ${{ compiler('c') }} + - nodejs + - pkg-config + - script: generic-testing --allow-pthread + requirements: + build: + - generic-testing + + about: + homepage: https://petsc.org/ + repository: https://gitlab.com/petsc/petsc + license: BSD-2-Clause + license_file: LICENSE + summary: Portable, Extensible Toolkit for Scientific Computation + description: | + PETSc is a suite of data structures and routines for the scalable solution of + scientific applications modeled by partial differential equations. This + WebAssembly build is serial (PETSc MPIUNI) and static, and bundles PETSc's C + translation of BLAS/LAPACK (f2cblaslapack), so consumers need no Fortran + compiler and no flang runtime. + documentation: https://petsc.org/release/ + +# Python bindings, built from the petsc4py tree shipped inside the PETSc sdist. +- package: + name: petsc4py + version: ${{ version }} + + build: + script: build_petsc4py.sh + # conda's binary prefix relocation is ELF-oriented and corrupts wasm side + # modules: it rewrites bytes inside the code section, not just strings. + # (build.dynamic_linking.binary_relocation is conda-build only and is + # ignored by rattler-build.) The extension links PETSc statically, so it + # needs no prefix rewriting. + prefix_detection: + ignore: true + files: + exclude: + - '**/__pycache__/**' + - '**/*.pyc' + - '**/test_*.py' + python: + skip_pyc_compilation: + - '**/*.py' + requirements: build: - - generic-testing + - ${{ compiler('c') }} + - cross-python_${{ target_platform }} + - python + - pip + - setuptools + - cython >=3 + host: + - ${{ pin_subpackage('petsc', exact=True) }} + - python-dev + - numpy + - cython >=3 + - setuptools + - pip + run: + - python + - numpy + + tests: + - package_contents: + site_packages: + - petsc4py/__init__.py + - petsc4py/PETSc.pyi + - petsc4py/lib/petsc.cfg + files: + - lib/python*/site-packages/petsc4py/lib/PETSc*.so + - lib/python*/site-packages/petsc4py/include/petsc4py/petsc4py.h + - script: pytester + files: + recipe: + - test_petsc4py.py + requirements: + build: + - pytester + run: + - pytester-run + - script: generic-testing --allow-pthread + requirements: + build: + - generic-testing + + about: + homepage: https://petsc.org/ + repository: https://gitlab.com/petsc/petsc + license: BSD-2-Clause + license_file: src/binding/petsc4py/LICENSE.rst + summary: PETSc for Python + description: | + petsc4py is a Python binding for PETSc, the Portable, Extensible Toolkit for + Scientific Computation. This WebAssembly build follows the serial static PETSc + package in the same recipe and links PETSc into the extension module, so no + extra libraries are needed at runtime. about: homepage: https://petsc.org/ @@ -60,10 +157,8 @@ about: summary: Portable, Extensible Toolkit for Scientific Computation description: | PETSc is a suite of data structures and routines for the scalable solution of - scientific applications modeled by partial differential equations. This - WebAssembly build is serial (PETSc MPIUNI) and static, and bundles PETSc's C - translation of BLAS/LAPACK (f2cblaslapack), so consumers need no Fortran - compiler and no flang runtime. + scientific applications modeled by partial differential equations. This recipe + produces the serial static WebAssembly PETSc library and the petsc4py bindings. documentation: https://petsc.org/release/ extra: diff --git a/recipes/recipes_wasm/petsc/test_petsc4py.py b/recipes/recipes_wasm/petsc/test_petsc4py.py new file mode 100644 index 00000000000..1716d9c1952 --- /dev/null +++ b/recipes/recipes_wasm/petsc/test_petsc4py.py @@ -0,0 +1,35 @@ +def test_petsc4py_solve(): + import petsc4py + + petsc4py.init([]) + from petsc4py import PETSc + + assert petsc4py.__version__ == "3.26.1" + + A = PETSc.Mat().create() + A.setSizes([3, 3]) + A.setType("dense") + A.setUp() + A[0, 0] = 4.0 + A[0, 1] = -1.0 + A[1, 0] = -1.0 + A[1, 1] = 4.0 + A[1, 2] = -1.0 + A[2, 1] = -1.0 + A[2, 2] = 4.0 + A.assemble() + + u = PETSc.Vec().createSeq(3) + u.set(1.0) + b = A.createVecRight() + A.mult(u, b) + + ksp = PETSc.KSP().create() + ksp.setOperators(A) + ksp.setType("preonly") + ksp.getPC().setType("lu") + x = b.duplicate() + ksp.solve(b, x) + + x.axpy(-1.0, u) + assert x.norm() < 1e-10, x.norm() From 9138aee1f83431046173a7a02791c2e5a6427001 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Sat, 28 Nov 2026 19:34:30 +0100 Subject: [PATCH 03/10] Narrow petsc4py prefix detection to binaries prefix_detection.ignore skipped text relocation too, leaving the build dir in petsc4py/lib/petsc.cfg. ignore_binary_files leaves the wasm side module untouched and still rewrites the .cfg at install. - test asserts PETSC_DIR is not a build path (caught at $PREFIX) --- recipes/recipes_wasm/petsc/recipe.yaml | 6 +++--- recipes/recipes_wasm/petsc/test_petsc4py.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index bca5a0fd3b5..e371d9804b3 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -82,10 +82,10 @@ outputs: # conda's binary prefix relocation is ELF-oriented and corrupts wasm side # modules: it rewrites bytes inside the code section, not just strings. # (build.dynamic_linking.binary_relocation is conda-build only and is - # ignored by rattler-build.) The extension links PETSc statically, so it - # needs no prefix rewriting. + # ignored by rattler-build.) Text files still get relocated, so + # petsc4py/lib/petsc.cfg picks up the install prefix. prefix_detection: - ignore: true + ignore_binary_files: true files: exclude: - '**/__pycache__/**' diff --git a/recipes/recipes_wasm/petsc/test_petsc4py.py b/recipes/recipes_wasm/petsc/test_petsc4py.py index 1716d9c1952..e5864f5fdc4 100644 --- a/recipes/recipes_wasm/petsc/test_petsc4py.py +++ b/recipes/recipes_wasm/petsc/test_petsc4py.py @@ -6,6 +6,12 @@ def test_petsc4py_solve(): assert petsc4py.__version__ == "3.26.1" + # petsc4py/lib/petsc.cfg records the prefix at install time; if conda's + # prefix relocation is skipped it keeps the build directory + # (output/bld/rattler-build_...), which never exists in a user env. + conf = petsc4py.get_config() + assert "/output/bld/" not in conf["PETSC_DIR"], conf["PETSC_DIR"] + A = PETSc.Mat().create() A.setSizes([3, 3]) A.setType("dense") From 39d9d1f915322501c20511bee483107b2c68cb35 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Sun, 29 Nov 2026 00:10:32 +0100 Subject: [PATCH 04/10] Drop version assertion, set maintainer emci auto-updates the version, so pinning it in a test breaks on every bump. - recipe-maintainers: Alex-PLACET --- recipes/recipes_wasm/petsc/recipe.yaml | 2 +- recipes/recipes_wasm/petsc/test_petsc4py.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index e371d9804b3..693b4ae72d0 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -163,4 +163,4 @@ about: extra: recipe-maintainers: - - Copilot + - Alex-PLACET diff --git a/recipes/recipes_wasm/petsc/test_petsc4py.py b/recipes/recipes_wasm/petsc/test_petsc4py.py index e5864f5fdc4..e50eeb5a8c5 100644 --- a/recipes/recipes_wasm/petsc/test_petsc4py.py +++ b/recipes/recipes_wasm/petsc/test_petsc4py.py @@ -4,8 +4,6 @@ def test_petsc4py_solve(): petsc4py.init([]) from petsc4py import PETSc - assert petsc4py.__version__ == "3.26.1" - # petsc4py/lib/petsc.cfg records the prefix at install time; if conda's # prefix relocation is skipped it keeps the build directory # (output/bld/rattler-build_...), which never exists in a user env. From 01cc389f378d6eb0b80a6c5aa4415dc7df730478 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:39:49 +0100 Subject: [PATCH 05/10] Add f2cblaslapack-static PETSc's C translation of BLAS/LAPACK as a standalone static package. - Plain C ABI: no hidden Fortran CHARACTER lengths, no Fortran runtime - Ships libf2cblas.a + libf2clapack.a and f2cblas/f2clapack .pc files - Verified wasm32 + wasm64: dgemm, dnrm2, dgetrf/dgetrs from C --- recipes/recipes_wasm/f2cblaslapack/LICENSE | 27 ++++++++ recipes/recipes_wasm/f2cblaslapack/build.sh | 40 ++++++++++++ .../recipes_wasm/f2cblaslapack/recipe.yaml | 64 +++++++++++++++++++ .../f2cblaslapack/test_f2cblaslapack.c | 64 +++++++++++++++++++ .../f2cblaslapack/test_f2cblaslapack.sh | 12 ++++ 5 files changed, 207 insertions(+) create mode 100644 recipes/recipes_wasm/f2cblaslapack/LICENSE create mode 100755 recipes/recipes_wasm/f2cblaslapack/build.sh create mode 100644 recipes/recipes_wasm/f2cblaslapack/recipe.yaml create mode 100644 recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.c create mode 100755 recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.sh diff --git a/recipes/recipes_wasm/f2cblaslapack/LICENSE b/recipes/recipes_wasm/f2cblaslapack/LICENSE new file mode 100644 index 00000000000..37aa71d7e04 --- /dev/null +++ b/recipes/recipes_wasm/f2cblaslapack/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 1991-2025, UChicago Argonne, LLC and the PETSc Developers and Contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This license DOES NOT apply to any software that may be obtained via the +--download-package option of the PETSc configuration. Each of those packages is +covered by its own license(s). diff --git a/recipes/recipes_wasm/f2cblaslapack/build.sh b/recipes/recipes_wasm/f2cblaslapack/build.sh new file mode 100755 index 00000000000..60f87c5c700 --- /dev/null +++ b/recipes/recipes_wasm/f2cblaslapack/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -eux + +# The upstream makefile includes PETSc's build-time configuration just to +# obtain CC/COPTFLAGS/AR. That file does not exist here, and everything it +# would provide is passed explicitly below. +sed -i '/^include \${PETSC_DIR}/d' makefile + +make -j"${CPU_COUNT}" CC=emcc AR=emar RANLIB=emranlib COPTFLAGS="-O2" \ + blas_lib lapack_lib + +mkdir -p "$PREFIX/lib" "$PREFIX/lib/pkgconfig" +cp libf2cblas.a libf2clapack.a "$PREFIX/lib/" + +# Mirror the pkg-config layout of libblas-static / liblapack-static so that +# pkg-config --static resolves the pair. +cat > "$PREFIX/lib/pkgconfig/f2cblas.pc" <<'EOF' +prefix=${pcfiledir}/../.. +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: F2CBLAS +Description: BLAS in C (f2c translation, as bundled by PETSc) +Version: 3.8.0.q2 +URL: https://petsc.org/ +Libs: -L${libdir} -lf2cblas +EOF + +cat > "$PREFIX/lib/pkgconfig/f2clapack.pc" <<'EOF' +prefix=${pcfiledir}/../.. +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: F2CLAPACK +Description: LAPACK in C (f2c translation, as bundled by PETSc) +Version: 3.8.0.q2 +URL: https://petsc.org/ +Libs: -L${libdir} -lf2clapack +Requires.private: f2cblas +EOF diff --git a/recipes/recipes_wasm/f2cblaslapack/recipe.yaml b/recipes/recipes_wasm/f2cblaslapack/recipe.yaml new file mode 100644 index 00000000000..0e9eaeca5ed --- /dev/null +++ b/recipes/recipes_wasm/f2cblaslapack/recipe.yaml @@ -0,0 +1,64 @@ +context: + name: f2cblaslapack + version: 3.8.0.q2 + +package: + name: ${{ name }}-static + version: ${{ version }} + +source: +# The upstream tarball carries no LICENSE file: the sources are the f2c +# translations that PETSc redistributes under its own BSD-2-Clause license. +- url: https://web.cels.anl.gov/projects/petsc/download/externalpackages/f2cblaslapack-${{ version }}.tar.gz + sha256: 12fa8d5001e313aeeea22eb2054883f59e3e3c656f11129f31abb02ddbf8ad60 +- path: LICENSE + +build: + number: 0 + script: build.sh + +requirements: + build: + - ${{ compiler('c') }} + - make + - sed + +tests: +- package_contents: + files: + - lib/libf2cblas.a + - lib/libf2clapack.a + - lib/pkgconfig/f2cblas.pc + - lib/pkgconfig/f2clapack.pc +- script: test_f2cblaslapack.sh + files: + recipe: + - test_f2cblaslapack.c + - test_f2cblaslapack.sh + requirements: + build: + - ${{ compiler('c') }} + - nodejs + - pkg-config +- script: generic-testing --allow-pthread + requirements: + build: + - generic-testing + +about: + homepage: https://petsc.org/ + repository: https://gitlab.com/petsc/petsc + license: BSD-2-Clause + license_file: LICENSE + summary: BLAS and LAPACK in C, as bundled with PETSc + description: | + f2cblaslapack is PETSc's C translation (via f2c) of the reference BLAS and + LAPACK routines. The entry points use the plain C calling convention, with no + hidden Fortran CHARACTER lengths and no Fortran runtime, so it can be linked + from C with emcc. It is the BLAS/LAPACK implementation PETSc itself uses when + built with a C compiler only. + documentation: https://petsc.org/release/ + +extra: + recipe-maintainers: + - Alex-PLACET diff --git a/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.c b/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.c new file mode 100644 index 00000000000..340a601e88a --- /dev/null +++ b/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.c @@ -0,0 +1,64 @@ +/* Links against f2cblaslapack with no Fortran runtime and no hidden + * CHARACTER length arguments, which is the whole point of this package. */ + +extern void dgemm_(const char *, const char *, const int *, const int *, + const int *, const double *, const double *, const int *, + const double *, const int *, const double *, double *, + const int *); +extern void dgetrf_(const int *, const int *, double *, const int *, int *, int *); +extern void dgetrs_(const char *, const int *, const int *, const double *, + const int *, const int *, double *, const int *, int *); +extern double dnrm2_(const int *, const double *, const int *); + +#include +#include + +static int check(const char *what, double got, double want) +{ + double err = fabs(got - want); + printf("%s: got %.12g want %.12g (%s)\n", what, got, want, err < 1e-12 ? "ok" : "FAIL"); + return err < 1e-12; +} + +int main(void) +{ + int ok = 1; + + /* BLAS: C = A*B with A = [[1,2],[3,4]], B = [[5,6],[7,8]] -> [[19,22],[43,50]] */ + { + double a[4] = {1, 3, 2, 4}; /* column-major */ + double b[4] = {5, 7, 6, 8}; + double c[4] = {0, 0, 0, 0}; + double alpha = 1.0, beta = 0.0; + int n = 2; + dgemm_("N", "N", &n, &n, &n, &alpha, a, &n, b, &n, &beta, c, &n); + ok &= check("dgemm C[0,0]", c[0], 19.0); + ok &= check("dgemm C[1,0]", c[1], 43.0); + ok &= check("dgemm C[0,1]", c[2], 22.0); + ok &= check("dgemm C[1,1]", c[3], 50.0); + } + + /* BLAS: ||[3,4]|| = 5 */ + { + double v[2] = {3, 4}; + int n = 2, inc = 1; + ok &= check("dnrm2", dnrm2_(&n, v, &inc), 5.0); + } + + /* LAPACK: solve [[4,-1],[-1,4]] x = [1,1] -> x = [1/3, 1/3] */ + { + double m[4] = {4, -1, -1, 4}; /* column-major */ + double rhs[2] = {1, 1}; + int n = 2, nrhs = 1, info = 0; + int ipiv[2]; + dgetrf_(&n, &n, m, &n, ipiv, &info); + if (info != 0) { printf("dgetrf info=%d FAIL\n", info); return 1; } + dgetrs_("N", &n, &nrhs, m, &n, ipiv, rhs, &n, &info); + if (info != 0) { printf("dgetrs info=%d FAIL\n", info); return 1; } + ok &= check("dgetrs x[0]", rhs[0], 1.0 / 3.0); + ok &= check("dgetrs x[1]", rhs[1], 1.0 / 3.0); + } + + printf("%s\n", ok ? "f2cblaslapack ALL OK" : "f2cblaslapack FAILED"); + return ok ? 0 : 1; +} diff --git a/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.sh b/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.sh new file mode 100755 index 00000000000..d3ac67a41de --- /dev/null +++ b/recipes/recipes_wasm/f2cblaslapack/test_f2cblaslapack.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eux + +export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" + +emcc test_f2cblaslapack.c -o test_f2cblaslapack.js \ + -sEXIT_RUNTIME=1 \ + -sALLOW_MEMORY_GROWTH=1 \ + $(pkg-config --cflags f2clapack) \ + $(pkg-config --static --libs f2clapack) + +node test_f2cblaslapack.js From c11d8be11d818618bd099417e76a5b1a15d6b21d Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:04:21 +0100 Subject: [PATCH 06/10] Use f2cblaslapack-static in the petsc recipe Drop the in-recipe f2cblaslapack source and build; take the archives from the f2cblaslapack-static package instead. - petsc: 10.7 -> 8.66 MiB, ships libpetsc.a only - Verified wasm32 + wasm64: petsc and petsc4py tests pass --- recipes/recipes_wasm/petsc/build.sh | 30 +++++++++++--------------- recipes/recipes_wasm/petsc/recipe.yaml | 15 +++++++------ 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/recipes/recipes_wasm/petsc/build.sh b/recipes/recipes_wasm/petsc/build.sh index 1d9097c1c9c..79426b1dd75 100755 --- a/recipes/recipes_wasm/petsc/build.sh +++ b/recipes/recipes_wasm/petsc/build.sh @@ -5,18 +5,14 @@ export PYTHON=${PYTHON:-$(command -v python3)} export PETSC_DIR=$SRC_DIR export PETSC_ARCH=arch-emscripten -# 1. Build PETSc's C BLAS/LAPACK (second source, extracted to -# $SRC_DIR/f2cblaslapack with its own top dir flattened). Its makefile pulls -# PETSc's *build-time* conf, which does not exist yet; drop that include and -# drive the compilers directly. -cd "$SRC_DIR/f2cblaslapack" -sed -i '/^include \${PETSC_DIR}/d' makefile -make -j"${CPU_COUNT}" CC=emcc AR=emar RANLIB=emranlib COPTFLAGS="-O2" \ - blas_lib lapack_lib -mkdir -p "$PREFIX/lib" -cp libf2cblas.a libf2clapack.a "$PREFIX/lib/" - -# 2. Configure PETSc in batch (cross-compile) mode against those archives. +# BLAS/LAPACK comes from f2cblaslapack-static (host dependency): PETSc's own C +# translation of BLAS/LAPACK, packaged separately so other C consumers can use it. + +# 1. Configure PETSc in batch (cross-compile) mode against the archives +# provided by f2cblaslapack-static (host dependency). +test -f "$PREFIX/lib/libf2cblas.a" +test -f "$PREFIX/lib/libf2clapack.a" + cd "$PETSC_DIR" "$PYTHON" ./configure \ --with-cc=emcc \ @@ -34,27 +30,27 @@ cd "$PETSC_DIR" --with-lapack-lib="[$PREFIX/lib/libf2clapack.a]" \ --prefix="$PREFIX" -# 3. Batch mode probes headers with the preprocessor only, so it "finds" +# 2. Batch mode probes headers with the preprocessor only, so it "finds" # , which exists in emscripten's sysroot but is unusable # (undeclared elf_gregset_t) and breaks src/sys/memory/mem.c. sed -i '/PETSC_HAVE_SYS_PROCFS_H/d' "$PETSC_ARCH/include/petscconf.h" -# 4. Build and install (install-lib skips ~60 MB of examples/data). +# 3. Build and install (install-lib skips ~60 MB of examples/data). make -j"${CPU_COUNT}" all make install-lib -# 5. Strip build-env tool paths; keep the tool names so they resolve on PATH. +# 4. Strip build-env tool paths; keep the tool names so they resolve on PATH. for f in $(grep -rl "$BUILD_PREFIX/bin/" "$PREFIX/lib/petsc" 2>/dev/null); do sed -i "s|$BUILD_PREFIX/bin/||g" "$f" done -# 6. PETSc's .pc files expand ${PETSC_DIR} without defining it; strict +# 5. PETSc's .pc files expand ${PETSC_DIR} without defining it; strict # pkg-config (0.29.2, as opposed to 3.x) then rejects the file outright. for pc in "$PREFIX"/lib/pkgconfig/petsc.pc "$PREFIX"/lib/pkgconfig/PETSc.pc; do sed -i '/^prefix=/a PETSC_DIR=${prefix}' "$pc" done -# 7. Drop build-only leftovers. +# 6. Drop build-only leftovers. rm -f "$PREFIX"/lib/petsc/conf/configure-hash \ "$PREFIX"/lib/petsc/conf/pkg.conf.f2cblaslapack rm -rf "$PREFIX"/share/petsc/examples/src diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index 693b4ae72d0..8066485a5e7 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -8,15 +8,13 @@ source: sha256: a4dc46c1b4403545ac2274741ce10801366c4a9a7b2683b678d18f6663b93496 patches: - patches/0001-skip-rpath-for-static-petsc.patch -- url: https://web.cels.anl.gov/projects/petsc/download/externalpackages/f2cblaslapack-${{ f2c_version }}.tar.gz - sha256: 12fa8d5001e313aeeea22eb2054883f59e3e3c656f11129f31abb02ddbf8ad60 - target_directory: f2cblaslapack build: number: 0 outputs: -# PETSc itself: serial, static, with PETSc's own C BLAS/LAPACK. +# PETSc itself: serial and static. BLAS/LAPACK comes from f2cblaslapack-static, +# which is PETSc's own C translation packaged separately. - package: name: ${{ name }} version: ${{ version }} @@ -31,6 +29,10 @@ outputs: - python - cmake - pkg-config + host: + - f2cblaslapack-static ${{ f2c_version }}.* + run: + - f2cblaslapack-static ${{ f2c_version }}.* run_exports: - ${{ pin_subpackage('petsc', upper_bound='x.x') }} @@ -40,8 +42,6 @@ outputs: - include/petsc.h - include/petscconf.h - lib/libpetsc.a - - lib/libf2cblas.a - - lib/libf2clapack.a - lib/pkgconfig/PETSc.pc - script: test_petsc.sh files: @@ -105,6 +105,8 @@ outputs: - cython >=3 host: - ${{ pin_subpackage('petsc', exact=True) }} + # petsc4py links libpetsc.a, whose BLAS/LAPACK symbols come from here. + - f2cblaslapack-static ${{ f2c_version }}.* - python-dev - numpy - cython >=3 @@ -113,6 +115,7 @@ outputs: run: - python - numpy + - f2cblaslapack-static ${{ f2c_version }}.* tests: - package_contents: From 25dcc057a6378fc2bcbc88ac429cdf290d785cae Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Wed, 2 Dec 2026 10:11:42 +0100 Subject: [PATCH 07/10] Generate f2cblaslapack .pc version from PKG_VERSION The version was a literal in build.sh. rattler-build exports PKG_VERSION, so read it there and keep the version in recipe.yaml only. - Verified wasm32 + wasm64: pkg-config --modversion 3.8.0.q2, tests pass --- recipes/recipes_wasm/f2cblaslapack/build.sh | 41 ++++++++++----------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/recipes/recipes_wasm/f2cblaslapack/build.sh b/recipes/recipes_wasm/f2cblaslapack/build.sh index 60f87c5c700..1612bdec270 100755 --- a/recipes/recipes_wasm/f2cblaslapack/build.sh +++ b/recipes/recipes_wasm/f2cblaslapack/build.sh @@ -12,29 +12,26 @@ make -j"${CPU_COUNT}" CC=emcc AR=emar RANLIB=emranlib COPTFLAGS="-O2" \ mkdir -p "$PREFIX/lib" "$PREFIX/lib/pkgconfig" cp libf2cblas.a libf2clapack.a "$PREFIX/lib/" -# Mirror the pkg-config layout of libblas-static / liblapack-static so that -# pkg-config --static resolves the pair. -cat > "$PREFIX/lib/pkgconfig/f2cblas.pc" <<'EOF' -prefix=${pcfiledir}/../.. -libdir=${prefix}/lib -includedir=${prefix}/include +# pkg-config files, matching the layout of libblas-static / liblapack-static so +# that pkg-config --static resolves the pair. The version comes from the recipe +# via PKG_VERSION, never a literal. +write_pc() { + local lib=$1 name=$2 kind=$3 requires=${4:-} + cat > "$PREFIX/lib/pkgconfig/${lib}.pc" <> "$PREFIX/lib/pkgconfig/${lib}.pc" + fi +} -cat > "$PREFIX/lib/pkgconfig/f2clapack.pc" <<'EOF' -prefix=${pcfiledir}/../.. -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: F2CLAPACK -Description: LAPACK in C (f2c translation, as bundled by PETSc) -Version: 3.8.0.q2 -URL: https://petsc.org/ -Libs: -L${libdir} -lf2clapack -Requires.private: f2cblas -EOF +write_pc f2cblas F2CBLAS BLAS +write_pc f2clapack F2CLAPACK LAPACK f2cblas From 9968e63862d90eb90c78c19b303ebe82e66117af Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:29:49 +0100 Subject: [PATCH 08/10] Rename PETSc package to include '-static' suffix and remove unnecessary build script --- recipes/recipes_wasm/petsc/recipe.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index 8066485a5e7..7abb51c28e1 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -16,12 +16,9 @@ outputs: # PETSc itself: serial and static. BLAS/LAPACK comes from f2cblaslapack-static, # which is PETSc's own C translation packaged separately. - package: - name: ${{ name }} + name: ${{ name }}-static version: ${{ version }} - build: - script: build.sh - requirements: build: - ${{ compiler('c') }} From 6c1f884f9163499ab2bc86d3a10a4f07c8b6ae64 Mon Sep 17 00:00:00 2001 From: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:10:09 +0100 Subject: [PATCH 09/10] Fix petsc-static rename fallout The output was renamed to petsc-static but its pin_subpackage references still said 'petsc', so rattler-build aborted with "missing output: petsc". Restore the build script for that output too; PETSc needs configure/make/install-lib. - Verified wasm32 + wasm64: petsc-static and petsc4py tests pass --- recipes/recipes_wasm/petsc/recipe.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recipes/recipes_wasm/petsc/recipe.yaml b/recipes/recipes_wasm/petsc/recipe.yaml index 7abb51c28e1..cdea616f142 100644 --- a/recipes/recipes_wasm/petsc/recipe.yaml +++ b/recipes/recipes_wasm/petsc/recipe.yaml @@ -19,6 +19,9 @@ outputs: name: ${{ name }}-static version: ${{ version }} + build: + script: build.sh + requirements: build: - ${{ compiler('c') }} @@ -31,7 +34,7 @@ outputs: run: - f2cblaslapack-static ${{ f2c_version }}.* run_exports: - - ${{ pin_subpackage('petsc', upper_bound='x.x') }} + - ${{ pin_subpackage('petsc-static', upper_bound='x.x') }} tests: - package_contents: @@ -101,7 +104,7 @@ outputs: - setuptools - cython >=3 host: - - ${{ pin_subpackage('petsc', exact=True) }} + - ${{ pin_subpackage('petsc-static', exact=True) }} # petsc4py links libpetsc.a, whose BLAS/LAPACK symbols come from here. - f2cblaslapack-static ${{ f2c_version }}.* - python-dev From fde754e754ea26954bac8128bf8f40570318409a Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Thu, 3 Dec 2026 20:25:08 +0100 Subject: [PATCH 10/10] Add f2cblaslapack-static and petsc-static to variant.yaml --- variant.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/variant.yaml b/variant.yaml index 1c89fe16696..fed62bc4b6b 100644 --- a/variant.yaml +++ b/variant.yaml @@ -298,6 +298,8 @@ libexpat: - 2 libexpat-static: - 2 +f2cblaslapack-static: + - 3.8.0.q2 ffmpeg-static: - 8 fflas-ffpack: @@ -771,6 +773,8 @@ perl: - 5.32.1 petsc: - 3.15 +petsc-static: + - '3.26' petsc4py: - 3.15 planarity: