MacOS: Support CommandLineTools for building (#1371)

Full Xcode application which can take up-to 40GB of disk space is not
necessary for building VeraCrypt, rather the CommandLineTools for XCode
are sufficient which only take few gigabytes. Instead of hardcoding the SDK
location, use xcrun --show-sdk-path to support also the CommandLineTools
instance.

The reason for switching the logic for the XCode version is because the
xcodebuild will not report a correct XCode version for the CommandLineTools,
thus it can't be relied for whether to use the -Wl,-ld_classic flags.
Instead, we can just check the ld version in use in the active developer
directory, and see whether we are using dyld (the new) or ld64 (the old).
This commit is contained in:
Jertzukka 2024-07-01 23:35:31 +03:00 committed by GitHub
parent 9697416919
commit ca69368ba4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 12 deletions

View File

@ -85,7 +85,7 @@ it is also available [online](https://www.veracrypt.fr/en/CompilingGuidelineLinu
- GNU Make - GNU Make
- GNU C++ Compiler 4.0 or compatible - GNU C++ Compiler 4.0 or compatible
- Apple Xcode (Mac OS X only) - Apple Xcode or Xcode command line tools (Mac OS X only)
- YASM 1.3.0 or newer (Linux only, x86/x64 architecture only) - YASM 1.3.0 or newer (Linux only, x86/x64 architecture only)
- pkg-config - pkg-config
- wxWidgets 3.0 shared library and header files installed or - wxWidgets 3.0 shared library and header files installed or

View File

@ -294,7 +294,10 @@ ifeq "$(shell uname -s)" "Darwin"
#check to see if XCode 3 path exists.Otherwise, use XCode 4 path #check to see if XCode 3 path exists.Otherwise, use XCode 4 path
VC_OSX_SDK_PATH := /Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk VC_OSX_SDK_PATH := /Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk
ifeq ($(wildcard $(VC_OSX_SDK_PATH)/SDKSettings.plist),) ifeq ($(wildcard $(VC_OSX_SDK_PATH)/SDKSettings.plist),)
VC_OSX_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk VC_OSX_SDK_PATH := $(shell xcrun --sdk macosx$(VC_OSX_SDK) --show-sdk-path)
ifeq ($(VC_OSX_SDK_PATH),)
$(error Specified SDK version was not found, ensure your active developer directory is correct through xcode-select)
endif
endif endif
#----- Legacy build if OSX <= 10.8: we build both 32-bit and 64-bit ---- #----- Legacy build if OSX <= 10.8: we build both 32-bit and 64-bit ----
@ -310,17 +313,12 @@ ifeq "$(shell uname -s)" "Darwin"
CXXFLAGS += -std=c++11 CXXFLAGS += -std=c++11
C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_MACOSX -mmacosx-version-min=$(VC_OSX_TARGET) -isysroot $(VC_OSX_SDK_PATH) 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) 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 # 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 # 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/ # https://mjtsai.com/blog/2024/03/15/xcode-15-no-platform-load-command-found/
# Check Xcode version for using specific linker flag # We can check whether newer linker is in use if ld -v reports dyld instead of ld64.
XCODE_VERSION := $(shell xcodebuild -version 2>/dev/null | grep 'Xcode' | sed -E 's/Xcode ([0-9]+).*/\1/') ifeq ($(shell xcrun --sdk macosx$(VC_OSX_SDK) ld -v 2>&1 | grep -oE 'PROJECT:[^-]+' | cut -d: -f2),dyld)
ifneq ($(XCODE_VERSION),) LFLAGS += -Wl,-ld_classic
ifeq "$(shell expr $(XCODE_VERSION) \>= 15)" "1"
LFLAGS += -Wl,-ld_classic
endif
else
$(error Xcode not found, please check your installation)
endif endif
WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH) WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH)

View File

@ -101,7 +101,7 @@ Requirements for Building VeraCrypt for Linux and Mac OS X:
- GNU Make - GNU Make
- GNU C++ Compiler 4.0 or compatible - GNU C++ Compiler 4.0 or compatible
- Apple Xcode (Mac OS X only) - Apple Xcode or Xcode command line tools (Mac OS X only)
- YASM 1.3.0 or newer (Linux only, x86/x64 architecture only) - YASM 1.3.0 or newer (Linux only, x86/x64 architecture only)
- pkg-config - pkg-config
- wxWidgets 3.0 shared library and header files installed or - wxWidgets 3.0 shared library and header files installed or