jasonacox / Build-OpenSSL-cURL

Scripts to build OpenSSL, HTTP/2 (nghttp2) and cURL (libcurl) for MacOS, iOS and tvOS devices (x86_64, armv7, armv7s, arm64, arm64e). Now Supporting Apple Silicon, OpenSSL 3.0.x with TLS 1.3 and Mac Catalyst builds.
MIT License
419 stars 125 forks source link

Set minimum OSX deployment version #50

Closed JoeySlomowitz closed 3 years ago

JoeySlomowitz commented 3 years ago

I'm using this script for my MacOS project.

My target's deployment is set to 10.14 and currently I'm having hundreds of warnings -

object file (/Users/username/Developer/Project/OpenSSL/lib/libcrypto.a(aes_cbc.o)) was built for newer macOS version (11.0) than being linked (10.14)

I understand the following flag needs to be set in the script somewhere but I'm unsure where.. -mmacosx-version-min=

edit: I've tried updating every line in openssl-build-phase1.sh with the line CFLAGS=" -O2 -mmacosx-version-min to set this to my minimum deployment version, but this doesn't seem to work.

jasonacox commented 3 years ago

Hi Joey, thanks for raising this. I suspect there are some Apple Silicon updates that are forcing a 11.0 build. I'll take a look. In the meantime, you should be able to pull the previous build script here:

https://github.com/jasonacox/Build-OpenSSL-cURL/releases/tag/v7.72.0

I would be interested to know if that version works for you.

One more thought, if your build machine is an x86_64, the logic will build the library for the host MacOS. What is your build host?

JoeySlomowitz commented 3 years ago

Thanks for jumping on this so quick @jasonacox !
I tried your suggestion and attempted a build from that previous release, but unfortunately it didn't work for me.

Please let me know if there's anything else I can try.

My machine is an Intel i7 running Big Sur - so you're saying it will always build for 11.0?

jasonacox commented 3 years ago

That's correct. Big Sur is going to build 11.x images. For MacOS images, the build is set to use the default build.

One suggestion - we could edit the buildMac() section to target a 10.14 macos image. In the openssl-build-phase1.sh file, find this section and see the added CFLAG for x86_64 builds on a x86_64 host:

buildMac()
{
    ARCH=$1

    echo -e "${subbold}Building ${OPENSSL_VERSION} for ${archbold}${ARCH}${dim}"

    TARGET="darwin-i386-cc"
    BUILD_MACHINE=`uname -m`

    if [[ $ARCH == "x86_64" ]]; then
        if [ ${BUILD_MACHINE} == 'arm64' ]; then
            # Apple ARM Silicon Build Machine Detected - cross compile
            TARGET="darwin64-x86_64-cc"
            export CC="clang"
            export CXX="clang"
            export CFLAGS=" -O2 -mmacosx-version-min=11.0 -arch x86_64 "
            export LDFLAGS=" -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk "
            export CPPFLAGS=" -I.. -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk "
            # ./Configure shared enable-rc5 zlib darwin64-arm64-cc
        else
            # Apple x86_64 Build Machine Detected 
            TARGET="darwin64-x86_64-cc"
            # 
            # SET target platform version
            # 
            export CFLAGS=" -O2 -mmacosx-version-min=10.14 -arch x86_64 "
        fi
    fi

I'm able to get it to build doing that but would love to see if this works with your project. If so, I'll leave a comment in there for other to use or add a flag to let people set target versions less than the build host.

JoeySlomowitz commented 3 years ago

Yess that worked. All the warnings are gone. Thank you very much! 🙏

If so, I'll leave a comment in there for other to use or add a flag to let people set target versions less than the build host.

Yes - I think this is a very good idea. Especially for people like me that aren't very good with scripts 😅