|
34 | 34 | # Updated 9/10/16 for openssl-1.1.0 |
35 | 35 | # Updated 1/25/18 for bulding openssl 1.1.0g (updated comemnts only) |
36 | 36 | # Updated 1/23/19 use libc++ instead of libstdc++ for Xcode 10 compatibility |
37 | | -# Updated 8/22/20 TO build Apple Silicon / arm64 and x86_64 Universal binary |
| 37 | +# Updated 10/20/20 To build Apple Silicon / arm64 and x86_64 Universal binary |
38 | 38 | # |
39 | 39 | ## This script requires OS 10.8 or later |
40 | 40 | # |
@@ -116,6 +116,42 @@ if [ "${doclean}" != "yes" ]; then |
116 | 116 | fi |
117 | 117 | fi |
118 | 118 |
|
| 119 | +## openssl 1.1.0g does not have a configure option for darwin arm64, |
| 120 | +## so we patch Configurations/10-main.conf to add it. |
| 121 | +## Derived from https://github.com/openssl/openssl/pull/12369/files |
| 122 | +## and https://cutecoder.org/programming/compile-open-ssl-apple-silicon/ |
| 123 | +## |
| 124 | +## Note: setting perlasm_scheme to "ios64" tells configure to use |
| 125 | +## the correct assembler instructions for Apple Silicon. Setting |
| 126 | +## it to "macosx" causes it to use x86_64 assembler instructions. |
| 127 | +## |
| 128 | +if [ ! -f Configurations/10-main.conf.orig ]; then |
| 129 | + cat >> /tmp/0-main_conf_diff << ENDOFFILE |
| 130 | +--- 10-main.conf 2017-11-02 07:29:01.000000000 -0700 |
| 131 | ++++ 10-main_patched.con2020-10-19 01:34:06.000000000 -0700 |
| 132 | +@@ -1614,6 +1614,14 @@ |
| 133 | + perlasm_scheme => "macosx", |
| 134 | + shared_ldflag => "-arch x86_64 -dynamiclib", |
| 135 | + }, |
| 136 | ++ "darwin64-arm64-cc" => { |
| 137 | ++ inherit_from => [ "darwin-common", asm("aarch64_asm") ], |
| 138 | ++ CFLAGS => add("-Wall"), |
| 139 | ++ cflags => add("-arch arm64"), |
| 140 | ++ lib_cppflags => add("-DL_ENDIAN"), |
| 141 | ++ bn_ops => "SIXTY_FOUR_BIT_LONG", |
| 142 | ++ perlasm_scheme => "ios64", |
| 143 | ++ }, |
| 144 | + |
| 145 | + #### iPhoneOS/iOS |
| 146 | + # |
| 147 | +ENDOFFILE |
| 148 | + patch -bfi /tmp/0-main_conf_diff Configurations/10-main.conf |
| 149 | + rm -f /tmp/0-main_conf_diff |
| 150 | +else |
| 151 | + echo "Configurations/10-main.conf already patched" |
| 152 | +fi |
| 153 | +echo "" |
| 154 | + |
119 | 155 | GPPPATH=`xcrun -find g++` |
120 | 156 | if [ $? -ne 0 ]; then |
121 | 157 | echo "ERROR: can't find g++ compiler" |
@@ -185,20 +221,13 @@ if [ $GCC_can_build_arm64 == "yes" ]; then |
185 | 221 | export SDKROOT="${SDKPATH}" |
186 | 222 | export MACOSX_DEPLOYMENT_TARGET=10.7 |
187 | 223 |
|
188 | | - ## TEMPORARY WORKAROUNDS because OpenSSL 1.1.0g has no configure option for |
189 | | - ## darwin arm64 |
190 | 224 | if [ "x${lprefix}" != "x" ]; then |
191 | | - ./configure --prefix=${lprefix} no-shared ios64-cross |
| 225 | + ./configure --prefix=${lprefix} no-shared darwin64-arm64-cc |
192 | 226 | if [ $? -ne 0 ]; then return 1; fi |
193 | 227 | else |
194 | | - ./configure no-shared ios64-cross |
| 228 | + ./configure no-shared darwin64-arm64-cc |
195 | 229 | if [ $? -ne 0 ]; then return 1; fi |
196 | 230 | fi |
197 | | - ## Patch the ios64-cross makefile to build for a Mac instead of iOS device |
198 | | - sed -i "" 's:-arch arm64:-target arm64-apple-macos10.7 -stdlib=libc++:g' Makefile |
199 | | - sed -i "" 's:-mios-version-min=7.0.0:-DMAC_OS_X_VERSION_MAX_ALLOWED=1070:g' Makefile |
200 | | - sed -i "" 's:-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK):-isysroot ${SDKROOT}:g' Makefile |
201 | | - ## END OF TEMPORARY WORKAROUNDS |
202 | 231 |
|
203 | 232 | # save x86_64 lib for later use |
204 | 233 | mv -f libcrypto.a libcrypto_x86_64.a |
@@ -232,9 +261,8 @@ if [ $GCC_can_build_arm64 == "yes" ]; then |
232 | 261 | rm -f libcrypto_x86_64.a libcrypto_arm64.a |
233 | 262 | rm -f libssl_x86_64.a libssl_arm64.a |
234 | 263 |
|
235 | | - ## openssl 1.1.0g does not have a configure option for darwin arm64, so we use |
236 | | - ## the same configure as for ios64-cross with some patches and hope it works |
237 | | - ## properly. |
| 264 | + ## openssl 1.1.0g does not have a configure option for darwin arm64, so we |
| 265 | + ## patched Configurations/10-main.conf to add it. |
238 | 266 | ## NOTE: At the time of writing, I do not have an arm64 Mac to test with. |
239 | 267 | # Revisit this if a newer version of openssl becomes available. |
240 | 268 | # |
|
0 commit comments