cross-compiles.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. 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. # gcc hppa seems to have some potential compiler issues
  66. # with -O2 on this platform, reduce optimization to -01
  67. arch: hppa-linux-gnu,
  68. libs: libc6-dev-hppa-cross,
  69. target: -static -O1 linux-generic32,
  70. fips: no,
  71. tests: -test_includes -test_store -test_x509_store
  72. }, {
  73. arch: m68k-linux-gnu,
  74. libs: libc6-dev-m68k-cross,
  75. target: -static -m68040 linux-latomic -Wno-stringop-overflow,
  76. fips: no,
  77. tests: -test_includes -test_store -test_x509_store
  78. }, {
  79. arch: mips-linux-gnu,
  80. libs: libc6-dev-mips-cross,
  81. target: -static linux-mips32,
  82. fips: no,
  83. tests: -test_includes -test_store -test_x509_store
  84. }, {
  85. arch: mips64-linux-gnuabi64,
  86. libs: libc6-dev-mips64-cross,
  87. target: -static linux64-mips64,
  88. fips: no
  89. }, {
  90. arch: mipsel-linux-gnu,
  91. libs: libc6-dev-mipsel-cross,
  92. target: linux-mips32,
  93. tests: -test_includes -test_store -test_x509_store
  94. }, {
  95. arch: powerpc64le-linux-gnu,
  96. libs: libc6-dev-ppc64el-cross,
  97. # The default compiler for this platform on Ubuntu 20.04 seems
  98. # buggy and causes test failures. Dropping the optimisation level
  99. # resolves it.
  100. target: -O2 linux-ppc64le
  101. }, {
  102. arch: riscv64-linux-gnu,
  103. libs: libc6-dev-riscv64-cross,
  104. target: linux64-riscv64
  105. }, {
  106. arch: s390x-linux-gnu,
  107. libs: libc6-dev-s390x-cross,
  108. target: linux64-s390x -Wno-stringop-overflow
  109. }, {
  110. arch: sh4-linux-gnu,
  111. libs: libc6-dev-sh4-cross,
  112. target: no-async linux-latomic,
  113. tests: -test_includes -test_store -test_x509_store
  114. },
  115. # These build with shared libraries but they crash when run
  116. # They mirror static builds above in order to cover more of the
  117. # code base.
  118. {
  119. arch: hppa-linux-gnu,
  120. libs: libc6-dev-hppa-cross,
  121. target: linux-generic32,
  122. tests: none
  123. }, {
  124. arch: m68k-linux-gnu,
  125. libs: libc6-dev-m68k-cross,
  126. target: -mcfv4e -mxgot linux-latomic -Wno-stringop-overflow no-quic,
  127. tests: none
  128. }, {
  129. arch: mips-linux-gnu,
  130. libs: libc6-dev-mips-cross,
  131. target: linux-mips32,
  132. tests: none
  133. }, {
  134. arch: mips64-linux-gnuabi64,
  135. libs: libc6-dev-mips64-cross,
  136. target: linux64-mips64,
  137. tests: none
  138. },
  139. # This build doesn't execute either with or without shared libraries.
  140. {
  141. arch: sparc64-linux-gnu,
  142. libs: libc6-dev-sparc64-cross,
  143. target: linux64-sparcv9,
  144. tests: none
  145. }
  146. ]
  147. runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
  148. steps:
  149. - name: install package repository
  150. if: matrix.platform.ppa != ''
  151. run: |
  152. sudo add-apt-repository ppa:${{ matrix.platform.ppa }}
  153. - name: install packages
  154. run: |
  155. sudo apt-get update
  156. sudo apt-get -yq --force-yes install \
  157. gcc-${{ matrix.platform.arch }} \
  158. ${{ matrix.platform.libs }}
  159. - uses: actions/checkout@v4
  160. - name: checkout fuzz/corpora submodule
  161. run: git submodule update --init --depth 1 fuzz/corpora
  162. - name: config with FIPS
  163. if: matrix.platform.fips != 'no'
  164. run: |
  165. ./config --banner=Configured --strict-warnings enable-fips \
  166. --cross-compile-prefix=${{ matrix.platform.arch }}- \
  167. ${{ matrix.platform.target }}
  168. - name: config without FIPS
  169. if: matrix.platform.fips == 'no'
  170. run: |
  171. ./config --banner=Configured --strict-warnings \
  172. --cross-compile-prefix=${{ matrix.platform.arch }}- \
  173. ${{ matrix.platform.target }}
  174. - name: config dump
  175. run: ./configdata.pm --dump
  176. - name: make
  177. run: make -s -j4
  178. - name: install qemu
  179. if: matrix.platform.tests != 'none'
  180. run: sudo apt-get -yq --force-yes install qemu-user
  181. - name: Set QEMU environment
  182. if: matrix.platform.qemucpu != ''
  183. run: echo "QEMU_CPU=${{ matrix.platform.qemucpu }}" >> $GITHUB_ENV
  184. - name: Set OpenSSL caps environment
  185. if: matrix.platform.opensslcapsname != ''
  186. run: echo "OPENSSL_${{ matrix.platform.opensslcapsname }}=\
  187. ${{ matrix.platform.opensslcaps }}" >> $GITHUB_ENV
  188. - name: get cpu info
  189. run: cat /proc/cpuinfo
  190. - name: make all tests
  191. if: github.event_name == 'push' && matrix.platform.tests == ''
  192. run: |
  193. .github/workflows/make-test \
  194. TESTS="-test_afalg" \
  195. QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
  196. - name: make some tests
  197. if: github.event_name == 'push' && matrix.platform.tests != 'none' && matrix.platform.tests != ''
  198. run: |
  199. .github/workflows/make-test \
  200. TESTS="${{ matrix.platform.tests }} -test_afalg" \
  201. QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
  202. - name: make evp tests
  203. if: github.event_name == 'pull_request' && matrix.platform.tests != 'none'
  204. run: |
  205. .github/workflows/make-test \
  206. TESTS="test_evp*" \
  207. QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
  208. - name: save artifacts
  209. uses: actions/upload-artifact@v3
  210. with:
  211. name: "cross-compiles@${{ matrix.platform.arch }}"
  212. path: artifacts.tar.gz
  213. if-no-files-found: ignore