为arm64 iOS模拟器构建openssl

3

描述

我正在尝试构建仅针对iphonesimulator目标的库,其架构为arm64,但链接步骤失败并出现错误:

${LDCMD:-/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang}  -O3 -fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -L. -Wl,-search_paths_first  \
                -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \
                 apps/libapps.a -lssl -lcrypto  
ld: building for iOS, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/lib/libSystem.tbd) built for iOS Simulator, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/lib/libSystem.tbd' for architecture arm64

配置命令:

./Configure iossimulator-xcrun threads no-shared "-fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC" no-asm no-hw no-async --prefix=/Users/macosuser/Build/OpenSSL/Install "-arch arm64" "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk"
Configuring OpenSSL version 1.1.1j (0x101010afL) for iossimulator-xcrun
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

构建命令的格式如下:

...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -I. -Iinclude -Iapps  -O3 -fvisibility=hidden -miphoneos-version-min=9.0 -fembed-bitcode -fPIC -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk -D_REENTRANT -DNDEBUG  -MMD -MF apps/x509.d.tmp -MT apps/x509.o -c -o apps/x509.o apps/x509.c
...

问题

我不明白为什么其他架构(i386x86_64)可以无问题地进行构建。也许我错过了一些微妙之处,但我无法理解是哪一个。

为什么需要这个 - 使用此库的应用程序必须在搭载 M1 处理器的 MacBook 上的模拟器上运行。

环境规格

  • MacOS 11.4
  • XCode v12.5
  • OpenSSL v1.1.1j
  • 编译器 - AppleClang 12.0.5.12050022
1个回答

8
因为我不是iOS开发人员,所以我一开始并不了解如何在这个平台上通过make来构建库的具体细节。
问题在于:
-miphoneos-version-min 指定了iOS的部署目标,但由于我正在为iOS模拟器构建库,因此需要使用 -mios-simulator-version-min。
因此,配置命令应该像这样:
./Configure iossimulator-xcrun threads no-shared "-fvisibility=hidden -mios-simulator-version-min=9.0 -fembed-bitcode -fPIC" no-asm no-hw no-async --prefix=/Users/macosuser/Build/OpenSSL/Install "-arch arm64" "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk"

如果有人能解释为什么-miphoneos-version-min标志对于i386和x86_64体系结构按预期工作,我将不胜感激。

2
非常感谢,使用-mios-simulator-version-min可以解决你遇到的相同问题。我不知道你是如何发现这个针对m1的更改的。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接