1# Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved. 2# 3# Licensed under the Apache License 2.0 (the "License"). You may not use 4# this file except in compliance with the License. You can obtain a copy 5# in the file LICENSE in the source distribution or at 6# https://www.openssl.org/source/license.html 7 8name: Cross Compile 9 10on: [pull_request, push] 11 12permissions: 13 contents: read 14 15jobs: 16 cross-compilation: 17 strategy: 18 fail-fast: false 19 matrix: 20 # The platform matrix specifies: 21 # arch: the architecture to build for, this defines the tool-chain 22 # prefix {arch}- and the Debian compiler package gcc-{arch} 23 # name. 24 # libs: the Debian package for the necessary link/runtime libraries. 25 # target: the OpenSSL configuration target to use, this is passed 26 # directly to the config command line. 27 # fips: set to "no" to disable building FIPS, leave unset to 28 # build the FIPS provider. 29 # tests: omit this to run all the tests using QEMU, set it to "none" 30 # to never run the tests, otherwise its value is passed to 31 # the "make test" command to allow selective disabling of 32 # tests. 33 # qemucpu: optional; string that describes CPU properties. 34 # The string will be used to set the QEMU_CPU variable. 35 # opensslcapsname: optional; string that describes the postfix of the 36 # OpenSSL environment variable that defines CPU 37 # capabilities. E.g. "foo" will result in an 38 # environment variable with the name OPENSSL_foo. 39 # opensslcaps: optional; if opensslcapsname (see above) is set, then 40 # this string will be used as content for the OpenSSL 41 # capabilities variable. 42 # ppa: Launchpad PPA repository to download packages from. 43 platform: [ 44 { 45 arch: i386-pc-msdosdjgpp, 46 libs: libc-djgpp-dev libwatt-djgpp-dev djgpp-utils, 47 target: no-threads 386 DJGPP, 48 tests: none, 49 ppa: jwt27/djgpp-toolchain 50 }, { 51 arch: aarch64-linux-gnu, 52 libs: libc6-dev-arm64-cross, 53 target: linux-aarch64 54 }, { 55 arch: alpha-linux-gnu, 56 libs: libc6.1-dev-alpha-cross, 57 target: linux-alpha-gcc 58 }, { 59 arch: arm-linux-gnueabi, 60 libs: libc6-dev-armel-cross, 61 target: linux-armv4, 62 tests: -test_includes -test_store -test_x509_store 63 }, { 64 arch: arm-linux-gnueabihf, 65 libs: libc6-dev-armhf-cross, 66 target: linux-armv4, 67 tests: -test_includes -test_store -test_x509_store 68 }, { 69 # gcc hppa seems to have some potential compiler issues 70 # with -O2 on this platform, reduce optimization to -01 71 arch: hppa-linux-gnu, 72 libs: libc6-dev-hppa-cross, 73 target: -static -O1 linux-generic32, 74 fips: no, 75 tests: -test_includes -test_store -test_x509_store 76 }, { 77 arch: m68k-linux-gnu, 78 libs: libc6-dev-m68k-cross, 79 target: -static -m68040 linux-latomic -Wno-stringop-overflow, 80 fips: no, 81 tests: -test_includes -test_store -test_x509_store 82 }, { 83 arch: mips-linux-gnu, 84 libs: libc6-dev-mips-cross, 85 target: -static linux-mips32, 86 fips: no, 87 tests: -test_includes -test_store -test_x509_store 88 }, { 89 arch: mips64-linux-gnuabi64, 90 libs: libc6-dev-mips64-cross, 91 target: -static linux64-mips64, 92 fips: no 93 }, { 94 arch: mipsel-linux-gnu, 95 libs: libc6-dev-mipsel-cross, 96 target: linux-mips32, 97 tests: -test_includes -test_store -test_x509_store 98 }, { 99 arch: powerpc64le-linux-gnu, 100 libs: libc6-dev-ppc64el-cross, 101 # The default compiler for this platform on Ubuntu 20.04 seems 102 # buggy and causes test failures. Dropping the optimisation level 103 # resolves it. 104 target: -O2 linux-ppc64le 105 }, { 106 arch: riscv64-linux-gnu, 107 libs: libc6-dev-riscv64-cross, 108 target: linux64-riscv64 109 }, { 110 arch: s390x-linux-gnu, 111 libs: libc6-dev-s390x-cross, 112 target: linux64-s390x -Wno-stringop-overflow 113 }, { 114 arch: sh4-linux-gnu, 115 libs: libc6-dev-sh4-cross, 116 target: no-async linux-latomic, 117 tests: -test_includes -test_store -test_x509_store 118 }, 119 120 # These build with shared libraries but they crash when run 121 # They mirror static builds above in order to cover more of the 122 # code base. 123 { 124 arch: hppa-linux-gnu, 125 libs: libc6-dev-hppa-cross, 126 target: linux-generic32, 127 tests: none 128 }, { 129 arch: m68k-linux-gnu, 130 libs: libc6-dev-m68k-cross, 131 target: -mcfv4e -mxgot linux-latomic -Wno-stringop-overflow no-quic, 132 tests: none 133 }, { 134 arch: mips-linux-gnu, 135 libs: libc6-dev-mips-cross, 136 target: linux-mips32, 137 tests: none 138 }, { 139 arch: mips64-linux-gnuabi64, 140 libs: libc6-dev-mips64-cross, 141 target: linux64-mips64, 142 tests: none 143 }, 144 145 # This build doesn't execute either with or without shared libraries. 146 { 147 arch: sparc64-linux-gnu, 148 libs: libc6-dev-sparc64-cross, 149 target: linux64-sparcv9, 150 tests: none 151 } 152 ] 153 runs-on: ubuntu-latest 154 steps: 155 - name: install package repository 156 if: matrix.platform.ppa != '' 157 run: | 158 sudo add-apt-repository ppa:${{ matrix.platform.ppa }} 159 - name: install packages 160 run: | 161 sudo apt-get update 162 sudo apt-get -yq --force-yes install \ 163 gcc-${{ matrix.platform.arch }} \ 164 ${{ matrix.platform.libs }} 165 - uses: actions/checkout@v4 166 - name: checkout fuzz/corpora submodule 167 run: git submodule update --init --depth 1 fuzz/corpora 168 169 - name: config with FIPS 170 if: matrix.platform.fips != 'no' 171 run: | 172 ./config --banner=Configured --strict-warnings enable-fips \ 173 --cross-compile-prefix=${{ matrix.platform.arch }}- \ 174 ${{ matrix.platform.target }} 175 - name: config without FIPS 176 if: matrix.platform.fips == 'no' 177 run: | 178 ./config --banner=Configured --strict-warnings \ 179 --cross-compile-prefix=${{ matrix.platform.arch }}- \ 180 ${{ matrix.platform.target }} 181 - name: config dump 182 run: ./configdata.pm --dump 183 184 - name: make 185 run: make -s -j4 186 187 - name: install qemu 188 if: matrix.platform.tests != 'none' 189 run: sudo apt-get -yq --force-yes install qemu-user 190 191 - name: Set QEMU environment 192 if: matrix.platform.qemucpu != '' 193 run: echo "QEMU_CPU=${{ matrix.platform.qemucpu }}" >> $GITHUB_ENV 194 195 - name: Set OpenSSL caps environment 196 if: matrix.platform.opensslcapsname != '' 197 run: echo "OPENSSL_${{ matrix.platform.opensslcapsname }}=\ 198 ${{ matrix.platform.opensslcaps }}" >> $GITHUB_ENV 199 200 - name: get cpu info 201 run: cat /proc/cpuinfo 202 203 - name: make all tests 204 if: github.event_name == 'push' && matrix.platform.tests == '' 205 run: | 206 .github/workflows/make-test \ 207 TESTS="-test_afalg" \ 208 QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }} 209 - name: make some tests 210 if: github.event_name == 'push' && matrix.platform.tests != 'none' && matrix.platform.tests != '' 211 run: | 212 .github/workflows/make-test \ 213 TESTS="${{ matrix.platform.tests }} -test_afalg" \ 214 QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }} 215 - name: make evp tests 216 if: github.event_name == 'pull_request' && matrix.platform.tests != 'none' 217 run: | 218 .github/workflows/make-test \ 219 TESTS="test_evp*" \ 220 QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }} 221 - name: save artifacts 222 uses: actions/upload-artifact@v3 223 with: 224 name: "cross-compiles@${{ matrix.platform.arch }}" 225 path: artifacts.tar.gz 226 if-no-files-found: ignore 227