build.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. PERL="${BUILD_PREFIX}/bin/perl"
  3. declare -a _CONFIG_OPTS
  4. _CONFIG_OPTS+=(--prefix=${PREFIX})
  5. _CONFIG_OPTS+=(--libdir=lib)
  6. _CONFIG_OPTS+=(shared)
  7. _CONFIG_OPTS+=(threads)
  8. _CONFIG_OPTS+=(no-ssl2) # broken, insecure protocol
  9. _CONFIG_OPTS+=(no-ssl3) # broken, insecure protocol
  10. _CONFIG_OPTS+=(no-zlib)
  11. _CONFIG_OPTS+=(enable-legacy) # necessary to support some function in Python package cryptography
  12. _BASE_CC=$(basename "${CC}")
  13. if [[ ${_BASE_CC} == *-* ]]; then
  14. # We are cross-compiling or using a specific compiler.
  15. # do not allow config to make any guesses based on uname.
  16. _CONFIGURATOR="perl ./Configure"
  17. case ${_BASE_CC} in
  18. x86_64-*linux*)
  19. _CONFIG_OPTS+=(linux-x86_64)
  20. CFLAGS="${CFLAGS} -Wa,--noexecstack"
  21. ;;
  22. aarch64-*-linux*)
  23. _CONFIG_OPTS+=(linux-aarch64)
  24. CFLAGS="${CFLAGS} -Wa,--noexecstack"
  25. ;;
  26. *powerpc64le-*linux*)
  27. _CONFIG_OPTS+=(linux-ppc64le)
  28. CFLAGS="${CFLAGS} -Wa,--noexecstack"
  29. ;;
  30. # Optimized s390x builds must use -fno-merge-constants.
  31. # Without this, a string ("private") in the nid_objs table
  32. # (obj_dat.c) will vanish when libcrypto.so is built.
  33. # This is currently assumed to be a bug in the -fmerge-constants
  34. # optimization for this architecture.
  35. # This issue prevents the OBJ_sn2nid function from ever finding
  36. # prime256v1, rendering it unusable as an ecparam.
  37. *s390x-*linux*)
  38. _CONFIG_OPTS+=(linux64-s390x)
  39. CFLAGS="${CFLAGS} -Wa,--noexecstack -fno-merge-constants"
  40. ;;
  41. *darwin-arm64*|*arm64-*-darwin*)
  42. _CONFIG_OPTS+=(darwin64-arm64-cc)
  43. ;;
  44. *darwin*)
  45. _CONFIG_OPTS+=(darwin64-x86_64-cc)
  46. ;;
  47. esac
  48. else
  49. if [[ $(uname) == Darwin ]]; then
  50. _CONFIG_OPTS+=(darwin64-x86_64-cc)
  51. _CONFIGURATOR="perl ./Configure"
  52. else
  53. # Use config, which is a config.guess-like wrapper around Configure
  54. _CONFIGURATOR=./config
  55. fi
  56. fi
  57. CC=${CC}" ${CPPFLAGS} ${CFLAGS}" \
  58. ${_CONFIGURATOR} ${_CONFIG_OPTS[@]} ${LDFLAGS}
  59. # This is not working yet. It may be important if we want to perform a parallel build
  60. # as enabled by openssl-1.0.2d-parallel-build.patch where the dependency info is old.
  61. # makedepend is a tool from xorg, but it seems to be little more than a wrapper for
  62. # '${CC} -M', so my plan is to replace it with that, or add a package for it? This
  63. # tool uses xorg headers (and maybe libraries) which is unfortunate.
  64. # http://stackoverflow.com/questions/6362705/replacing-makedepend-with-cc-mm
  65. # echo "echo \$*" > "${SRC_DIR}"/makedepend
  66. # echo "${CC} -M $(echo \"\$*\" | sed s'# --##g')" >> "${SRC_DIR}"/makedepend
  67. # chmod +x "${SRC_DIR}"/makedepend
  68. # PATH=${SRC_DIR}:${PATH} make -j1 depend
  69. make -j${CPU_COUNT} ${VERBOSE_AT}
  70. # expected error: https://github.com/openssl/openssl/issues/6953
  71. # OK to ignore: https://github.com/openssl/openssl/issues/6953#issuecomment-415428340
  72. rm test/recipes/04-test_err.t
  73. # When testing this via QEMU, even though it ends printing:
  74. # "ALL TESTS SUCCESSFUL."
  75. # .. it exits with a failure code.
  76. if [[ "${HOST}" == "${BUILD}" ]]; then
  77. # Using verbosity on failed (sub-)tests only VF=1
  78. make test V=1 > testsuite.log 2>&1 || true
  79. if ! cat testsuite.log | grep -i "all tests successful"; then
  80. echo "Testsuite failed! See $(pwd)/testsuite.log for more info."
  81. cat $(pwd)/testsuite.log
  82. exit 1
  83. fi
  84. fi
  85. make install_sw install_ssldirs
  86. # https://github.com/ContinuumIO/anaconda-issues/issues/6424
  87. if [[ ${HOST} =~ .*linux.* ]]; then
  88. if execstack -q "${PREFIX}"/lib/libcrypto.so.3.0 | grep -e '^X '; then
  89. echo "Error, executable stack found in libcrypto.so.3.0"
  90. exit 1
  91. fi
  92. fi