darwin.mk raw
1 OSX_MIN_VERSION=13.0
2 OSX_SDK_VERSION=14.0
3 XCODE_VERSION=15.0
4 XCODE_BUILD_ID=15A240d
5 LLD_VERSION=711
6
7 OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers
8
9 # We can't just use $(shell command -v clang) because GNU Make handles builtins
10 # in a special way and doesn't know that `command` is a POSIX-standard builtin
11 # prior to 1af314465e5dfe3e8baa839a32a72e83c04f26ef, first released in v4.2.90.
12 # At the time of writing, GNU Make v4.2.1 is still being used in supported
13 # distro releases.
14 #
15 # Source: https://lists.gnu.org/archive/html/bug-make/2017-11/msg00017.html
16 clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
17 clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
18
19 darwin_AR=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ar")
20 darwin_DSYMUTIL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v dsymutil")
21 darwin_NM=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-nm")
22 darwin_OBJCOPY=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objcopy")
23 darwin_OBJDUMP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objdump")
24 darwin_RANLIB=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ranlib")
25 darwin_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip")
26
27 # Flag explanations:
28 #
29 # -mlinker-version
30 #
31 # Ensures that modern linker features are enabled. See here for more
32 # details: https://github.com/limenka/limenka/pull/19407.
33 #
34 # -isysroot$(OSX_SDK) -nostdlibinc
35 #
36 # Disable default include paths built into the compiler as well as
37 # those normally included for libc and libc++. The only path that
38 # remains implicitly is the clang resource dir.
39 #
40 # -iwithsysroot / -iframeworkwithsysroot
41 #
42 # Adds the desired paths from the SDK
43 #
44 # -platform_version
45 #
46 # Indicate to the linker the platform, the oldest supported version,
47 # and the SDK used.
48 #
49 # -no_adhoc_codesign
50 #
51 # Disable adhoc codesigning (for now) when using LLVM tooling, to avoid
52 # non-determinism issues with the Identifier field.
53
54 darwin_CC=$(clang_prog) --target=$(host) \
55 -isysroot$(OSX_SDK) -nostdlibinc \
56 -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
57
58 darwin_CXX=$(clangxx_prog) --target=$(host) \
59 -isysroot$(OSX_SDK) -nostdlibinc \
60 -iwithsysroot/usr/include/c++/v1 \
61 -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
62
63 darwin_CFLAGS=-pipe -std=$(C_STANDARD) -mmacos-version-min=$(OSX_MIN_VERSION)
64 darwin_CXXFLAGS=-pipe -std=$(CXX_STANDARD) -mmacos-version-min=$(OSX_MIN_VERSION)
65 darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION)
66
67 ifneq ($(build_os),darwin)
68 darwin_CFLAGS += -mlinker-version=$(LLD_VERSION)
69 darwin_CXXFLAGS += -mlinker-version=$(LLD_VERSION)
70 darwin_LDFLAGS += -Wl,-no_adhoc_codesign -fuse-ld=lld
71 endif
72
73 darwin_release_CFLAGS=-O2
74 darwin_release_CXXFLAGS=$(darwin_release_CFLAGS)
75
76 darwin_debug_CFLAGS=-O1 -g
77 darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS)
78
79 darwin_cmake_system_name=Darwin
80 # Darwin version, which corresponds to OSX_MIN_VERSION.
81 # See https://en.wikipedia.org/wiki/Darwin_(operating_system)
82 darwin_cmake_system_version=20.1
83