diff --git a/.github/workflows/build_recipes.yaml b/.github/workflows/build_recipes.yaml index 498ef30f8..b56806e0a 100644 --- a/.github/workflows/build_recipes.yaml +++ b/.github/workflows/build_recipes.yaml @@ -13,6 +13,7 @@ jobs: build_recipes: runs-on: ubuntu-latest + timeout-minutes: 8 # limit build, REMOVE later env: TARGET_PLATFORM: emscripten-wasm32 GITHUB_OWNER: "emscripten-forge" diff --git a/recipes/recipes_emscripten/lapack/build.sh b/recipes/recipes_emscripten/lapack/build.sh new file mode 100644 index 000000000..cb4cf5926 --- /dev/null +++ b/recipes/recipes_emscripten/lapack/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -ex + +mkdir -p build +cd build + +mkdir -p $PREFIX/include + +export EMSDK_PATH=${EMSCRIPTEN_FORGE_EMSDK_DIR} +export LDFLAGS="$LDFLAGS -fno-optimize-sibling-calls" +export FFLAGS="$FFLAGS \ + --target=wasm32-unknown-emscripten \ + --generate-object-code \ + --fixed-form-infer \ + --implicit-interface" + +# CMAKE_INSTALL_LIBDIR="lib" suppresses CentOS default of lib64 (conda expects lib) + +# See https://github.com/Shaikh-Ubaid/lapack/blob/lf_01/LF_README.md +emcmake cmake .. \ + -DCMAKE_Fortran_COMPILER=lfortran \ + -DTEST_FORTRAN_COMPILER=OFF \ + -DCBLAS=no \ + -DLAPACKE=no \ + -DBUILD_TESTING=no \ + -DBUILD_DOUBLE=no \ + -DBUILD_COMPLEX=no \ + -DBUILD_COMPLEX16=no \ + -DLAPACKE_WITH_TMG=no \ + -DCMAKE_Fortran_PREPROCESS=yes \ + -DCMAKE_Fortran_FLAGS="$FFLAGS" \ + -DCMAKE_INSTALL_LIBDIR="lib" \ + -DCMAKE_INSTALL_PREFIX=$PREFIX + +# emcmake cmake \ +# -DCMAKE_INSTALL_PREFIX=${PREFIX} \ +# -DCMAKE_INSTALL_LIBDIR="lib" \ +# -DBUILD_TESTING=ON \ +# -DBUILD_SHARED_LIBS=OFF \ +# -DLAPACKE=ON \ +# -DCBLAS=ON \ +# -DBUILD_DEPRECATED=ON \ +# -DTEST_FORTRAN_COMPILER=OFF \ +# ${CMAKE_ARGS} .. + +make install -j${CPU_COUNT} VERBOSE=1 diff --git a/recipes/recipes_emscripten/lapack/patches/00_disable_fortran_compiler_check.patch b/recipes/recipes_emscripten/lapack/patches/00_disable_fortran_compiler_check.patch new file mode 100644 index 000000000..e5c32e479 --- /dev/null +++ b/recipes/recipes_emscripten/lapack/patches/00_disable_fortran_compiler_check.patch @@ -0,0 +1,11 @@ +diff --git a/BLAS/CMakeLists.txt b/BLAS/CMakeLists.txt +index a33f38f..308e67f 100644 +--- a/BLAS/CMakeLists.txt ++++ b/BLAS/CMakeLists.txt +@@ -1,5 +1,5 @@ ++set(CMAKE_Fortran_COMPILER_WORKS TRUE) + enable_language(Fortran) +- + # Check for any necessary platform specific compiler flags + include(CheckLAPACKCompilerFlags) + CheckLAPACKCompilerFlags() diff --git a/recipes/recipes_emscripten/lapack/patches/01_disable_fortran_c_interface_check.patch b/recipes/recipes_emscripten/lapack/patches/01_disable_fortran_c_interface_check.patch new file mode 100644 index 000000000..1cdc20faa --- /dev/null +++ b/recipes/recipes_emscripten/lapack/patches/01_disable_fortran_c_interface_check.patch @@ -0,0 +1,13 @@ +diff --git a/LAPACKE/include/CMakeLists.txt b/LAPACKE/include/CMakeLists.txt +index 034491e..1ecf561 100644 +--- a/LAPACKE/include/CMakeLists.txt ++++ b/LAPACKE/include/CMakeLists.txt +@@ -14,7 +14,7 @@ if(CMAKE_Fortran_COMPILER AND CMAKE_C_COMPILER) + enable_language(C) + include(FortranCInterface) + ## Ensure that the fortran compiler and c compiler specified are compatible +- FortranCInterface_VERIFY() ++ # FortranCInterface_VERIFY() + FortranCInterface_HEADER(${LAPACK_BINARY_DIR}/include/lapacke_mangling.h + MACRO_NAMESPACE "LAPACK_" + SYMBOL_NAMESPACE "LAPACK_") diff --git a/recipes/recipes_emscripten/lapack/patches/02_fix_unexpected_argument_pp.patch b/recipes/recipes_emscripten/lapack/patches/02_fix_unexpected_argument_pp.patch new file mode 100644 index 000000000..63eeed897 --- /dev/null +++ b/recipes/recipes_emscripten/lapack/patches/02_fix_unexpected_argument_pp.patch @@ -0,0 +1,13 @@ +diff --git a/BLAS/SRC/CMakeLists.txt b/BLAS/SRC/CMakeLists.txt +index 9df128e..2f4d478 100644 +--- a/BLAS/SRC/CMakeLists.txt ++++ b/BLAS/SRC/CMakeLists.txt +@@ -126,7 +126,7 @@ if(BUILD_INDEX64_EXT_API) + if(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") + set(COPT_64_F -fpp) + else() +- set(COPT_64_F -cpp) ++ set(COPT_64_F --cpp) + endif() + file(STRINGS ${F} ${F}.lst) + list(FILTER ${F}.lst INCLUDE REGEX "subroutine|SUBROUTINE|external|EXTERNAL|function|FUNCTION") diff --git a/recipes/recipes_emscripten/lapack/patches/03_skip_error_files.patch b/recipes/recipes_emscripten/lapack/patches/03_skip_error_files.patch new file mode 100644 index 000000000..30fe1a99d --- /dev/null +++ b/recipes/recipes_emscripten/lapack/patches/03_skip_error_files.patch @@ -0,0 +1,13 @@ +diff --git a/SRC/CMakeLists.txt b/SRC/CMakeLists.txt +index 767165a..8442c83 100644 +--- a/SRC/CMakeLists.txt ++++ b/SRC/CMakeLists.txt +@@ -87,7 +87,7 @@ set(SLASRC + sgebrd.f sgecon.f sgeequ.f sgees.f sgeesx.f sgeev.f sgeevx.f + sgehd2.f sgehrd.f sgelq2.f sgelqf.f + sgels.f sgelst.f sgelsd.f sgelss.f sgelsy.f sgeql2.f sgeqlf.f +- sgeqp3.f sgeqp3rk.f sgeqr2.f sgeqr2p.f sgeqrf.f sgeqrfp.f sgerfs.f sgerq2.f sgerqf.f ++ sgeqp3.f sgeqr2.f sgeqr2p.f sgeqrf.f sgeqrfp.f sgerfs.f sgerq2.f sgerqf.f + sgesc2.f sgesdd.f sgesv.f sgesvd.f sgesvdx.f sgesvx.f sgetc2.f sgetf2.f + sgetri.f + sggbak.f sggbal.f diff --git a/recipes/recipes_emscripten/lapack/recipe.yaml b/recipes/recipes_emscripten/lapack/recipe.yaml new file mode 100644 index 000000000..b8ce5054e --- /dev/null +++ b/recipes/recipes_emscripten/lapack/recipe.yaml @@ -0,0 +1,113 @@ +context: + version: 3.12.0 + blas_major: 2 + blas_minor: 200 + lfortran_version: 0.36 + +# TODO: verify version numbers + +source: + url: https://github.com/Reference-LAPACK/lapack/archive/v${{ version }}.tar.gz + # sha256: 4b9ba79bfd4921ca820e83979db76ab3363155709444a787979e81c22285ffa9 # v3.11.0 + sha256: eac9570f8e0ad6f30ce4b963f4f033f0f643e7c3912fc9ee6cd99120675ad48b # v3.12.0 + patches: + - patches/00_disable_fortran_compiler_check.patch + - patches/01_disable_fortran_c_interface_check.patch + - patches/02_fix_unexpected_argument_pp.patch + - patches/03_skip_error_files.patch + +build: + number: 0 + +outputs: + - package: + name: libblas + version: ${{ blas_major }}.${{ blas_minor }} + requirements: + build: + - ${{ compiler("c") }} + - lfortran>=${{ lfortran_version }} + +# TODO: saving for later + # - package: + # name: libtmglib + # version: ${{ version }} + # requirements: + # build: + # - ${{ compiler("c") }} + # - lfortran + +# TODO: saving for later + # - package: + # name: libcblas + # version: ${{ blas_major }}.${{ blas_minor }} + # requirements: + # build: + # - ${{ compiler("c") }} + # - lfortran + # run: + # - libblas + + - package: + name: liblapack + version: ${{ version }} + requirements: + build: + - ${{ compiler("c") }} + - lfortran>=${{ lfortran_version }} + run: + - libblas + +# TODO: saving for later + # - package: + # name: liblapacke + # version: ${{ version }} + # requirements: + # build: + # - ${{ compiler("c") }} + # - lfortran + # run: + # - libblas + # - libcblas + # - liblapack + +# TODO: saving for later + # - package: + # name: blas-devel + # version: ${{ blas_major }}.${{ blas_minor }} + # requirements: + # run: + # - libblas + # - libcblas + # - liblapack + # - liblapacke + + - package: + name: blas + version: ${{ blas_major }}.${{ blas_minor }} + requirements: + run: + - liblapack + - liblapacke + - libcblas + - blas-devel + - libtmglib + + - package: + name: lapack + version: ${{ version }} + requirements: + run: + - liblapack + +# TODO: add tests + +about: + homepage: http://www.netlib.org/lapack + license: BSD-3-Clause + license_file: LICENSE + summary: Linear Algebra PACKage + +extra: + recipe-maintainers: + - IsabelParedes \ No newline at end of file