Skip to content

Commit 2701daf

Browse files
committed
use clang instead of gcc
1 parent 5f7fc1a commit 2701daf

File tree

5 files changed

+97
-9
lines changed

5 files changed

+97
-9
lines changed

.github/workflows/posix.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ jobs:
3939

4040
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
4141
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '2014', MB_ML_LIBC: manylinux}
42-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '0', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux}
43-
- { os: ubuntu-24.04-arm, PLAT: aarch64, INTERFACE64: '1', MB_ML_VER: '_2_28', MB_ML_LIBC: manylinux}
4442

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

ci-before-build.sh

Lines changed: 3 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

@@ -87,6 +87,8 @@ else
8787
# Default Manylinux version
8888
MB_ML_VER=${MB_ML_VER:-2014}
8989
fi
90+
./tools/install-static-clang.sh
91+
export PATH=/opt/clang/bin:$PATH
9092
fi
9193

9294
# Work round bug in travis xcode image described at

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
"MACOSX_DEPLOYMENT_TARGET",
@@ -54,4 +54,7 @@ environment-pass = [
5454
"BUILD_DIR",
5555
"PLAT",
5656
"OS-NAME",
57+
"RUNNER_ARCH",
5758
]
59+
[tool.cibuildwheel.linux]
60+
environment = { CC = "/opt/clang/bin/clang", CXX = "/opt/clang/bin/clang++", LDFLAGS = "-fuse-ld=lld" }

tools/build_steps.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ EOF
171171
Linux-aarch64)
172172
local bitness=64
173173
local target="ARMV8"
174-
# manylinux2014 image uses gcc-10, which miscompiles ARMV8SVE and up
175-
if [ "$MB_ML_VER" == "2014" ]; then
176-
echo setting DYNAMIC_LIST for manylinux2014 to ARMV8 only
177-
local dynamic_list="ARMV8"
178-
fi
179174
;;
180175
Darwin-arm64)
181176
local bitness=64

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)