Skip to content

Commit 66380df

Browse files
authored
Merge pull request #1157 from amontoison/precompilation
Provide precompiled artifacts for future releases
2 parents 6b92a7a + 3c59d17 commit 66380df

File tree

3 files changed

+394
-0
lines changed

3 files changed

+394
-0
lines changed

.github/julia/build_tarballs.jl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using BinaryBuilder, Pkg
2+
3+
haskey(ENV, "BLAS_LAPACK_RELEASE") || error("The environment variable BLAS_LAPACK_RELEASE is not defined.")
4+
haskey(ENV, "BLAS_LAPACK_COMMIT") || error("The environment variable BLAS_LAPACK_COMMIT is not defined.")
5+
haskey(ENV, "BLAS_LAPACK_URL") || error("The environment variable BLAS_LAPACK_URL is not defined.")
6+
7+
name = "blas_lapack"
8+
version = VersionNumber(ENV["BLAS_LAPACK_RELEASE"])
9+
10+
# Collection of sources required to complete build
11+
sources = [
12+
GitSource(ENV["BLAS_LAPACK_URL"], ENV["BLAS_LAPACK_COMMIT"])
13+
]
14+
15+
# Bash recipe for building across all platforms
16+
script = raw"""
17+
cd ${WORKSPACE}/srcdir/lapack
18+
19+
# FortranCInterface_VERIFY fails on macOS, but it's not actually needed for the current build
20+
sed -i 's/FortranCInterface_VERIFY/# FortranCInterface_VERIFY/g' ./CBLAS/CMakeLists.txt
21+
sed -i 's/FortranCInterface_VERIFY/# FortranCInterface_VERIFY/g' ./LAPACKE/include/CMakeLists.txt
22+
23+
mkdir build && cd build
24+
cmake .. \
25+
-DCBLAS=ON \
26+
-DLAPACKE=ON \
27+
-DCMAKE_INSTALL_PREFIX="$prefix" \
28+
-DCMAKE_FIND_ROOT_PATH="$prefix" \
29+
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TARGET_TOOLCHAIN}" \
30+
-DCMAKE_BUILD_TYPE=Release \
31+
-DBUILD_SHARED_LIBS=OFF \
32+
-DBUILD_INDEX64_EXT_API=OFF \
33+
-DTEST_FORTRAN_COMPILER=OFF \
34+
-DLAPACKE_WITH_TMG=OFF
35+
36+
make -j${nproc}
37+
make install
38+
39+
install_license $WORKSPACE/srcdir/lapack/LICENSE
40+
"""
41+
42+
# These are the platforms we will build for by default, unless further
43+
# platforms are passed in on the command line
44+
platforms = supported_platforms()
45+
platforms = expand_gfortran_versions(platforms)
46+
47+
# The products that we will ensure are always built
48+
products = [
49+
FileProduct("lib/libblas.a", :libblas_a),
50+
FileProduct("lib/libcblas.a", :libcblas_a),
51+
FileProduct("lib/liblapack.a", :liblapack_a),
52+
FileProduct("lib/liblapacke.a", :liblapacke_a),
53+
# LibraryProduct("libblas", :libblas),
54+
# LibraryProduct("libcblas", :libcblas),
55+
# LibraryProduct("liblapack", :liblapack),
56+
# LibraryProduct("liblapacke", :liblapacke),
57+
]
58+
59+
# Dependencies that must be installed before this package can be built
60+
dependencies = [
61+
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")),
62+
]
63+
64+
# Build the tarballs, and possibly a `build.jl` as well.
65+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6")

.github/julia/generate_binaries.jl

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Version
2+
haskey(ENV, "BLAS_LAPACK_RELEASE") || error("The environment variable BLAS_LAPACK_RELEASE is not defined.")
3+
version = VersionNumber(ENV["BLAS_LAPACK_RELEASE"])
4+
version2 = ENV["BLAS_LAPACK_RELEASE"]
5+
package = "blas_lapack"
6+
7+
platforms = [
8+
("aarch64-apple-darwin-libgfortran5" , "lib", "dylib"),
9+
# ("aarch64-linux-gnu-libgfortran3" , "lib", "so" ),
10+
# ("aarch64-linux-gnu-libgfortran4" , "lib", "so" ),
11+
("aarch64-linux-gnu-libgfortran5" , "lib", "so" ),
12+
# ("aarch64-linux-musl-libgfortran3" , "lib", "so" ),
13+
# ("aarch64-linux-musl-libgfortran4" , "lib", "so" ),
14+
# ("aarch64-linux-musl-libgfortran5" , "lib", "so" ),
15+
# ("powerpc64le-linux-gnu-libgfortran3" , "lib", "so" ),
16+
# ("powerpc64le-linux-gnu-libgfortran4" , "lib", "so" ),
17+
# ("powerpc64le-linux-gnu-libgfortran5" , "lib", "so" ),
18+
# ("x86_64-apple-darwin-libgfortran3" , "lib", "dylib"),
19+
# ("x86_64-apple-darwin-libgfortran4" , "lib", "dylib"),
20+
("x86_64-apple-darwin-libgfortran5" , "lib", "dylib"),
21+
# ("x86_64-linux-gnu-libgfortran3" , "lib", "so" ),
22+
# ("x86_64-linux-gnu-libgfortran4" , "lib", "so" ),
23+
("x86_64-linux-gnu-libgfortran5" , "lib", "so" ),
24+
# ("x86_64-linux-musl-libgfortran3" , "lib", "so" ),
25+
# ("x86_64-linux-musl-libgfortran4" , "lib", "so" ),
26+
# ("x86_64-linux-musl-libgfortran5" , "lib", "so" ),
27+
# ("x86_64-unknown-freebsd-libgfortran3", "lib", "so" ),
28+
# ("x86_64-unknown-freebsd-libgfortran4", "lib", "so" ),
29+
# ("x86_64-unknown-freebsd-libgfortran5", "lib", "so" ),
30+
# ("x86_64-w64-mingw32-libgfortran3" , "bin", "dll" ),
31+
# ("x86_64-w64-mingw32-libgfortran4" , "bin", "dll" ),
32+
("x86_64-w64-mingw32-libgfortran5" , "bin", "dll" ),
33+
]
34+
35+
36+
for (platform, libdir, ext) in platforms
37+
38+
tarball_name = "$package.v$version.$platform.tar.gz"
39+
40+
if isfile("products/$(tarball_name)")
41+
# Unzip the tarball generated by BinaryBuilder.jl
42+
isdir("products/$platform") && rm("products/$platform", recursive=true)
43+
mkdir("products/$platform")
44+
run(`tar -xzf products/$(tarball_name) -C products/$platform`)
45+
46+
if isfile("products/$platform/deps.tar.gz")
47+
# Unzip the tarball of the dependencies
48+
run(`tar -xzf products/$platform/deps.tar.gz -C products/$platform`)
49+
50+
# Copy the license of each dependency
51+
for folder in readdir("products/$platform/deps/licenses")
52+
cp("products/$platform/deps/licenses/$folder", "products/$platform/share/licenses/$folder")
53+
end
54+
rm("products/$platform/deps/licenses", recursive=true)
55+
56+
# Copy the shared library of each dependency
57+
for file in readdir("products/$platform/deps")
58+
cp("products/$platform/deps/$file", "products/$platform/$libdir/$file")
59+
end
60+
61+
# Remove the folder used to unzip the tarball of the dependencies
62+
rm("products/$platform/deps", recursive=true)
63+
rm("products/$platform/deps.tar.gz", recursive=true)
64+
end
65+
66+
# Create the archives *_binaries
67+
isfile("$(package)_binaries.$version2.$platform.tar.gz") && rm("$(package)_binaries.$version2.$platform.tar.gz")
68+
isfile("$(package)_binaries.$version2.$platform.zip") && rm("$(package)_binaries.$version2.$platform.zip")
69+
cd("products/$platform")
70+
71+
# Create a folder with the version number of the package
72+
mkdir("$(package)_binaries.$version2")
73+
for folder in ("include", "share", "lib")
74+
cp(folder, "$(package)_binaries.$version2/$folder")
75+
end
76+
77+
cd("$(package)_binaries.$version2")
78+
if ext == "dll"
79+
run(`zip -r --symlinks ../../../$(package)_binaries.$version2.$platform.zip include share lib`)
80+
else
81+
run(`tar -czf ../../../$(package)_binaries.$version2.$platform.tar.gz include share lib`)
82+
end
83+
cd("../../..")
84+
85+
# Remove the folder used to unzip the tarball generated by BinaryBuilder.jl
86+
rm("products/$platform", recursive=true)
87+
else
88+
@warn("The tarball for the platform $platform was not generated!")
89+
end
90+
end

.github/workflows/release.yml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v2023.11.15
8+
9+
jobs:
10+
build-linux-x64:
11+
name: blas / lapack -- Linux (x86_64) -- Release ${{ github.ref_name }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout lapack
15+
uses: actions/checkout@v4
16+
17+
- name: Install Julia
18+
uses: julia-actions/setup-julia@v2
19+
with:
20+
version: "1.7"
21+
arch: x64
22+
23+
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, BLAS_LAPACK_RELEASE, BLAS_LAPACK_COMMIT
24+
shell: bash
25+
run: |
26+
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
27+
echo "BLAS_LAPACK_RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
28+
echo "BLAS_LAPACK_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
29+
echo "BLAS_LAPACK_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
30+
31+
- name: Cross-compilation of blas / lapack -- x86_64-linux-gnu-libgfortran5
32+
run: |
33+
julia --color=no -e 'using Pkg; Pkg.add("BinaryBuilder")'
34+
julia --color=no .github/julia/build_tarballs.jl x86_64-linux-gnu-libgfortran5 --verbose
35+
36+
- name: Archive artifact
37+
run: julia --color=no .github/julia/generate_binaries.jl
38+
39+
- name: Upload artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: blas_lapack_binaries.${{ github.ref_name }}.x86_64-linux-gnu-libgfortran5.tar.gz
43+
path: ./blas_lapack_binaries.${{ github.ref_name }}.x86_64-linux-gnu-libgfortran5.tar.gz
44+
45+
build-linux-aarch64:
46+
name: blas / lapack -- Linux (aarch64) -- Release ${{ github.ref_name }}
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout lapack
50+
uses: actions/checkout@v4
51+
52+
- name: Install Julia
53+
uses: julia-actions/setup-julia@v2
54+
with:
55+
version: "1.7"
56+
arch: x64
57+
58+
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, BLAS_LAPACK_RELEASE, BLAS_LAPACK_COMMIT
59+
shell: bash
60+
run: |
61+
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
62+
echo "BLAS_LAPACK_RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
63+
echo "BLAS_LAPACK_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
64+
echo "BLAS_LAPACK_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
65+
66+
- name: Cross-compilation of blas / lapack -- aarch64-linux-gnu-libgfortran5
67+
run: |
68+
julia --color=no -e 'using Pkg; Pkg.add("BinaryBuilder")'
69+
julia --color=no .github/julia/build_tarballs.jl aarch64-linux-gnu-libgfortran5 --verbose
70+
71+
- name: Archive artifact
72+
run: julia --color=no .github/julia/generate_binaries.jl
73+
74+
- name: Upload artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: blas_lapack_binaries.${{ github.ref_name }}.aarch64-linux-gnu-libgfortran5.tar.gz
78+
path: ./blas_lapack_binaries.${{ github.ref_name }}.aarch64-linux-gnu-libgfortran5.tar.gz
79+
80+
build-windows-x64:
81+
name: blas / lapack -- Windows (x86_64) -- Release ${{ github.ref_name }}
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Checkout lapack
85+
uses: actions/checkout@v4
86+
87+
- name: Install Julia
88+
uses: julia-actions/setup-julia@v2
89+
with:
90+
version: "1.7"
91+
arch: x64
92+
93+
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, BLAS_LAPACK_RELEASE, BLAS_LAPACK_COMMIT
94+
shell: bash
95+
run: |
96+
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
97+
echo "BLAS_LAPACK_RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
98+
echo "BLAS_LAPACK_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
99+
echo "BLAS_LAPACK_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
100+
101+
- name: Cross-compilation of blas / lapack -- x86_64-w64-mingw32-libgfortran5
102+
run: |
103+
julia --color=no -e 'using Pkg; Pkg.add("BinaryBuilder")'
104+
julia --color=no .github/julia/build_tarballs.jl x86_64-w64-mingw32-libgfortran5 --verbose
105+
- name: Archive artifact
106+
run: julia --color=no .github/julia/generate_binaries.jl
107+
108+
- name: Upload artifact
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: blas_lapack_binaries.${{ github.ref_name }}.x86_64-w64-mingw32-libgfortran5.zip
112+
path: ./blas_lapack_binaries.${{ github.ref_name }}.x86_64-w64-mingw32-libgfortran5.zip
113+
114+
build-mac-x64:
115+
name: blas / lapack -- macOS (x86_64) -- Release ${{ github.ref_name }}
116+
runs-on: ubuntu-latest
117+
steps:
118+
- name: Checkout lapack
119+
uses: actions/checkout@v4
120+
121+
- name: Install Julia
122+
uses: julia-actions/setup-julia@v2
123+
with:
124+
version: "1.7"
125+
arch: x64
126+
127+
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, BLAS_LAPACK_RELEASE, BLAS_LAPACK_COMMIT
128+
shell: bash
129+
run: |
130+
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
131+
echo "BLAS_LAPACK_RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
132+
echo "BLAS_LAPACK_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
133+
echo "BLAS_LAPACK_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
134+
135+
- name: Cross-compilation of blas / lapack -- x86_64-apple-darwin-libgfortran5
136+
run: |
137+
julia --color=no -e 'using Pkg; Pkg.add("BinaryBuilder")'
138+
julia --color=no .github/julia/build_tarballs.jl x86_64-apple-darwin-libgfortran5 --verbose
139+
140+
- name: Archive artifact
141+
run: julia --color=no .github/julia/generate_binaries.jl
142+
143+
- name: Upload artifact
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: blas_lapack_binaries.${{ github.ref_name }}.x86_64-apple-darwin-libgfortran5.tar.gz
147+
path: ./blas_lapack_binaries.${{ github.ref_name }}.x86_64-apple-darwin-libgfortran5.tar.gz
148+
149+
build-mac-aarch64:
150+
name: blas / lapack -- macOS (aarch64) -- Release ${{ github.ref_name }}
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Checkout lapack
154+
uses: actions/checkout@v4
155+
156+
- name: Install Julia
157+
uses: julia-actions/setup-julia@v2
158+
with:
159+
version: "1.7"
160+
arch: x64
161+
162+
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, BLAS_LAPACK_RELEASE, BLAS_LAPACK_COMMIT
163+
shell: bash
164+
run: |
165+
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
166+
echo "BLAS_LAPACK_RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV
167+
echo "BLAS_LAPACK_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
168+
echo "BLAS_LAPACK_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
169+
170+
- name: Cross-compilation of blas / lapack -- aarch64-apple-darwin-libgfortran5
171+
run: |
172+
julia --color=no -e 'using Pkg; Pkg.add("BinaryBuilder")'
173+
julia --color=no .github/julia/build_tarballs.jl aarch64-apple-darwin-libgfortran5 --verbose
174+
175+
- name: Archive artifact
176+
run: julia --color=no .github/julia/generate_binaries.jl
177+
178+
- name: Upload artifact
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: blas_lapack_binaries.${{ github.ref_name }}.aarch64-apple-darwin-libgfortran5.tar.gz
182+
path: ./blas_lapack_binaries.${{ github.ref_name }}.aarch64-apple-darwin-libgfortran5.tar.gz
183+
184+
release:
185+
name: Create Release and Upload Binaries
186+
needs: [build-windows-x64, build-linux-x64, build-linux-aarch64, build-mac-x64, build-mac-aarch64]
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Checkout lapack
190+
uses: actions/checkout@v4
191+
192+
- name: Download artifacts
193+
uses: actions/download-artifact@v4
194+
with:
195+
path: .
196+
197+
- name: Create GitHub Release
198+
run: |
199+
gh release create ${{ github.ref_name }} \
200+
--title "${{ github.ref_name }}" \
201+
--notes "" \
202+
--verify-tag
203+
env:
204+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
205+
206+
- name: Upload Linux (x86_64) artifact
207+
run: |
208+
gh release upload ${{ github.ref_name }} \
209+
blas_lapack_binaries.${{ github.ref_name }}.x86_64-linux-gnu-libgfortran5.tar.gz/blas_lapack_binaries.${{ github.ref_name }}.x86_64-linux-gnu-libgfortran5.tar.gz#blas_lapack.${{ github.ref_name }}.linux.x86_64.tar.gz
210+
env:
211+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212+
213+
- name: Upload Linux (aarch64) artifact
214+
run: |
215+
gh release upload ${{ github.ref_name }} \
216+
blas_lapack_binaries.${{ github.ref_name }}.aarch64-linux-gnu-libgfortran5.tar.gz/blas_lapack_binaries.${{ github.ref_name }}.aarch64-linux-gnu-libgfortran5.tar.gz#blas_lapack.${{ github.ref_name }}.linux.aarch64.tar.gz
217+
env:
218+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219+
220+
- name: Upload Mac (x86_64) artifact
221+
run: |
222+
gh release upload ${{ github.ref_name }} \
223+
blas_lapack_binaries.${{ github.ref_name }}.x86_64-apple-darwin-libgfortran5.tar.gz/blas_lapack_binaries.${{ github.ref_name }}.x86_64-apple-darwin-libgfortran5.tar.gz#blas_lapack.${{ github.ref_name }}.mac.x86_64.tar.gz
224+
env:
225+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226+
227+
- name: Upload Mac (aarch64) artifact
228+
run: |
229+
gh release upload ${{ github.ref_name }} \
230+
blas_lapack_binaries.${{ github.ref_name }}.aarch64-apple-darwin-libgfortran5.tar.gz/blas_lapack_binaries.${{ github.ref_name }}.aarch64-apple-darwin-libgfortran5.tar.gz#blas_lapack.${{ github.ref_name }}.mac.aarch64.tar.gz
231+
env:
232+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233+
234+
- name: Upload Windows (x86_64) artifact
235+
run: |
236+
gh release upload ${{ github.ref_name }} \
237+
blas_lapack_binaries.${{ github.ref_name }}.x86_64-w64-mingw32-libgfortran5.zip/blas_lapack_binaries.${{ github.ref_name }}.x86_64-w64-mingw32-libgfortran5.zip#blas_lapack.${{ github.ref_name }}.windows.x86_64.zip
238+
env:
239+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)