]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | # -*- mode: makefile;-*- |
1c79356b | 2 | # |
f427ee49 | 3 | # Copyright (C) 1999-2020 Apple Inc. All rights reserved. |
1c79356b | 4 | # |
39236c6e A |
5 | # MakeInc.def contains global definitions for building, |
6 | # linking, and installing files. | |
1c79356b | 7 | # |
1c79356b | 8 | |
6d2010ae | 9 | # |
39236c6e | 10 | # Architecture Configuration options |
6d2010ae | 11 | # |
d9a64523 | 12 | SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H ARM ARM64 |
6d2010ae | 13 | |
2d21ac55 | 14 | # |
39037602 | 15 | # Kernel Configuration options |
1c79356b | 16 | # |
5ba3f43e | 17 | SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN |
2d21ac55 | 18 | |
cb323159 | 19 | |
316670eb | 20 | # |
39037602 | 21 | # Machine Configuration options |
316670eb | 22 | # |
39236c6e A |
23 | |
24 | SUPPORTED_X86_64_MACHINE_CONFIGS = NONE | |
fe8ab488 | 25 | SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE |
6d2010ae | 26 | |
f427ee49 A |
27 | ifneq ($(findstring _Sim,$(RC_ProjectName)),) |
28 | SUPPORTED_ARM_MACHINE_CONFIGS = NONE | |
29 | SUPPORTED_ARM64_MACHINE_CONFIGS = NONE | |
30 | else ifneq ($(findstring _host,$(RC_ProjectName)),) | |
31 | SUPPORTED_ARM_MACHINE_CONFIGS = NONE | |
32 | SUPPORTED_ARM64_MACHINE_CONFIGS = NONE | |
33 | else | |
34 | SUPPORTED_ARM_MACHINE_CONFIGS = T8002 T8004 | |
2a1bd2d3 | 35 | SUPPORTED_ARM64_MACHINE_CONFIGS = T7000 T7001 S8000 S8001 T8010 T8011 BCM2837 T8020 T8101 T8103 |
d9a64523 | 36 | |
f427ee49 | 37 | endif |
6d2010ae | 38 | |
6d2010ae | 39 | # |
39236c6e | 40 | # Setup up *_LC variables during recursive invocations |
6d2010ae | 41 | # |
6d2010ae | 42 | |
39236c6e | 43 | ifndef CURRENT_ARCH_CONFIG_LC |
39037602 | 44 | export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z) |
6d2010ae A |
45 | endif |
46 | ||
39236c6e A |
47 | ifndef CURRENT_KERNEL_CONFIG_LC |
48 | export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z) | |
316670eb | 49 | endif |
6d2010ae | 50 | |
39236c6e A |
51 | ifndef CURRENT_MACHINE_CONFIG_LC |
52 | export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z) | |
6d2010ae A |
53 | endif |
54 | ||
2d21ac55 | 55 | # |
39236c6e | 56 | # Component List |
2d21ac55 | 57 | # |
5ba3f43e | 58 | COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security san |
39037602 A |
59 | COMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))) |
60 | COMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST)) | |
1c79356b | 61 | |
c3c9b80d A |
62 | MACHINE_FLAGS_ARM64_T7000 = -DARM64_BOARD_CONFIG_T7000 -mcpu=apple-h7 |
63 | MACHINE_FLAGS_ARM64_T7001 = -DARM64_BOARD_CONFIG_T7001 -mcpu=apple-h7 | |
64 | MACHINE_FLAGS_ARM64_S8000 = -DARM64_BOARD_CONFIG_S8000 -mcpu=apple-h8 | |
65 | MACHINE_FLAGS_ARM64_S8001 = -DARM64_BOARD_CONFIG_S8001 -mcpu=apple-h8 | |
d9a64523 A |
66 | MACHINE_FLAGS_ARM_T8002 = -DARM_BOARD_CONFIG_T8002 |
67 | MACHINE_FLAGS_ARM_T8004 = -DARM_BOARD_CONFIG_T8004 | |
68 | MACHINE_FLAGS_ARM64_T8010 = -DARM64_BOARD_CONFIG_T8010 -mcpu=hurricane | |
69 | MACHINE_FLAGS_ARM64_T8011 = -DARM64_BOARD_CONFIG_T8011 -mcpu=hurricane | |
70 | MACHINE_FLAGS_ARM64_BCM2837 = -DARM64_BOARD_CONFIG_BCM2837 | |
2a1bd2d3 | 71 | MACHINE_FLAGS_ARM64_T8020 = -DARM64_BOARD_CONFIG_T8020 -mcpu=vortex |
c3c9b80d A |
72 | MACHINE_FLAGS_ARM64_T8101 = -DARM64_BOARD_CONFIG_T8101 -mcpu=apple-a14 |
73 | MACHINE_FLAGS_ARM64_T8103 = -DARM64_BOARD_CONFIG_T8103 -mcpu=apple-a14 | |
d9a64523 | 74 | |
1c79356b | 75 | |
316670eb A |
76 | # |
77 | # Deployment target flag | |
78 | # | |
316670eb | 79 | ifeq ($(PLATFORM),MacOSX) |
cb323159 | 80 | DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) -DXNU_TARGET_OS_OSX |
d9a64523 | 81 | DEPLOYMENT_LINKER_FLAGS = -Wl,-macosx_version_min,$(SDKVERSION) |
cb323159 A |
82 | else ifeq ($(PLATFORM),DriverKit) |
83 | DEPLOYMENT_TARGET_FLAGS = -target x86_64-apple-driverkit$(SDKVERSION) -DXNU_TARGET_OS_OSX | |
84 | DEPLOYMENT_LINKER_FLAGS = -Wl,-target,x86_64-apple-driverkit$(SDKVERSION) | |
3e170ce0 | 85 | else ifeq ($(PLATFORM),WatchOS) |
d9a64523 A |
86 | DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_WATCH |
87 | DEPLOYMENT_LINKER_FLAGS = | |
3e170ce0 | 88 | else ifeq ($(PLATFORM),tvOS) |
cb323159 | 89 | DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV |
d9a64523 | 90 | DEPLOYMENT_LINKER_FLAGS = |
3e170ce0 | 91 | else ifeq ($(PLATFORM),AppleTVOS) |
cb323159 | 92 | DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV |
5ba3f43e | 93 | else ifeq ($(PLATFORM),BridgeOS) |
5c9f4661 | 94 | DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_BRIDGE |
d9a64523 | 95 | DEPLOYMENT_LINKER_FLAGS = |
3e170ce0 | 96 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) |
cb323159 | 97 | DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_IOS |
d9a64523 | 98 | DEPLOYMENT_LINKER_FLAGS = -Wl,-ios_version_min,$(SDKVERSION) |
3e170ce0 | 99 | else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) |
39236c6e | 100 | DEPLOYMENT_TARGET_FLAGS = |
d9a64523 | 101 | DEPLOYMENT_LINKER_FLAGS = |
316670eb | 102 | else |
39236c6e | 103 | DEPLOYMENT_TARGET_FLAGS = |
d9a64523 | 104 | DEPLOYMENT_LINKER_FLAGS = |
316670eb A |
105 | endif |
106 | ||
3e170ce0 A |
107 | DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM) |
108 | ||
39236c6e | 109 | |
f427ee49 A |
110 | ifneq ($(RC_ENABLE_PRODUCT_INFO_FILTER),) |
111 | SEED_DEFINES += -DRC_ENABLE_XNU_PRODUCT_INFO_FILTER | |
112 | else | |
113 | SEED_DEFINES += -URC_ENABLE_XNU_PRODUCT_INFO_FILTER | |
114 | endif | |
115 | ||
1c79356b A |
116 | # |
117 | # Standard defines list | |
118 | # | |
39236c6e | 119 | DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \ |
f427ee49 A |
120 | -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile -DXNU_KERN_EVENT_DATA_IS_VLA \ |
121 | $(CONFIG_DEFINES) $(SEED_DEFINES) | |
122 | ||
123 | # Enable caching with `make CCACHE=ccache` | |
124 | # This intentionally does not override $(CC) because that will confuse | |
125 | # utilities like mig. | |
126 | CCACHE ?= | |
1c79356b A |
127 | |
128 | # | |
129 | # Compiler command | |
130 | # | |
f427ee49 A |
131 | KCC = $(CCACHE) $(CC) |
132 | KC++ = $(CCACHE) $(CXX) | |
9bccf70c | 133 | |
f427ee49 | 134 | GENASSYM_KCC = $(CCACHE) $(CC) |
3e170ce0 | 135 | |
91447636 A |
136 | # |
137 | # Compiler warning flags | |
138 | # | |
139 | ||
5ba3f43e A |
140 | USE_WERROR := 1 |
141 | ifneq ($(BUILD_WERROR),) | |
142 | USE_WERROR := $(BUILD_WERROR) | |
143 | endif | |
144 | ||
145 | ifeq ($(USE_WERROR),1) | |
146 | WERROR := -Werror | |
147 | endif | |
148 | ||
149 | # Shared C/C++ warning flags | |
cb323159 | 150 | # NOTE: order matters here. -Wno-xxx goes before opt-in of ones we want |
5ba3f43e A |
151 | WARNFLAGS_STD := \ |
152 | -Weverything \ | |
a39ff7e2 | 153 | -Wno-pedantic \ |
5ba3f43e | 154 | $(WERROR) \ |
39037602 | 155 | -Wno-bad-function-cast \ |
39037602 | 156 | -Wno-c++-compat \ |
cb323159 | 157 | -Wno-c++98-compat \ |
39037602 | 158 | -Wno-conditional-uninitialized \ |
39037602 A |
159 | -Wno-covered-switch-default \ |
160 | -Wno-disabled-macro-expansion \ | |
161 | -Wno-documentation-unknown-command \ | |
cb323159 | 162 | -Wno-extra-semi-stmt \ |
39037602 A |
163 | -Wno-format-non-iso \ |
164 | -Wno-format-nonliteral \ | |
39037602 A |
165 | -Wno-language-extension-token \ |
166 | -Wno-missing-variable-declarations \ | |
167 | -Wno-packed \ | |
168 | -Wno-padded \ | |
169 | -Wno-partial-availability \ | |
cb323159 | 170 | -Wno-reserved-id-macro \ |
39037602 A |
171 | -Wno-shift-sign-overflow \ |
172 | -Wno-switch-enum \ | |
173 | -Wno-undef \ | |
174 | -Wno-unused-macros \ | |
175 | -Wno-used-but-marked-unused \ | |
176 | -Wno-variadic-macros \ | |
177 | -Wno-vla \ | |
178 | -Wno-zero-length-array | |
6d2010ae | 179 | |
f427ee49 | 180 | # When a new clang has new warnings disable them here until the kernel is fixed. |
a39ff7e2 A |
181 | WARNFLAGS_STD := $(WARNFLAGS_STD) \ |
182 | -Wno-unknown-warning-option \ | |
f427ee49 A |
183 | -Wno-anon-enum-enum-conversion \ |
184 | -Wno-error=enum-enum-conversion \ | |
185 | -Wno-error=c99-designator \ | |
186 | -Wno-error=reorder-init-list | |
187 | ||
188 | # Hand-written sign conversion diagnostics are resolved, but the | |
189 | # auto-generated ones need mig and iig to be updated to fix. Disable the | |
190 | # diagnostic here until we've completed that: | |
191 | WARNFLAGS_STD := $(WARNFLAGS_STD) \ | |
192 | -Wno-sign-compare \ | |
193 | -Wno-sign-conversion | |
a39ff7e2 | 194 | |
5ba3f43e | 195 | CWARNFLAGS_STD = \ |
a39ff7e2 | 196 | $(WARNFLAGS_STD) |
5ba3f43e | 197 | |
cb323159 A |
198 | |
199 | ||
6d2010ae | 200 | # Can be overridden in Makefile.template or Makefile.$arch |
91447636 A |
201 | export CWARNFLAGS ?= $(CWARNFLAGS_STD) |
202 | ||
6d2010ae A |
203 | define add_perfile_cflags |
204 | $(1)_CWARNFLAGS_ADD += $2 | |
205 | endef | |
206 | ||
cb323159 A |
207 | define rm_perfile_cflags |
208 | $(1)_CFLAGS_RM += $2 | |
209 | endef | |
210 | ||
91447636 | 211 | CXXWARNFLAGS_STD = \ |
5ba3f43e | 212 | $(WARNFLAGS_STD) \ |
39037602 | 213 | -Wno-c++98-compat-pedantic \ |
39037602 | 214 | -Wno-exit-time-destructors \ |
39037602 | 215 | -Wno-global-constructors \ |
cb323159 | 216 | -Wno-old-style-cast |
91447636 | 217 | |
6d2010ae | 218 | # Can be overridden in Makefile.template or Makefile.$arch |
91447636 A |
219 | export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD) |
220 | ||
6d2010ae A |
221 | define add_perfile_cxxflags |
222 | $(1)_CXXWARNFLAGS_ADD += $2 | |
223 | endef | |
9bccf70c | 224 | |
2d21ac55 A |
225 | # |
226 | # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers | |
227 | ||
b0d623f7 | 228 | ARCH_FLAGS_X86_64 = -arch x86_64 |
fe8ab488 | 229 | ARCH_FLAGS_X86_64H = -arch x86_64h |
c910b4d9 | 230 | |
a991bd8d A |
231 | ifeq ($(RC_ProjectName),xnu_libraries) |
232 | WILL_BUILD_STATIC_KC := 1 | |
233 | BUILD_STATIC_LINK := 1 | |
234 | BUILD_XNU_LIBRARY := 1 | |
235 | RC_NONARCH_CFLAGS += -D__BUILDING_XNU_LIBRARY__=1 | |
236 | endif | |
237 | ||
d9a64523 A |
238 | ifneq ($(filter ARM ARM64,$(CURRENT_ARCH_CONFIG)),) |
239 | ||
f427ee49 A |
240 | ifneq ($(findstring _Sim,$(RC_ProjectName)),) |
241 | ARCH_FLAGS_ARM64 = -arch arm64e | |
242 | else ifneq ($(findstring _host,$(RC_ProjectName)),) | |
243 | ARCH_FLAGS_ARM64 = -arch arm64e | |
244 | else | |
245 | ||
d9a64523 | 246 | ifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG |
f427ee49 A |
247 | |
248 | ifneq ($(EMBEDDED_DEVICE_MAP),) | |
d9a64523 | 249 | export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT KernelMachOArchitecture FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" LIMIT 1 || echo UNKNOWN ) |
f427ee49 A |
250 | else |
251 | # Without embdedded device map, use a default arch string | |
252 | export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) | |
2a1bd2d3 A |
253 | ifneq ($(filter ARM64,$(CURRENT_ARCH_CONFIG)),) |
254 | export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := arm64e | |
255 | endif | |
f427ee49 | 256 | endif |
d9a64523 A |
257 | endif |
258 | ||
cb323159 A |
259 | # |
260 | # This can have false negatives, and is used to avoid calling CTF when we'll build a static KC | |
261 | # | |
262 | ifndef WILL_BUILD_STATIC_KC | |
f427ee49 | 263 | ifneq ($(EMBEDDED_DEVICE_MAP),) |
cb323159 A |
264 | export WILL_BUILD_STATIC_KC := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) \ |
265 | -query 'SELECT COUNT(*) != 0 FROM Targets WHERE KernelPlatform IS "$(CURRENT_MACHINE_CONFIG_LC)" \ | |
266 | AND (KernelMachOArchitecture LIKE "arm64e" OR ProductType LIKE "iphone10,%")') | |
f427ee49 A |
267 | else |
268 | export WILL_BUILD_STATIC_KC := 0 | |
269 | endif | |
cb323159 A |
270 | endif |
271 | ||
d9a64523 | 272 | BUILD_STATIC_LINK := 1 |
2d21ac55 | 273 | |
d9a64523 A |
274 | ARCH_FLAGS_ARM = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG) |
275 | ARCH_FLAGS_ARM64 = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG) | |
276 | ||
f427ee49 A |
277 | endif |
278 | ||
d9a64523 | 279 | else |
f427ee49 A |
280 | # non arm machine config string |
281 | ifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG | |
282 | export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) | |
d9a64523 | 283 | endif |
f427ee49 | 284 | |
d9a64523 | 285 | endif |
39037602 | 286 | |
1c79356b A |
287 | # |
288 | # Default CFLAGS | |
289 | # | |
5ba3f43e | 290 | ifdef RC_NONARCH_CFLAGS |
2a1bd2d3 | 291 | OTHER_CFLAGS = $(RC_NONARCH_CFLAGS) |
1c79356b A |
292 | endif |
293 | ||
39236c6e A |
294 | # |
295 | # Debug info | |
296 | # | |
39236c6e A |
297 | DSYMINFODIR = Contents |
298 | DSYMKGMACROSDIR = Contents/Resources | |
299 | DSYMLLDBMACROSDIR = Contents/Resources/Python | |
300 | DSYMDWARFDIR = Contents/Resources/DWARF | |
301 | ||
5ba3f43e | 302 | DEBUG_CFLAGS := -g |
39236c6e | 303 | BUILD_DSYM := 1 |
2d21ac55 A |
304 | |
305 | # | |
306 | # We must not use -fno-keep-inline-functions, or it will remove the dtrace | |
307 | # probes from the kernel. | |
308 | # | |
39236c6e | 309 | CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \ |
cb323159 A |
310 | -ferror-limit=10000 \ |
311 | -fno-builtin \ | |
312 | -fno-common \ | |
313 | -ftrivial-auto-var-init=zero \ | |
314 | -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \ | |
315 | -fsigned-bitfields \ | |
316 | -fmerge-all-constants \ | |
317 | -fno-c++-static-destructors \ | |
318 | $(OTHER_CFLAGS) | |
1c79356b | 319 | |
39037602 A |
320 | CFLAGS_RELEASE = |
321 | CFLAGS_DEVELOPMENT = | |
322 | CFLAGS_DEBUG = | |
5ba3f43e | 323 | CFLAGS_KASAN = $(CFLAGS_DEVELOPMENT) |
39037602 | 324 | CFLAGS_PROFILE = -pg |
1c79356b | 325 | |
39236c6e | 326 | CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \ |
39037602 | 327 | -DPAGE_SIZE_FIXED -mkernel -msoft-float |
fe8ab488 A |
328 | |
329 | CFLAGS_X86_64H = $(CFLAGS_X86_64) | |
316670eb | 330 | |
d9a64523 | 331 | CFLAGS_ARM = -Darm -DARM -D__ARM__ -DPAGE_SIZE_FIXED \ |
cb323159 | 332 | -momit-leaf-frame-pointer -fno-strict-aliasing -D__API__=v4 |
d9a64523 | 333 | |
f427ee49 A |
334 | LARGE_MEMORY_DEFINE=-UARM_LARGE_MEMORY |
335 | ARM64_PLKSEG_ADDR =0xfffffff004004000 | |
336 | ARM64_LINK_ADDR =0xfffffff007004000 | |
337 | ||
338 | # Use ARM_LARGE_MEMORY config for all MacOSX targets. | |
339 | ifneq ($(filter $(PLATFORM),MacOSX),) | |
340 | LARGE_MEMORY_DEFINE=-DARM_LARGE_MEMORY=1 | |
341 | ARM64_PLKSEG_ADDR =0xfffffe0004004000 | |
342 | ARM64_LINK_ADDR =0xfffffe0007004000 | |
343 | endif | |
344 | ||
345 | ||
346 | CFLAGS_ARM64 = -Darm64 -DARM64 -D__ARM64__ -DLP64 -DPAGE_SIZE_FIXED -DVM_KERNEL_LINK_ADDRESS=$(ARM64_LINK_ADDR) \ | |
347 | $(LARGE_MEMORY_DEFINE) -momit-leaf-frame-pointer -fno-strict-aliasing -D__API__=v4 -mkernel | |
2d21ac55 | 348 | |
39236c6e A |
349 | CFLAGS_RELEASEX86_64 = -O2 |
350 | CFLAGS_DEVELOPMENTX86_64 = -O2 | |
5ba3f43e | 351 | CFLAGS_KASANX86_64 = $(CFLAGS_DEVELOPMENTX86_64) |
b0d623f7 | 352 | # No space optimization for the DEBUG kernel for the benefit of gdb: |
39236c6e A |
353 | CFLAGS_DEBUGX86_64 = -O0 |
354 | CFLAGS_PROFILEX86_64 = -O2 | |
355 | ||
fe8ab488 A |
356 | CFLAGS_RELEASEX86_64H = -O2 |
357 | CFLAGS_DEVELOPMENTX86_64H = -O2 | |
5ba3f43e | 358 | CFLAGS_KASANX86_64H = $(CFLAGS_DEVELOPMENTX86_64H) |
fe8ab488 A |
359 | # No space optimization for the DEBUG kernel for the benefit of gdb: |
360 | CFLAGS_DEBUGX86_64H = -O0 | |
361 | CFLAGS_PROFILEX86_64H = -O2 | |
362 | ||
39236c6e A |
363 | CFLAGS_RELEASEARM = -O2 |
364 | CFLAGS_DEVELOPMENTARM = -O2 | |
365 | CFLAGS_DEBUGARM = -O0 | |
366 | CFLAGS_PROFILEARM = -O2 | |
367 | ||
d9a64523 A |
368 | CFLAGS_RELEASEARM64 = -O2 |
369 | CFLAGS_DEVELOPMENTARM64 = -O2 | |
370 | CFLAGS_KASANARM64 = $(CFLAGS_DEVELOPMENTARM64) | |
371 | CFLAGS_DEBUGARM64 = -O0 | |
372 | CFLAGS_PROFILEARM64 = -O2 | |
5ba3f43e A |
373 | |
374 | # | |
d9a64523 | 375 | # Sanitizers Support (KASan, UBSan) |
5ba3f43e A |
376 | # |
377 | ||
378 | ||
d9a64523 A |
379 | SAN=0 |
380 | ||
f427ee49 A |
381 | # KASan support |
382 | # | |
383 | ||
5ba3f43e | 384 | ifeq ($(CURRENT_KERNEL_CONFIG),KASAN) |
cb323159 A |
385 | # KASan kernel config implicitly enables the KASan instrumentation. |
386 | # Instrumentation for other sanitizers is enabled explicitly at build time. | |
5ba3f43e A |
387 | KASAN = 1 |
388 | endif | |
389 | ||
390 | ifeq ($(KASAN),1) | |
d9a64523 | 391 | SAN=1 |
f427ee49 A |
392 | BUILD_LTO=0 |
393 | ||
394 | # Shadow map scale size. With KASAN_SCALE=N, the shadow memory consumes 1/2^N of | |
395 | # the virtual address space. | |
396 | KASAN_SCALE=3 | |
397 | ||
398 | KASAN_OFFSET_ARM64=0xe000000000000000 | |
0a7de745 | 399 | # |
f427ee49 | 400 | # To calculate the kasan offset, subtract the lowest KVA to sanitize, shifted right by 3 bits, |
0a7de745 | 401 | # from the base address of the kasan shadow area, (e.g. solve the following equation: |
f427ee49 A |
402 | # OFFSET = {VA mapped by the first KASAN PML4 [Currently #494]} - (LOWEST_KVA >> 3) |
403 | # OFFSET = (0ULL - (512GiB * (512 - 494))) - (LOWEST_SAN_KVA >> 3) | |
404 | # OFFSET = FFFFF70000000000 - ((0ULL - (512GiB * (512 - 496))) >> 3) [PML4 #496 is the first possible KVA] | |
405 | # OFFSET = FFFFF70000000000 - (FFFFF80000000000 >> 3) | |
406 | # OFFSET = DFFFF80000000000 | |
0a7de745 | 407 | # ). |
f427ee49 A |
408 | KASAN_OFFSET_X86_64=0xdffff80000000000 |
409 | KASAN_OFFSET_X86_64H=$(KASAN_OFFSET_X86_64) | |
410 | KASAN_OFFSET=$($(addsuffix $(CURRENT_ARCH_CONFIG),KASAN_OFFSET_)) | |
411 | KASAN_BLACKLIST=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC) | |
412 | CFLAGS_GEN += -DKASAN=1 -DKASAN_OFFSET=$(KASAN_OFFSET) -DKASAN_SCALE=$(KASAN_SCALE) -fsanitize=address \ | |
5ba3f43e | 413 | -mllvm -asan-globals-live-support \ |
f427ee49 A |
414 | -mllvm -asan-mapping-offset=$(KASAN_OFFSET) \ |
415 | -fsanitize-blacklist=$(KASAN_BLACKLIST) | |
5ba3f43e A |
416 | |
417 | endif | |
418 | ||
d9a64523 A |
419 | ifeq ($(UBSAN),1) |
420 | SAN=1 | |
cb323159 A |
421 | UBSAN_CHECKS = signed-integer-overflow shift pointer-overflow bounds object-size # non-fatal (calls runtime, can return) |
422 | # UBSAN_CHECKS = undefined nullability unsigned-integer-overflow # everything | |
d9a64523 A |
423 | UBSAN_CHECKS_FATAL = # fatal (calls runtime, must not return) |
424 | UBSAN_CHECKS_TRAP = vla-bound builtin # emit a trap instruction (no runtime support) | |
cb323159 | 425 | UBSAN_DISABLED = |
d9a64523 | 426 | |
cb323159 A |
427 | UBSAN_DISABLED += vptr function # requires unsupported C++ runtime |
428 | ifeq ($(KASAN),1) | |
429 | # UBSan alignment + KASan code size is too large | |
430 | # UBSan unreachable doesn't play nice with ASan (40723397) | |
431 | UBSAN_DISABLED += alignment unreachable | |
d9a64523 A |
432 | endif |
433 | ||
434 | CFLAGS_GEN += -DUBSAN=1 | |
435 | CFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS) $(UBSAN_CHECKS_FATAL) $(UBSAN_CHECKS_TRAP),-fsanitize=$(x)) | |
436 | CFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_FATAL),-fno-sanitize-recover=$(x)) | |
437 | CFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_TRAP),-fsanitize-trap=$(x)) | |
cb323159 A |
438 | CFLAGS_GEN += $(foreach x,$(UBSAN_DISABLED),-fno-sanitize=$(x)) |
439 | endif | |
440 | ||
441 | ifeq ($(KSANCOV),1) | |
442 | # Enable SanitizerCoverage instrumentation in xnu | |
443 | SAN = 1 | |
444 | KSANCOV_CFLAGS := -fsanitize-coverage=trace-pc-guard | |
445 | CFLAGS_GEN += $(KSANCOV_CFLAGS) -DKSANCOV=1 | |
d9a64523 A |
446 | endif |
447 | ||
448 | ifeq ($(SAN),1) | |
449 | CFLAGS_GEN += -fsanitize-blacklist=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC) | |
450 | endif | |
451 | ||
cb323159 | 452 | |
39037602 | 453 | CFLAGS = $(CFLAGS_GEN) \ |
39236c6e A |
454 | $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ |
455 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ | |
456 | $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \ | |
457 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \ | |
458 | $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \ | |
316670eb | 459 | $(DEPLOYMENT_TARGET_FLAGS) \ |
3e170ce0 | 460 | $(DEPLOYMENT_TARGET_DEFINES) \ |
1c79356b A |
461 | $(DEFINES) |
462 | ||
6d2010ae | 463 | # |
55e303ae | 464 | # Default C++ flags |
1c79356b | 465 | # |
6d2010ae A |
466 | |
467 | OTHER_CXXFLAGS = | |
316670eb | 468 | |
cb323159 | 469 | CXXFLAGS_GEN = -std=gnu++1z -fsized-deallocation -fapple-kext $(OTHER_CXXFLAGS) |
fe8ab488 | 470 | |
55e303ae | 471 | CXXFLAGS = $(CXXFLAGS_GEN) \ |
39236c6e A |
472 | $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \ |
473 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_)) | |
474 | ||
1c79356b A |
475 | # |
476 | # Assembler command | |
477 | # | |
f427ee49 | 478 | AS = $(CCACHE) $(CC) |
0c530ab8 | 479 | S_KCC = $(CC) |
1c79356b A |
480 | |
481 | # | |
482 | # Default SFLAGS | |
483 | # | |
fe8ab488 | 484 | SFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS) |
1c79356b | 485 | |
39037602 A |
486 | SFLAGS_RELEASE = |
487 | SFLAGS_DEVELOPMENT = | |
5ba3f43e | 488 | SFLAGS_KASAN = $(SFLAGS_DEVELOPMENT) -DKASAN=1 |
39037602 A |
489 | SFLAGS_DEBUG = |
490 | SFLAGS_PROFILE = | |
1c79356b | 491 | |
39037602 A |
492 | SFLAGS_X86_64 = $(CFLAGS_X86_64) |
493 | SFLAGS_X86_64H = $(CFLAGS_X86_64H) | |
d9a64523 A |
494 | SFLAGS_ARM = $(CFLAGS_ARM) |
495 | SFLAGS_ARM64 = $(CFLAGS_ARM64) | |
1c79356b | 496 | |
39037602 | 497 | SFLAGS = $(SFLAGS_GEN) \ |
39236c6e A |
498 | $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ |
499 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ | |
500 | $($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \ | |
501 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \ | |
316670eb | 502 | $(DEPLOYMENT_TARGET_FLAGS) \ |
3e170ce0 | 503 | $(DEPLOYMENT_TARGET_DEFINES) \ |
1c79356b A |
504 | $(DEFINES) |
505 | ||
506 | # | |
507 | # Linker command | |
508 | # | |
0c530ab8 | 509 | LD = $(KC++) -nostdlib |
1c79356b A |
510 | |
511 | # | |
512 | # Default LDFLAGS | |
513 | # | |
39236c6e A |
514 | # Availability of DWARF allows DTrace CTF (compressed type format) to be constructed. |
515 | # ctf_insert creates the CTF section. It needs reserved padding in the | |
516 | # headers for the load command segment and the CTF section structures. | |
517 | # | |
518 | LDFLAGS_KERNEL_GEN = \ | |
6d2010ae | 519 | -nostdlib \ |
0c530ab8 | 520 | -fapple-kext \ |
0c530ab8 | 521 | -Wl,-e,__start \ |
0c530ab8 | 522 | -Wl,-sectalign,__TEXT,__text,0x1000 \ |
f427ee49 | 523 | -Wl,-sectalign,__DATA,__percpu,0x80 \ |
0c530ab8 A |
524 | -Wl,-sectalign,__DATA,__common,0x1000 \ |
525 | -Wl,-sectalign,__DATA,__bss,0x1000 \ | |
d9a64523 | 526 | -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \ |
f427ee49 | 527 | -Wl,-segprot,__PRELINK_TEXT,r-x,r-x \ |
316670eb A |
528 | -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \ |
529 | -Wl,-new_linker \ | |
530 | -Wl,-pagezero_size,0x0 \ | |
531 | -Wl,-version_load_command \ | |
39236c6e A |
532 | -Wl,-function_starts \ |
533 | -Wl,-headerpad,152 | |
b0d623f7 | 534 | |
d9a64523 A |
535 | # LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel |
536 | LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel | |
39037602 A |
537 | |
538 | LDFLAGS_KERNEL_RELEASE = | |
5ba3f43e A |
539 | LDFLAGS_KERNEL_DEVELOPMENT = |
540 | LDFLAGS_KERNEL_KASAN = $(LDFLAGS_KERNEL_DEVELOPMENT) | |
39037602 A |
541 | LDFLAGS_KERNEL_DEBUG = |
542 | LDFLAGS_KERNEL_PROFILE = | |
b0d623f7 | 543 | |
316670eb A |
544 | # KASLR static slide config: |
545 | ifndef SLIDE | |
546 | SLIDE=0x00 | |
547 | endif | |
39236c6e A |
548 | KERNEL_MIN_ADDRESS = 0xffffff8000000000 |
549 | KERNEL_BASE_OFFSET = 0x100000 | |
550 | KERNEL_STATIC_SLIDE = $(shell printf "0x%016x" \ | |
551 | $$[ $(SLIDE) << 21 ]) | |
552 | KERNEL_STATIC_BASE = $(shell printf "0x%016x" \ | |
553 | $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ]) | |
554 | KERNEL_HIB_SECTION_BASE = $(shell printf "0x%016x" \ | |
555 | $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ]) | |
556 | KERNEL_TEXT_BASE = $(shell printf "0x%016x" \ | |
557 | $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ]) | |
558 | ||
559 | LDFLAGS_KERNEL_RELEASEX86_64 = \ | |
316670eb A |
560 | -Wl,-pie \ |
561 | -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \ | |
562 | -Wl,-image_base,$(KERNEL_TEXT_BASE) \ | |
563 | -Wl,-seg_page_size,__TEXT,0x200000 \ | |
316670eb A |
564 | -Wl,-sectalign,__HIB,__bootPT,0x1000 \ |
565 | -Wl,-sectalign,__HIB,__desc,0x1000 \ | |
566 | -Wl,-sectalign,__HIB,__data,0x1000 \ | |
567 | -Wl,-sectalign,__HIB,__text,0x1000 \ | |
568 | -Wl,-sectalign,__HIB,__const,0x1000 \ | |
569 | -Wl,-sectalign,__HIB,__bss,0x1000 \ | |
570 | -Wl,-sectalign,__HIB,__common,0x1000 \ | |
3e170ce0 A |
571 | -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \ |
572 | -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \ | |
573 | -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \ | |
574 | -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \ | |
f427ee49 | 575 | -Wl,-sectalign,__HIB,__cstring,0x1000 \ |
cb323159 | 576 | -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ |
f427ee49 | 577 | -Wl,-segprot,__DATA_CONST,r--,r-- \ |
c3c9b80d A |
578 | -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ |
579 | -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ | |
580 | -Wl,-segprot,__KLDDATA,rw-,rw- \ | |
581 | -Wl,-segprot,__KLD,r-x,r-x \ | |
39037602 | 582 | -Wl,-no_zero_fill_sections \ |
39236c6e | 583 | $(LDFLAGS_NOSTRIP_FLAG) |
316670eb | 584 | |
d9a64523 A |
585 | ifeq ($(SAN),1) |
586 | LDFLAGS_KERNEL_RELEASEX86_64 += \ | |
587 | -Wl,-sectalign,__HIB,__cstring,0x1000 | |
588 | endif | |
589 | ||
cb323159 | 590 | ifeq ($(KSANCOV),1) |
5ba3f43e | 591 | LDFLAGS_KERNEL_RELEASEX86_64 += \ |
cb323159 A |
592 | -Wl,-sectalign,__HIB,__sancov_guards,0x1000 \ |
593 | -Wl,-sectalign,__HIB,__sancov_pcs,0x1000 | |
5ba3f43e A |
594 | endif |
595 | ||
316670eb | 596 | # Define KERNEL_BASE_OFFSET so known at compile time: |
39236c6e | 597 | CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) |
fe8ab488 | 598 | CFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) |
2d21ac55 | 599 | |
39236c6e A |
600 | LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) |
601 | LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) | |
cb323159 A |
602 | LDFLAGS_KERNEL_KASANX86_64 = $(LDFLAGS_KERNEL_DEVELOPMENTX86_64) \ |
603 | -Wl,-sectalign,__HIB,__asan_globals,0x1000 \ | |
604 | -Wl,-sectalign,__HIB,__asan_liveness,0x1000 \ | |
605 | -Wl,-sectalign,__HIB,__mod_term_func,0x1000 \ | |
606 | -Wl,-rename_section,__HIB,__mod_init_func,__NULL,__mod_init_func \ | |
607 | -Wl,-rename_section,__HIB,__eh_frame,__NULL,__eh_frame | |
39236c6e | 608 | LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) |
d1ecb069 | 609 | |
fe8ab488 A |
610 | LDFLAGS_KERNEL_RELEASEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64) |
611 | LDFLAGS_KERNEL_DEBUGX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) | |
612 | LDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) | |
cb323159 | 613 | LDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_KASANX86_64) |
fe8ab488 A |
614 | LDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) |
615 | ||
d9a64523 A |
616 | # We preload ___udivmoddi4 in order to work around an issue with building |
617 | # LTO on armv7. | |
618 | LDFLAGS_KERNEL_GENARM = \ | |
619 | -Wl,-pie \ | |
620 | -Wl,-static \ | |
621 | -Wl,-image_base,0x80001000 \ | |
622 | -Wl,-sectalign,__DATA,__const,0x1000 \ | |
c3c9b80d A |
623 | -Wl,-u,___udivmoddi4 \ |
624 | -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ | |
625 | -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ | |
626 | -Wl,-segprot,__KLDDATA,rw-,rw- \ | |
627 | -Wl,-segprot,__KLD,r-x,r-x | |
d9a64523 A |
628 | |
629 | LDFLAGS_KERNEL_RELEASEARM = \ | |
cb323159 A |
630 | $(LDFLAGS_KERNEL_GENARM) \ |
631 | $(LDFLAGS_KERNEL_STRIP_LTO) | |
d9a64523 | 632 | |
f427ee49 | 633 | LDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM = \ |
d9a64523 A |
634 | -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp |
635 | ||
636 | LDFLAGS_KERNEL_DEVELOPMENTARM = \ | |
637 | $(LDFLAGS_KERNEL_GENARM) \ | |
638 | $(LDFLAGS_NOSTRIP_FLAG) | |
639 | ||
f427ee49 | 640 | LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM = |
d9a64523 A |
641 | |
642 | LDFLAGS_KERNEL_DEBUGARM = $(LDFLAGS_KERNEL_DEVELOPMENTARM) | |
f427ee49 | 643 | LDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM) |
d9a64523 A |
644 | |
645 | # Offset image base by page to have iBoot load kernel TEXT correctly. | |
646 | # First page is used for various purposes : sleep token, reset vector. | |
647 | # We also need a 32MB offset, as this is the minimum block mapping size | |
648 | # for a 16KB page runtime, and we wish to use the first virtual block | |
649 | # to map the low globals page. We also need another 4MB to account for | |
650 | # the address space reserved by L4 (because the reservation is not a | |
651 | # multiple of the block size in alignment/length, we will implictly map | |
652 | # it with our block mapping, and we therefore must reflect that the | |
653 | # first 4MB of the block mapping for xnu do not belong to xnu). | |
654 | # For the moment, kaliber has a unique memory layout (monitor at the top | |
655 | # of memory). Support this by breaking 16KB on other platforms and | |
656 | # mandating 32MB alignment. Image base (i.e. __TEXT) must be 16KB | |
657 | # aligned since ld64 will link with 16KB alignment for ARM64. | |
658 | # | |
659 | # We currently offset by an additional 32MB in order to reclaim memory. | |
660 | # We need a dedicated virtual page for the low globals. Our bootloader | |
661 | # may have a significant chunk of memory (up to an L2 entry in size) | |
662 | # that lies before the kernel. The addition 32MB of virtual padding | |
663 | # ensures that we have enough virtual address space to map all of that | |
664 | # memory as part of the V-to-P mapping. | |
665 | # 23355738 - put __PRELINK_TEXT first. We reserve enough room | |
666 | # for 0x0000000003000000 = 48MB of kexts | |
667 | # | |
668 | # 0xfffffff000000000 (32MB range for low globals) | |
669 | # 0xfffffff002000000 (32MB range to allow for large page physical slide) | |
670 | # 0xfffffff004000000 (16KB range to reserve the first available page) | |
671 | # 0xfffffff004004000 (48MB range for kexts) | |
672 | # 0xfffffff007004000 (Start of xnu proper). | |
673 | LDFLAGS_KERNEL_GENARM64 = \ | |
674 | -Wl,-pie \ | |
675 | -Wl,-static \ | |
f427ee49 A |
676 | -Wl,-segaddr,__PRELINK_TEXT,$(ARM64_PLKSEG_ADDR) \ |
677 | -Wl,-image_base,$(ARM64_LINK_ADDR) \ | |
678 | \ | |
679 | -Wl,-rename_section,__HIB,__text,__TEXT_EXEC,__hib_text \ | |
680 | \ | |
681 | -Wl,-rename_section,__HIB,__const,__DATA_CONST,__hib_const \ | |
682 | -Wl,-rename_section,__HIB,__cstring,__DATA_CONST,__hib_const \ | |
683 | -Wl,-rename_section,__HIB,__literal8,__DATA_CONST,__hib_const \ | |
684 | -Wl,-rename_section,__HIB,__literal16,__DATA_CONST,__hib_const \ | |
685 | \ | |
686 | -Wl,-rename_segment,__HIB,__HIBDATA \ | |
687 | \ | |
d9a64523 | 688 | -Wl,-sectalign,__DATA,__const,0x4000 \ |
f427ee49 | 689 | -Wl,-sectalign,__DATA,__data,0x4000 \ |
d9a64523 A |
690 | -Wl,-rename_section,__DATA,__mod_init_func,__DATA_CONST,__mod_init_func \ |
691 | -Wl,-rename_section,__DATA,__mod_term_func,__DATA_CONST,__mod_term_func \ | |
0a7de745 A |
692 | -Wl,-rename_section,__DATA,__auth_ptr,__DATA_CONST,__auth_ptr \ |
693 | -Wl,-rename_section,__DATA,__auth_got,__DATA_CONST,__auth_got \ | |
d9a64523 | 694 | -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ |
f427ee49 | 695 | -Wl,-segprot,__DATA_CONST,r--,r-- \ |
c3c9b80d A |
696 | -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ |
697 | -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ | |
698 | -Wl,-segprot,__KLDDATA,rw-,rw- \ | |
699 | -Wl,-segprot,__KLD,r-x,r-x \ | |
d9a64523 A |
700 | -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text \ |
701 | -Wl,-rename_section,__TEXT,__stubs,__TEXT_EXEC,__stubs \ | |
d9a64523 A |
702 | -Wl,-sectcreate,"__PLK_TEXT_EXEC",__text,/dev/null \ |
703 | -Wl,-sectcreate,__PRELINK_DATA,__data,/dev/null \ | |
704 | -Wl,-sectcreate,"__PLK_DATA_CONST",__data,/dev/null \ | |
705 | -Wl,-sectcreate,"__PLK_LLVM_COV",__llvm_covmap,/dev/null \ | |
706 | -Wl,-sectcreate,"__PLK_LINKEDIT",__data,/dev/null | |
707 | ||
2a1bd2d3 A |
708 | LDFLAGS_KERNEL_SEGARM64 = \ |
709 | -Wl,-rename_section,__PPLDATA,__const,__PPLDATA_CONST,__const \ | |
c3c9b80d A |
710 | -Wl,-segment_order,__TEXT:__DATA_CONST:__LINKEDIT:__TEXT_EXEC:__KLD:__PPLTEXT:__PPLTRAMP:__PPLDATA_CONST:__LASTDATA_CONST:__LAST:__PPLDATA:__KLDDATA:__DATA:__HIBDATA:__BOOTDATA \ |
711 | -Wl,-segprot,__PPLTEXT,r-x,r-x -Wl,-segprot,__PPLTRAMP,r-x,r-x -Wl,-segprot,__PPLDATA_CONST,r--,r-- -Wl,-segprot,__LASTDATA_CONST,r--,r-- -Wl,-segprot,__LAST,r-x,r-x \ | |
d9a64523 A |
712 | |
713 | LDFLAGS_KERNEL_RELEASEARM64 = \ | |
714 | $(LDFLAGS_KERNEL_GENARM64) \ | |
cb323159 A |
715 | $(LDFLAGS_KERNEL_SEGARM64) \ |
716 | $(LDFLAGS_KERNEL_STRIP_LTO) | |
d9a64523 | 717 | |
f427ee49 | 718 | LDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM64 = \ |
d9a64523 A |
719 | -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp |
720 | ||
721 | LDFLAGS_KERNEL_DEVELOPMENTARM64 = \ | |
722 | $(LDFLAGS_KERNEL_GENARM64) \ | |
723 | $(LDFLAGS_KERNEL_SEGARM64) \ | |
724 | $(LDFLAGS_NOSTRIP_FLAG) | |
725 | ||
f427ee49 | 726 | LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64 = |
d9a64523 A |
727 | |
728 | LDFLAGS_KERNEL_KASANARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) | |
729 | LDFLAGS_KERNEL_DEBUGARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) | |
730 | ||
f427ee49 A |
731 | LDFLAGS_KERNEL_ONLY_CONFIG_KASANARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) |
732 | LDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) | |
733 | ||
734 | # | |
735 | # arm64e specific linker flags that should be used only when linking the kernel | |
736 | # (and not the static kernel cache / kcgen) | |
737 | # | |
738 | LDFLAGS_KERNEL_ONLY_SUBARCH_arm64e = \ | |
739 | -Wl,-add_split_seg_info \ | |
740 | -Wl,-kernel | |
741 | ||
742 | LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64 = \ | |
743 | -Wl,-add_split_seg_info \ | |
744 | -Wl,-kernel | |
745 | LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64h = $(LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64) | |
d1ecb069 | 746 | |
39236c6e | 747 | LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \ |
39037602 | 748 | $(LDFLAGS_KERNEL_SDK) \ |
39236c6e A |
749 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ |
750 | $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \ | |
751 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \ | |
752 | $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \ | |
316670eb | 753 | $(DEPLOYMENT_TARGET_FLAGS) |
1c79356b | 754 | |
2a1bd2d3 | 755 | LDFLAGS_KERNEL_ONLY += \ |
f427ee49 A |
756 | $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_ONLY_CONFIG_))) \ |
757 | $($(addsuffix $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),LDFLAGS_KERNEL_ONLY_SUBARCH_)) \ | |
758 | -Wl,-alias_list,$(TARGET)/all-alias.exp \ | |
759 | -Wl,-sectcreate,__LINKINFO,__symbolsets,$(TARGET)/symbolsets.plist -Wl,-segprot,__LINKINFO,r--,r-- | |
d9a64523 | 760 | |
1c79356b A |
761 | # |
762 | # Default runtime libraries to be linked with the kernel | |
763 | # | |
d9a64523 A |
764 | LD_KERNEL_LIBS = -lcc_kext |
765 | LD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel | |
2a1bd2d3 | 766 | # Link opensource binary library |
a991bd8d A |
767 | ifneq ($(filter T8020 T8101 T8020 T8101,$(CURRENT_MACHINE_CONFIG)),) |
768 | LDFLAGS_KERNEL_ONLY += -rdynamic -Wl,-force_load,$(KDKROOT)/System/Library/KernelSupport/lib$(CURRENT_MACHINE_CONFIG).os.$(CURRENT_KERNEL_CONFIG).a | |
2a1bd2d3 A |
769 | endif |
770 | ||
39236c6e A |
771 | # |
772 | # DTrace support | |
773 | # | |
cb323159 A |
774 | ifndef DO_CTFMERGE |
775 | DO_CTFMERGE := 1 | |
39236c6e | 776 | ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) |
f427ee49 | 777 | ifneq ($(PLATFORM),MacOSX) |
cb323159 | 778 | DO_CTFMERGE := 0 |
39236c6e | 779 | endif |
39236c6e | 780 | endif |
cb323159 | 781 | ifneq ($(CURRENT_KERNEL_CONFIG),KASAN) |
f427ee49 | 782 | ifneq ($(PLATFORM),MacOSX) |
cb323159 A |
783 | ifeq ($(WILL_BUILD_STATIC_KC),1) |
784 | DO_CTFMERGE := 0 | |
785 | endif | |
786 | endif | |
f427ee49 | 787 | endif |
cb323159 A |
788 | endif # DO_CTFMERGE |
789 | ||
b0d623f7 | 790 | |
1c79356b A |
791 | # |
792 | # Default INCFLAGS | |
793 | # | |
39037602 A |
794 | INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST)) |
795 | INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS | |
39236c6e A |
796 | INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT) |
797 | INCFLAGS_LOCAL = -I. | |
39037602 | 798 | INCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel |
1c79356b | 799 | |
39037602 | 800 | INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK) |
1c79356b A |
801 | |
802 | # | |
803 | # Default MIGFLAGS | |
804 | # | |
fe8ab488 | 805 | MIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ |
39236c6e | 806 | $(DEPLOYMENT_TARGET_FLAGS) |
316670eb | 807 | |
3e170ce0 A |
808 | # Support for LLVM Profile Guided Optimization (PGO) |
809 | ||
810 | ifeq ($(BUILD_PROFILE),1) | |
811 | CFLAGS_GEN += -fprofile-instr-generate -DPROFILE | |
812 | CXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE | |
813 | endif | |
814 | ||
815 | ifdef USE_PROFILE | |
816 | CFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
817 | CXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
818 | LDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
819 | ||
820 | CFLAGS_GEN += -Wno-error=profile-instr-out-of-date | |
821 | endif | |
822 | ||
316670eb A |
823 | # |
824 | # Support for LLVM Link Time Optimization (LTO) | |
825 | # | |
fe8ab488 A |
826 | # LTO can be explicitly enabled or disabled with BUILD_LTO=1|0 |
827 | # and defaults to enabled except for DEBUG kernels | |
828 | # | |
39236c6e A |
829 | # CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files |
830 | # that deal poorly with LTO, or files that must be machine | |
831 | # code *.o files for xnu to build (i.e, setsegname runs on | |
832 | # them). | |
833 | # | |
834 | # LDFLAGS_NOSTRIP_FLAG is used to support configurations that | |
835 | # do not utilize an export list. For these configs to build, | |
836 | # we need to prevent the LTO logic from dead stripping them. | |
316670eb | 837 | |
fe8ab488 A |
838 | LTO_ENABLED_RELEASE = 1 |
839 | LTO_ENABLED_DEVELOPMENT = 1 | |
840 | LTO_ENABLED_DEBUG = 0 | |
5ba3f43e | 841 | LTO_ENABLED_KASAN = 0 |
fe8ab488 A |
842 | |
843 | ifneq ($(BUILD_LTO),) | |
844 | USE_LTO = $(BUILD_LTO) | |
845 | else | |
846 | USE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG)) | |
847 | endif | |
848 | ||
849 | ifeq ($(USE_LTO),1) | |
39236c6e A |
850 | CFLAGS_GEN += -flto |
851 | CXXFLAGS_GEN += -flto | |
cb323159 A |
852 | LDFLAGS_KERNEL_LTO = -Wl,-mllvm,-inline-threshold=100 |
853 | LDFLAGS_KERNEL_GEN += $(LDFLAGS_KERNEL_LTO) -Wl,-object_path_lto,$(TARGET)/lto.o | |
39236c6e | 854 | LDFLAGS_NOSTRIP_FLAG = -rdynamic |
cb323159 A |
855 | LDFLAGS_KERNEL_STRIP_LTO = -Wl,-dead_strip,-no_dead_strip_inits_and_terms |
856 | ||
39236c6e | 857 | CFLAGS_NOLTO_FLAG = -fno-lto |
316670eb | 858 | else |
cb323159 | 859 | LDFLAGS_KERNEL_LTO = |
39236c6e | 860 | LDFLAGS_NOSTRIP_FLAG = |
cb323159 | 861 | LDFLAGS_KERNEL_STRIP_LTO = |
39236c6e | 862 | CFLAGS_NOLTO_FLAG = |
316670eb | 863 | endif |
1c79356b | 864 | |
3e170ce0 A |
865 | ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1) |
866 | BUILD_DSYM := 0 | |
cb323159 | 867 | DO_CTFMERGE := 0 |
3e170ce0 A |
868 | KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) |
869 | KC++ = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CXX) | |
870 | S_KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) | |
871 | STRIP = true | |
872 | endif | |
873 | ||
1c79356b A |
874 | # |
875 | # Default VPATH | |
876 | # | |
39236c6e | 877 | export VPATH = .:$(SOURCE) |
1c79356b | 878 | |
813fb2f6 A |
879 | |
880 | ||
1c79356b | 881 | # |
2d21ac55 | 882 | # Macros that control installation of kernel and its header files |
1c79356b A |
883 | # |
884 | # install flags for header files | |
39037602 | 885 | # |
39236c6e A |
886 | INSTALL_FLAGS = -c -S -m 0444 |
887 | DATA_INSTALL_FLAGS = -c -S -m 0644 | |
f427ee49 | 888 | DATA_INSTALL_FLAGS_RO = -c -S -m 0444 |
39236c6e | 889 | EXEC_INSTALL_FLAGS = -c -S -m 0755 |
1c79356b A |
890 | |
891 | # | |
892 | # Header file destinations | |
893 | # | |
cb323159 A |
894 | |
895 | ifeq ($(DRIVERKIT),1) | |
896 | SDKHEADERSROOT=$(DRIVERKITRUNTIMEROOT) | |
897 | # only whitelisted headers install outside of the DriverKit Runtime hierarchy | |
898 | DRIVERKITSDKHEADERSROOT=$(DRIVERKITROOT) | |
899 | DRIVERKITFRAMEDIR = $(DRIVERKITROOT)/System/Library/Frameworks | |
900 | endif | |
901 | ||
902 | FRAMEDIR = $(SDKHEADERSROOT)/System/Library/Frameworks | |
6d2010ae A |
903 | |
904 | SINCVERS = B | |
905 | SINCFRAME = $(FRAMEDIR)/System.framework | |
906 | SINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers | |
907 | SPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders | |
908 | SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources | |
909 | ||
1c79356b | 910 | ifndef INCDIR |
cb323159 A |
911 | INCDIR = $(SDKHEADERSROOT)/usr/include |
912 | endif | |
913 | ifndef DRIVERKITINCDIR | |
914 | DRIVERKITINCDIR = $(DRIVERKITSDKHEADERSROOT)/usr/include | |
1c79356b A |
915 | endif |
916 | ifndef LCLDIR | |
f427ee49 A |
917 | ifeq ($(LIBKERN_USE_USR_LOCAL_INCLUDE),) |
918 | LCLDIR = $(SPINCDIR) | |
919 | else | |
920 | LCLDIR = $(SDKHEADERSROOT)/usr/local/include | |
921 | endif | |
1c79356b | 922 | endif |
cb323159 A |
923 | ifndef DRIVERKITLCLDIR |
924 | DRIVERKITLCLDIR = $(DRIVERKITSDKHEADERSROOT)/usr/local/include | |
925 | endif | |
1c79356b A |
926 | |
927 | KINCVERS = A | |
928 | KINCFRAME = $(FRAMEDIR)/Kernel.framework | |
929 | KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers | |
0b4e3aa0 | 930 | KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders |
91447636 A |
931 | KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources |
932 | ||
cb323159 A |
933 | DKIT_INCVERS = A |
934 | DKIT_INCFRAME = DriverKit.framework | |
935 | DKIT_INCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/Headers | |
936 | DKIT_PINCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/PrivateHeaders | |
937 | # DriverKit SDK frameworks use shallow bundle structure | |
938 | DRIVERKIT_DKIT_INCDIR = $(DKIT_INCFRAME)/Headers | |
939 | DRIVERKIT_DKIT_PINCDIR = $(DKIT_INCFRAME)/PrivateHeaders | |
940 | ||
91447636 A |
941 | XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE |
942 | ||
6d2010ae | 943 | |
39236c6e A |
944 | PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UPLATFORM_$(x))) |
945 | ||
d9a64523 | 946 | |
cb323159 A |
947 | SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -UDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ |
948 | SINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -UDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
949 | DKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -DDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ | |
950 | DKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -DDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
951 | KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DKERNEL -DPRIVATE -UDRIVERKIT -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ | |
952 | KINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -DKERNEL -UPRIVATE -UDRIVERKIT -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
953 | DATA_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
1c79356b A |
954 | |
955 | # | |
39236c6e | 956 | # Compononent Header file destinations |
1c79356b A |
957 | # |
958 | EXPDIR = EXPORT_HDRS/$(COMPONENT) | |
959 | ||
960 | # | |
961 | # Strip Flags | |
962 | # | |
39037602 A |
963 | STRIP_FLAGS_RELEASE = -S -x |
964 | STRIP_FLAGS_DEVELOPMENT = -S | |
5ba3f43e | 965 | STRIP_FLAGS_KASAN = $(STRIP_FLAGS_DEVELOPMENT) |
39037602 | 966 | STRIP_FLAGS_DEBUG = -S |
39236c6e | 967 | STRIP_FLAGS_PROFILE = -S -x |
1c79356b | 968 | |
39037602 | 969 | STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_)) |
1c79356b | 970 | |
2d21ac55 A |
971 | # |
972 | # dsymutil flags | |
973 | # | |
fe8ab488 | 974 | DSYMUTIL_FLAGS_GEN = --minimize |
2d21ac55 | 975 | |
fe8ab488 A |
976 | DSYMUTIL_FLAGS_X86_64 = --arch=x86_64 |
977 | DSYMUTIL_FLAGS_X86_64H = --arch=x86_64h | |
d9a64523 A |
978 | DSYMUTIL_FLAGS_ARM = --arch=arm |
979 | DSYMUTIL_FLAGS_ARM64 = | |
fe8ab488 A |
980 | |
981 | DSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \ | |
982 | $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_)) | |
2d21ac55 | 983 | |
9bccf70c A |
984 | # |
985 | # Man Page destination | |
986 | # | |
39236c6e | 987 | MANDIR = /usr/share/man |
9bccf70c | 988 | |
b0d623f7 A |
989 | # |
990 | # DEBUG alias location | |
991 | # | |
5ba3f43e | 992 | DEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_$(CURRENT_KERNEL_CONFIG_LC) |
2d21ac55 | 993 | |
1c79356b | 994 | # |
39236c6e | 995 | # mach_kernel install location |
1c79356b | 996 | # |
39236c6e | 997 | INSTALL_KERNEL_DIR = / |
1c79356b | 998 | |
fe8ab488 A |
999 | # |
1000 | # new OS X install location | |
1001 | # | |
1002 | SYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels | |
1003 | ||
1004 | # | |
1005 | # File names in DSTROOT | |
1006 | # | |
1007 | ||
1008 | ifeq ($(PLATFORM),MacOSX) | |
1009 | KERNEL_FILE_NAME_PREFIX = kernel | |
1010 | else | |
1011 | KERNEL_FILE_NAME_PREFIX = mach | |
1012 | endif | |
1013 | ||
1014 | ifeq ($(CURRENT_MACHINE_CONFIG),NONE) | |
1015 | ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) | |
1016 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX) | |
1017 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py | |
1018 | else | |
1019 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC) | |
1020 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py | |
1021 | endif | |
1022 | else | |
1023 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_MACHINE_CONFIG_LC) | |
1024 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py | |
1025 | endif | |
1026 | ||
39037602 A |
1027 | CURRENT_ALIAS_MACHINE_CONFIG = $(word 4,$(subst ^, ,$(CURRENT_BUILD_CONFIG))) |
1028 | CURRENT_ALIAS_MACHINE_CONFIG_LC = $(shell printf "%s" "$(CURRENT_ALIAS_MACHINE_CONFIG)" | $(TR) A-Z a-z) | |
1029 | ifneq ($(CURRENT_ALIAS_MACHINE_CONFIG),) | |
1030 | ALIAS_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_ALIAS_MACHINE_CONFIG_LC) | |
1031 | endif | |
1032 | ||
39236c6e A |
1033 | # |
1034 | # System.kext pseudo-kext install location | |
1035 | # | |
1036 | INSTALL_EXTENSIONS_DIR = /System/Library/Extensions | |
1037 | ||
1038 | # | |
fe8ab488 | 1039 | # KDK location |
39236c6e A |
1040 | # |
1041 | INSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK | |
1042 | ||
1043 | # | |
1044 | # Misc. Etc. | |
1045 | # | |
1046 | INSTALL_SHARE_MISC_DIR = /usr/share/misc | |
1047 | INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace | |
39037602 | 1048 | INSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace |
39236c6e A |
1049 | |
1050 | # | |
1051 | # Overrides for XBS build aliases | |
1052 | # | |
f427ee49 | 1053 | ifneq ($(filter $(RC_ProjectName),xnu_debug),) |
39236c6e | 1054 | INSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR) |
fe8ab488 A |
1055 | INSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR) |
1056 | INSTALL_KERNEL_SYM_TO_KDK = 1 | |
39236c6e | 1057 | INSTALL_XNU_DEBUG_FILES = 1 |
3e170ce0 | 1058 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) |
39236c6e A |
1059 | INSTALL_KERNEL_SYM_TO_KDK = 1 |
1060 | USE_BINARY_PLIST = 1 | |
3e170ce0 | 1061 | else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) |
39236c6e | 1062 | USE_BINARY_PLIST = 1 |
fe8ab488 A |
1063 | else ifeq ($(PLATFORM),MacOSX) |
1064 | INSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) | |
1065 | INSTALL_KERNEL_SYM_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) | |
1066 | INSTALL_KERNEL_SYM_TO_KDK = $(if $(filter YES,$(DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT)),1,0) | |
39236c6e | 1067 | endif |
1c79356b | 1068 | |
f427ee49 | 1069 | ifneq ($(filter $(RC_ProjectName),xnu_kasan),) |
5c9f4661 A |
1070 | INSTALL_KASAN_ONLY = 1 |
1071 | endif | |
1072 | ||
2d21ac55 | 1073 | # vim: set ft=make: |