MacOSX: Better build flags logic handling. Suppress Xcode 15 linked warning.

This commit is contained in:
Mounir IDRASSI 2024-06-16 14:46:31 +02:00
parent 406a1686f5
commit 8a4962dc07
No known key found for this signature in database
GPG Key ID: C2FF2438CD26E3B7

View File

@ -296,7 +296,8 @@ ifeq "$(shell uname -s)" "Darwin"
APPNAME := VeraCrypt
export VC_OSX_TARGET ?= 12
export VC_OSX_SDK ?= $(VC_OSX_TARGET)
# use the output of the command "xcrun --show-sdk-version" to set the SDK version if not set
export VC_OSX_SDK ?= $(shell xcrun --show-sdk-version)
#check to see if XCode 3 path exists.Otherwise, use XCode 4 path
VC_OSX_SDK_PATH := /Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk
@ -316,20 +317,31 @@ ifeq "$(shell uname -s)" "Darwin"
C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_MACOSX -mmacosx-version-min=$(VC_OSX_TARGET) -isysroot $(VC_OSX_SDK_PATH)
LFLAGS += -mmacosx-version-min=$(VC_OSX_TARGET) -Wl,-syslibroot $(VC_OSX_SDK_PATH)
#Xcode 15 linker emits a warning "no platform load command found" when linking object files generated by yasm
# To suppress this warning, we need to use -Wl,-ld_classic flag in order to use the old ld64 linker
# https://mjtsai.com/blog/2024/03/15/xcode-15-no-platform-load-command-found/
# Check Xcode version for using specific linker flag
XCODE_VERSION := $(shell xcodebuild -version 2>/dev/null | grep 'Xcode' | sed -E 's/Xcode ([0-9]+).*/\1/')
ifneq ($(XCODE_VERSION),)
ifeq "$(shell expr $(XCODE_VERSION) \>= 15)" "1"
LFLAGS += -Wl,-ld_classic
endif
else
$(error Xcode not found, please check your installation)
endif
WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH)
ifeq "$(CPU_ARCH)" "x64"
CPU_ARCH = x86
# Set x86 assembly flags (-msse2, -mssse3, -msse4.1)
# Apply flags if SIMD_SUPPORTED is 1 or if not in local development build (we are creating universal binary in this case)
ifneq "$(LOCAL_DEVELOPMENT_BUILD)" "true"
SIMD_SUPPORTED = 1
endif
ifeq "$(CPU_ARCH)" "arm64"
CPU_ARCH = arm64
endif
ifneq "$(CPU_ARCH)" "arm64"
ifeq "$(SIMD_SUPPORTED)" "1"
CFLAGS += -msse2
CXXFLAGS += -msse2
endif
ifeq "$(origin SSSE3)" "command line"
CFLAGS += -mssse3
@ -340,6 +352,7 @@ ifeq "$(shell uname -s)" "Darwin"
CFLAGS += -mssse3 -msse4.1
CXXFLAGS += -mssse3 -msse4.1
endif
endif
AS ?= $(BASE_DIR)/Build/Tools/MacOSX/yasm
export ASFLAGS32 := -D __GNUC__ -D __YASM__ -D __BITS__=32 --prefix=_ -f macho32
@ -349,50 +362,36 @@ ifeq "$(shell uname -s)" "Darwin"
export DISABLE_PRECOMPILED_HEADERS := 1
S := $(C_CXX_FLAGS)
C_CXX_FLAGS = $(subst -MMD,,$(S))
C_CXX_FLAGS := $(subst -MMD,,$(C_CXX_FLAGS)) -gfull
LFLAGS += -Wl,-dead_strip
# only build local arch in development builds
# Initialize architecture flag
ARCH_FLAG := -arch x86_64
# Set architecture flags based on build type and CPU architecture
ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true"
ifeq "$(CPU_ARCH)" "arm64"
C_CXX_FLAGS += -gfull -arch $(CPU_ARCH)
LFLAGS += -Wl,-dead_strip -arch $(CPU_ARCH)
else
C_CXX_FLAGS += -gfull -arch x86_64
LFLAGS += -Wl,-dead_strip -arch x86_64
endif
else
# leave previous logic as is
C_CXX_FLAGS += -gfull -arch x86_64
LFLAGS += -Wl,-dead_strip -arch x86_64
endif
WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-svg
#----- Legacy build: we build both 32-bit and 64-bit ----
ifdef VC_LEGACY_BUILD
C_CXX_FLAGS += -arch i386
LFLAGS += -arch i386
WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64
else
CXXFLAGS += -std=c++11
ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true"
ifeq "$(CPU_ARCH)" "arm64"
C_CXX_FLAGS += -arch arm64
LFLAGS += -arch arm64
else
C_CXX_FLAGS += -arch x86_64
LFLAGS += -arch x86_64
ARCH_FLAG := -arch arm64
endif
WX_CONFIGURE_FLAGS += --disable-universal_binary
else
# leave previous logic as is
C_CXX_FLAGS += -arch arm64
LFLAGS += -arch arm64
# Legacy build settings
ifdef VC_LEGACY_BUILD
ARCH_FLAG += -arch i386
WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64
else
CXXFLAGS += -std=c++11
# Non-development build defaults to universal binary for arm64 and x86_64
ARCH_FLAG += -arch arm64
WX_CONFIGURE_FLAGS += --enable-universal_binary=arm64,x86_64
endif
endif
# Apply architecture flags
C_CXX_FLAGS += $(ARCH_FLAG)
LFLAGS += $(ARCH_FLAG)
WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-svg
WXCONFIG_CFLAGS += -gfull
WXCONFIG_CXXFLAGS += -gfull