Build-OpenSSL-cURL icon indicating copy to clipboard operation
Build-OpenSSL-cURL copied to clipboard

Error ouccured when build open-ssl on apple silicon mac book air(M1)

Open mgu1206 opened this issue 3 years ago • 6 comments

When I try to build on my macbook air(M1, basic model).

it occured error, I think build script try to build for x86_64, not arm64.

is there any option to build for arm64 architecture?

mgu1206 avatar Feb 03 '22 00:02 mgu1206

Hi @mgu1206 I'm building on a M1 iMac but that should be the same as the Macbook Air M1. It builds both arm64 and x86_6 binaries. Please make sure you have the xcode command line tools installed. Can you post the error you are getting?

jasonacox avatar Feb 03 '22 02:02 jasonacox

Hi @jasonacox :) I try to build by using ./build.sh and I got these error messages.

Building OpenSSL Using openssl-1.1.1l.tar.gz ** Building OpenSSL 1.1.1 ** Unpacking openssl Building Mac libraries Building openssl-1.1.1l for x86_64 (MacOS 12.1) ** ERROR with Build - Check /tmp/openssl*.log 1 error generated. make[1]: *** [apps/apps.o] Error 1 make: *** [all] Error 2

But there is no openssl*.log in tmp.

mgu1206 avatar Feb 05 '22 04:02 mgu1206

Interesting. My M1 is on MacOS 11.6.2. I'll upgrade (looks like 12.2 is latest) and see if I can replicate your error.

Would you mind also running this and pasting output?

uname -m
xcode-select -print-path
clang --version
gcc --version

jasonacox avatar Feb 05 '22 06:02 jasonacox

@mgu1206 - Ok, I upgraded to MacOS 2.2 and did a fresh clone and build. I'm able to build M1 binaries:

Build-OpenSSL-cURL
This script builds OpenSSL, nghttp2 and libcurl for MacOS, iOS and tvOS devices.
Targets: x86_64, armv7, armv7s, arm64 and arm64e

Building OpenSSL
Downloading openssl-1.1.1l.tar.gz
** Building OpenSSL 1.1.1 **
Unpacking openssl
Building Mac libraries
Building openssl-1.1.1l for x86_64 (MacOS 12.2)
Building openssl-1.1.1l for arm64 (MacOS 12.2)
Testing binary for arm64:
OpenSSL 1.1.1l  24 Aug 2021

...

Testing Universal Mac binaries for arm64...
  cURL
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/curl: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/curl (for architecture x86_64):	Mach-O 64-bit executable x86_64
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/curl (for architecture arm64):	Mach-O 64-bit executable arm64
curl 7.80.0 (x86_64-apple-darwin) libcurl/7.80.0 OpenSSL/1.1.1l zlib/1.2.11 libidn2/2.3.2 nghttp2/1.46.0
Release-Date: 2021-11-10
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets
  OpenSSL
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/openssl: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/openssl (for architecture x86_64):	Mach-O 64-bit executable x86_64
archive/libcurl-7.80.0-openssl-1.1.1l-nghttp2-1.46.0/bin/openssl (for architecture arm64):	Mach-O 64-bit executable arm64
OpenSSL 1.1.1l  24 Aug 2021
Sat Feb  5 09:57:27 2022 - End

Build Complete
  Duration 00h:14m:23s

I am getting some warning for the tvOS build that I need to troubleshoot, but it looks like the MacOS and iOS binaries are still building correctly at least with MacOS 12.2.

As usual, I had to launch the Xcode GUI and have it "install additional tools". Make sure you are doing that. In the past, I also had to install at least one Simulator version - you might try this too (Xcode -> Preferences):

image

jasonacox avatar Feb 05 '22 18:02 jasonacox

Interesting. My M1 is on MacOS 11.6.2. I'll upgrade (looks like 12.2 is latest) and see if I can replicate your error.

Would you mind also running this and pasting output?

uname -m
xcode-select -print-path
clang --version
gcc --version

It's so late, sorry :)

mingyeonguk@Mins-MacBook-Air ~ % uname -m
arm64
mingyeonguk@Mins-MacBook-Air ~ % xcode-select -print-path
/Library/Developer/CommandLineTools
mingyeonguk@Mins-MacBook-Air ~ % clang --version
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
mingyeonguk@Mins-MacBook-Air ~ % gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

here is my cmd output. :)

mgu1206 avatar Feb 11 '22 11:02 mgu1206

Thanks @mgu1206 ! You seems to be using the command line tools without Xcode. Did you install Xcode? I'm not certain, but it seems likely that you are missing the libraries needed to do cross-compiling. The first step in build.shscript is to cross-compile to a x86_64 target. If your M1 doesn't have the needed x86_64 libraries, it will fail.

Here is the output from my iMac, notice the paths are pointing inside Xcode.app:

jason@iMac:~$ uname -m
arm64
jason@iMac:~$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
jason@iMac:~$ clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
jason@iMac:~$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

You could try changing your development environment to the Xcode path:

sudo xcode-select -switch /Applications/Xcode.app

jasonacox avatar Feb 12 '22 03:02 jasonacox

Closing with new build - please re-open if the problem persists.

jasonacox avatar Jul 20 '23 02:07 jasonacox