Skip to content

Commit 9a15791

Browse files
authored
Merge pull request #3722 from FlyGoat/ci
GitHub Actions: Add cross compile tests
2 parents bd30120 + 1569a43 commit 9a15791

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

.github/workflows/dynamic_arch.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,53 @@ jobs:
257257
- name: Run tests
258258
timeout-minutes: 60
259259
run: cd build && ctest
260+
261+
cross_build:
262+
runs-on: ubuntu-22.04
263+
264+
strategy:
265+
fail-fast: false
266+
matrix:
267+
include:
268+
- target: mips64el
269+
triple: mips64el-linux-gnuabi64
270+
opts: DYNAMIC_ARCH=1
271+
- target: riscv64
272+
triple: riscv64-linux-gnu
273+
opts: TARGET=RISCV64_GENERIC
274+
- target: mipsel
275+
triple: mipsel-linux-gnu
276+
opts: TARGET=MIPS1004K
277+
- target: alpha
278+
triple: alpha-linux-gnu
279+
opts: TARGET=EV4
280+
281+
steps:
282+
- name: Checkout repository
283+
uses: actions/checkout@v3
284+
285+
- name: Install Dependencies
286+
run: |
287+
sudo apt-get install -y ccache gcc-${{ matrix.triple }} gfortran-${{ matrix.triple }} libgomp1-${{ matrix.target }}-cross
288+
289+
- name: Compilation cache
290+
uses: actions/cache@v3
291+
with:
292+
path: ~/.ccache
293+
key: ccache-${{ runner.os }}-${{ matrix.target }}-${{ github.ref }}-${{ github.sha }}
294+
restore-keys: |
295+
ccache-${{ runner.os }}-${{ matrix.target }}-${{ github.ref }}
296+
ccache-${{ runner.os }}-${{ matrix.target }}
297+
298+
- name: Configure ccache
299+
run: |
300+
# Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota (5 GB).
301+
test -d ~/.ccache || mkdir -p ~/.ccache
302+
echo "max_size = 300M" > ~/.ccache/ccache.conf
303+
echo "compression = true" >> ~/.ccache/ccache.conf
304+
ccache -s
305+
306+
307+
- name: Build OpenBLAS
308+
run: |
309+
make -j$(nproc) HOSTCC="ccache gcc" CC="ccache ${{ matrix.triple }}-gcc" FC="ccache ${{ matrix.triple }}-gfortran" ARCH=${{ matrix.target }} ${{ matrix.opts }}

Makefile.prebuild

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ all: getarch_2nd
6060
./getarch_2nd 1 >> $(TARGET_CONF)
6161

6262
$(TARGET_CONF): c_check$(SCRIPTSUFFIX) f_check$(SCRIPTSUFFIX) getarch
63-
./c_check$(SCRIPTSUFFIX) $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS) $(CFLAGS)
63+
./c_check$(SCRIPTSUFFIX) $(TARGET_MAKE) $(TARGET_CONF) "$(CC)" "$(TARGET_FLAGS) $(CFLAGS)"
6464
ifneq ($(ONLY_CBLAS), 1)
65-
./f_check$(SCRIPTSUFFIX) $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS)
65+
./f_check$(SCRIPTSUFFIX) $(TARGET_MAKE) $(TARGET_CONF) "$(FC)" "$(TARGET_FLAGS)"
6666
else
6767
#When we only build CBLAS, we set NOFORTRAN=2
6868
echo "NOFORTRAN=2" >> $(TARGET_MAKE)
@@ -77,8 +77,8 @@ endif
7777

7878

7979
getarch : getarch.c cpuid.S dummy $(CPUIDEMU)
80-
avx512=$$(./c_check$(SCRIPTSUFFIX) - - $(CC) $(TARGET_FLAGS) $(CFLAGS) | grep NO_AVX512); \
81-
rv64gv=$$(./c_check$(SCRIPTSUFFIX) - - $(CC) $(TARGET_FLAGS) $(CFLAGS) | grep NO_RV64GV); \
80+
avx512=$$(./c_check$(SCRIPTSUFFIX) - - "$(CC)" "$(TARGET_FLAGS) $(CFLAGS)" | grep NO_AVX512); \
81+
rv64gv=$$(./c_check$(SCRIPTSUFFIX) - - "$(CC)" "$(TARGET_FLAGS) $(CFLAGS)" | grep NO_RV64GV); \
8282
$(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) $${avx512:+-D$${avx512}} $${rv64gv:+-D$${rv64gv}} -o $(@F) getarch.c cpuid.S $(CPUIDEMU)
8383

8484
getarch_2nd : getarch_2nd.c $(TARGET_CONF) dummy

c_check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ flags="$*"
3131

3232
cross_suffix=""
3333

34-
if [ "`dirname $compiler_name`" != '.' ]; then
35-
cross_suffix="$cross_suffix`dirname $compiler_name`/"
34+
if [ "`dirname \"$compiler_name\"`" != '.' ]; then
35+
cross_suffix="$cross_suffix`dirname \"$compiler_name\"`/"
3636
fi
3737

3838
bn=`basename $compiler_name`

0 commit comments

Comments
 (0)