1 # -*- mode: makefile;-*-
3 # Copyright (C) 1999-2020 Apple Inc. All rights reserved.
5 # MakeInc.def contains global definitions for building,
6 # linking, and installing files.
10 # Architecture Configuration options
12 SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H ARM ARM64
15 # Kernel Configuration options
17 SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN
21 # Machine Configuration options
24 SUPPORTED_X86_64_MACHINE_CONFIGS = NONE
25 SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE
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
34 SUPPORTED_ARM_MACHINE_CONFIGS = T8002 T8004
35 SUPPORTED_ARM64_MACHINE_CONFIGS = T7000 T7001 S8000 S8001 T8010 T8011 BCM2837 T8020 T8101 T8103
40 # Setup up *_LC variables during recursive invocations
43 ifndef CURRENT_ARCH_CONFIG_LC
44 export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z)
47 ifndef CURRENT_KERNEL_CONFIG_LC
48 export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z)
51 ifndef CURRENT_MACHINE_CONFIG_LC
52 export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z)
58 COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security san
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))
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
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
71 MACHINE_FLAGS_ARM64_T8020 = -DARM64_BOARD_CONFIG_T8020 -mcpu=vortex
72 MACHINE_FLAGS_ARM64_T8101 = -DARM64_BOARD_CONFIG_T8101 -mcpu=apple-a14
73 MACHINE_FLAGS_ARM64_T8103 = -DARM64_BOARD_CONFIG_T8103 -mcpu=apple-a14
77 # Deployment target flag
79 ifeq ($(PLATFORM),MacOSX)
80 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) -DXNU_TARGET_OS_OSX
81 DEPLOYMENT_LINKER_FLAGS = -Wl,-macosx_version_min,$(SDKVERSION)
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)
85 else ifeq ($(PLATFORM),WatchOS)
86 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_WATCH
87 DEPLOYMENT_LINKER_FLAGS =
88 else ifeq ($(PLATFORM),tvOS)
89 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV
90 DEPLOYMENT_LINKER_FLAGS =
91 else ifeq ($(PLATFORM),AppleTVOS)
92 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV
93 else ifeq ($(PLATFORM),BridgeOS)
94 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_BRIDGE
95 DEPLOYMENT_LINKER_FLAGS =
96 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
97 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_IOS
98 DEPLOYMENT_LINKER_FLAGS = -Wl,-ios_version_min,$(SDKVERSION)
99 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
100 DEPLOYMENT_TARGET_FLAGS =
101 DEPLOYMENT_LINKER_FLAGS =
103 DEPLOYMENT_TARGET_FLAGS =
104 DEPLOYMENT_LINKER_FLAGS =
107 DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
110 ifneq ($(RC_ENABLE_PRODUCT_INFO_FILTER),)
111 SEED_DEFINES += -DRC_ENABLE_XNU_PRODUCT_INFO_FILTER
113 SEED_DEFINES += -URC_ENABLE_XNU_PRODUCT_INFO_FILTER
117 # Standard defines list
119 DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \
120 -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile -DXNU_KERN_EVENT_DATA_IS_VLA \
121 $(CONFIG_DEFINES) $(SEED_DEFINES)
123 # Enable caching with `make CCACHE=ccache`
124 # This intentionally does not override $(CC) because that will confuse
125 # utilities like mig.
131 KCC = $(CCACHE) $(CC)
132 KC++ = $(CCACHE) $(CXX)
134 GENASSYM_KCC = $(CCACHE) $(CC)
137 # Compiler warning flags
141 ifneq ($(BUILD_WERROR),)
142 USE_WERROR := $(BUILD_WERROR)
145 ifeq ($(USE_WERROR),1)
149 # Shared C/C++ warning flags
150 # NOTE: order matters here. -Wno-xxx goes before opt-in of ones we want
155 -Wno-bad-function-cast \
158 -Wno-conditional-uninitialized \
159 -Wno-covered-switch-default \
160 -Wno-disabled-macro-expansion \
161 -Wno-documentation-unknown-command \
162 -Wno-extra-semi-stmt \
163 -Wno-format-non-iso \
164 -Wno-format-nonliteral \
165 -Wno-language-extension-token \
166 -Wno-missing-variable-declarations \
169 -Wno-partial-availability \
170 -Wno-reserved-id-macro \
171 -Wno-shift-sign-overflow \
175 -Wno-used-but-marked-unused \
176 -Wno-variadic-macros \
178 -Wno-zero-length-array
180 # When a new clang has new warnings disable them here until the kernel is fixed.
181 WARNFLAGS_STD := $(WARNFLAGS_STD) \
182 -Wno-unknown-warning-option \
183 -Wno-anon-enum-enum-conversion \
184 -Wno-error=enum-enum-conversion \
185 -Wno-error=c99-designator \
186 -Wno-error=reorder-init-list
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) \
200 # Can be overridden in Makefile.template or Makefile.$arch
201 export CWARNFLAGS ?= $(CWARNFLAGS_STD)
203 define add_perfile_cflags
204 $(1)_CWARNFLAGS_ADD += $2
207 define rm_perfile_cflags
213 -Wno-c++98-compat-pedantic \
214 -Wno-exit-time-destructors \
215 -Wno-global-constructors \
218 # Can be overridden in Makefile.template or Makefile.$arch
219 export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
221 define add_perfile_cxxflags
222 $(1)_CXXWARNFLAGS_ADD += $2
226 # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers
228 ARCH_FLAGS_X86_64 = -arch x86_64
229 ARCH_FLAGS_X86_64H = -arch x86_64h
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
238 ifneq ($(filter ARM ARM64,$(CURRENT_ARCH_CONFIG)),)
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
246 ifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG
248 ifneq ($(EMBEDDED_DEVICE_MAP),)
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 )
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)
253 ifneq ($(filter ARM64,$(CURRENT_ARCH_CONFIG)),)
254 export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := arm64e
260 # This can have false negatives, and is used to avoid calling CTF when we'll build a static KC
262 ifndef WILL_BUILD_STATIC_KC
263 ifneq ($(EMBEDDED_DEVICE_MAP),)
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,%")')
268 export WILL_BUILD_STATIC_KC := 0
272 BUILD_STATIC_LINK := 1
274 ARCH_FLAGS_ARM = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG)
275 ARCH_FLAGS_ARM64 = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG)
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)
290 ifdef RC_NONARCH_CFLAGS
291 OTHER_CFLAGS = $(RC_NONARCH_CFLAGS)
297 DSYMINFODIR = Contents
298 DSYMKGMACROSDIR = Contents/Resources
299 DSYMLLDBMACROSDIR = Contents/Resources/Python
300 DSYMDWARFDIR = Contents/Resources/DWARF
306 # We must not use -fno-keep-inline-functions, or it will remove the dtrace
307 # probes from the kernel.
309 CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
310 -ferror-limit=10000 \
313 -ftrivial-auto-var-init=zero \
314 -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \
316 -fmerge-all-constants \
317 -fno-c++-static-destructors \
323 CFLAGS_KASAN = $(CFLAGS_DEVELOPMENT)
326 CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
327 -DPAGE_SIZE_FIXED -mkernel -msoft-float
329 CFLAGS_X86_64H = $(CFLAGS_X86_64)
331 CFLAGS_ARM = -Darm -DARM -D__ARM__ -DPAGE_SIZE_FIXED \
332 -momit-leaf-frame-pointer -fno-strict-aliasing -D__API__=v4
334 LARGE_MEMORY_DEFINE=-UARM_LARGE_MEMORY
335 ARM64_PLKSEG_ADDR =0xfffffff004004000
336 ARM64_LINK_ADDR =0xfffffff007004000
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
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
349 CFLAGS_RELEASEX86_64 = -O2
350 CFLAGS_DEVELOPMENTX86_64 = -O2
351 CFLAGS_KASANX86_64 = $(CFLAGS_DEVELOPMENTX86_64)
352 # No space optimization for the DEBUG kernel for the benefit of gdb:
353 CFLAGS_DEBUGX86_64 = -O0
354 CFLAGS_PROFILEX86_64 = -O2
356 CFLAGS_RELEASEX86_64H = -O2
357 CFLAGS_DEVELOPMENTX86_64H = -O2
358 CFLAGS_KASANX86_64H = $(CFLAGS_DEVELOPMENTX86_64H)
359 # No space optimization for the DEBUG kernel for the benefit of gdb:
360 CFLAGS_DEBUGX86_64H = -O0
361 CFLAGS_PROFILEX86_64H = -O2
363 CFLAGS_RELEASEARM = -O2
364 CFLAGS_DEVELOPMENTARM = -O2
365 CFLAGS_DEBUGARM = -O0
366 CFLAGS_PROFILEARM = -O2
368 CFLAGS_RELEASEARM64 = -O2
369 CFLAGS_DEVELOPMENTARM64 = -O2
370 CFLAGS_KASANARM64 = $(CFLAGS_DEVELOPMENTARM64)
371 CFLAGS_DEBUGARM64 = -O0
372 CFLAGS_PROFILEARM64 = -O2
375 # Sanitizers Support (KASan, UBSan)
384 ifeq ($(CURRENT_KERNEL_CONFIG),KASAN)
385 # KASan kernel config implicitly enables the KASan instrumentation.
386 # Instrumentation for other sanitizers is enabled explicitly at build time.
394 # Shadow map scale size. With KASAN_SCALE=N, the shadow memory consumes 1/2^N of
395 # the virtual address space.
398 KASAN_OFFSET_ARM64=0xe000000000000000
400 # To calculate the kasan offset, subtract the lowest KVA to sanitize, shifted right by 3 bits,
401 # from the base address of the kasan shadow area, (e.g. solve the following equation:
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
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 \
413 -mllvm -asan-globals-live-support \
414 -mllvm -asan-mapping-offset=$(KASAN_OFFSET) \
415 -fsanitize-blacklist=$(KASAN_BLACKLIST)
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
423 UBSAN_CHECKS_FATAL = # fatal (calls runtime, must not return)
424 UBSAN_CHECKS_TRAP = vla-bound builtin # emit a trap instruction (no runtime support)
427 UBSAN_DISABLED += vptr function # requires unsupported C++ runtime
429 # UBSan alignment + KASan code size is too large
430 # UBSan unreachable doesn't play nice with ASan (40723397)
431 UBSAN_DISABLED += alignment unreachable
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))
438 CFLAGS_GEN += $(foreach x,$(UBSAN_DISABLED),-fno-sanitize=$(x))
442 # Enable SanitizerCoverage instrumentation in xnu
444 KSANCOV_CFLAGS := -fsanitize-coverage=trace-pc-guard
445 CFLAGS_GEN += $(KSANCOV_CFLAGS) -DKSANCOV=1
449 CFLAGS_GEN += -fsanitize-blacklist=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC)
453 CFLAGS = $(CFLAGS_GEN) \
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_))) \
459 $(DEPLOYMENT_TARGET_FLAGS) \
460 $(DEPLOYMENT_TARGET_DEFINES) \
469 CXXFLAGS_GEN = -std=gnu++1z -fsized-deallocation -fapple-kext $(OTHER_CXXFLAGS)
471 CXXFLAGS = $(CXXFLAGS_GEN) \
472 $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \
473 $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_))
484 SFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS)
488 SFLAGS_KASAN = $(SFLAGS_DEVELOPMENT) -DKASAN=1
492 SFLAGS_X86_64 = $(CFLAGS_X86_64)
493 SFLAGS_X86_64H = $(CFLAGS_X86_64H)
494 SFLAGS_ARM = $(CFLAGS_ARM)
495 SFLAGS_ARM64 = $(CFLAGS_ARM64)
497 SFLAGS = $(SFLAGS_GEN) \
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_)) \
502 $(DEPLOYMENT_TARGET_FLAGS) \
503 $(DEPLOYMENT_TARGET_DEFINES) \
509 LD = $(KC++) -nostdlib
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.
518 LDFLAGS_KERNEL_GEN = \
522 -Wl,-sectalign,__TEXT,__text,0x1000 \
523 -Wl,-sectalign,__DATA,__percpu,0x80 \
524 -Wl,-sectalign,__DATA,__common,0x1000 \
525 -Wl,-sectalign,__DATA,__bss,0x1000 \
526 -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
527 -Wl,-segprot,__PRELINK_TEXT,r-x,r-x \
528 -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \
530 -Wl,-pagezero_size,0x0 \
531 -Wl,-version_load_command \
532 -Wl,-function_starts \
535 # LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel
536 LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel
538 LDFLAGS_KERNEL_RELEASE =
539 LDFLAGS_KERNEL_DEVELOPMENT =
540 LDFLAGS_KERNEL_KASAN = $(LDFLAGS_KERNEL_DEVELOPMENT)
541 LDFLAGS_KERNEL_DEBUG =
542 LDFLAGS_KERNEL_PROFILE =
544 # KASLR static slide config:
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 ])
559 LDFLAGS_KERNEL_RELEASEX86_64 = \
561 -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
562 -Wl,-image_base,$(KERNEL_TEXT_BASE) \
563 -Wl,-seg_page_size,__TEXT,0x200000 \
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 \
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 \
575 -Wl,-sectalign,__HIB,__cstring,0x1000 \
576 -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \
577 -Wl,-segprot,__DATA_CONST,r--,r-- \
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 \
582 -Wl,-no_zero_fill_sections \
583 $(LDFLAGS_NOSTRIP_FLAG)
586 LDFLAGS_KERNEL_RELEASEX86_64 += \
587 -Wl,-sectalign,__HIB,__cstring,0x1000
591 LDFLAGS_KERNEL_RELEASEX86_64 += \
592 -Wl,-sectalign,__HIB,__sancov_guards,0x1000 \
593 -Wl,-sectalign,__HIB,__sancov_pcs,0x1000
596 # Define KERNEL_BASE_OFFSET so known at compile time:
597 CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
598 CFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
600 LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
601 LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
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
608 LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
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)
613 LDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_KASANX86_64)
614 LDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
616 # We preload ___udivmoddi4 in order to work around an issue with building
618 LDFLAGS_KERNEL_GENARM = \
621 -Wl,-image_base,0x80001000 \
622 -Wl,-sectalign,__DATA,__const,0x1000 \
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
629 LDFLAGS_KERNEL_RELEASEARM = \
630 $(LDFLAGS_KERNEL_GENARM) \
631 $(LDFLAGS_KERNEL_STRIP_LTO)
633 LDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM = \
634 -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp
636 LDFLAGS_KERNEL_DEVELOPMENTARM = \
637 $(LDFLAGS_KERNEL_GENARM) \
638 $(LDFLAGS_NOSTRIP_FLAG)
640 LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM =
642 LDFLAGS_KERNEL_DEBUGARM = $(LDFLAGS_KERNEL_DEVELOPMENTARM)
643 LDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM)
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.
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
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 = \
676 -Wl,-segaddr,__PRELINK_TEXT,$(ARM64_PLKSEG_ADDR) \
677 -Wl,-image_base,$(ARM64_LINK_ADDR) \
679 -Wl,-rename_section,__HIB,__text,__TEXT_EXEC,__hib_text \
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 \
686 -Wl,-rename_segment,__HIB,__HIBDATA \
688 -Wl,-sectalign,__DATA,__const,0x4000 \
689 -Wl,-sectalign,__DATA,__data,0x4000 \
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 \
692 -Wl,-rename_section,__DATA,__auth_ptr,__DATA_CONST,__auth_ptr \
693 -Wl,-rename_section,__DATA,__auth_got,__DATA_CONST,__auth_got \
694 -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \
695 -Wl,-segprot,__DATA_CONST,r--,r-- \
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 \
700 -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text \
701 -Wl,-rename_section,__TEXT,__stubs,__TEXT_EXEC,__stubs \
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
708 LDFLAGS_KERNEL_SEGARM64 = \
709 -Wl,-rename_section,__PPLDATA,__const,__PPLDATA_CONST,__const \
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 \
713 LDFLAGS_KERNEL_RELEASEARM64 = \
714 $(LDFLAGS_KERNEL_GENARM64) \
715 $(LDFLAGS_KERNEL_SEGARM64) \
716 $(LDFLAGS_KERNEL_STRIP_LTO)
718 LDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM64 = \
719 -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp
721 LDFLAGS_KERNEL_DEVELOPMENTARM64 = \
722 $(LDFLAGS_KERNEL_GENARM64) \
723 $(LDFLAGS_KERNEL_SEGARM64) \
724 $(LDFLAGS_NOSTRIP_FLAG)
726 LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64 =
728 LDFLAGS_KERNEL_KASANARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64)
729 LDFLAGS_KERNEL_DEBUGARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64)
731 LDFLAGS_KERNEL_ONLY_CONFIG_KASANARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64)
732 LDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64)
735 # arm64e specific linker flags that should be used only when linking the kernel
736 # (and not the static kernel cache / kcgen)
738 LDFLAGS_KERNEL_ONLY_SUBARCH_arm64e = \
739 -Wl,-add_split_seg_info \
742 LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64 = \
743 -Wl,-add_split_seg_info \
745 LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64h = $(LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64)
747 LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
748 $(LDFLAGS_KERNEL_SDK) \
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_))) \
753 $(DEPLOYMENT_TARGET_FLAGS)
755 LDFLAGS_KERNEL_ONLY += \
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--
762 # Default runtime libraries to be linked with the kernel
764 LD_KERNEL_LIBS = -lcc_kext
765 LD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel
766 # Link opensource binary library
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
776 ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE)
777 ifneq ($(PLATFORM),MacOSX)
781 ifneq ($(CURRENT_KERNEL_CONFIG),KASAN)
782 ifneq ($(PLATFORM),MacOSX)
783 ifeq ($(WILL_BUILD_STATIC_KC),1)
794 INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
795 INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS
796 INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
798 INCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel
800 INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK)
805 MIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
806 $(DEPLOYMENT_TARGET_FLAGS)
808 # Support for LLVM Profile Guided Optimization (PGO)
810 ifeq ($(BUILD_PROFILE),1)
811 CFLAGS_GEN += -fprofile-instr-generate -DPROFILE
812 CXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE
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)
820 CFLAGS_GEN += -Wno-error=profile-instr-out-of-date
824 # Support for LLVM Link Time Optimization (LTO)
826 # LTO can be explicitly enabled or disabled with BUILD_LTO=1|0
827 # and defaults to enabled except for DEBUG kernels
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
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.
838 LTO_ENABLED_RELEASE = 1
839 LTO_ENABLED_DEVELOPMENT = 1
840 LTO_ENABLED_DEBUG = 0
841 LTO_ENABLED_KASAN = 0
843 ifneq ($(BUILD_LTO),)
844 USE_LTO = $(BUILD_LTO)
846 USE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG))
851 CXXFLAGS_GEN += -flto
852 LDFLAGS_KERNEL_LTO = -Wl,-mllvm,-inline-threshold=100
853 LDFLAGS_KERNEL_GEN += $(LDFLAGS_KERNEL_LTO) -Wl,-object_path_lto,$(TARGET)/lto.o
854 LDFLAGS_NOSTRIP_FLAG = -rdynamic
855 LDFLAGS_KERNEL_STRIP_LTO = -Wl,-dead_strip,-no_dead_strip_inits_and_terms
857 CFLAGS_NOLTO_FLAG = -fno-lto
860 LDFLAGS_NOSTRIP_FLAG =
861 LDFLAGS_KERNEL_STRIP_LTO =
865 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
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)
877 export VPATH = .:$(SOURCE)
882 # Macros that control installation of kernel and its header files
884 # install flags for header files
886 INSTALL_FLAGS = -c -S -m 0444
887 DATA_INSTALL_FLAGS = -c -S -m 0644
888 DATA_INSTALL_FLAGS_RO = -c -S -m 0444
889 EXEC_INSTALL_FLAGS = -c -S -m 0755
892 # Header file destinations
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
902 FRAMEDIR = $(SDKHEADERSROOT)/System/Library/Frameworks
905 SINCFRAME = $(FRAMEDIR)/System.framework
906 SINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers
907 SPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders
908 SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources
911 INCDIR = $(SDKHEADERSROOT)/usr/include
913 ifndef DRIVERKITINCDIR
914 DRIVERKITINCDIR = $(DRIVERKITSDKHEADERSROOT)/usr/include
917 ifeq ($(LIBKERN_USE_USR_LOCAL_INCLUDE),)
920 LCLDIR = $(SDKHEADERSROOT)/usr/local/include
923 ifndef DRIVERKITLCLDIR
924 DRIVERKITLCLDIR = $(DRIVERKITSDKHEADERSROOT)/usr/local/include
928 KINCFRAME = $(FRAMEDIR)/Kernel.framework
929 KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers
930 KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders
931 KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources
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
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
944 PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UPLATFORM_$(x)))
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__
956 # Compononent Header file destinations
958 EXPDIR = EXPORT_HDRS/$(COMPONENT)
963 STRIP_FLAGS_RELEASE = -S -x
964 STRIP_FLAGS_DEVELOPMENT = -S
965 STRIP_FLAGS_KASAN = $(STRIP_FLAGS_DEVELOPMENT)
966 STRIP_FLAGS_DEBUG = -S
967 STRIP_FLAGS_PROFILE = -S -x
969 STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_))
974 DSYMUTIL_FLAGS_GEN = --minimize
976 DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
977 DSYMUTIL_FLAGS_X86_64H = --arch=x86_64h
978 DSYMUTIL_FLAGS_ARM = --arch=arm
979 DSYMUTIL_FLAGS_ARM64 =
981 DSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \
982 $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_))
985 # Man Page destination
987 MANDIR = /usr/share/man
990 # DEBUG alias location
992 DEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_$(CURRENT_KERNEL_CONFIG_LC)
995 # mach_kernel install location
997 INSTALL_KERNEL_DIR = /
1000 # new OS X install location
1002 SYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels
1005 # File names in DSTROOT
1008 ifeq ($(PLATFORM),MacOSX)
1009 KERNEL_FILE_NAME_PREFIX = kernel
1011 KERNEL_FILE_NAME_PREFIX = mach
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
1019 KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC)
1020 KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py
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
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)
1034 # System.kext pseudo-kext install location
1036 INSTALL_EXTENSIONS_DIR = /System/Library/Extensions
1041 INSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK
1046 INSTALL_SHARE_MISC_DIR = /usr/share/misc
1047 INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace
1048 INSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace
1051 # Overrides for XBS build aliases
1053 ifneq ($(filter $(RC_ProjectName),xnu_debug),)
1054 INSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR)
1055 INSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR)
1056 INSTALL_KERNEL_SYM_TO_KDK = 1
1057 INSTALL_XNU_DEBUG_FILES = 1
1058 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
1059 INSTALL_KERNEL_SYM_TO_KDK = 1
1060 USE_BINARY_PLIST = 1
1061 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
1062 USE_BINARY_PLIST = 1
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)
1069 ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
1070 INSTALL_KASAN_ONLY = 1