From 5e24d4f32214bdbadf3fbb3120069cbddaea9f6e Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 27 Dec 2024 21:32:33 -0500 Subject: [PATCH] build: Support Xcode 16.2 on Linux, including cross-compiling OpenSSL. --- GNUmakefile | 35 +++++++++++++++++++++++++++++------ test.c | 3 +++ tools/ssl-local | 7 ++++--- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 test.c diff --git a/GNUmakefile b/GNUmakefile index 07d23f64..f50b905f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -238,7 +238,8 @@ $(IOS_TARGETS): CC = xcrun --sdk iphoneos clang -isysroot $(IOS_SYSROOT) -arch a $(IOSSIM_TARGETS): IOSSIM_SYSROOT := $(shell xcrun --sdk iphonesimulator --show-sdk-path) $(IOSSIM_TARGETS): CC = xcrun --sdk iphonesimulator clang -isysroot $(IOSSIM_SYSROOT) -arch x86_64 else ifeq ($(UNAME_S),Linux) -$(IOS_TARGETS): IOS_SYSROOT := deps/iPhoneOS17.0.sdk +$(IOS_TARGETS): CFLAGS += -isysroot deps/ios_toolchain/target/SDKs/iPhoneOS18.2.sdk -arch arm64 +$(IOS_TARGETS): LDFLAGS += -isysroot deps/ios_toolchain/target/SDKs/iPhoneOS18.2.sdk $(IOS_TARGETS): CC = PATH=$$PATH:deps/ios_toolchain/target/bin deps/ios_toolchain/target/bin/arm-apple-darwin11-clang endif $(ANDROID_X86_64_TARGETS): ANDROID_NDK_TARGET_TRIPLE := x86_64-linux-android @@ -261,8 +262,15 @@ $(ANDROID_X86_64_TARGETS): CFLAGS += -Ideps/openssl/android/x86_64/usr/local/inc $(ANDROID_X86_64_TARGETS): LDFLAGS += -Ldeps/openssl/android/x86_64/usr/local/lib $(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type $(DEADSTRIP_TARGETS): LDFLAGS += -Wl,--gc-sections -$(IOS_TARGETS): CFLAGS += -miphoneos-version-min=9.0 -Ideps/openssl/ios/ios64-xcrun/usr/local/include -$(IOS_TARGETS): LDFLAGS += -miphoneos-version-min=9.0 -Ldeps/openssl/ios/ios64-xcrun/usr/local/lib +$(IOS_TARGETS): CFLAGS += -miphoneos-version-min=9.0 +$(IOS_TARGETS): LDFLAGS += -miphoneos-version-min=9.0 +ifeq ($(UNAME_S),Darwin) +$(IOS_TARGETS): CFLAGS += -Ideps/openssl/ios/ios64-xcrun/usr/local/include +$(IOS_TARGETS): LDFLAGS += -Ldeps/openssl/ios/ios64-xcrun/usr/local/lib +else +$(IOS_TARGETS): CFLAGS += -Ideps/openssl/$(UNAME_S)/ios64-cross/usr/local/include +$(IOS_TARGETS): LDFLAGS += -Ldeps/openssl/$(UNAME_S)/ios64-cross/usr/local/lib +endif $(IOSSIM_TARGETS): CFLAGS += -Ideps/openssl/ios/iossimulator-xcrun/usr/local/include $(IOSSIM_TARGETS): LDFLAGS += -Ldeps/openssl/ios/iossimulator-xcrun/usr/local/lib $(LINUX_TARGETS) $(MACOS_TARGETS): CFLAGS += -Ideps/openssl/$(UNAME_S)/$(UNAME_M)/usr/local/include @@ -1136,21 +1144,36 @@ $(filter $(BUILD_DIR)/android%,$(APP_OBJS)): | $(ANDROID_DEPS) ifeq ($(UNAME_S),Linux) LOCAL_DEPS := deps/openssl/$(UNAME_S)/$(UNAME_M)/usr/local/lib/libssl.a $(LOCAL_DEPS): - +@tools/ssl-local + +@OPTIONS=-flto tools/ssl-local $(filter $(BUILD_DIR)/debug/%,$(APP_OBJS)) $(filter $(BUILD_DIR)/release/%,$(APP_OBJS)): | $(LOCAL_DEPS) ifeq ($(HAVE_CROSS_AARCH64),1) LOCAL_DEPS := deps/openssl/$(UNAME_S)/aarch64/usr/local/lib/libssl.a $(LOCAL_DEPS): - +@OPTIONS=--cross-compile-prefix=aarch64-linux-gnu- BUILD_TARGET=aarch64 tools/ssl-local + +@OPTIONS="--cross-compile-prefix=aarch64-linux-gnu- -flto" BUILD_TARGET=aarch64 tools/ssl-local $(filter $(BUILD_DIR)/armdebug/%,$(APP_OBJS)) $(filter $(BUILD_DIR)/armrelease/%,$(APP_OBJS)): | $(LOCAL_DEPS) endif + +ifeq ($(HAVE_LINUX_IOS),1) +LOCAL_DEPS := deps/openssl/$(UNAME_S)/ios64-cross/usr/local/lib/libssl.a +$(LOCAL_DEPS): + +@PATH=deps/ios_toolchain/target/bin:$$PATH \ + BUILD_TARGET=ios64-cross \ + SSL_TARGET=ios64-cross \ + CROSS_COMPILE=../../deps/ios_toolchain/target/bin/arm-apple-darwin11- \ + CROSS_TOP=../../deps/ios_toolchain/target \ + CROSS_SDK=iPhoneOS18.2.sdk \ + CC=clang \ + OPTIONS=-miphoneos-version-min=9.0 \ + tools/ssl-local +$(filter $(BUILD_DIR)/ios%,$(APP_OBJS)): | $(LOCAL_DEPS) +endif endif ifeq ($(UNAME_S),Darwin) LOCAL_DEPS := deps/openssl/$(UNAME_S)/$(UNAME_M)/usr/local/lib/libssl.a $(LOCAL_DEPS): - +@tools/ssl-local + +@OPTIONS=-flto tools/ssl-local $(filter $(BUILD_DIR)/macosdebug/%,$(APP_OBJS)) $(filter $(BUILD_DIR)/macosrelease/%,$(APP_OBJS)): | $(LOCAL_DEPS) endif diff --git a/test.c b/test.c new file mode 100644 index 00000000..cb3f7482 --- /dev/null +++ b/test.c @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/tools/ssl-local b/tools/ssl-local index 299d5b2f..c614453f 100755 --- a/tools/ssl-local +++ b/tools/ssl-local @@ -6,7 +6,9 @@ if [[ -z $BUILD_TARGET ]]; then WORK_DIR=out/openssl-local else WORK_DIR=out/openssl-$BUILD_TARGET - SSL_TARGET=linux-$BUILD_TARGET + if [[ -z $SSL_TARGET ]]; then + SSL_TARGET=linux-$BUILD_TARGET + fi fi rm -rf $WORK_DIR @@ -72,8 +74,7 @@ no-zlib -Os -DOPENSSL_SMALL_FOOTPRINT -ffunction-sections --fdata-sections --flto" +-fdata-sections" pwd echo "./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS" && \ ./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS && \