From b7d732b782d6130a351b187380179315c7a13fa6 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 1 Jul 2022 11:29:21 +0300 Subject: [PATCH] Add arch flag to assembler to fix build on ARM64 macOS / iOS. (cherry picked from commit b767d2e0fdf835dc181bb21c8be69a35671b60b8) --- core/SCsub | 5 ++--- platform/iphone/detect.py | 5 +++++ platform/osx/detect.py | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/SCsub b/core/SCsub index 69ce8cdb7..3ee202803 100644 --- a/core/SCsub +++ b/core/SCsub @@ -133,10 +133,9 @@ if env["builtin_zstd"]: "decompress/zstd_decompress_block.c", "decompress/zstd_decompress.c", ] - - if env["platform"] in ["android", "osx", "server", "x11"]: + + if env["platform"] in ["android", "iphone", "osx", "server", "x11"]: # Match platforms with ZSTD_ASM_SUPPORTED in common/portability_macros.h - # iOS x86_64 should be supported in theory, but it fails arm64 build, seems to use host S_compiler. thirdparty_zstd_sources.append("decompress/huf_decompress_amd64.S") thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources] diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 1dd6eab22..c3077fe06 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -109,11 +109,13 @@ def configure(env): if env["ios_simulator"]: detect_darwin_sdk_path("iphonesimulator", env) + env.Append(ASFLAGS=["-mios-simulator-version-min=10.0"]) env.Append(CCFLAGS=["-mios-simulator-version-min=10.0"]) env.Append(LINKFLAGS=["-mios-simulator-version-min=10.0"]) env.extra_suffix = ".simulator" + env.extra_suffix else: detect_darwin_sdk_path("iphone", env) + env.Append(ASFLAGS=["-miphoneos-version-min=10.0"]) env.Append(CCFLAGS=["-miphoneos-version-min=10.0"]) env.Append(LINKFLAGS=["-miphoneos-version-min=10.0"]) @@ -127,16 +129,19 @@ def configure(env): + " -fobjc-arc -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK" ).split() ) + env.Append(ASFLAGS=["-arch", arch_flag]) elif env["arch"] == "arm": detect_darwin_sdk_path("iphone", env) env.Append( CCFLAGS='-fobjc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -MMD -MT dependencies'.split() ) + env.Append(ASFLAGS=["-arch", "armv7"]) elif env["arch"] == "arm64": detect_darwin_sdk_path("iphone", env) env.Append( CCFLAGS="-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -isysroot $IPHONESDK".split() ) + env.Append(ASFLAGS=["-arch", "arm64"]) env.Append(CPPDEFINES=["NEED_LONG_INT"]) env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"]) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index b60b10c67..4e54c54eb 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -79,10 +79,12 @@ def configure(env): if env["arch"] == "arm64": print("Building for macOS 10.15+, platform arm64.") + env.Append(ASFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) else: print("Building for macOS 10.12+, platform x86-64.") + env.Append(ASFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"])