cross-compiles.yml 8.4 KB

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