From 0639dd0f042eadcfd30a9bb1c50a33d921ba8dae Mon Sep 17 00:00:00 2001 From: DJtheRedstoner <52044242+DJtheRedstoner@users.noreply.github.com> Date: Fri, 21 Oct 2022 03:16:28 -0400 Subject: [PATCH] Fix macos deployment target not being configured properly (#451) Motivation:: Previously, the native library would fail to load on older macos versions since the target macos version was not specified correctly. Now, the generated dylib correctly targets macos 10.12. This can be verified with `otool -l codec-native-quic/target/native-build/target/lib/libnetty_quiche_osx_x86_64.jnilib | grep LC_VERSION_MIN_MACOSX -A4` (the output will contain a `version 10.12` line). Modifications: The `-mmacosx-version-min` option is manually added to `cmakeAsmFlags` since cmake doesn't take `MACOSX_DEPLOYMENT_TARGET` into account for asm compilation. The flag is manually added to `extraCflags` and `extraLdflags` since that is the best way I could find to pass the option to hawtjni. Result: This builds and all tests pass on my macbook running macos High Sierra (10.13). I tried running the cross compile profile (though it's not actually cross compiling) and that also build correctly, however I would still suggest testing this on a aarch64 machine. --- codec-native-quic/pom.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/codec-native-quic/pom.xml b/codec-native-quic/pom.xml index ba9e6a0ad..2927724dd 100644 --- a/codec-native-quic/pom.xml +++ b/codec-native-quic/pom.xml @@ -115,14 +115,15 @@ --> 10.12 - -Wa,--noexecstack + -Wa,--noexecstack -mmacosx-version-min=${macosxDeploymentTarget} + -mmacosx-version-min=${macosxDeploymentTarget} ${extraCflags} -O3 -fno-omit-frame-pointer -DOPENSSL_C11_ATOMIC ${extraCxxflags} -O3 -fno-omit-frame-pointer -DOPENSSL_C11_ATOMIC -Wno-error=range-loop-analysis libssl.a libcrypto.a libquiche.a - -platform_version,macos,${macosxDeploymentTarget},${macosxDeploymentTarget} + -platform_version,macos,${macosxDeploymentTarget},${macosxDeploymentTarget} -mmacosx-version-min=${macosxDeploymentTarget} MACOSX_DEPLOYMENT_TARGET=${macosxDeploymentTarget} META-INF/native/lib${jniLibName}.jnilib;osname=macos;osname=macosx;processor=${os.detected.arch} @@ -164,10 +165,10 @@ osx-x86_64 osx.x86_64 10.12 - -target x86_64-apple-macos10.12 + -target x86_64-apple-macos10.12 -mmacosx-version-min=${macosxDeploymentTarget} -target x86_64-apple-macos10.12 - -Wa,--noexecstack -target x86_64-apple-macos10.12 + -Wa,--noexecstack -target x86_64-apple-macos10.12 -mmacosx-version-min=${macosxDeploymentTarget} -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_OSX_ARCHITECTURES=x86_64 ${extraCflags} -O3 -fno-omit-frame-pointer -DOPENSSL_C11_ATOMIC @@ -175,7 +176,7 @@ libssl.a libcrypto.a libquiche.a - -arch x86_64 -platform_version,macos,${macosxDeploymentTarget},${macosxDeploymentTarget} + -arch x86_64 -platform_version,macos,${macosxDeploymentTarget},${macosxDeploymentTarget} -mmacosx-version-min=${macosxDeploymentTarget} --host=x86_64-apple-darwin MACOSX_DEPLOYMENT_TARGET=${macosxDeploymentTarget} META-INF/native/lib${jniLibName}.jnilib;osname=macos;osname=macosx;processor=x86_64 @@ -746,6 +747,7 @@ + @@ -757,6 +759,7 @@ +