Fix OpenSSL 3 build issues (#52)

* OpenSSL 1.1.1x is EOL, this should make it work for 3.x.x versions.
See https://www.openssl.org/blog/blog/2023/03/28/1.1.1-EOL/

* Removed asm inheritance from config

* Make 3.x the standard parsing logic

* Drop all references to Bitcode

* Use newer -platform_version

* Default to 3.2.0

---------

Co-authored-by: Davide De Rosa <keeshux@gmail.com>
This commit is contained in:
hoppjan 2023-12-12 11:41:50 +01:00 committed by GitHub
parent 2d1df58291
commit 12ad7b9efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 58 deletions

View File

@ -1 +1 @@
1.1.1q-0
3.2.0-0

View File

@ -25,7 +25,7 @@ set -u
# SCRIPT DEFAULTS
# Default version in case no version is specified
DEFAULTVERSION="1.1.1q"
DEFAULTVERSION="3.2.0"
# Default (=full) set of targets (OpenSSL >= 1.1.1) to build
DEFAULTTARGETS=`cat <<TARGETS

View File

@ -6,13 +6,9 @@ my %targets = ();
## Base settings for cross-compile
# Based on 10-main.conf: iphoneos-cross
# Add generic compiler flags
# Add embed-bitcode option if SDK version is 9 or higher
"all-base" => {
template => 1,
cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common',
sub { ((!defined($ENV{'CONFIG_DISABLE_BITCODE'}) || $ENV{'CONFIG_DISABLE_BITCODE'} ne 'true') && defined($ENV{'SDKVERSION'}) && $ENV{'SDKVERSION'} =~ /^(9|[1-9][0-9]+)\./ && $disabled{shared})
? '-fembed-bitcode' : (); },
),
cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common')
},
## Base settings
@ -47,14 +43,14 @@ my %targets = ();
# Device
"ios64-cross-arm64" => {
inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ],
inherit_from => [ "darwin-common", "ios-cross-base" ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",
sys_id => "iOS",
},
"ios64-cross-arm64e" => {
inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ],
inherit_from => [ "darwin-common", "ios-cross-base" ],
cflags => add("-arch arm64e"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",
@ -96,20 +92,20 @@ my %targets = ();
# Device
"watchos-cross-armv7k" => {
inherit_from => [ "darwin-common", "watchos-cross-base", asm("armv7_asm") ],
cflags => add("-arch armv7k -fembed-bitcode"),
inherit_from => [ "darwin-common", "watchos-cross-base" ],
cflags => add("-arch armv7k"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-cross-arm64_32" => {
inherit_from => [ "darwin-common", "watchos-cross-base"],
cflags => add("-arch arm64_32 -fembed-bitcode"),
cflags => add("-arch arm64_32"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-cross-arm64" => {
inherit_from => [ "darwin-common", "watchos-cross-base", asm("aarch64_asm") ],
cflags => add("-arch arm64 -fembed-bitcode"),
inherit_from => [ "darwin-common", "watchos-cross-base" ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",
defines => [ "HAVE_FORK=0" ],
@ -118,19 +114,19 @@ my %targets = ();
# Simulator
"watchos-sim-cross-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "watchos-cross-base"],
cflags => add("-fembed-bitcode"),
cflags => add(""),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-sim-cross-arm64" => {
inherit_from => [ "darwin64-arm64-cc", "watchos-cross-base"],
cflags => add("-target arm64-apple-watchos7.2-simulator -mwatchos-version-min=7.2 -fembed-bitcode"),
cflags => add("-target arm64-apple-watchos7.2-simulator -mwatchos-version-min=7.2"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
"watchos-sim-cross-i386" => {
inherit_from => [ "darwin-common", "watchos-cross-base"],
cflags => add("-arch i386 -fembed-bitcode"),
cflags => add("-arch i386"),
defines => [ "HAVE_FORK=0" ],
sys_id => "WatchOS",
},
@ -139,7 +135,7 @@ my %targets = ();
# Device
"tvos64-cross-arm64" => {
inherit_from => [ "darwin-common", "tvos-cross-base", asm("aarch64_asm") ],
inherit_from => [ "darwin-common", "tvos-cross-base" ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",

View File

@ -25,29 +25,6 @@ fi
#ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX" "Catalyst" "Watch")
ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator")
function check_bitcode() {
local BITCODE_PATH=$1
local IS_VERBOSE=$2
if [[ $FWTYPE == "dynamic" ]]; then
BITCODE_PATTERN="__LLVM"
else
BITCODE_PATTERN="__bitcode"
fi
if otool -l "$BITCODE_PATH" | grep "${BITCODE_PATTERN}" >/dev/null; then
if $IS_VERBOSE; then
echo "INFO: $BITCODE_PATH contains Bitcode"
fi
BITCODE_ENABLED=1
else
if $IS_VERBOSE; then
echo "INFO: $BITCODE_PATH doesn't contain Bitcode"
fi
BITCODE_ENABLED=0
fi
}
# Inspect Mach-O load commands to get minimum SDK version.
#
# Depending on the actual minimum SDK version it may look like this
@ -139,22 +116,22 @@ if [ $FWTYPE == "dynamic" ]; then
MIN_SDK_VERSION=$(get_min_sdk "${TARGETDIR}/lib/libcrypto.a")
if [[ $PLATFORM == AppleTVSimulator* ]]; then
MIN_SDK="-tvos_simulator_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version tvos-simulator $MIN_SDK_VERSION"
elif [[ $PLATFORM == AppleTV* ]]; then
MIN_SDK="-tvos_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version tvos $MIN_SDK_VERSION"
elif [[ $PLATFORM == MacOSX* ]]; then
MIN_SDK="-macosx_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version macos $MIN_SDK_VERSION"
elif [[ $PLATFORM == Catalyst* ]]; then
MIN_SDK="-platform_version mac-catalyst $MIN_SDK_VERSION $MIN_SDK_VERSION"
PLATFORM="MacOSX"
elif [[ $PLATFORM == iPhoneSimulator* ]]; then
MIN_SDK="-ios_simulator_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version ios-simulator $MIN_SDK_VERSION"
elif [[ $PLATFORM == WatchOS* ]]; then
MIN_SDK="-watchos_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version watchos $MIN_SDK_VERSION"
elif [[ $PLATFORM == WatchSimulator* ]]; then
MIN_SDK="-watchos_simulator_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version watchos-simulator $MIN_SDK_VERSION"
else
MIN_SDK="-ios_version_min $MIN_SDK_VERSION"
MIN_SDK="-platform_version ios $MIN_SDK_VERSION"
fi
CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
@ -172,15 +149,8 @@ if [ $FWTYPE == "dynamic" ]; then
ar -x ../lib/libssl.a
cd ..
BUNDLE_BITCODE=""
check_bitcode "lib/libssl.a" false
if [[ $BITCODE_ENABLED == 1 ]]; then
BUNDLE_BITCODE="-bitcode_bundle"
fi
ld obj/*.o \
-dylib \
$BUNDLE_BITCODE \
-lSystem \
-arch $ARCH \
$MIN_SDK \
@ -212,7 +182,6 @@ if [ $FWTYPE == "dynamic" ]; then
-e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \
-i '' "$FWDIR/Info.plist"
echo "Created $FWDIR"
check_bitcode "$FWDIR/$FWNAME" true
else
echo "Skipped framework for $SYS"
fi
@ -242,7 +211,6 @@ else
-e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \
-i '' "$FWDIR/Info.plist"
echo "Created $FWDIR"
check_bitcode "$FWDIR/$FWNAME" true
else
echo "Skipped framework for $SYS"
fi

View File

@ -1,6 +1,7 @@
#!/bin/bash
function get_openssl_version() {
local std_version=$1
local std_version=$1
if [[ ! "$std_version" =~ 3.*.* ]]; then
local script_version=${2:-}
local generic_version=${std_version%?}
local subpatch=${std_version: -1}
@ -9,4 +10,7 @@ function get_openssl_version() {
script_version="$(printf '%02d' $script_version)"
local normalized_version="${generic_version}${subpatch_number}${script_version}"
echo $normalized_version
return
fi
echo $std_version
}