Skip to content

Commit 202309a

Browse files
authored
Merge pull request #238 from mayeut/use-clang
Use clang instead of gcc to build on Linux
2 parents 83c2ecb + 6d02658 commit 202309a

File tree

9 files changed

+140
-82
lines changed

9 files changed

+140
-82
lines changed

.github/workflows/posix.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
- cron: '0 0 * * 0'
1313

1414
env:
15-
OPENBLAS_COMMIT: "v0.3.30-349-gf6df9beb"
15+
OPENBLAS_COMMIT: "v0.3.30-359-g29fab2b9"
1616

1717
jobs:
1818
build:
@@ -40,12 +40,16 @@ jobs:
4040

4141
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
4242
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
43-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux}
44-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux}
4543

4644
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
4745
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_1_2', MB_ML_LIBC: musllinux}
4846

47+
- { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
48+
- { os: ubuntu-24.04-arm, PLAT: ppc64le, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
49+
50+
- { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
51+
- { os: ubuntu-24.04-arm, PLAT: s390x, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
52+
4953
env:
5054
NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
5155
MB_ML_LIBC: ${{ matrix.MB_ML_LIBC }}
@@ -71,6 +75,12 @@ jobs:
7175
with:
7276
xcode-version: '15.4'
7377

78+
- name: Set up QEMU
79+
if: matrix.PLAT == 'ppc64le' || matrix.PLAT == 's390x'
80+
uses: docker/setup-qemu-action@v3
81+
with:
82+
platforms: all
83+
7484
- name: Print some Environment variable
7585
run: |
7686
echo "PLAT: ${PLAT}"
@@ -82,7 +92,8 @@ jobs:
8292
# limit-access-to-actor: true
8393

8494
- name: Build and Test wheels
85-
uses: pypa/[email protected]
95+
uses: pypa/[email protected]
96+
timeout-minutes: 60
8697
with:
8798
output-dir: dist
8899
env:
@@ -95,6 +106,10 @@ jobs:
95106
CIBW_MUSLLINUX_X86_64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
96107
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
97108
CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
109+
CIBW_MANYLINUX_PPC64LE_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
110+
CIBW_MUSLLINUX_PPC64LE_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
111+
CIBW_MANYLINUX_S390X_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
112+
CIBW_MUSLLINUX_S390X_IMAGE: ${{ matrix.MB_ML_LIBC }}${{matrix.MB_ML_VER}}
98113

99114
- name: Upload wheels to artifacts
100115
uses: actions/[email protected]

.github/workflows/windows-arm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- maintenance/**
1010

1111
env:
12-
OPENBLAS_COMMIT: "v0.3.30-349-gf6df9beb"
12+
OPENBLAS_COMMIT: "v0.3.30-359-g29fab2b9"
1313
OPENBLAS_ROOT: "c:\\opt"
1414
# Preserve working directory for calls into bash
1515
# Without this, invoking bash will cd to the home directory

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
workflow_dispatch: null
1111

1212
env:
13-
OPENBLAS_COMMIT: "v0.3.30-349-gf6df9beb"
13+
OPENBLAS_COMMIT: "v0.3.30-359-g29fab2b9"
1414
OPENBLAS_ROOT: "c:\\opt"
1515
# Preserve working directory for calls into bash
1616
# Without this, invoking bash will cd to the home directory

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

OpenBLAS

ci-before-build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /bin/bash
22

33

4-
# Most of the content in this file comes from https://github.com/multi-build/multibuild, with some modifications
4+
# Most of the content in this file comes from https://github.com/multi-build/multibuild, with some modifications
55
# Follow the license below
66

77
# .. _license:
@@ -50,6 +50,11 @@ if [[ "$NIGHTLY" = "true" ]]; then
5050
sed -e "s/^version = .*/version = \"${version}\"/" -i.bak pyproject.toml
5151
fi
5252

53+
if [ "$(uname)" != "Darwin" ]; then
54+
./tools/install-static-clang.sh
55+
export PATH=/opt/clang/bin:$PATH
56+
fi
57+
5358
# Work round bug in travis xcode image described at
5459
# https://github.com/direnv/direnv/issues/210
5560
shell_session_update() { :; }

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "scipy-openblas64"
11-
# v0.3.30-349-gf6df9beb
12-
version = "0.3.30.349.1"
11+
# v0.3.30-359-g29fab2b9
12+
version = "0.3.30.359.0"
1313
requires-python = ">=3.7"
1414
description = "Provides OpenBLAS for python packaging"
1515
readme = "README.md"
@@ -43,7 +43,7 @@ scipy_openblas64 = ["lib/*", "include/*", "lib/pkgconfig/*", "lib/cmake/openblas
4343
[tool.cibuildwheel]
4444
before-build = "bash ci-before-build.sh"
4545
repair-wheel-command = "bash ci-repair-wheel.sh {dest_dir} {wheel}"
46-
test-command = "cd {package} && bash ci-test.sh "
46+
test-command = "cd {package} && bash ci-test.sh"
4747
environment-pass = [
4848
"OPENBLAS_COMMIT",
4949
"NIGHTLY",
@@ -53,4 +53,7 @@ environment-pass = [
5353
"BUILD_DIR",
5454
"PLAT",
5555
"OS-NAME",
56+
"RUNNER_ARCH",
5657
]
58+
[tool.cibuildwheel.linux]
59+
environment = { CC = "/opt/clang/bin/clang", CXX = "/opt/clang/bin/clang++", LDFLAGS = "-fuse-ld=lld" }

tools/build_steps.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function clean_code {
5454
pushd OpenBLAS
5555
git fetch origin --tags
5656
git checkout $build_commit
57-
git clean -fxd
57+
git clean -fxd
5858
git submodule update --init --recursive
5959
popd
6060
}
@@ -149,11 +149,6 @@ function do_build_lib {
149149
Linux-aarch64)
150150
local bitness=64
151151
local target="ARMV8"
152-
if [ "$MB_ML_VER" == "2014" ]; then
153-
# manylinux2014 image uses gcc-10, which miscompiles ARMV8SVE and up
154-
echo setting DYNAMIC_LIST for manylinux2014 to ARMV8 only
155-
local dynamic_list="ARMV8"
156-
fi
157152
;;
158153
Darwin-arm64)
159154
local bitness=64
@@ -163,7 +158,10 @@ function do_build_lib {
163158
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
164159
;;
165160
*-s390x)
161+
# The TargetList.txt has only ZARCH_GENERIC, Z13, Z14. Not worth
162+
# messing with dynamic lists.
166163
local bitness=64
164+
local target="ZARCH_GENERIC"
167165
;;
168166
*-ppc64le)
169167
local bitness=64
@@ -196,6 +194,18 @@ function do_build_lib {
196194
echo -n > utest/test_dsdot.c
197195
echo "Due to the qemu versions 7.2 causing utest cases to fail,"
198196
echo "the utest dsdot:dsdot_n_1 have been temporarily disabled."
197+
elif [ "$plat" == "s390x" ]; then
198+
sed -i 's/CTEST(samin, positive_step_1_N_70){/CTEST_SKIP(samin, positive_step_1_N_70){/g' ./utest/test_extensions/test_samin.c
199+
sed -i 's/CTEST(samin, negative_step_1_N_70){/CTEST_SKIP(samin, negative_step_1_N_70){/g' ./utest/test_extensions/test_samin.c
200+
sed -i 's/CTEST(damin, positive_step_1_N_70){/CTEST_SKIP(damin, positive_step_1_N_70){/g' ./utest/test_extensions/test_damin.c
201+
sed -i 's/CTEST(damin, negative_step_1_N_70){/CTEST_SKIP(damin, negative_step_1_N_70){/g' ./utest/test_extensions/test_damin.c
202+
echo "the utest samin/damin have been temporarily disabled."
203+
echo "QEMU does not support the 'lper' /'lpdr' instructions used"
204+
fi
205+
if [ "$plat" == "loongarch64" ] || [ "$plat" == "ppc64le" ] || [ "$plat" == "s390x" ]; then
206+
sed -i 's/CTEST(fork, safety)/CTEST_SKIP(fork, safety)/g' ./utest/test_fork.c
207+
sed -i 's/CTEST(fork, safety_after_fork_in_parent)/CTEST_SKIP(fork, safety_after_fork_in_parent)/g' ./utest/test_post_fork.c
208+
echo "QEMU has a race condition preventing fork tests to work as expected"
199209
fi
200210
if [ -n "$dynamic_list" ]; then
201211
CFLAGS="$CFLAGS -fvisibility=protected -Wno-uninitialized" \

tools/install-static-clang.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
# Stop at any error, show all commands
4+
set -exuo pipefail
5+
6+
TOOLCHAIN_PATH=/opt/clang
7+
8+
# Download static-clang
9+
DEFAULT_ARCH="$(uname -m)"
10+
if [ "${STATIC_CLANG_ARCH:-}" == "" ]; then
11+
STATIC_CLANG_ARCH="${RUNNER_ARCH:-${DEFAULT_ARCH}}"
12+
fi
13+
case "${STATIC_CLANG_ARCH}" in
14+
ARM64|aarch64|arm64|arm64/*) GO_ARCH=arm64;;
15+
ARM|armv7l|armv8l|arm|arm/v7) GO_ARCH=arm;; # assume arm/v7 for arm
16+
X64|x86_64|amd64|amd64/*) GO_ARCH=amd64;;
17+
X86|i686|386) GO_ARCH=386;;
18+
ppc64le) GO_ARCH=ppc64le;;
19+
riscv64) GO_ARCH=riscv64;;
20+
s390x) GO_ARCH=s390x;;
21+
*) echo "No static-clang toolchain for ${CLANG_ARCH}">2; exit 1;;
22+
esac
23+
STATIC_CLANG_VERSION=21.1.6.0
24+
STATIC_CLANG_FILENAME="static-clang-linux-${GO_ARCH}.tar.xz"
25+
STATIC_CLANG_URL="https://github.com/mayeut/static-clang-images/releases/download/v${STATIC_CLANG_VERSION}/${STATIC_CLANG_FILENAME}"
26+
pushd /tmp
27+
cat<<'EOF' | grep "${STATIC_CLANG_FILENAME}" > "${STATIC_CLANG_FILENAME}.sha256"
28+
3f92a131d27ca606dae8230550236a0c897a7f5990d61a293814e0abea8d0e1f static-clang-linux-386.tar.xz
29+
3fc6a3500cb9514b2c3af6d4a95676842769c301f872b6cea8c15576a64e756c static-clang-linux-amd64.tar.xz
30+
82ea0c148ec75f72a2f6f61cc877561efe9675c6e59a1a2c4d130f088f9dc868 static-clang-linux-arm.tar.xz
31+
9b5ad28877b6d56aff530164f7f88590e5d3441a1fddd7a73370539783056120 static-clang-linux-arm64.tar.xz
32+
2adccbcad99d033222c8a63872739919375a7aef2339ce2e8ab7dcfc938502b1 static-clang-linux-loong64.tar.xz
33+
5f551911ad73ecbbcf278e6d05a04bc68bd0dc4918a6a145352072f7734959c6 static-clang-linux-ppc64le.tar.xz
34+
90f5beda1004bec124607df1f9fc0a70c2b9f382b82ab1db2703ebd131c920ef static-clang-linux-riscv64.tar.xz
35+
e4047765a5e64bace4be36f6aae4d859e96bc1298d3ff5ba6b7d6100ea7d23f7 static-clang-linux-s390x.tar.xz
36+
EOF
37+
curl -fsSLO "${STATIC_CLANG_URL}"
38+
sha256sum -c "${STATIC_CLANG_FILENAME}.sha256"
39+
tar -C /opt -xf "${STATIC_CLANG_FILENAME}"
40+
popd
41+
42+
# configure target triple
43+
case "${AUDITWHEEL_POLICY}-${AUDITWHEEL_ARCH}" in
44+
manylinux*-armv7l) TARGET_TRIPLE=armv7-unknown-linux-gnueabihf;;
45+
musllinux*-armv7l) TARGET_TRIPLE=armv7-alpine-linux-musleabihf;;
46+
manylinux*-ppc64le) TARGET_TRIPLE=powerpc64le-unknown-linux-gnu;;
47+
musllinux*-ppc64le) TARGET_TRIPLE=powerpc64le-alpine-linux-musl;;
48+
manylinux*-*) TARGET_TRIPLE=${AUDITWHEEL_ARCH}-unknown-linux-gnu;;
49+
musllinux*-*) TARGET_TRIPLE=${AUDITWHEEL_ARCH}-alpine-linux-musl;;
50+
esac
51+
case "${AUDITWHEEL_POLICY}-${AUDITWHEEL_ARCH}" in
52+
*-riscv64) M_ARCH="-march=rv64gc";;
53+
*-x86_64) M_ARCH="-march=x86-64";;
54+
*-armv7l) M_ARCH="-march=armv7a";;
55+
manylinux*-i686) M_ARCH="-march=k8 -mtune=generic";; # same as gcc manylinux2014 / manylinux_2_28
56+
musllinux*-i686) M_ARCH="-march=pentium-m -mtune=generic";; # same as gcc musllinux_1_2
57+
esac
58+
GCC_TRIPLE=$(gcc -dumpmachine)
59+
60+
cat<<EOF >"${TOOLCHAIN_PATH}/bin/${AUDITWHEEL_PLAT}.cfg"
61+
-target ${TARGET_TRIPLE}
62+
${M_ARCH:-}
63+
--gcc-toolchain=${DEVTOOLSET_ROOTPATH:-}/usr
64+
--gcc-triple=${GCC_TRIPLE}
65+
EOF
66+
67+
cat<<EOF >"${TOOLCHAIN_PATH}/bin/clang.cfg"
68+
@${AUDITWHEEL_PLAT}.cfg
69+
EOF
70+
71+
cat<<EOF >"${TOOLCHAIN_PATH}/bin/clang++.cfg"
72+
@${AUDITWHEEL_PLAT}.cfg
73+
EOF
74+
75+
cat<<EOF >"${TOOLCHAIN_PATH}/bin/clang-cpp.cfg"
76+
@${AUDITWHEEL_PLAT}.cfg
77+
EOF
78+
79+
# override entrypoint to add the toolchain to PATH
80+
mv /usr/local/bin/manylinux-entrypoint /usr/local/bin/manylinux-entrypoint-org
81+
cat<<EOF >/usr/local/bin/manylinux-entrypoint
82+
#!/bin/bash
83+
84+
set -eu
85+
86+
export PATH="${TOOLCHAIN_PATH}/bin:\${PATH}"
87+
exec /usr/local/bin/manylinux-entrypoint-org "\$@"
88+
EOF
89+
90+
chmod +x /usr/local/bin/manylinux-entrypoint

0 commit comments

Comments
 (0)