Skip to content

Add openblas with flang #1377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 25, 2025
18 changes: 18 additions & 0 deletions recipes/recipes_emscripten/openblas-flang/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -ex

emmake make libs \
NO_SHARED=1 \
TARGET=RISCV64_GENERIC \
CC=$CC \
FC=$FC \
HOSTCC=gcc \
USE_THREAD=0 \
BINARY=64 \
LDFLAGS="${SIDE_MODULE_LDFLAGS}"

emmake make install PREFIX=$PREFIX NO_SHARED=1

mkdir -p $PREFIX/lib
cp libopenblas.a $PREFIX/lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 89fc62b849dc59398ff348d6b958d80d658b8de3 Mon Sep 17 00:00:00 2001
From: Isabel Paredes <[email protected]>
Date: Fri, 25 Apr 2025 14:25:50 +0200
Subject: [PATCH 1/2] Add no-implicit-function-declaration flag

gfortran option for LAPACK to improve thread safety
It is enabled by default in Makefile.system for gfortran
---
Makefile.rule | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.rule b/Makefile.rule
index c3edd1c..950a1fc 100644
--- a/Makefile.rule
+++ b/Makefile.rule
@@ -256,7 +256,7 @@ NO_AFFINITY = 1
# Common Optimization Flag;
# The default -O2 is enough.
# Flags for POWER8 are defined in Makefile.power. Don't modify COMMON_OPT
-# COMMON_OPT = -O2
+COMMON_OPT = -O2 -Wno-implicit-function-declaration

# gfortran option for LAPACK to improve thread-safety
# It is enabled by default in Makefile.system for gfortran
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
From 850c0d1396e7f6062b30d4fce19b1f73d4c0fd7f Mon Sep 17 00:00:00 2001
From: Isabel Paredes <[email protected]>
Date: Fri, 25 Apr 2025 14:29:53 +0200
Subject: [PATCH 2/2] Remove -march flags

---
0001-Add-Wno-return-type-flag.patch | 13 ++++++++++
0002-march.patch | 39 +++++++++++++++++++++++++++++
Makefile.prebuild | 4 ---
Makefile.riscv64 | 4 ---
Makefile.system | 2 +-
5 files changed, 53 insertions(+), 9 deletions(-)
create mode 100644 0001-Add-Wno-return-type-flag.patch
create mode 100644 0002-march.patch

diff --git a/0001-Add-Wno-return-type-flag.patch b/0001-Add-Wno-return-type-flag.patch
new file mode 100644
index 0000000..b1c64a3
--- /dev/null
+++ b/0001-Add-Wno-return-type-flag.patch
@@ -0,0 +1,13 @@
+diff --git a/Makefile.rule b/Makefile.rule
+index e57388844..3e2f23611 100644
+--- a/Makefile.rule
++++ b/Makefile.rule
+@@ -256,7 +256,7 @@ NO_AFFINITY = 1
+ # Common Optimization Flag;
+ # The default -O2 is enough.
+ # Flags for POWER8 are defined in Makefile.power. Don't modify COMMON_OPT
+-# COMMON_OPT = -O2
++COMMON_OPT = -O2 -Wno-implicit-function-declaration
+
+ # gfortran option for LAPACK to improve thread-safety
+ # It is enabled by default in Makefile.system for gfortran
\ No newline at end of file
diff --git a/0002-march.patch b/0002-march.patch
new file mode 100644
index 0000000..23ea356
--- /dev/null
+++ b/0002-march.patch
@@ -0,0 +1,39 @@
+diff --git a/Makefile.prebuild b/Makefile.prebuild
+index b7d695a75..47cbcbf83 100644
+--- a/Makefile.prebuild
++++ b/Makefile.prebuild
+@@ -71,10 +71,6 @@ ifeq ($(TARGET), RISCV64_ZVL128B)
+ TARGET_FLAGS = -march=rv64imafdcv -mabi=lp64d
+ endif
+
+-ifeq ($(TARGET), RISCV64_GENERIC)
+-TARGET_FLAGS = -march=rv64imafdc -mabi=lp64d
+-endif
+-
+ all: getarch_2nd
+ ./getarch_2nd 0 >> $(TARGET_MAKE)
+ ./getarch_2nd 1 >> $(TARGET_CONF)
+diff --git a/Makefile.riscv64 b/Makefile.riscv64
+index 9f6e48b7a..da9848a98 100644
+--- a/Makefile.riscv64
++++ b/Makefile.riscv64
+@@ -14,7 +14,3 @@ ifeq ($(CORE), RISCV64_ZVL128B)
+ CCOMMON_OPT += -march=rv64imafdcv -mabi=lp64d
+ FCOMMON_OPT += -march=rv64imafdcv -mabi=lp64d
+ endif
+-ifeq ($(CORE), RISCV64_GENERIC)
+-CCOMMON_OPT += -march=rv64imafdc -mabi=lp64d
+-FCOMMON_OPT += -march=rv64imafdc -mabi=lp64d
+-endif
+diff --git a/Makefile.system b/Makefile.system
+index 7bae72855..f9b2c0e78 100644
+--- a/Makefile.system
++++ b/Makefile.system
+@@ -202,7 +202,7 @@ endif
+ # On x86_64 build getarch with march=native unless the compiler is PGI. This is required to detect AVX512 support in getarch.
+ ifeq ($(HOSTARCH), x86_64)
+ ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),)
+-GETARCH_FLAGS += -march=native
++# GETARCH_FLAGS += -march=native
+ endif
+ endif
\ No newline at end of file
diff --git a/Makefile.prebuild b/Makefile.prebuild
index b7d695a..47cbcbf 100644
--- a/Makefile.prebuild
+++ b/Makefile.prebuild
@@ -71,10 +71,6 @@ ifeq ($(TARGET), RISCV64_ZVL128B)
TARGET_FLAGS = -march=rv64imafdcv -mabi=lp64d
endif

-ifeq ($(TARGET), RISCV64_GENERIC)
-TARGET_FLAGS = -march=rv64imafdc -mabi=lp64d
-endif
-
all: getarch_2nd
./getarch_2nd 0 >> $(TARGET_MAKE)
./getarch_2nd 1 >> $(TARGET_CONF)
diff --git a/Makefile.riscv64 b/Makefile.riscv64
index 0ee26c1..bf21fd6 100644
--- a/Makefile.riscv64
+++ b/Makefile.riscv64
@@ -14,7 +14,3 @@ ifeq ($(CORE), RISCV64_ZVL128B)
CCOMMON_OPT += -march=rv64imafdcv -mabi=lp64d
FCOMMON_OPT += -march=rv64imafdcv -mabi=lp64d
endif
-ifeq ($(CORE), RISCV64_GENERIC)
-CCOMMON_OPT += -march=rv64imafdc -mabi=lp64d
-FCOMMON_OPT += -march=rv64imafdc -mabi=lp64d
-endif
diff --git a/Makefile.system b/Makefile.system
index ac278ba..2dd4a68 100644
--- a/Makefile.system
+++ b/Makefile.system
@@ -202,7 +202,7 @@ endif
# On x86_64 build getarch with march=native unless the compiler is PGI. This is required to detect AVX512 support in getarch.
ifeq ($(HOSTARCH), x86_64)
ifeq ($(findstring pgcc,$(HOSTCC))$(findstring nvc,$(HOSTCC)),)
-GETARCH_FLAGS += -march=native
+# GETARCH_FLAGS += -march=native
endif
endif

44 changes: 44 additions & 0 deletions recipes/recipes_emscripten/openblas-flang/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
context:
name: openblas-flang
version: 0.3.29

package:
name: ${{ name }}
version: ${{ version }}

source:
url: https://github.com/OpenMathLib/OpenBLAS/archive/v${{ version }}.tar.gz
sha256: 38240eee1b29e2bde47ebb5d61160207dc68668a54cac62c076bb5032013b1eb
patches:
- patches/0001-Add-no-implicit-function-declaration-flag.patch
- patches/0002-Remove-march-flags.patch

build:
number: 0

requirements:
build:
- ${{ compiler('c') }}
- flang_${{ target_platform }}
- cmake
- make
host:
- libflang # for FortranRuntime

tests:
- package_contents:
lib:
- libopenblas.a

about:
homepage: http://www.openblas.net/
repository: https://github.com/OpenMathLib/OpenBLAS
license: BSD-3-Clause
license_file: LICENSE
summary: An optimized BLAS library based on GotoBLAS2 1.13 BSD version

extra:
maintainers:
- DerThorsten
- anutosh491
- IsabelParedes