Skip to content

Commit 88d9b01

Browse files
committed
Disable bitcode for openssl 3
1 parent 58792e4 commit 88d9b01

File tree

6 files changed

+86
-71
lines changed

6 files changed

+86
-71
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ The build script accepts several arguments to adjust versions and toggle feature
2121
```
2222
./build.sh [-o <OpenSSL version>] [-c <curl version>] [-n <nghttp2 version>] [-d] [-e] [-3] [-x] [-h] [...]
2323
24-
-o <version> Build OpenSSL version (default 1.1.1o)
25-
-c <version> Build curl version (default 7.83.1)
26-
-n <version> Build nghttp2 version (default 1.47.0)
24+
-o <version> Build OpenSSL version (default 3.0.9)
25+
-c <version> Build curl version (default 8.1.2)
26+
-n <version> Build nghttp2 version (default 1.55.1)
2727
-d Compile without HTTP2 support
2828
-e Compile with OpenSSL engine support
2929
-b Compile without bitcode
@@ -72,9 +72,9 @@ You can update the default version by editing this section in the `build.sh` scr
7272
# EDIT this section to Select Default Versions #
7373
################################################
7474

75-
OPENSSL="1.1.1o" # https://www.openssl.org/source/
76-
LIBCURL="7.83.1" # https://curl.haxx.se/download.html
77-
NGHTTP2="1.47.0" # https://nghttp2.org/
75+
OPENSSL="3.0.9" # https://www.openssl.org/source/
76+
LIBCURL="8.1.2" # https://curl.haxx.se/download.html
77+
NGHTTP2="1.55.1" # https://nghttp2.org/
7878

7979
################################################
8080
```

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ echo "Targets: x86_64, armv7, armv7s, arm64 and arm64e"
169169
## Start Counter
170170
START=$(date +%s)
171171

172+
# Starting with OpenSSL 3.0 force nobitcode
173+
if [[ "$OPENSSL" = "3.0"* ]]; then
174+
disablebitcode="-b"
175+
fi
176+
172177
## OpenSSL Build
173178
echo
174179
cd openssl

curl/libcurl-build.sh

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ buildIOSsim()
407407
buildTVOS()
408408
{
409409
ARCH=$1
410+
BITCODE=$2
411+
412+
if [[ "${BITCODE}" == "nobitcode" ]]; then
413+
CC_BITCODE_FLAG=""
414+
else
415+
CC_BITCODE_FLAG="-fembed-bitcode"
416+
fi
410417

411418
pushd . > /dev/null
412419
cd "${CURL_VERSION}"
@@ -426,7 +433,7 @@ buildTVOS()
426433
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
427434
export CROSS_SDK="${PLATFORM}${TVOS_SDK_VERSION}.sdk"
428435
export CC="${DEVELOPER}/usr/bin/gcc"
429-
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} -fembed-bitcode"
436+
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} ${CC_BITCODE_FLAG}"
430437
export LDFLAGS="-arch ${ARCH} -isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -L${OPENSSL}/tvOS/lib ${NGHTTP2LIB}"
431438
# export PKG_CONFIG_PATH
432439

@@ -448,6 +455,13 @@ buildTVOS()
448455
buildTVOSsim()
449456
{
450457
ARCH=$1
458+
BITCODE=$2
459+
460+
if [[ "${BITCODE}" == "nobitcode" ]]; then
461+
CC_BITCODE_FLAG=""
462+
else
463+
CC_BITCODE_FLAG="-fembed-bitcode"
464+
fi
451465

452466
pushd . > /dev/null
453467
cd "${CURL_VERSION}"
@@ -467,11 +481,10 @@ buildTVOSsim()
467481
export SYSROOT=$(xcrun --sdk appletvsimulator --show-sdk-path)
468482
export CC="${DEVELOPER}/usr/bin/gcc"
469483
export CXX="${DEVELOPER}/usr/bin/gcc"
470-
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} -fembed-bitcode ${RUNTARGET}"
484+
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} ${CC_BITCODE_FLAG} ${RUNTARGET}"
471485
export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT} -L${OPENSSL}/${PLATFORMDIR}/lib ${NGHTTP2LIB}"
472486
export CPPFLAGS=" -I.. -isysroot ${SYSROOT} "
473487

474-
475488
echo -e "${subbold}Building ${CURL_VERSION} for ${PLATFORM} ${TVOS_SDK_VERSION} ${archbold}${ARCH}${dim} (tvOS SIM ${TVOS_MIN_SDK_VERSION})"
476489

477490
if [[ "${ARCH}" == "arm64" ]]; then
@@ -548,67 +561,73 @@ lipo \
548561
-create -output lib/libcurl_Catalyst.a
549562
fi
550563

551-
echo -e "${bold}Building iOS libraries (bitcode)${dim}"
552-
buildIOS "armv7" "bitcode"
553-
buildIOS "armv7s" "bitcode"
554-
buildIOS "arm64" "bitcode"
555-
buildIOS "arm64e" "bitcode"
564+
if ! [[ "${NOBITCODE}" == "yes" ]]; then
565+
BITCODE="bitcode"
566+
else
567+
BITCODE="nobitcode"
568+
fi
569+
570+
echo -e "${bold}Building iOS libraries (${BITCODE})${dim}"
571+
buildIOS "armv7" "${BITCODE}"
572+
buildIOS "armv7s" "${BITCODE}"
573+
buildIOS "arm64" "${BITCODE}"
574+
buildIOS "arm64e" "${BITCODE}"
556575

557576
lipo \
558-
"/tmp/${CURL_VERSION}-iOS-armv7-bitcode/lib/libcurl.a" \
559-
"/tmp/${CURL_VERSION}-iOS-armv7s-bitcode/lib/libcurl.a" \
560-
"/tmp/${CURL_VERSION}-iOS-arm64-bitcode/lib/libcurl.a" \
561-
"/tmp/${CURL_VERSION}-iOS-arm64e-bitcode/lib/libcurl.a" \
577+
"/tmp/${CURL_VERSION}-iOS-armv7-${BITCODE}/lib/libcurl.a" \
578+
"/tmp/${CURL_VERSION}-iOS-armv7s-${BITCODE}/lib/libcurl.a" \
579+
"/tmp/${CURL_VERSION}-iOS-arm64-${BITCODE}/lib/libcurl.a" \
580+
"/tmp/${CURL_VERSION}-iOS-arm64e-${BITCODE}/lib/libcurl.a" \
562581
-create -output lib/libcurl_iOS.a
563582

564-
buildIOSsim "i386" "bitcode"
565-
buildIOSsim "x86_64" "bitcode"
566-
buildIOSsim "arm64" "bitcode"
583+
buildIOSsim "i386" "${BITCODE}"
584+
buildIOSsim "x86_64" "${BITCODE}"
585+
buildIOSsim "arm64" "${BITCODE}"
567586

568587
lipo \
569-
"/tmp/${CURL_VERSION}-iOS-simulator-i386-bitcode/lib/libcurl.a" \
570-
"/tmp/${CURL_VERSION}-iOS-simulator-x86_64-bitcode/lib/libcurl.a" \
571-
"/tmp/${CURL_VERSION}-iOS-simulator-arm64-bitcode/lib/libcurl.a" \
588+
"/tmp/${CURL_VERSION}-iOS-simulator-i386-${BITCODE}/lib/libcurl.a" \
589+
"/tmp/${CURL_VERSION}-iOS-simulator-x86_64-${BITCODE}/lib/libcurl.a" \
590+
"/tmp/${CURL_VERSION}-iOS-simulator-arm64-${BITCODE}/lib/libcurl.a" \
572591
-create -output lib/libcurl_iOS-simulator.a
573592

574593
lipo \
575-
"/tmp/${CURL_VERSION}-iOS-armv7-bitcode/lib/libcurl.a" \
576-
"/tmp/${CURL_VERSION}-iOS-armv7s-bitcode/lib/libcurl.a" \
577-
"/tmp/${CURL_VERSION}-iOS-arm64-bitcode/lib/libcurl.a" \
578-
"/tmp/${CURL_VERSION}-iOS-arm64e-bitcode/lib/libcurl.a" \
579-
"/tmp/${CURL_VERSION}-iOS-simulator-i386-bitcode/lib/libcurl.a" \
580-
"/tmp/${CURL_VERSION}-iOS-simulator-x86_64-bitcode/lib/libcurl.a" \
594+
"/tmp/${CURL_VERSION}-iOS-armv7-${BITCODE}/lib/libcurl.a" \
595+
"/tmp/${CURL_VERSION}-iOS-armv7s-${BITCODE}/lib/libcurl.a" \
596+
"/tmp/${CURL_VERSION}-iOS-arm64-${BITCODE}/lib/libcurl.a" \
597+
"/tmp/${CURL_VERSION}-iOS-arm64e-${BITCODE}/lib/libcurl.a" \
598+
"/tmp/${CURL_VERSION}-iOS-simulator-i386-${BITCODE}/lib/libcurl.a" \
599+
"/tmp/${CURL_VERSION}-iOS-simulator-x86_64-${BITCODE}/lib/libcurl.a" \
581600
-create -output lib/libcurl_iOS-fat.a
582601

583-
if [[ "${NOBITCODE}" == "yes" ]]; then
584-
echo -e "${bold}Building iOS libraries (nobitcode)${dim}"
585-
buildIOS "armv7" "nobitcode"
586-
buildIOS "armv7s" "nobitcode"
587-
buildIOS "arm64" "nobitcode"
588-
buildIOS "arm64e" "nobitcode"
589-
buildIOSsim "x86_64" "nobitcode"
590-
buildIOSsim "i386" "nobitcode"
591-
592-
lipo \
593-
"/tmp/${CURL_VERSION}-iOS-armv7-nobitcode/lib/libcurl.a" \
594-
"/tmp/${CURL_VERSION}-iOS-armv7s-nobitcode/lib/libcurl.a" \
595-
"/tmp/${CURL_VERSION}-iOS-simulator-i386-nobitcode/lib/libcurl.a" \
596-
"/tmp/${CURL_VERSION}-iOS-arm64-nobitcode/lib/libcurl.a" \
597-
"/tmp/${CURL_VERSION}-iOS-arm64e-nobitcode/lib/libcurl.a" \
598-
"/tmp/${CURL_VERSION}-iOS-simulator-x86_64-nobitcode/lib/libcurl.a" \
599-
-create -output lib/libcurl_iOS_nobitcode.a
600602

601-
fi
603+
# if [[ "${NOBITCODE}" == "yes" ]]; then
604+
# echo -e "${bold}Building iOS libraries (nobitcode)${dim}"
605+
# buildIOS "armv7" "nobitcode"
606+
# buildIOS "armv7s" "nobitcode"
607+
# buildIOS "arm64" "nobitcode"
608+
# buildIOS "arm64e" "nobitcode"
609+
# buildIOSsim "x86_64" "nobitcode"
610+
# buildIOSsim "i386" "nobitcode"
611+
612+
# lipo \
613+
# "/tmp/${CURL_VERSION}-iOS-armv7-nobitcode/lib/libcurl.a" \
614+
# "/tmp/${CURL_VERSION}-iOS-armv7s-nobitcode/lib/libcurl.a" \
615+
# "/tmp/${CURL_VERSION}-iOS-simulator-i386-nobitcode/lib/libcurl.a" \
616+
# "/tmp/${CURL_VERSION}-iOS-arm64-nobitcode/lib/libcurl.a" \
617+
# "/tmp/${CURL_VERSION}-iOS-arm64e-nobitcode/lib/libcurl.a" \
618+
# "/tmp/${CURL_VERSION}-iOS-simulator-x86_64-nobitcode/lib/libcurl.a" \
619+
# -create -output lib/libcurl_iOS_nobitcode.a
620+
# fi
602621

603622
echo -e "${bold}Building tvOS libraries${dim}"
604-
buildTVOS "arm64"
623+
buildTVOS "arm64" "${BITCODE}"
605624

606625
lipo \
607626
"/tmp/${CURL_VERSION}-tvOS-arm64/lib/libcurl.a" \
608627
-create -output lib/libcurl_tvOS.a
609628

610-
buildTVOSsim "x86_64"
611-
buildTVOSsim "arm64"
629+
buildTVOSsim "x86_64" "${BITCODE}"
630+
buildTVOSsim "arm64" "${BITCODE}"
612631

613632
lipo \
614633
"/tmp/${CURL_VERSION}-tvOS-arm64/lib/libcurl.a" \

openssl/openssl-build-phase1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ alertdim="\033[0m${red}\033[2m"
3030
trap 'echo -e "${alert}** ERROR with Build - Check /tmp/openssl*.log${alertdim}"; tail -3 /tmp/openssl*.log' INT TERM EXIT
3131

3232
# Set defaults
33-
VERSION="1.1.1i" # OpenSSL version default
33+
VERSION="3.0.9" # OpenSSL version default
3434
catalyst="0"
3535

3636
# Set minimum OS versions for target

openssl/openssl-build-phase2.sh

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IOS_SDK_VERSION=""
3838
TVOS_MIN_SDK_VERSION="9.0"
3939
TVOS_SDK_VERSION=""
4040
catalyst="0"
41-
VERSION="1.1.1i" # OpenSSL version default
41+
VERSION="3.0.9" # OpenSSL version default
4242

4343
CORES=$(sysctl -n hw.ncpu)
4444
OPENSSL_VERSION="openssl-${VERSION}"
@@ -150,10 +150,13 @@ buildIOS()
150150
export CROSS_SDK="${PLATFORM}${IOS_SDK_VERSION}.sdk"
151151
export BUILD_TOOLS="${DEVELOPER}"
152152
ADDCFLAG=""
153+
DSO_LDFLAGS="DSO_LDFLAGS=-fembed-bitcode"
153154
if [[ "$OPENSSL_VERSION" = "openssl-3.0"* ]]; then
155+
# disable bitcode for openssl 3
154156
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
157+
DSO_LDFLAGS=""
155158
if [[ "${ARCH}" == "armv7" || "${ARCH}" == "armv7s" ]]; then
156-
# armv7 doesn't work with atomic
159+
# armv7 doesn't work with atomics
157160
ADDCFLAG="-DBROKEN_CLANG_ATOMICS "
158161
fi
159162
else
@@ -162,24 +165,12 @@ buildIOS()
162165

163166
echo -e "${subbold}Building ${OPENSSL_VERSION} for ${PLATFORM} ${IOS_SDK_VERSION} ${archbold}${ARCH}${dim} (iOS ${IOS_MIN_SDK_VERSION})"
164167

165-
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
166-
TARGET="darwin-i386-cc"
167-
if [[ $ARCH == "x86_64" ]]; then
168-
TARGET="darwin64-x86_64-cc"
169-
fi
170-
if [[ "$OPENSSL_VERSION" = "openssl-1.0"* ]]; then
171-
./Configure no-asm ${TARGET} -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
172-
else
173-
./Configure no-asm ${TARGET} -no-shared --prefix="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
174-
fi
168+
if [[ "$OPENSSL_VERSION" = "openssl-1.0"* ]]; then
169+
./Configure iphoneos-cross -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
175170
else
176-
if [[ "$OPENSSL_VERSION" = "openssl-1.0"* ]]; then
177-
# export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
178-
./Configure iphoneos-cross -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
179-
else
180-
./Configure iphoneos-cross DSO_LDFLAGS=-fembed-bitcode --prefix="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
181-
fi
171+
./Configure iphoneos-cross $DSO_LDFLAGS --prefix="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" -no-shared --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" $CUSTOMCONFIG &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
182172
fi
173+
183174
# add -isysroot to CC=
184175
if [[ "$OPENSSL_VERSION" = "openssl-1.0"* ]]; then
185176
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${IOS_MIN_SDK_VERSION} !" "Makefile"

openssl/openssl-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set -e
99

1010
# Default Version
11-
VERSION="openssl-1.1.1i"
11+
VERSION="openssl-3.0.9"
1212

1313
# Phase 1 - Mac, Catalyst and tvOS
1414
OPENSSL_VERSION="$VERSION" ./openssl-build-phase1.sh "$@"

0 commit comments

Comments
 (0)