1*43a90889SApple OSS Distributions# -*- mode: makefile;-*- 2*43a90889SApple OSS Distributions# 3*43a90889SApple OSS Distributions# Copyright (C) 1999-2023 Apple Inc. All rights reserved. 4*43a90889SApple OSS Distributions# 5*43a90889SApple OSS Distributions# MakeInc.def contains global definitions for building, 6*43a90889SApple OSS Distributions# linking, and installing files. 7*43a90889SApple OSS Distributions# 8*43a90889SApple OSS Distributions 9*43a90889SApple OSS Distributions# 10*43a90889SApple OSS Distributions# Architecture Configuration options 11*43a90889SApple OSS Distributions# 12*43a90889SApple OSS DistributionsSUPPORTED_ARCH_CONFIGS := X86_64 X86_64H ARM64 13*43a90889SApple OSS Distributions 14*43a90889SApple OSS Distributions# 15*43a90889SApple OSS Distributions# Kernel Configuration options 16*43a90889SApple OSS Distributions# 17*43a90889SApple OSS DistributionsSUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN SPTM 18*43a90889SApple OSS Distributions 19*43a90889SApple OSS Distributions 20*43a90889SApple OSS Distributions# 21*43a90889SApple OSS Distributions# Machine Configuration options 22*43a90889SApple OSS Distributions# 23*43a90889SApple OSS Distributions 24*43a90889SApple OSS DistributionsSUPPORTED_X86_64_MACHINE_CONFIGS = NONE 25*43a90889SApple OSS DistributionsSUPPORTED_X86_64H_MACHINE_CONFIGS = NONE 26*43a90889SApple OSS Distributions 27*43a90889SApple OSS Distributionsifneq ($(findstring _Sim,$(RC_ProjectName)),) 28*43a90889SApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = NONE 29*43a90889SApple OSS Distributionselse ifneq ($(findstring _host,$(RC_ProjectName)),) 30*43a90889SApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = NONE 31*43a90889SApple OSS Distributionselse 32*43a90889SApple OSS DistributionsSUPPORTED_ARM64_MACHINE_CONFIGS = T6000 T6020 T6030 T6031 T6041 T8101 T8103 T8112 T8122 T8132 VMAPPLE 33*43a90889SApple OSS Distributions 34*43a90889SApple OSS DistributionsSPTM_ENABLED_SOCS_MacOSX = t6041 t8132 35*43a90889SApple OSS Distributions 36*43a90889SApple OSS Distributionsendif 37*43a90889SApple OSS Distributions 38*43a90889SApple OSS Distributions# 39*43a90889SApple OSS Distributions# Setup up *_LC variables during recursive invocations 40*43a90889SApple OSS Distributions# 41*43a90889SApple OSS Distributions 42*43a90889SApple OSS Distributionsifndef CURRENT_ARCH_CONFIG_LC 43*43a90889SApple OSS Distributions export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z) 44*43a90889SApple OSS Distributionsendif 45*43a90889SApple OSS Distributions 46*43a90889SApple OSS Distributionsifndef CURRENT_KERNEL_CONFIG_LC 47*43a90889SApple OSS Distributions export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z) 48*43a90889SApple OSS Distributionsendif 49*43a90889SApple OSS Distributions 50*43a90889SApple OSS Distributionsifndef CURRENT_MACHINE_CONFIG_LC 51*43a90889SApple OSS Distributions export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z) 52*43a90889SApple OSS Distributionsendif 53*43a90889SApple OSS Distributions 54*43a90889SApple OSS Distributions# Enable BTI by default for all ARM64 targets 55*43a90889SApple OSS DistributionsBTI_BUILD = 1 56*43a90889SApple OSS Distributions 57*43a90889SApple OSS Distributions 58*43a90889SApple OSS Distributions# -mkernel contains BTI by default 59*43a90889SApple OSS Distributionsifeq ($(BTI_BUILD),1) 60*43a90889SApple OSS Distributions BTI_BUILD_FLAGS = -DXNU_BUILT_WITH_BTI 61*43a90889SApple OSS Distributionselse 62*43a90889SApple OSS Distributions BTI_BUILD_FLAGS = -fno-branch-target-identification -UXNU_BUILT_WITH_BTI 63*43a90889SApple OSS Distributionsendif 64*43a90889SApple OSS Distributions 65*43a90889SApple OSS Distributions 66*43a90889SApple OSS Distributions# 67*43a90889SApple OSS Distributions# Component List 68*43a90889SApple OSS Distributions# 69*43a90889SApple OSS DistributionsCOMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security san 70*43a90889SApple OSS DistributionsCOMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))) 71*43a90889SApple OSS DistributionsCOMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST)) 72*43a90889SApple OSS Distributions 73*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T8101 = -DARM64_BOARD_CONFIG_T8101 -mcpu=apple-a14 74*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T8103 = -DARM64_BOARD_CONFIG_T8103 -mcpu=apple-a14 75*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T6000 = -DARM64_BOARD_CONFIG_T6000 -mcpu=apple-a14 76*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T6020 = -DARM64_BOARD_CONFIG_T6020 -mcpu=apple-a15 77*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T8112 = -DARM64_BOARD_CONFIG_T8112 -mcpu=apple-a15 78*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T6030 = -DARM64_BOARD_CONFIG_T6030 -mcpu=apple-m3 79*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T6031 = -DARM64_BOARD_CONFIG_T6031 -mcpu=apple-m3 80*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T6041 = -DARM64_BOARD_CONFIG_T6041 -mcpu=apple-m4 81*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T8122 = -DARM64_BOARD_CONFIG_T8122_T8130 -mcpu=apple-m3 82*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_T8132 = -DARM64_BOARD_CONFIG_T8132 -mcpu=apple-m4 83*43a90889SApple OSS DistributionsMACHINE_FLAGS_ARM64_VMAPPLE = -DARM64_BOARD_CONFIG_VMAPPLE -march=armv8.5a+sme2 84*43a90889SApple OSS Distributions 85*43a90889SApple OSS Distributions 86*43a90889SApple OSS Distributions# 87*43a90889SApple OSS Distributions# Deployment target flag 88*43a90889SApple OSS Distributions# 89*43a90889SApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 90*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) -DXNU_TARGET_OS_OSX 91*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-macosx_version_min,$(SDKVERSION) 92*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),DriverKit) 93*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -target apple-driverkit$(SDKVERSION) -DXNU_TARGET_OS_OSX 94*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-target,apple-driverkit$(SDKVERSION) 95*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),WatchOS) 96*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_WATCH 97*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 98*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),tvOS) 99*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV 100*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 101*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),AppleTVOS) 102*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_TV 103*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),BridgeOS) 104*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_BRIDGE 105*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 106*43a90889SApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 107*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_IOS 108*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = -Wl,-ios_version_min,$(SDKVERSION) 109*43a90889SApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 110*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = 111*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 112*43a90889SApple OSS Distributionselse 113*43a90889SApple OSS Distributions DEPLOYMENT_TARGET_FLAGS = 114*43a90889SApple OSS Distributions DEPLOYMENT_LINKER_FLAGS = 115*43a90889SApple OSS Distributionsendif 116*43a90889SApple OSS Distributions 117*43a90889SApple OSS Distributions 118*43a90889SApple OSS DistributionsDEPLOYMENT_TARGET_DEFINES = -DXNU_PLATFORM_$(PLATFORM) 119*43a90889SApple OSS Distributions 120*43a90889SApple OSS Distributions 121*43a90889SApple OSS Distributions# 122*43a90889SApple OSS Distributions# Standard defines list 123*43a90889SApple OSS Distributions# 124*43a90889SApple OSS DistributionsDEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \ 125*43a90889SApple OSS Distributions -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile -DXNU_KERN_EVENT_DATA_IS_VLA \ 126*43a90889SApple OSS Distributions -DCURRENT_MACHINE_CONFIG_LC=$(CURRENT_MACHINE_CONFIG_LC) \ 127*43a90889SApple OSS Distributions $(CONFIG_DEFINES) $(SEED_DEFINES) 128*43a90889SApple OSS Distributions 129*43a90889SApple OSS Distributions# Enable caching with `make CCACHE=ccache` 130*43a90889SApple OSS Distributions# This intentionally does not override $(CC) because that will confuse 131*43a90889SApple OSS Distributions# utilities like mig. 132*43a90889SApple OSS DistributionsCCACHE ?= 133*43a90889SApple OSS Distributions 134*43a90889SApple OSS Distributions# 135*43a90889SApple OSS Distributions# Compiler command 136*43a90889SApple OSS Distributions# 137*43a90889SApple OSS DistributionsKCC = $(CCACHE) $(CC) 138*43a90889SApple OSS DistributionsKC++ = $(CCACHE) $(CXX) 139*43a90889SApple OSS Distributions 140*43a90889SApple OSS DistributionsGENASSYM_KCC = $(CCACHE) $(CC) 141*43a90889SApple OSS Distributions 142*43a90889SApple OSS Distributions# 143*43a90889SApple OSS Distributions# Compiler warning flags 144*43a90889SApple OSS Distributions# 145*43a90889SApple OSS Distributions 146*43a90889SApple OSS DistributionsUSE_WERROR := 1 147*43a90889SApple OSS Distributionsifneq ($(BUILD_WERROR),) 148*43a90889SApple OSS DistributionsUSE_WERROR := $(BUILD_WERROR) 149*43a90889SApple OSS Distributionsendif 150*43a90889SApple OSS Distributions 151*43a90889SApple OSS Distributionsifeq ($(USE_WERROR),1) 152*43a90889SApple OSS DistributionsWERROR := -Werror 153*43a90889SApple OSS Distributionsendif 154*43a90889SApple OSS Distributions 155*43a90889SApple OSS Distributions# Shared C/C++ warning flags 156*43a90889SApple OSS Distributions# NOTE: order matters here. -Wno-xxx goes before opt-in of ones we want 157*43a90889SApple OSS DistributionsWARNFLAGS_STD := \ 158*43a90889SApple OSS Distributions -Weverything \ 159*43a90889SApple OSS Distributions -Wundef-prefix=TARGET_OS_ \ 160*43a90889SApple OSS Distributions -Wundef-prefix=LCK_GRP_USE_ARG \ 161*43a90889SApple OSS Distributions -Wno-pedantic \ 162*43a90889SApple OSS Distributions $(WERROR) \ 163*43a90889SApple OSS Distributions -Wno-bad-function-cast \ 164*43a90889SApple OSS Distributions -Wno-bitwise-instead-of-logical \ 165*43a90889SApple OSS Distributions -Wno-c++-compat \ 166*43a90889SApple OSS Distributions -Wno-c++98-compat \ 167*43a90889SApple OSS Distributions -Wno-conditional-uninitialized \ 168*43a90889SApple OSS Distributions -Wno-covered-switch-default \ 169*43a90889SApple OSS Distributions -Wno-disabled-macro-expansion \ 170*43a90889SApple OSS Distributions -Wno-documentation-unknown-command \ 171*43a90889SApple OSS Distributions -Wno-extra-semi-stmt \ 172*43a90889SApple OSS Distributions -Wno-format-non-iso \ 173*43a90889SApple OSS Distributions -Wno-language-extension-token \ 174*43a90889SApple OSS Distributions -Wno-missing-variable-declarations \ 175*43a90889SApple OSS Distributions -Wno-packed \ 176*43a90889SApple OSS Distributions -Wno-padded \ 177*43a90889SApple OSS Distributions -Wno-partial-availability \ 178*43a90889SApple OSS Distributions -Wno-reserved-id-macro \ 179*43a90889SApple OSS Distributions -Wno-shift-sign-overflow \ 180*43a90889SApple OSS Distributions -Wno-switch-enum \ 181*43a90889SApple OSS Distributions -Wno-unaligned-access \ 182*43a90889SApple OSS Distributions -Wno-undef \ 183*43a90889SApple OSS Distributions -Wno-invalid-offsetof \ 184*43a90889SApple OSS Distributions -Wno-unused-macros \ 185*43a90889SApple OSS Distributions -Wno-used-but-marked-unused \ 186*43a90889SApple OSS Distributions -Wno-variadic-macros \ 187*43a90889SApple OSS Distributions -Wno-zero-length-array \ 188*43a90889SApple OSS Distributions -Wno-packed \ 189*43a90889SApple OSS Distributions -Wno-cast-function-type-strict \ 190*43a90889SApple OSS Distributions -Wno-incompatible-function-pointer-types-strict 191*43a90889SApple OSS Distributions 192*43a90889SApple OSS Distributions# When a new clang has new warnings disable them here until the kernel is fixed. 193*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 194*43a90889SApple OSS Distributions -Wno-unknown-warning-option \ 195*43a90889SApple OSS Distributions -Wno-anon-enum-enum-conversion \ 196*43a90889SApple OSS Distributions -Wno-error=enum-enum-conversion \ 197*43a90889SApple OSS Distributions -Wno-error=c99-designator \ 198*43a90889SApple OSS Distributions -Wno-error=reorder-init-list \ 199*43a90889SApple OSS Distributions -Wno-error=switch-default \ 200*43a90889SApple OSS Distributions -Wno-deprecated-volatile \ 201*43a90889SApple OSS Distributions -Wno-error=incompatible-function-pointer-types-strict \ 202*43a90889SApple OSS Distributions -Wno-cast-function-type-strict 203*43a90889SApple OSS Distributions 204*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 205*43a90889SApple OSS Distributions -Wno-declaration-after-statement 206*43a90889SApple OSS Distributions 207*43a90889SApple OSS Distributions# Hand-written sign conversion diagnostics are resolved, but the 208*43a90889SApple OSS Distributions# auto-generated ones need mig and iig to be updated to fix. Disable the 209*43a90889SApple OSS Distributions# diagnostic here until we've completed that: 210*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 211*43a90889SApple OSS Distributions -Wno-sign-compare \ 212*43a90889SApple OSS Distributions -Wno-sign-conversion 213*43a90889SApple OSS Distributions 214*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 215*43a90889SApple OSS Distributions -Wno-pre-c11-compat 216*43a90889SApple OSS Distributions 217*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 218*43a90889SApple OSS Distributions -Wno-missing-designated-field-initializers 219*43a90889SApple OSS Distributions 220*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 221*43a90889SApple OSS Distributions -Wno-format-signedness 222*43a90889SApple OSS Distributions 223*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 224*43a90889SApple OSS Distributions -Wno-switch-default 225*43a90889SApple OSS Distributions 226*43a90889SApple OSS Distributions# Opt-ins: 227*43a90889SApple OSS DistributionsWARNFLAGS_STD := $(WARNFLAGS_STD) \ 228*43a90889SApple OSS Distributions -Wpointer-arith \ 229*43a90889SApple OSS Distributions -Wxnu-typed-allocators 230*43a90889SApple OSS Distributions 231*43a90889SApple OSS Distributions 232*43a90889SApple OSS DistributionsCWARNFLAGS_STD = \ 233*43a90889SApple OSS Distributions $(WARNFLAGS_STD) 234*43a90889SApple OSS Distributions 235*43a90889SApple OSS Distributions 236*43a90889SApple OSS Distributions# Can be overridden in Makefile.template or Makefile.$arch 237*43a90889SApple OSS Distributionsexport CWARNFLAGS ?= $(CWARNFLAGS_STD) 238*43a90889SApple OSS Distributions 239*43a90889SApple OSS Distributionsdefine add_perfile_cflags 240*43a90889SApple OSS Distributions$(1)_CWARNFLAGS_ADD += $2 241*43a90889SApple OSS Distributionsendef 242*43a90889SApple OSS Distributions 243*43a90889SApple OSS Distributionsdefine rm_perfile_cflags 244*43a90889SApple OSS Distributions$(1)_CFLAGS_RM += $2 245*43a90889SApple OSS Distributionsendef 246*43a90889SApple OSS Distributions 247*43a90889SApple OSS DistributionsCXXWARNFLAGS_STD = \ 248*43a90889SApple OSS Distributions $(WARNFLAGS_STD) \ 249*43a90889SApple OSS Distributions -Wno-c++98-compat-pedantic \ 250*43a90889SApple OSS Distributions -Wno-exit-time-destructors \ 251*43a90889SApple OSS Distributions -Wno-global-constructors \ 252*43a90889SApple OSS Distributions -Wno-old-style-cast 253*43a90889SApple OSS Distributions 254*43a90889SApple OSS Distributions# Can be overridden in Makefile.template or Makefile.$arch 255*43a90889SApple OSS Distributionsexport CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD) 256*43a90889SApple OSS Distributions 257*43a90889SApple OSS Distributionsdefine add_perfile_cxxflags 258*43a90889SApple OSS Distributions$(1)_CXXWARNFLAGS_ADD += $2 259*43a90889SApple OSS Distributionsendef 260*43a90889SApple OSS Distributions 261*43a90889SApple OSS Distributions# 262*43a90889SApple OSS Distributions# Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers 263*43a90889SApple OSS Distributions 264*43a90889SApple OSS DistributionsARCH_FLAGS_X86_64 = -arch x86_64 265*43a90889SApple OSS DistributionsARCH_FLAGS_X86_64H = -arch x86_64h 266*43a90889SApple OSS Distributions 267*43a90889SApple OSS Distributionsifeq ($(RC_ProjectName),xnu_libraries) 268*43a90889SApple OSS DistributionsBUILD_STATIC_LINK := 1 269*43a90889SApple OSS DistributionsBUILD_XNU_LIBRARY := 1 270*43a90889SApple OSS DistributionsRC_NONARCH_CFLAGS += -D__BUILDING_XNU_LIBRARY__=1 271*43a90889SApple OSS Distributionsendif 272*43a90889SApple OSS Distributions 273*43a90889SApple OSS Distributionsifneq ($(filter ARM ARM64,$(CURRENT_ARCH_CONFIG)),) 274*43a90889SApple OSS Distributions 275*43a90889SApple OSS Distributionsifneq ($(findstring _Sim,$(RC_ProjectName)),) 276*43a90889SApple OSS DistributionsARCH_FLAGS_ARM64 = -arch arm64e 277*43a90889SApple OSS Distributionselse ifneq ($(findstring _host,$(RC_ProjectName)),) 278*43a90889SApple OSS DistributionsARCH_FLAGS_ARM64 = -arch arm64e 279*43a90889SApple OSS Distributionselse 280*43a90889SApple OSS Distributions 281*43a90889SApple OSS DistributionsARCH_STRING_FOR_CURRENT_MACHINE_CONFIG ?= 282*43a90889SApple OSS Distributions 283*43a90889SApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 284*43a90889SApple OSS Distributions 285*43a90889SApple OSS Distributionsifneq ($(EMBEDDED_DEVICE_MAP),) 286*43a90889SApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -list -query SELECT DISTINCT KernelMachOArchitecture FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" LIMIT 1 || echo UNKNOWN ) 287*43a90889SApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 288*43a90889SApple OSS Distributionsifeq ($(filter $(EXTRA_TARGET_CONFIGS_$(CURRENT_KERNEL_CONFIG)),$(CURRENT_MACHINE_CONFIG)),) 289*43a90889SApple OSS Distributions$(error Machine config $(CURRENT_MACHINE_CONFIG_LC) not found in EmbeddedDeviceMap) 290*43a90889SApple OSS Distributionsendif 291*43a90889SApple OSS Distributionsendif 292*43a90889SApple OSS Distributionsendif 293*43a90889SApple OSS Distributions 294*43a90889SApple OSS Distributionsendif 295*43a90889SApple OSS Distributions 296*43a90889SApple OSS Distributionsifeq ($(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),) 297*43a90889SApple OSS Distributions 298*43a90889SApple OSS Distributions# Without embdedded device map, use a default arch string 299*43a90889SApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) 300*43a90889SApple OSS Distributionsifneq ($(filter arm64,$(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG)),) 301*43a90889SApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := arm64e 302*43a90889SApple OSS Distributionsendif 303*43a90889SApple OSS Distributions 304*43a90889SApple OSS Distributionsendif 305*43a90889SApple OSS Distributions 306*43a90889SApple OSS Distributions 307*43a90889SApple OSS DistributionsBUILD_STATIC_LINK := 1 308*43a90889SApple OSS Distributions 309*43a90889SApple OSS DistributionsARCH_FLAGS_ARM64 = -arch $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG) 310*43a90889SApple OSS Distributions 311*43a90889SApple OSS Distributionsendif 312*43a90889SApple OSS Distributions 313*43a90889SApple OSS Distributionselse 314*43a90889SApple OSS Distributions# non arm machine config string 315*43a90889SApple OSS Distributionsifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG 316*43a90889SApple OSS Distributionsexport ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z) 317*43a90889SApple OSS Distributionsendif 318*43a90889SApple OSS Distributions 319*43a90889SApple OSS Distributionsendif 320*43a90889SApple OSS Distributions 321*43a90889SApple OSS Distributions# 322*43a90889SApple OSS Distributions# Default CFLAGS 323*43a90889SApple OSS Distributions# 324*43a90889SApple OSS Distributionsifdef RC_NONARCH_CFLAGS 325*43a90889SApple OSS DistributionsOTHER_CFLAGS = $(RC_NONARCH_CFLAGS) 326*43a90889SApple OSS Distributionsendif 327*43a90889SApple OSS Distributions 328*43a90889SApple OSS Distributions# 329*43a90889SApple OSS Distributions# Debug info 330*43a90889SApple OSS Distributions# 331*43a90889SApple OSS DistributionsDSYMINFODIR = Contents 332*43a90889SApple OSS DistributionsDSYMKGMACROSDIR = Contents/Resources 333*43a90889SApple OSS DistributionsDSYMLLDBMACROSDIR = Contents/Resources/Python 334*43a90889SApple OSS DistributionsDSYMDWARFDIR = Contents/Resources/DWARF 335*43a90889SApple OSS Distributions 336*43a90889SApple OSS DistributionsDEBUG_CFLAGS := -g 337*43a90889SApple OSS DistributionsBUILD_DSYM := 1 338*43a90889SApple OSS Distributions 339*43a90889SApple OSS Distributions# 340*43a90889SApple OSS Distributions# We must not use -fno-keep-inline-functions, or it will remove the dtrace 341*43a90889SApple OSS Distributions# probes from the kernel. 342*43a90889SApple OSS Distributions# 343*43a90889SApple OSS DistributionsCFLAGS_GEN = $(DEBUG_CFLAGS) -nostdlibinc \ 344*43a90889SApple OSS Distributions -ferror-limit=10000 \ 345*43a90889SApple OSS Distributions -fno-builtin \ 346*43a90889SApple OSS Distributions -fno-common \ 347*43a90889SApple OSS Distributions -ftrivial-auto-var-init=zero \ 348*43a90889SApple OSS Distributions -fsigned-bitfields \ 349*43a90889SApple OSS Distributions -fmerge-all-constants \ 350*43a90889SApple OSS Distributions -fno-c++-static-destructors \ 351*43a90889SApple OSS Distributions -Wframe-larger-than=0 -Wno-frame-larger-than \ 352*43a90889SApple OSS Distributions $(OTHER_CFLAGS) 353*43a90889SApple OSS Distributions 354*43a90889SApple OSS DistributionsCFLAGS_RELEASE = 355*43a90889SApple OSS DistributionsCFLAGS_DEVELOPMENT = 356*43a90889SApple OSS DistributionsCFLAGS_DEBUG = 357*43a90889SApple OSS DistributionsCFLAGS_KASAN = $(CFLAGS_DEVELOPMENT) 358*43a90889SApple OSS DistributionsCFLAGS_PROFILE = -pg 359*43a90889SApple OSS Distributions 360*43a90889SApple OSS DistributionsCFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \ 361*43a90889SApple OSS Distributions -DPAGE_SIZE_FIXED -mkernel -msoft-float 362*43a90889SApple OSS Distributions 363*43a90889SApple OSS DistributionsCFLAGS_X86_64H = $(CFLAGS_X86_64) 364*43a90889SApple OSS Distributions 365*43a90889SApple OSS DistributionsLARGE_MEMORY_DEFINE=-UARM_LARGE_MEMORY 366*43a90889SApple OSS DistributionsARM64_PLKSEG_ADDR =0xfffffff004004000 367*43a90889SApple OSS DistributionsARM64_LINK_ADDR =0xfffffff007004000 368*43a90889SApple OSS Distributions 369*43a90889SApple OSS Distributions# Use ARM_LARGE_MEMORY config for all MacOSX targets. 370*43a90889SApple OSS Distributionsifneq ($(filter $(PLATFORM),MacOSX),) 371*43a90889SApple OSS DistributionsLARGE_MEMORY_DEFINE=-DARM_LARGE_MEMORY=1 372*43a90889SApple OSS DistributionsARM64_PLKSEG_ADDR =0xfffffe0004004000 373*43a90889SApple OSS DistributionsARM64_LINK_ADDR =0xfffffe0007004000 374*43a90889SApple OSS Distributionsendif 375*43a90889SApple OSS Distributions 376*43a90889SApple OSS Distributions 377*43a90889SApple OSS DistributionsCFLAGS_ARM64 = -Darm64 -DARM64 -D__ARM64__ -DLP64 -DPAGE_SIZE_FIXED -DVM_KERNEL_LINK_ADDRESS=$(ARM64_LINK_ADDR) \ 378*43a90889SApple OSS Distributions $(LARGE_MEMORY_DEFINE) -momit-leaf-frame-pointer -fno-strict-aliasing -D__API__=v4 -mkernel \ 379*43a90889SApple OSS Distributions $(BTI_BUILD_FLAGS) 380*43a90889SApple OSS Distributions 381*43a90889SApple OSS DistributionsCXXFLAGS_ARM64 = $(BTI_BUILD_FLAGS) 382*43a90889SApple OSS Distributions 383*43a90889SApple OSS DistributionsCFLAGS_RELEASEX86_64 = -O2 384*43a90889SApple OSS DistributionsCFLAGS_DEVELOPMENTX86_64 = -O2 385*43a90889SApple OSS DistributionsCFLAGS_KASANX86_64 = $(CFLAGS_DEVELOPMENTX86_64) 386*43a90889SApple OSS Distributions# No space optimization for the DEBUG kernel for the benefit of gdb: 387*43a90889SApple OSS DistributionsCFLAGS_DEBUGX86_64 = -O0 388*43a90889SApple OSS DistributionsCFLAGS_PROFILEX86_64 = -O2 389*43a90889SApple OSS Distributions 390*43a90889SApple OSS DistributionsCFLAGS_RELEASEX86_64H = -O2 391*43a90889SApple OSS DistributionsCFLAGS_DEVELOPMENTX86_64H = -O2 392*43a90889SApple OSS DistributionsCFLAGS_KASANX86_64H = $(CFLAGS_DEVELOPMENTX86_64H) 393*43a90889SApple OSS Distributions# No space optimization for the DEBUG kernel for the benefit of gdb: 394*43a90889SApple OSS DistributionsCFLAGS_DEBUGX86_64H = -O0 395*43a90889SApple OSS DistributionsCFLAGS_PROFILEX86_64H = -O2 396*43a90889SApple OSS Distributions 397*43a90889SApple OSS DistributionsCFLAGS_RELEASEARM = -O2 398*43a90889SApple OSS DistributionsCFLAGS_DEVELOPMENTARM = -O2 399*43a90889SApple OSS DistributionsCFLAGS_DEBUGARM = -O0 400*43a90889SApple OSS DistributionsCFLAGS_PROFILEARM = -O2 401*43a90889SApple OSS Distributions 402*43a90889SApple OSS DistributionsCFLAGS_RELEASEARM64 = -O2 403*43a90889SApple OSS DistributionsCFLAGS_DEVELOPMENTARM64 = -O2 404*43a90889SApple OSS DistributionsCFLAGS_KASANARM64 = $(CFLAGS_DEVELOPMENTARM64) 405*43a90889SApple OSS DistributionsCFLAGS_DEBUGARM64 = -O0 406*43a90889SApple OSS DistributionsCFLAGS_SPTMARM64 = $(CFLAGS_DEVELOPMENTARM64) 407*43a90889SApple OSS DistributionsCFLAGS_PROFILEARM64 = -O2 408*43a90889SApple OSS Distributions 409*43a90889SApple OSS Distributions# 410*43a90889SApple OSS Distributions# bounds-safety support 411*43a90889SApple OSS Distributions# 412*43a90889SApple OSS Distributions# Controlling flags: 413*43a90889SApple OSS Distributions# 414*43a90889SApple OSS Distributions# BOUND_CHECKS controls the support for the bounds-safety features. 415*43a90889SApple OSS Distributions# - On x86_64, bounds-safety features are disabled. 416*43a90889SApple OSS Distributions# - On other platforms, explicitly setting BOUND_CHECKS=0 417*43a90889SApple OSS Distributions# disables the support for the bounds-safety features 418*43a90889SApple OSS Distributions# - Otherwise, the support for the bounds-safety features 419*43a90889SApple OSS Distributions# is dynamically detected. 420*43a90889SApple OSS Distributions# 421*43a90889SApple OSS Distributions# BOUND_CHECKS_SOFT controls the support for the resumption of the bounds-safety traps. 422*43a90889SApple OSS Distributions# - On x86_64, resumption of bounds-safety traps is not available. 423*43a90889SApple OSS Distributions# - On other platforms, explicitly setting BOUND_CHECKS_SOFT=0 424*43a90889SApple OSS Distributions# disables the support for the bounds-safety resumption 425*43a90889SApple OSS Distributions# - Otherwise, the support for the bounds-safety features 426*43a90889SApple OSS Distributions# is dynamically detected. 427*43a90889SApple OSS Distributions# 428*43a90889SApple OSS Distributions# Note: while it is generally expected that BOUND_CHECKS_SOFT will always 429*43a90889SApple OSS Distributions# be accompanied with BOUND_CHECKS, a developer is allowed to use 430*43a90889SApple OSS Distributions# BOUND_CHECKS_SOFT=1 as a shortcut for BOUND_CHECKS=1 BOUND_CHECKS_SOFT=1 431*43a90889SApple OSS Distributions# The combination BOUND_CHECKS_SOFT=1 BOUND_CHECKS=0 is not supported. 432*43a90889SApple OSS Distributions# 433*43a90889SApple OSS Distributions# 434*43a90889SApple OSS Distributionsifndef BOUND_CHECKS 435*43a90889SApple OSS Distributions ifeq ($(shell $(CC) -E -fbounds-safety /dev/null 2>/dev/null && echo 1),1) 436*43a90889SApple OSS Distributions BOUND_CHECKS := 1 437*43a90889SApple OSS Distributions else 438*43a90889SApple OSS Distributions BOUND_CHECKS := 0 439*43a90889SApple OSS Distributions endif 440*43a90889SApple OSS Distributions export BOUND_CHECKS 441*43a90889SApple OSS Distributionsendif # ifndef BOUND_CHECKS 442*43a90889SApple OSS Distributions 443*43a90889SApple OSS Distributionsifndef BOUND_CHECKS_SOFT 444*43a90889SApple OSS Distributions ifeq ($(shell $(CC) -E -fbounds-safety -ftrap-function-returns /dev/null 2>/dev/null && echo 1),1) 445*43a90889SApple OSS Distributions BOUND_CHECKS_SOFT := 1 446*43a90889SApple OSS Distributions else 447*43a90889SApple OSS Distributions BOUND_CHECKS_SOFT := 0 448*43a90889SApple OSS Distributions endif 449*43a90889SApple OSS Distributions export BOUND_CHECKS_SOFT 450*43a90889SApple OSS Distributionsendif # ifndef BOUND_CHECKS_SOFT 451*43a90889SApple OSS Distributions 452*43a90889SApple OSS Distributions# On x86_64, the bounds-safety features are disabled 453*43a90889SApple OSS Distributionsifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64) 454*43a90889SApple OSS Distributions BOUND_CHECKS := 0 455*43a90889SApple OSS Distributions BOUND_CHECKS_SOFT := 0 456*43a90889SApple OSS Distributionsendif # x86_64 457*43a90889SApple OSS Distributions 458*43a90889SApple OSS Distributions# if BOUND_CHECKS_SOFT is enabled, ensure that BOUND_CHECKS is enabled as well 459*43a90889SApple OSS Distributionsifneq ($(BOUND_CHECKS_SOFT),0) 460*43a90889SApple OSS Distributions ifeq ($(BOUND_CHECKS),0) 461*43a90889SApple OSS Distributions BOUND_CHECKS := 1 462*43a90889SApple OSS Distributions endif # ifeq ($(BOUND_CHECKS),0) 463*43a90889SApple OSS Distributionsendif # ifneq($(BOUND_CHECKS_SOFT),0) 464*43a90889SApple OSS Distributions 465*43a90889SApple OSS Distributions# Set the values for the CFLAGS_BOUND_CHECKS* variables. 466*43a90889SApple OSS Distributions# Notes: 467*43a90889SApple OSS Distributions# 1. If building at desk, and the developer had set any of 468*43a90889SApple OSS Distributions# CFLAGS_BOUND_CHECKS, CFLAGS_BOUND_CHECKS_SOFT, or CFLAGS_BOUND_CHECKS_DEBUG 469*43a90889SApple OSS Distributions# the values are preserved. For B&I builds the values are reset. 470*43a90889SApple OSS Distributions# 2. The CFLAGS_BOUND_CHECKS_PENDING, CFLAGS_BOUND_CHECKS_ENABLE_NEW_CHECKS, 471*43a90889SApple OSS Distributions# and CFLAGS_BOUND_CHECKS_DISABLE_NEW_CHECKS variables do not take into 472*43a90889SApple OSS Distributions# consideration any pre-existing value. 473*43a90889SApple OSS Distributions# 474*43a90889SApple OSS Distributionsifeq ($(RC_XBS),YES) 475*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS := 476*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_SOFT := 477*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_DEBUG := 478*43a90889SApple OSS Distributionselse # ifeq ($(RC_XBS),YES) 479*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS ?= 480*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_SOFT ?= 481*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_DEBUG ?= 482*43a90889SApple OSS Distributionsendif # ifeq ($(RC_XBS),YES) 483*43a90889SApple OSS Distributions 484*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS 485*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS_SOFT 486*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS_DEBUG 487*43a90889SApple OSS DistributionsCFLAGS_BOUND_CHECKS_PENDING = -DBOUND_CHECKS_PENDING=1 -Wno-self-assign 488*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS_PENDING 489*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS_ENABLE_NEW_CHECKS 490*43a90889SApple OSS Distributionsexport CFLAGS_BOUND_CHECKS_DISABLE_NEW_CHECKS 491*43a90889SApple OSS Distributions 492*43a90889SApple OSS Distributions# If bounds-safety is available, update the CFLAGS_BOUND_CHECKS accordingly. 493*43a90889SApple OSS Distributionsifneq ($(BOUND_CHECKS),0) 494*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS += -fbounds-safety 495*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_ENABLE_NEW_CHECKS := -fbounds-safety-bringup-missing-checks 496*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_DISABLE_NEW_CHECKS := -fno-bounds-safety-bringup-missing-checks 497*43a90889SApple OSS Distributionselse # ifneq($(BOUND_CHECKS),0) 498*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS += -Wno-error=self-assign 499*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_ENABLE_NEW_CHECKS := 500*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_DISABLE_NEW_CHECKS := 501*43a90889SApple OSS Distributionsendif # ifneq($(BOUND_CHECKS),0) 502*43a90889SApple OSS Distributions 503*43a90889SApple OSS Distributions# Propagate the value of CFLAGS_BOUND_CHECKS CFLAGS_BOUND_CHECKS_{SOFT,DEBUG} variants, 504*43a90889SApple OSS Distributions# and set the appropriate flags if trap resumption is supported. 505*43a90889SApple OSS DistributionsCFLAGS_BOUND_CHECKS_SOFT += $(CFLAGS_BOUND_CHECKS) 506*43a90889SApple OSS DistributionsCFLAGS_BOUND_CHECKS_DEBUG = $(CFLAGS_BOUND_CHECKS_SOFT) 507*43a90889SApple OSS Distributionsifneq ($(BOUND_CHECKS_SOFT),0) 508*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_SOFT += -ftrap-function=ml_bound_chk_soft_trap -ftrap-function-returns 509*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS_DEBUG += -DBOUND_CHECKS_DEBUG=1 510*43a90889SApple OSS Distributionsendif # ifneq($(BOUND_CHECKS_SOFT),0) 511*43a90889SApple OSS Distributions 512*43a90889SApple OSS Distributions# Bounds-safety adoption mode 513*43a90889SApple OSS Distributions# 514*43a90889SApple OSS Distributions# * Tells Clang to run in bounds-safety adoption mode which is allowed to 515*43a90889SApple OSS Distributions# produce better diagnostics but a slower build. 516*43a90889SApple OSS Distributions# * Doesn't try to suppress any warnings in staging (see Bounds-safety warning 517*43a90889SApple OSS Distributions# staging) 518*43a90889SApple OSS Distributions# 519*43a90889SApple OSS DistributionsBOUNDS_SAFETY_ADOPTION_MODE ?= 0 520*43a90889SApple OSS Distributionsifneq ($(BOUNDS_SAFETY_ADOPTION_MODE),0) 521*43a90889SApple OSS Distributions ifeq ($(BOUND_CHECKS),0) 522*43a90889SApple OSS Distributions $(error BOUNDS_SAFETY_ADOPTION_MODE cannot be enabled when BOUND_CHECKS=0) 523*43a90889SApple OSS Distributions endif 524*43a90889SApple OSS Distributions ifeq ($(RC_XBS),YES) 525*43a90889SApple OSS Distributions # This mode should **only** be used at engineers' desks and not in B&I 526*43a90889SApple OSS Distributions # builds because it may add compile-time overhead. 527*43a90889SApple OSS Distributions $(error BOUNDS_SAFETY_ADOPTION_MODE should not be enabled in B&I builds) 528*43a90889SApple OSS Distributions endif 529*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS += -fbounds-safety-adoption-mode 530*43a90889SApple OSS Distributionsendif 531*43a90889SApple OSS Distributions 532*43a90889SApple OSS Distributions# Bounds-safety warning staging 533*43a90889SApple OSS Distributions# 534*43a90889SApple OSS Distributions# To prevent new bounds-safety warnings in a soon to be submitted Clang from 535*43a90889SApple OSS Distributions# breaking the build they can be explicitly be prevented from being errors by 536*43a90889SApple OSS Distributions# adding `-Wno-error=<new_warning_name>` to 537*43a90889SApple OSS Distributions# `BOUNDS_SAFETY_DOWNGRADED_UPCOMING_WARNFLAGS`. 538*43a90889SApple OSS Distributions# 539*43a90889SApple OSS Distributions# A warning in `BOUNDS_SAFETY_DOWNGRADED_UPCOMING_WARNFLAGS` should be 540*43a90889SApple OSS Distributions# removed once the new Clang with the warning is in the OS and the code builds 541*43a90889SApple OSS Distributions# without it firing. 542*43a90889SApple OSS Distributions# 543*43a90889SApple OSS DistributionsBOUNDS_SAFETY_DOWNGRADED_UPCOMING_WARNFLAGS = 544*43a90889SApple OSS Distributions 545*43a90889SApple OSS Distributionsifneq ($(words $(BOUNDS_SAFETY_DOWNGRADED_UPCOMING_WARNFLAGS)),0) 546*43a90889SApple OSS Distributions ifeq ($(BOUNDS_SAFETY_ADOPTION_MODE),0) 547*43a90889SApple OSS Distributions # Note this implicitly relies on `-Wno-unknown-warning-option` already being 548*43a90889SApple OSS Distributions # passed to the compiler. 549*43a90889SApple OSS Distributions CFLAGS_BOUND_CHECKS += $(BOUNDS_SAFETY_DOWNGRADED_UPCOMING_WARNFLAGS) 550*43a90889SApple OSS Distributions endif 551*43a90889SApple OSS Distributionsendif 552*43a90889SApple OSS Distributions 553*43a90889SApple OSS Distributions# 554*43a90889SApple OSS Distributions# Sanitizers Support (KASan, UBSan) 555*43a90889SApple OSS Distributions# 556*43a90889SApple OSS Distributions 557*43a90889SApple OSS Distributions# Which kernel configurations are built with KCOV enabled. 558*43a90889SApple OSS DistributionsKCOV_RUNTIME := KASAN 559*43a90889SApple OSS Distributions 560*43a90889SApple OSS Distributionsifneq ($(filter RELEASE, $(KCOV_RUNTIME)),) 561*43a90889SApple OSS Distributions$(error "Sanitizer runtime should not be enabled for RELEASE kernel.") 562*43a90889SApple OSS Distributionsendif 563*43a90889SApple OSS Distributions 564*43a90889SApple OSS Distributions 565*43a90889SApple OSS DistributionsSAN=0 566*43a90889SApple OSS Distributions 567*43a90889SApple OSS Distributions# KASan support 568*43a90889SApple OSS Distributions# 569*43a90889SApple OSS Distributions 570*43a90889SApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),KASAN) 571*43a90889SApple OSS Distributions# KASan kernel config implicitly enables the KASan instrumentation. 572*43a90889SApple OSS Distributions# Instrumentation for other sanitizers is enabled explicitly at build time. 573*43a90889SApple OSS DistributionsKASAN = 1 574*43a90889SApple OSS Distributionsendif 575*43a90889SApple OSS Distributions 576*43a90889SApple OSS Distributionsifeq ($(KASAN),1) 577*43a90889SApple OSS DistributionsSAN=1 578*43a90889SApple OSS DistributionsBUILD_LTO=0 579*43a90889SApple OSS Distributions 580*43a90889SApple OSS Distributions# KASan Light support 581*43a90889SApple OSS Distributions# 582*43a90889SApple OSS Distributions# Light mode omits the HWASAN stack instrumentation. 583*43a90889SApple OSS Distributions# Not supported by KASan Classic at this moment. 584*43a90889SApple OSS Distributions 585*43a90889SApple OSS DistributionsKASAN_LIGHT_PLATFORM := WatchOS 586*43a90889SApple OSS Distributions 587*43a90889SApple OSS Distributionsifneq ($(filter $(PLATFORM), $(KASAN_LIGHT_PLATFORM)),) 588*43a90889SApple OSS DistributionsKASAN_LIGHT=1 589*43a90889SApple OSS DistributionsHWASAN_INSTRUMENT_STACK=0 590*43a90889SApple OSS Distributionselse 591*43a90889SApple OSS DistributionsKASAN_LIGHT=0 592*43a90889SApple OSS DistributionsHWASAN_INSTRUMENT_STACK=1 593*43a90889SApple OSS Distributionsendif 594*43a90889SApple OSS Distributions 595*43a90889SApple OSS DistributionsKASAN_DENYLIST=$(OBJROOT)/san/kasan-denylist-$(CURRENT_ARCH_CONFIG_LC) 596*43a90889SApple OSS Distributions 597*43a90889SApple OSS Distributions# To calculate the kasan offset, subtract the lowest KVA to sanitize, shifted right by KASAN_SCALE_$INSTRUMENTATION bits, 598*43a90889SApple OSS Distributions# from the base address of the kasan shadow area, (e.g. for x86_64 solve the following equation: 599*43a90889SApple OSS Distributions# OFFSET = {VA mapped by the first KASAN PML4 [Currently #494]} - (LOWEST_KVA >> 3) 600*43a90889SApple OSS Distributions# OFFSET = (0ULL - (512GiB * (512 - 494))) - (LOWEST_SAN_KVA >> 3) 601*43a90889SApple OSS Distributions# OFFSET = FFFFF70000000000 - ((0ULL - (512GiB * (512 - 496))) >> 3) [PML4 #496 is the first possible KVA] 602*43a90889SApple OSS Distributions# OFFSET = FFFFF70000000000 - (FFFFF80000000000 >> 3) 603*43a90889SApple OSS Distributions# OFFSET = DFFFF80000000000 604*43a90889SApple OSS Distributions# ). 605*43a90889SApple OSS DistributionsKASAN_OFFSET_X86_64=0xdffff80000000000 606*43a90889SApple OSS DistributionsKASAN_OFFSET_X86_64H=$(KASAN_OFFSET_X86_64) 607*43a90889SApple OSS DistributionsKASAN_OFFSET_ARM64=0xf000000000000000 608*43a90889SApple OSS Distributions 609*43a90889SApple OSS DistributionsKASAN_OFFSET=$($(addsuffix $(CURRENT_ARCH_CONFIG),KASAN_OFFSET_)) 610*43a90889SApple OSS Distributions 611*43a90889SApple OSS Distributions# CLANG HWASAN/KHWASAN instrumentation powers KASAN_TBI. HWASAN traditional prefixing 612*43a90889SApple OSS Distributions# is replaced by __asan_ to commonize exports across models. 613*43a90889SApple OSS DistributionsKASAN_SCALE_TBI=4 614*43a90889SApple OSS DistributionsCFLAGS_KASAN_INSTRUMENTATION_TBI = -DKASAN_TBI=1 -DKASAN_SCALE=$(KASAN_SCALE_TBI) \ 615*43a90889SApple OSS Distributions -fsanitize=kernel-hwaddress \ 616*43a90889SApple OSS Distributions -fsanitize-ignorelist=$(KASAN_DENYLIST) \ 617*43a90889SApple OSS Distributions -mllvm -hwasan-recover=0 \ 618*43a90889SApple OSS Distributions -mllvm -hwasan-mapping-offset=$(KASAN_OFFSET) \ 619*43a90889SApple OSS Distributions -mllvm -hwasan-instrument-atomics=1 \ 620*43a90889SApple OSS Distributions -mllvm -hwasan-instrument-stack=$(HWASAN_INSTRUMENT_STACK) \ 621*43a90889SApple OSS Distributions -mllvm -hwasan-generate-tags-with-calls=1 \ 622*43a90889SApple OSS Distributions -mllvm -hwasan-instrument-with-calls=0 \ 623*43a90889SApple OSS Distributions -mllvm -hwasan-use-short-granules=0 \ 624*43a90889SApple OSS Distributions -mllvm -hwasan-memory-access-callback-prefix="__asan_" 625*43a90889SApple OSS Distributions 626*43a90889SApple OSS Distributions 627*43a90889SApple OSS DistributionsKASAN_SCALE_CLASSIC=3 628*43a90889SApple OSS DistributionsCFLAGS_KASAN_INSTRUMENTATION_CLASSIC = -DKASAN_CLASSIC=1 -DKASAN_SCALE=$(KASAN_SCALE_CLASSIC) \ 629*43a90889SApple OSS Distributions -fsanitize=address \ 630*43a90889SApple OSS Distributions -mllvm -asan-globals-live-support \ 631*43a90889SApple OSS Distributions -mllvm -asan-mapping-offset=$(KASAN_OFFSET) \ 632*43a90889SApple OSS Distributions -fsanitize-ignorelist=$(KASAN_DENYLIST) 633*43a90889SApple OSS Distributions 634*43a90889SApple OSS DistributionsCFLAGS_KASANARM64 += $(CFLAGS_KASAN_INSTRUMENTATION_TBI) 635*43a90889SApple OSS DistributionsCFLAGS_KASANX86_64 += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 636*43a90889SApple OSS DistributionsCFLAGS_KASANX86_64H += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 637*43a90889SApple OSS DistributionsCFLAGS_GEN += -DKASAN=1 -DKASAN_OFFSET=$(KASAN_OFFSET) -DKASAN_LIGHT=$(KASAN_LIGHT) 638*43a90889SApple OSS Distributions 639*43a90889SApple OSS DistributionsSFLAGS_KASANARM64 += $(CFLAGS_KASAN_INSTRUMENTATION_TBI) 640*43a90889SApple OSS DistributionsSFLAGS_KASANX86_64 += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 641*43a90889SApple OSS DistributionsSFLAGS_KASANX86_64H += $(CFLAGS_KASAN_INSTRUMENTATION_CLASSIC) 642*43a90889SApple OSS DistributionsSFLAGS_GEN += -DKASAN=1 -DKASAN_OFFSET=$(KASAN_OFFSET) -DKASAN_LIGHT=$(KASAN_LIGHT) 643*43a90889SApple OSS Distributions 644*43a90889SApple OSS Distributionsendif 645*43a90889SApple OSS Distributions 646*43a90889SApple OSS Distributions# UBSan 647*43a90889SApple OSS Distributions# 648*43a90889SApple OSS Distributions# The Undefined Behavior sanitizer runtime is always built as part of, and only for, 649*43a90889SApple OSS Distributions# KASAN variants. UBSan instrumentation is disabled by default and only enabled explicitly 650*43a90889SApple OSS Distributions# when building with UBSAN=1. 651*43a90889SApple OSS Distributions# 652*43a90889SApple OSS Distributions# On iOS RELEASE and DEVELOPMENT kernels, a subset of UBSan checks is enabled along with a minimal 653*43a90889SApple OSS Distributions# runtime that emulates trap mode (but makes it recoverable). 654*43a90889SApple OSS Distributions 655*43a90889SApple OSS Distributionsifeq ($(KASAN), 1) 656*43a90889SApple OSS Distributions 657*43a90889SApple OSS Distributionsifeq ($(UBSAN),1) 658*43a90889SApple OSS DistributionsSAN=1 659*43a90889SApple OSS Distributions 660*43a90889SApple OSS DistributionsUBSAN_RUNTIME = 661*43a90889SApple OSS DistributionsUBSAN_CHECKS += signed-integer-overflow shift pointer-overflow bounds object-size # non-fatal (calls runtime, can return) 662*43a90889SApple OSS Distributions# UBSAN_CHECKS = undefined nullability unsigned-integer-overflow # everything 663*43a90889SApple OSS DistributionsUBSAN_CHECKS_FATAL = # fatal (calls runtime, must not return) 664*43a90889SApple OSS DistributionsUBSAN_CHECKS_TRAP = vla-bound builtin # emit a trap instruction (no runtime support) 665*43a90889SApple OSS DistributionsUBSAN_DISABLED += vptr function # requires unsupported C++ runtime 666*43a90889SApple OSS Distributions 667*43a90889SApple OSS Distributions# UBSan alignment + KASan code size is too large 668*43a90889SApple OSS Distributions# UBSan unreachable doesn't play nice with ASan (40723397) 669*43a90889SApple OSS DistributionsUBSAN_DISABLED += alignment unreachable 670*43a90889SApple OSS Distributions 671*43a90889SApple OSS Distributionsendif 672*43a90889SApple OSS Distributions 673*43a90889SApple OSS Distributionselse 674*43a90889SApple OSS Distributions 675*43a90889SApple OSS Distributions# DEVELOPMENT and RELEASE variants 676*43a90889SApple OSS Distributionsifeq ($(PLATFORM),iPhoneOS) 677*43a90889SApple OSS Distributions 678*43a90889SApple OSS Distributions# Currently we have to keep alive two separated UBSAN runtimes (minimal for DEVELOPMENT, 679*43a90889SApple OSS Distributions# full for KASAN). This implies that we cannot use CFLAGS_$(CURRENT_KERNEL_CONFIG), because 680*43a90889SApple OSS Distributions# CFLAGS_DEVELOPMENT is folded into CFLAGS_KASAN. For the time being we leave this check here, 681*43a90889SApple OSS Distributions# as we work (independently) to both break the CFLAGS direct dependency and commonize the 682*43a90889SApple OSS Distributions# sanitizer runtimes. 683*43a90889SApple OSS DistributionsUBSAN_MINIMAL_RUNTIME := DEVELOPMENT DEBUG 684*43a90889SApple OSS Distributionsifneq ($(filter $(CURRENT_KERNEL_CONFIG), $(UBSAN_MINIMAL_RUNTIME)),) 685*43a90889SApple OSS Distributions 686*43a90889SApple OSS Distributions# This is (unfortunately) intentional. Currently the "kasan" denylist, which folds both 687*43a90889SApple OSS Distributions# ubsan and kasan specific files, is generated for all builds during the 688*43a90889SApple OSS Distributions# setup phase. The denylist file itself is divided per-sanitizer, so won't 689*43a90889SApple OSS Distributions# affect the UBSAN build outside of the entries that are legitimately 690*43a90889SApple OSS Distributions# intended for it. 691*43a90889SApple OSS DistributionsUBSAN_DENYLIST=$(OBJROOT)/san/kasan-denylist-$(CURRENT_ARCH_CONFIG_LC) 692*43a90889SApple OSS Distributions 693*43a90889SApple OSS DistributionsUBSAN_CHECKS = signed-integer-overflow 694*43a90889SApple OSS DistributionsUBSAN_RUNTIME = -fsanitize-minimal-runtime -fsanitize-ignorelist=$(UBSAN_DENYLIST) 695*43a90889SApple OSS DistributionsUBSAN_CHECKS_TRAP = 696*43a90889SApple OSS DistributionsUBSAN_CHECKS_FATAL = 697*43a90889SApple OSS DistributionsUBSAN_DISABLED = 698*43a90889SApple OSS Distributionsendif 699*43a90889SApple OSS Distributionsendif 700*43a90889SApple OSS Distributions 701*43a90889SApple OSS Distributionsendif 702*43a90889SApple OSS Distributions 703*43a90889SApple OSS DistributionsCFLAGS_GEN += $(UBSAN_RUNTIME) 704*43a90889SApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS) $(UBSAN_CHECKS_FATAL) $(UBSAN_CHECKS_TRAP),-fsanitize=$(x)) 705*43a90889SApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_FATAL),-fno-sanitize-recover=$(x)) 706*43a90889SApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_CHECKS_TRAP),-fsanitize-trap=$(x)) 707*43a90889SApple OSS DistributionsCFLAGS_GEN += $(foreach x,$(UBSAN_DISABLED),-fno-sanitize=$(x)) 708*43a90889SApple OSS Distributions 709*43a90889SApple OSS Distributionsifeq ($(KSANCOV),1) 710*43a90889SApple OSS Distributions# Enable SanitizerCoverage instrumentation in xnu 711*43a90889SApple OSS DistributionsSAN = 1 712*43a90889SApple OSS DistributionsKCOV_DENYLIST := $(OBJROOT)/san/kcov-denylist-$(CURRENT_ARCH_CONFIG_LC) 713*43a90889SApple OSS DistributionsKCOV_CFLAGS := -fsanitize-coverage=trace-pc-guard -fsanitize-coverage-ignorelist=$(KCOV_DENYLIST) 714*43a90889SApple OSS DistributionsCFLAGS_GEN += $(KCOV_CFLAGS) -DKSANCOV=1 715*43a90889SApple OSS Distributionsendif 716*43a90889SApple OSS Distributions 717*43a90889SApple OSS Distributionsifeq ($(SAN),1) 718*43a90889SApple OSS DistributionsCFLAGS_GEN += -fsanitize-ignorelist=$(OBJROOT)/san/kasan-denylist-$(CURRENT_ARCH_CONFIG_LC) 719*43a90889SApple OSS Distributionsendif 720*43a90889SApple OSS Distributions 721*43a90889SApple OSS Distributions# Any extra flags that get passed at the command line during build. 722*43a90889SApple OSS Distributionsifeq ($(CFLAGS_EXTRA),) 723*43a90889SApple OSS DistributionsCFLAGS_EXTRA = 724*43a90889SApple OSS Distributionsendif 725*43a90889SApple OSS Distributions 726*43a90889SApple OSS DistributionsCFLAGS = $(CFLAGS_GEN) \ 727*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ 728*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 729*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \ 730*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \ 731*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \ 732*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) \ 733*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_DEFINES) \ 734*43a90889SApple OSS Distributions $(DEFINES) \ 735*43a90889SApple OSS Distributions $(CFLAGS_EXTRA) 736*43a90889SApple OSS Distributions 737*43a90889SApple OSS Distributions# 738*43a90889SApple OSS Distributions# Default C++ flags 739*43a90889SApple OSS Distributions# 740*43a90889SApple OSS Distributions 741*43a90889SApple OSS DistributionsOTHER_CXXFLAGS = 742*43a90889SApple OSS Distributions 743*43a90889SApple OSS DistributionsCXXFLAGS_GEN = -std=gnu++2b -fsized-deallocation -fapple-kext $(OTHER_CXXFLAGS) 744*43a90889SApple OSS Distributions 745*43a90889SApple OSS DistributionsCXXFLAGS = $(CXXFLAGS_GEN) \ 746*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \ 747*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_)) 748*43a90889SApple OSS Distributions 749*43a90889SApple OSS Distributions# 750*43a90889SApple OSS Distributions# Assembler command 751*43a90889SApple OSS Distributions# 752*43a90889SApple OSS DistributionsAS = $(CCACHE) $(CC) 753*43a90889SApple OSS DistributionsS_KCC = $(CC) 754*43a90889SApple OSS Distributions 755*43a90889SApple OSS Distributions# 756*43a90889SApple OSS Distributions# Default SFLAGS 757*43a90889SApple OSS Distributions# 758*43a90889SApple OSS DistributionsSFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS) 759*43a90889SApple OSS Distributions 760*43a90889SApple OSS DistributionsSFLAGS_RELEASE = 761*43a90889SApple OSS DistributionsSFLAGS_DEVELOPMENT = 762*43a90889SApple OSS Distributions 763*43a90889SApple OSS Distributions# When making non-compatible changes to the XNU runtime, it can be useful to build 764*43a90889SApple OSS Distributions# a KASAN kernel + runtime, but linked against a DEVELOPMENT kernel cache. 765*43a90889SApple OSS Distributions# Uncomment the lines below to be able to build development, but passing KASAN=1. 766*43a90889SApple OSS Distributions# #_ifeq ($(KASAN),1) 767*43a90889SApple OSS Distributions# SFLAGS_DEVELOPMENT += -DKASAN=1 768*43a90889SApple OSS Distributions# #_endif 769*43a90889SApple OSS Distributions 770*43a90889SApple OSS DistributionsSFLAGS_KASAN = $(SFLAGS_DEVELOPMENT) -DKASAN=1 771*43a90889SApple OSS DistributionsSFLAGS_DEBUG = 772*43a90889SApple OSS DistributionsSFLAGS_PROFILE = 773*43a90889SApple OSS Distributions 774*43a90889SApple OSS DistributionsSFLAGS_X86_64 = $(CFLAGS_X86_64) 775*43a90889SApple OSS DistributionsSFLAGS_X86_64H = $(CFLAGS_X86_64H) 776*43a90889SApple OSS DistributionsSFLAGS_ARM64 = $(CFLAGS_ARM64) 777*43a90889SApple OSS Distributions 778*43a90889SApple OSS DistributionsSFLAGS = $(SFLAGS_GEN) \ 779*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ 780*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 781*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \ 782*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \ 783*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_))) \ 784*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) \ 785*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_DEFINES) \ 786*43a90889SApple OSS Distributions $(DEFINES) 787*43a90889SApple OSS Distributions 788*43a90889SApple OSS Distributions# 789*43a90889SApple OSS Distributions# Linker command 790*43a90889SApple OSS Distributions# 791*43a90889SApple OSS DistributionsLD = $(KC++) -nostdlib 792*43a90889SApple OSS Distributions 793*43a90889SApple OSS Distributions# 794*43a90889SApple OSS Distributions# Default LDFLAGS 795*43a90889SApple OSS Distributions# 796*43a90889SApple OSS Distributions# Availability of DWARF allows DTrace CTF (compressed type format) to be constructed. 797*43a90889SApple OSS Distributions# ctf_insert creates the CTF section. It needs reserved padding in the 798*43a90889SApple OSS Distributions# headers for the load command segment and the CTF section structures. 799*43a90889SApple OSS Distributions# 800*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_GEN = \ 801*43a90889SApple OSS Distributions -nostdlib \ 802*43a90889SApple OSS Distributions -fapple-kext \ 803*43a90889SApple OSS Distributions -Wl,-e,__start \ 804*43a90889SApple OSS Distributions -Wl,-sectalign,__TEXT,__text,0x1000 \ 805*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__common,0x1000 \ 806*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__bss,0x1000 \ 807*43a90889SApple OSS Distributions -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \ 808*43a90889SApple OSS Distributions -Wl,-segprot,__PRELINK_TEXT,r-x,r-x \ 809*43a90889SApple OSS Distributions -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \ 810*43a90889SApple OSS Distributions -Wl,-pagezero_size,0x0 \ 811*43a90889SApple OSS Distributions -Wl,-version_load_command \ 812*43a90889SApple OSS Distributions -Wl,-function_starts \ 813*43a90889SApple OSS Distributions -Wl,-headerpad,152 814*43a90889SApple OSS Distributions 815*43a90889SApple OSS Distributions# LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel 816*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -L$(SDKROOT)/usr/local/lib/kernel/platform 817*43a90889SApple OSS Distributionsifneq ($(KDKROOT),) 818*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_SDK += -L$(KDKROOT)/usr/local/lib/kernel/platform 819*43a90889SApple OSS Distributionsendif 820*43a90889SApple OSS Distributions 821*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASE = 822*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENT = 823*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_KASAN = $(LDFLAGS_KERNEL_DEVELOPMENT) 824*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEBUG = 825*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_PROFILE = 826*43a90889SApple OSS Distributions 827*43a90889SApple OSS Distributions# Tightbeam finds modules in the "tightbeam" subdirectory. 828*43a90889SApple OSS DistributionsTIGHTBEAM_MODULE_DIR = $(SDKROOT)/usr/local/lib/kernel/tightbeam 829*43a90889SApple OSS Distributions 830*43a90889SApple OSS Distributions# KASLR static slide config: 831*43a90889SApple OSS Distributionsifndef SLIDE 832*43a90889SApple OSS DistributionsSLIDE=0x00 833*43a90889SApple OSS Distributionsendif 834*43a90889SApple OSS DistributionsKERNEL_MIN_ADDRESS = 0xffffff8000000000 835*43a90889SApple OSS DistributionsKERNEL_BASE_OFFSET = 0x100000 836*43a90889SApple OSS Distributions# POSIX shells use signed long for their arithmetic expressions. However, 837*43a90889SApple OSS Distributions# we're dealing with uintptr_t values here, so explicitly use bash which 838*43a90889SApple OSS Distributions# is known to be able to handle such larger values. ksh also works; dash 839*43a90889SApple OSS Distributions# and zsh both fail with different results (zsh even warns you). 840*43a90889SApple OSS DistributionsKERNEL_STATIC_SLIDE = $(shell $(BASH) -c 'printf "0x%016x" \ 841*43a90889SApple OSS Distributions $$(( $(SLIDE) << 21 ))') 842*43a90889SApple OSS DistributionsKERNEL_STATIC_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 843*43a90889SApple OSS Distributions $$(( $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ))') 844*43a90889SApple OSS DistributionsKERNEL_HIB_SECTION_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 845*43a90889SApple OSS Distributions $$(( $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ))') 846*43a90889SApple OSS DistributionsKERNEL_TEXT_BASE = $(shell $(BASH) -c 'printf "0x%016x" \ 847*43a90889SApple OSS Distributions $$(( $(KERNEL_HIB_SECTION_BASE) + 0x100000 ))') 848*43a90889SApple OSS Distributions 849*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 = \ 850*43a90889SApple OSS Distributions -Wl,-pie \ 851*43a90889SApple OSS Distributions -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \ 852*43a90889SApple OSS Distributions -Wl,-image_base,$(KERNEL_TEXT_BASE) \ 853*43a90889SApple OSS Distributions -Wl,-seg_page_size,__TEXT,0x200000 \ 854*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__bootPT,0x1000 \ 855*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__desc,0x1000 \ 856*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__data,0x1000 \ 857*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__text,0x1000 \ 858*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__const,0x1000 \ 859*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__bss,0x1000 \ 860*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__common,0x1000 \ 861*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \ 862*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \ 863*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \ 864*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \ 865*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__cstring,0x1000 \ 866*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__percpu,0x1000 \ 867*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ 868*43a90889SApple OSS Distributions -Wl,-segprot,__DATA_CONST,r--,r-- \ 869*43a90889SApple OSS Distributions -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ 870*43a90889SApple OSS Distributions -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ 871*43a90889SApple OSS Distributions -Wl,-segprot,__KLDDATA,rw-,rw- \ 872*43a90889SApple OSS Distributions -Wl,-segprot,__KLD,r-x,r-x \ 873*43a90889SApple OSS Distributions -Wl,-no_zero_fill_sections \ 874*43a90889SApple OSS Distributions $(LDFLAGS_NOSTRIP_FLAG) 875*43a90889SApple OSS Distributions 876*43a90889SApple OSS Distributionsifeq ($(SAN),1) 877*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 += \ 878*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__cstring,0x1000 879*43a90889SApple OSS Distributionsendif 880*43a90889SApple OSS Distributions 881*43a90889SApple OSS Distributionsifeq ($(KSANCOV),1) 882*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64 += \ 883*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__sancov_guards,0x1000 \ 884*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__sancov_pcs,0x1000 885*43a90889SApple OSS Distributionsendif 886*43a90889SApple OSS Distributions 887*43a90889SApple OSS Distributions# Define KERNEL_BASE_OFFSET so known at compile time: 888*43a90889SApple OSS DistributionsCFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) 889*43a90889SApple OSS DistributionsCFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) 890*43a90889SApple OSS Distributions 891*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 892*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 893*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_KASANX86_64 = $(LDFLAGS_KERNEL_DEVELOPMENTX86_64) \ 894*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__asan_globals,0x1000 \ 895*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__asan_liveness,0x1000 \ 896*43a90889SApple OSS Distributions -Wl,-sectalign,__HIB,__mod_term_func,0x1000 \ 897*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__mod_init_func,__NULL,__mod_init_func \ 898*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__eh_frame,__NULL,__eh_frame 899*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) 900*43a90889SApple OSS Distributions 901*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64) 902*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEBUGX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 903*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 904*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_KASANX86_64) 905*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) 906*43a90889SApple OSS Distributions 907*43a90889SApple OSS Distributions# Offset image base by page to have iBoot load kernel TEXT correctly. 908*43a90889SApple OSS Distributions# First page is used for various purposes : sleep token, reset vector. 909*43a90889SApple OSS Distributions# We also need a 32MB offset, as this is the minimum block mapping size 910*43a90889SApple OSS Distributions# for a 16KB page runtime, and we wish to use the first virtual block 911*43a90889SApple OSS Distributions# to map the low globals page. We also need another 4MB to account for 912*43a90889SApple OSS Distributions# the address space reserved by L4 (because the reservation is not a 913*43a90889SApple OSS Distributions# multiple of the block size in alignment/length, we will implictly map 914*43a90889SApple OSS Distributions# it with our block mapping, and we therefore must reflect that the 915*43a90889SApple OSS Distributions# first 4MB of the block mapping for xnu do not belong to xnu). 916*43a90889SApple OSS Distributions# For the moment, kaliber has a unique memory layout (monitor at the top 917*43a90889SApple OSS Distributions# of memory). Support this by breaking 16KB on other platforms and 918*43a90889SApple OSS Distributions# mandating 32MB alignment. Image base (i.e. __TEXT) must be 16KB 919*43a90889SApple OSS Distributions# aligned since ld64 will link with 16KB alignment for ARM64. 920*43a90889SApple OSS Distributions# 921*43a90889SApple OSS Distributions# We currently offset by an additional 32MB in order to reclaim memory. 922*43a90889SApple OSS Distributions# We need a dedicated virtual page for the low globals. Our bootloader 923*43a90889SApple OSS Distributions# may have a significant chunk of memory (up to an L2 entry in size) 924*43a90889SApple OSS Distributions# that lies before the kernel. The addition 32MB of virtual padding 925*43a90889SApple OSS Distributions# ensures that we have enough virtual address space to map all of that 926*43a90889SApple OSS Distributions# memory as part of the V-to-P mapping. 927*43a90889SApple OSS Distributions# 23355738 - put __PRELINK_TEXT first. We reserve enough room 928*43a90889SApple OSS Distributions# for 0x0000000003000000 = 48MB of kexts 929*43a90889SApple OSS Distributions# 930*43a90889SApple OSS Distributions# 0xfffffff000000000 (32MB range for low globals) 931*43a90889SApple OSS Distributions# 0xfffffff002000000 (32MB range to allow for large page physical slide) 932*43a90889SApple OSS Distributions# 0xfffffff004000000 (16KB range to reserve the first available page) 933*43a90889SApple OSS Distributions# 0xfffffff004004000 (48MB range for kexts) 934*43a90889SApple OSS Distributions# 0xfffffff007004000 (Start of xnu proper). 935*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_GENARM64 = \ 936*43a90889SApple OSS Distributions -Wl,-pie \ 937*43a90889SApple OSS Distributions -Wl,-static \ 938*43a90889SApple OSS Distributions -Wl,-segaddr,__PRELINK_TEXT,$(ARM64_PLKSEG_ADDR) \ 939*43a90889SApple OSS Distributions -Wl,-image_base,$(ARM64_LINK_ADDR) \ 940*43a90889SApple OSS Distributions \ 941*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__text,__TEXT_EXEC,__hib_text \ 942*43a90889SApple OSS Distributions \ 943*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__const,__DATA_CONST,__hib_const \ 944*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__cstring,__DATA_CONST,__hib_const \ 945*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__literal8,__DATA_CONST,__hib_const \ 946*43a90889SApple OSS Distributions -Wl,-rename_section,__HIB,__literal16,__DATA_CONST,__hib_const \ 947*43a90889SApple OSS Distributions \ 948*43a90889SApple OSS Distributions -Wl,-rename_segment,__HIB,__HIBDATA \ 949*43a90889SApple OSS Distributions \ 950*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__const,0x4000 \ 951*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__percpu,0x4000 \ 952*43a90889SApple OSS Distributions -Wl,-sectalign,__DATA,__data,0x4000 \ 953*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__mod_init_func,__DATA_CONST,__mod_init_func \ 954*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__mod_term_func,__DATA_CONST,__mod_term_func \ 955*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__auth_ptr,__DATA_CONST,__auth_ptr \ 956*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__auth_got,__DATA_CONST,__auth_got \ 957*43a90889SApple OSS Distributions -Wl,-rename_section,__DATA,__const,__DATA_CONST,__const \ 958*43a90889SApple OSS Distributions -Wl,-segprot,__DATA_CONST,r--,r-- \ 959*43a90889SApple OSS Distributions -Wl,-rename_section,__KLD,__const,__KLDDATA,__const \ 960*43a90889SApple OSS Distributions -Wl,-rename_section,__KLD,__cstring,__KLDDATA,__cstring \ 961*43a90889SApple OSS Distributions -Wl,-segprot,__KLDDATA,rw-,rw- \ 962*43a90889SApple OSS Distributions -Wl,-segprot,__KLD,r-x,r-x \ 963*43a90889SApple OSS Distributions -Wl,-rename_section,__TEXT,__text,__TEXT_EXEC,__text \ 964*43a90889SApple OSS Distributions -Wl,-rename_section,__TEXT,__stubs,__TEXT_EXEC,__stubs \ 965*43a90889SApple OSS Distributions -Wl,-sectcreate,"__PLK_TEXT_EXEC",__text,/dev/null \ 966*43a90889SApple OSS Distributions -Wl,-sectcreate,__PRELINK_DATA,__data,/dev/null \ 967*43a90889SApple OSS Distributions -Wl,-sectcreate,"__PLK_DATA_CONST",__data,/dev/null \ 968*43a90889SApple OSS Distributions -Wl,-sectcreate,"__PLK_LLVM_COV",__llvm_covmap,/dev/null \ 969*43a90889SApple OSS Distributions -Wl,-sectcreate,"__PLK_LINKEDIT",__data,/dev/null 970*43a90889SApple OSS Distributions 971*43a90889SApple OSS Distributions# To support code coverage for kexts, the coverage mapping sections __llvm_covmap 972*43a90889SApple OSS Distributions# and __llvm_covfun are put into the __PLK_LLVM_COV segment rather than the 973*43a90889SApple OSS Distributions# standard __LLVM_COV segment. For later processing of the coverage data using 974*43a90889SApple OSS Distributions# llvm-cov, we move the coverage mapping for the kernel itself into the same 975*43a90889SApple OSS Distributions# segment (see also rdar://104951137) 976*43a90889SApple OSS Distributionsifeq ($(BUILD_CODE_COVERAGE),1) 977*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_GENARM64 += \ 978*43a90889SApple OSS Distributions -Wl,-rename_section,__LLVM_COV,__llvm_covmap,__PLK_LLVM_COV,__llvm_covmap \ 979*43a90889SApple OSS Distributions -Wl,-rename_section,__LLVM_COV,__llvm_covfun,__PLK_LLVM_COV,__llvm_covfun 980*43a90889SApple OSS Distributionsendif 981*43a90889SApple OSS Distributions 982*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_SEGARM64_SEG_ORDER = \ 983*43a90889SApple OSS Distributions __TEXT:__DATA_CONST:__DATA_SPTM:__LINKEDIT:__TEXT_EXEC:__TEXT_BOOT_EXEC:__KLD:__PPLTEXT:__PPLTRAMP:__PPLDATA_CONST:__LASTDATA_CONST:__LAST:__PPLDATA:__KLDDATA:__DATA:__HIBDATA:__BOOTDATA 984*43a90889SApple OSS Distributions 985*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_SEGARM64 = \ 986*43a90889SApple OSS Distributions -Wl,-rename_section,__PPLDATA,__const,__PPLDATA_CONST,__const \ 987*43a90889SApple OSS Distributions -Wl,-segment_order,$(LDFLAGS_KERNEL_SEGARM64_SEG_ORDER) \ 988*43a90889SApple OSS Distributions -Wl,-segprot,__TEXT,r--,r-- \ 989*43a90889SApple OSS Distributions -Wl,-segprot,__TEXT_EXEC,r-x,r-x \ 990*43a90889SApple OSS Distributions -Wl,-segprot,__TEXT_BOOT_EXEC,r-x,r-x \ 991*43a90889SApple OSS Distributions -Wl,-segprot,__PPLTEXT,r-x,r-x \ 992*43a90889SApple OSS Distributions -Wl,-segprot,__PPLTRAMP,r-x,r-x \ 993*43a90889SApple OSS Distributions -Wl,-segprot,__PPLDATA_CONST,r--,r-- \ 994*43a90889SApple OSS Distributions -Wl,-segprot,__LASTDATA_CONST,r--,r-- \ 995*43a90889SApple OSS Distributions -Wl,-segprot,__LAST,r-x,r-x \ 996*43a90889SApple OSS Distributions 997*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_RELEASEARM64 = \ 998*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_GENARM64) \ 999*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_SEGARM64) \ 1000*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_STRIP_LTO) 1001*43a90889SApple OSS Distributions 1002*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_RELEASEARM64 = \ 1003*43a90889SApple OSS Distributions -Wl,-exported_symbols_list,$(TARGET)/all-kpi.exp 1004*43a90889SApple OSS Distributions 1005*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEVELOPMENTARM64 = \ 1006*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_GENARM64) \ 1007*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_SEGARM64) \ 1008*43a90889SApple OSS Distributions $(LDFLAGS_NOSTRIP_FLAG) 1009*43a90889SApple OSS Distributions 1010*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64 = 1011*43a90889SApple OSS Distributions 1012*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_KASANARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) 1013*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_DEBUGARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) 1014*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_SPTMARM64 = $(LDFLAGS_KERNEL_DEVELOPMENTARM64) 1015*43a90889SApple OSS Distributions 1016*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_KASANARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) 1017*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_CONFIG_DEBUGARM64 = $(LDFLAGS_KERNEL_ONLY_CONFIG_DEVELOPMENTARM64) 1018*43a90889SApple OSS Distributions 1019*43a90889SApple OSS Distributions# 1020*43a90889SApple OSS Distributions# arm64e specific linker flags that should be used only when linking the kernel 1021*43a90889SApple OSS Distributions# (and not the static kernel cache / kcgen) 1022*43a90889SApple OSS Distributions# 1023*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_arm64e = \ 1024*43a90889SApple OSS Distributions -Wl,-add_split_seg_info \ 1025*43a90889SApple OSS Distributions -Wl,-kernel 1026*43a90889SApple OSS Distributions 1027*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_x86_64 = \ 1028*43a90889SApple OSS Distributions -Wl,-add_split_seg_info \ 1029*43a90889SApple OSS Distributions -Wl,-kernel 1030*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY_SUBARCH_x86_64h = $(LDFLAGS_KERNEL_ONLY_SUBARCH_x86_64) 1031*43a90889SApple OSS Distributions 1032*43a90889SApple OSS DistributionsLDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \ 1033*43a90889SApple OSS Distributions $(LDFLAGS_KERNEL_SDK) \ 1034*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 1035*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \ 1036*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \ 1037*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \ 1038*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) 1039*43a90889SApple OSS Distributions 1040*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_ONLY += \ 1041*43a90889SApple OSS Distributions $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_ONLY_CONFIG_))) \ 1042*43a90889SApple OSS Distributions $($(addsuffix $(ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG),LDFLAGS_KERNEL_ONLY_SUBARCH_)) \ 1043*43a90889SApple OSS Distributions -Wl,-alias_list,$(TARGET)/all-alias.exp \ 1044*43a90889SApple OSS Distributions -Wl,-sectcreate,__LINKINFO,__symbolsets,$(TARGET)/symbolsets.plist -Wl,-segprot,__LINKINFO,r--,r-- 1045*43a90889SApple OSS Distributions 1046*43a90889SApple OSS DistributionsLDFILES_KERNEL_ONLY = $(TARGET)/all-kpi.exp $(TARGET)/all-alias.exp $(TARGET)/symbolsets.plist 1047*43a90889SApple OSS Distributions 1048*43a90889SApple OSS Distributions# 1049*43a90889SApple OSS Distributions# Default runtime libraries to be linked with the kernel 1050*43a90889SApple OSS Distributions# 1051*43a90889SApple OSS DistributionsLD_KERNEL_LIBS = -lcc_kext 1052*43a90889SApple OSS DistributionsLD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel 1053*43a90889SApple OSS Distributions 1054*43a90889SApple OSS Distributions# Link binary support library 1055*43a90889SApple OSS Distributionsifneq ($(KDKROOT),) 1056*43a90889SApple OSS Distributions LDFLAGS_KERNEL_ONLY += -rdynamic -Wl,-force_load,$(KDKROOT)/System/Library/KernelSupport/lib$(CURRENT_MACHINE_CONFIG).os.$(CURRENT_KERNEL_CONFIG).a 1057*43a90889SApple OSS Distributionsendif 1058*43a90889SApple OSS Distributions 1059*43a90889SApple OSS Distributions# 1060*43a90889SApple OSS Distributions# Derive SPTM/TXM and Exclaves enablement from the EDM properties. 1061*43a90889SApple OSS Distributions# 1062*43a90889SApple OSS Distributionsifneq ($(EMBEDDED_DEVICE_MAP),) 1063*43a90889SApple OSS DistributionsPLATFORM_NORMALIZED := $(shell echo $(PLATFORM) | tr '[:upper:]' '[:lower:]') 1064*43a90889SApple OSS Distributions 1065*43a90889SApple OSS DistributionsSPTM_ENABLED := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT EnableSPTMTXM FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" AND SDKPlatform IS \"$(PLATFORM_NORMALIZED)\" AND EnableSPTMTXM == 1) 1066*43a90889SApple OSS Distributions 1067*43a90889SApple OSS DistributionsEXCLAVES_ENABLED := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT HascL4 FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" AND SDKPlatform IS \"$(PLATFORM_NORMALIZED)\" AND HascL4 == 1) 1068*43a90889SApple OSS Distributionsendif # !EMBEDDED_DEVICE_MAP 1069*43a90889SApple OSS Distributions 1070*43a90889SApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),SPTM) 1071*43a90889SApple OSS Distributions SPTM_ENABLED = 1 1072*43a90889SApple OSS Distributionsendif # SPTM 1073*43a90889SApple OSS Distributions 1074*43a90889SApple OSS Distributionsifneq ($(filter $(CURRENT_MACHINE_CONFIG_LC),$(SPTM_ENABLED_SOCS_$(PLATFORM))),) 1075*43a90889SApple OSS Distributions SPTM_ENABLED = 1 1076*43a90889SApple OSS Distributionsendif 1077*43a90889SApple OSS Distributions 1078*43a90889SApple OSS Distributionsifeq ($(SPTM_ENABLED),1) 1079*43a90889SApple OSS Distributions LD_KERNEL_ARCHIVES += -lTrustedExecutionMonitor_Kernel 1080*43a90889SApple OSS Distributions LD_KERNEL_ARCHIVES += -lsptm_xnu 1081*43a90889SApple OSS Distributions DOCONF_SPTM := -sptm 1082*43a90889SApple OSS Distributionsendif # !SPTM_ENABLED 1083*43a90889SApple OSS Distributions 1084*43a90889SApple OSS Distributionsifeq ($(EXCLAVES_ENABLED),1) 1085*43a90889SApple OSS Distributions DOCONF_EXCLAVES := -exclaves 1086*43a90889SApple OSS Distributionsendif # !EXCLAVES_ENABLED 1087*43a90889SApple OSS Distributions 1088*43a90889SApple OSS DistributionsTIGHTBEAM_EXPORTS := $(SRCROOT)/config/libTightbeam.exports 1089*43a90889SApple OSS Distributions 1090*43a90889SApple OSS Distributions# 1091*43a90889SApple OSS Distributions# DTrace support 1092*43a90889SApple OSS Distributions# 1093*43a90889SApple OSS Distributionsifndef DO_CTFMERGE 1094*43a90889SApple OSS DistributionsDO_CTFMERGE := 1 1095*43a90889SApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) 1096*43a90889SApple OSS Distributionsifneq ($(PLATFORM),MacOSX) 1097*43a90889SApple OSS DistributionsDO_CTFMERGE := 0 1098*43a90889SApple OSS Distributionsendif 1099*43a90889SApple OSS Distributionsendif 1100*43a90889SApple OSS Distributionsendif # DO_CTFMERGE 1101*43a90889SApple OSS Distributions 1102*43a90889SApple OSS Distributions 1103*43a90889SApple OSS Distributions# 1104*43a90889SApple OSS Distributions# Default INCFLAGS 1105*43a90889SApple OSS Distributions# 1106*43a90889SApple OSS DistributionsINCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST)) 1107*43a90889SApple OSS DistributionsINCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS 1108*43a90889SApple OSS DistributionsINCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT) 1109*43a90889SApple OSS DistributionsINCFLAGS_LOCAL = -I. 1110*43a90889SApple OSS DistributionsINCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel -I$(SDKROOT)/$(KPINCDIR)/AppleFeatures 1111*43a90889SApple OSS DistributionsINCFLAGS_PLATFORM = -I$(SDKROOT)/$(KPINCDIR)/platform 1112*43a90889SApple OSS Distributionsifneq ($(KDKROOT),) 1113*43a90889SApple OSS DistributionsINCFLAGS_SDK += -I$(KDKROOT)/$(KPINCDIR) 1114*43a90889SApple OSS DistributionsINCFLAGS_PLATFORM += -I$(KDKROOT)/$(KINCDIR)/platform -I$(KDKROOT)/$(KPINCDIR)/platform 1115*43a90889SApple OSS Distributionsendif 1116*43a90889SApple OSS Distributions 1117*43a90889SApple OSS DistributionsINCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK) $(INCFLAGS_PLATFORM) 1118*43a90889SApple OSS Distributions 1119*43a90889SApple OSS Distributions# 1120*43a90889SApple OSS Distributions# Default MIGFLAGS 1121*43a90889SApple OSS Distributions# 1122*43a90889SApple OSS DistributionsMIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ 1123*43a90889SApple OSS Distributions $(DEPLOYMENT_TARGET_FLAGS) 1124*43a90889SApple OSS Distributions 1125*43a90889SApple OSS Distributions# 1126*43a90889SApple OSS Distributions# Default MIG Kernel Server flags 1127*43a90889SApple OSS Distributions# 1128*43a90889SApple OSS DistributionsMIGKSFLAGS = \ 1129*43a90889SApple OSS Distributions -DMACH_KERNEL_PRIVATE \ 1130*43a90889SApple OSS Distributions -DKERNEL_SERVER=1 \ 1131*43a90889SApple OSS Distributions -mach_msg2 1132*43a90889SApple OSS Distributions 1133*43a90889SApple OSS Distributions# 1134*43a90889SApple OSS Distributions# Default MIG KernelUser flags 1135*43a90889SApple OSS Distributions# 1136*43a90889SApple OSS DistributionsMIGKUFLAGS = \ 1137*43a90889SApple OSS Distributions -DMACH_KERNEL_PRIVATE \ 1138*43a90889SApple OSS Distributions -DKERNEL_USER=1 \ 1139*43a90889SApple OSS Distributions -maxonstack 1024 1140*43a90889SApple OSS Distributions 1141*43a90889SApple OSS Distributions# Support for LLVM Profile Guided Optimization (PGO) 1142*43a90889SApple OSS Distributions 1143*43a90889SApple OSS Distributionsifeq ($(BUILD_PROFILE),1) 1144*43a90889SApple OSS DistributionsCFLAGS_GEN += -fprofile-instr-generate -DPROFILE 1145*43a90889SApple OSS DistributionsCXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE 1146*43a90889SApple OSS Distributionsendif 1147*43a90889SApple OSS Distributions 1148*43a90889SApple OSS Distributionsifdef USE_PROFILE 1149*43a90889SApple OSS DistributionsCFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) 1150*43a90889SApple OSS DistributionsCXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) 1151*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE) 1152*43a90889SApple OSS Distributions 1153*43a90889SApple OSS DistributionsCFLAGS_GEN += -Wno-error=profile-instr-out-of-date 1154*43a90889SApple OSS Distributionsendif 1155*43a90889SApple OSS Distributions 1156*43a90889SApple OSS Distributions# Support for LLVM Source-based Code coverage. Since enabling code coverage 1157*43a90889SApple OSS Distributions# increases the size of __LINKEDIT, it might be necessary to set the keepsyms=1 1158*43a90889SApple OSS Distributions# boot-arg when building the kernel with code coverage enabled. 1159*43a90889SApple OSS Distributionsifeq ($(BUILD_CODE_COVERAGE),1) 1160*43a90889SApple OSS DistributionsCFLAGS_GEN += -fprofile-instr-generate -fcoverage-mapping 1161*43a90889SApple OSS DistributionsCXXFLAGS_GEN += -fprofile-instr-generate -fcoverage-mapping 1162*43a90889SApple OSS Distributionsendif 1163*43a90889SApple OSS Distributions 1164*43a90889SApple OSS Distributions# 1165*43a90889SApple OSS Distributions# Support for LLVM Link Time Optimization (LTO) 1166*43a90889SApple OSS Distributions# 1167*43a90889SApple OSS Distributions# LTO can be explicitly enabled or disabled with BUILD_LTO=1|0 1168*43a90889SApple OSS Distributions# and defaults to enabled except for DEBUG kernels 1169*43a90889SApple OSS Distributions# 1170*43a90889SApple OSS Distributions# CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files 1171*43a90889SApple OSS Distributions# that deal poorly with LTO, or files that must be machine 1172*43a90889SApple OSS Distributions# code *.o files for xnu to build (i.e, setsegname runs on 1173*43a90889SApple OSS Distributions# them). 1174*43a90889SApple OSS Distributions# 1175*43a90889SApple OSS Distributions# LDFLAGS_NOSTRIP_FLAG is used to support configurations that 1176*43a90889SApple OSS Distributions# do not utilize an export list. For these configs to build, 1177*43a90889SApple OSS Distributions# we need to prevent the LTO logic from dead stripping them. 1178*43a90889SApple OSS Distributions 1179*43a90889SApple OSS DistributionsLTO_ENABLED_RELEASE = 1 1180*43a90889SApple OSS DistributionsLTO_ENABLED_DEVELOPMENT = 1 1181*43a90889SApple OSS DistributionsLTO_ENABLED_DEBUG = 0 1182*43a90889SApple OSS DistributionsLTO_ENABLED_KASAN = 0 1183*43a90889SApple OSS DistributionsLTO_ENABLED_SPTM = $(LTO_ENABLED_DEVELOPMENT) 1184*43a90889SApple OSS Distributions 1185*43a90889SApple OSS Distributionsifneq ($(BUILD_LTO),) 1186*43a90889SApple OSS DistributionsUSE_LTO = $(BUILD_LTO) 1187*43a90889SApple OSS Distributionselse 1188*43a90889SApple OSS DistributionsUSE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG)) 1189*43a90889SApple OSS Distributionsendif 1190*43a90889SApple OSS Distributions 1191*43a90889SApple OSS Distributionsifeq ($(USE_LTO),1) 1192*43a90889SApple OSS DistributionsCFLAGS_GEN += -flto -DBUILT_LTO=1 1193*43a90889SApple OSS DistributionsCXXFLAGS_GEN += -flto -DBUILT_LTO=1 1194*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_LTO = -Wl,-mllvm,-inline-threshold=100 1195*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_GEN += $(LDFLAGS_KERNEL_LTO) -Wl,-object_path_lto,$(TARGET)/lto.o 1196*43a90889SApple OSS DistributionsLDFLAGS_NOSTRIP_FLAG = -rdynamic 1197*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_STRIP_LTO = -Wl,-dead_strip,-no_dead_strip_inits_and_terms 1198*43a90889SApple OSS Distributions 1199*43a90889SApple OSS DistributionsCFLAGS_NOLTO_FLAG = -fno-lto 1200*43a90889SApple OSS Distributionselse 1201*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_LTO = 1202*43a90889SApple OSS DistributionsLDFLAGS_NOSTRIP_FLAG = 1203*43a90889SApple OSS DistributionsLDFLAGS_KERNEL_STRIP_LTO = 1204*43a90889SApple OSS DistributionsCFLAGS_NOLTO_FLAG = 1205*43a90889SApple OSS Distributionsendif 1206*43a90889SApple OSS Distributions 1207*43a90889SApple OSS Distributions# 1208*43a90889SApple OSS Distributions# Default VPATH 1209*43a90889SApple OSS Distributions# 1210*43a90889SApple OSS Distributionsexport VPATH = .:$(SOURCE) 1211*43a90889SApple OSS Distributions 1212*43a90889SApple OSS Distributions 1213*43a90889SApple OSS Distributions 1214*43a90889SApple OSS Distributions# 1215*43a90889SApple OSS Distributions# Macros that control installation of kernel and its header files 1216*43a90889SApple OSS Distributions# 1217*43a90889SApple OSS Distributions# install flags for header files 1218*43a90889SApple OSS Distributions# 1219*43a90889SApple OSS DistributionsINSTALL_FLAGS = -c -S -m 0444 1220*43a90889SApple OSS DistributionsDATA_INSTALL_FLAGS = -c -S -m 0644 1221*43a90889SApple OSS DistributionsDATA_INSTALL_FLAGS_RO = -c -S -m 0444 1222*43a90889SApple OSS DistributionsEXEC_INSTALL_FLAGS = -c -S -m 0755 1223*43a90889SApple OSS Distributions 1224*43a90889SApple OSS Distributions# 1225*43a90889SApple OSS Distributions# Header file destinations 1226*43a90889SApple OSS Distributions# 1227*43a90889SApple OSS Distributions 1228*43a90889SApple OSS Distributionsifeq ($(DRIVERKIT),1) 1229*43a90889SApple OSS Distributions SDKHEADERSROOT=$(DRIVERKITRUNTIMEROOT) 1230*43a90889SApple OSS Distributions # only whitelisted headers install outside of the DriverKit Runtime hierarchy 1231*43a90889SApple OSS Distributions DRIVERKITSDKHEADERSROOT=$(DRIVERKITROOT) 1232*43a90889SApple OSS Distributions DRIVERKITFRAMEDIR = $(DRIVERKITROOT)/System/Library/Frameworks 1233*43a90889SApple OSS Distributionsendif 1234*43a90889SApple OSS Distributions 1235*43a90889SApple OSS Distributionsifeq ($(EXCLAVEKIT),1) 1236*43a90889SApple OSS Distributions EXCLAVEKITSDKHEADERSROOT=$(EXCLAVEKITROOT) 1237*43a90889SApple OSS Distributions EXCLAVEKITFRAMEDIR = $(EXCLAVEKITROOT)/System/Library/Frameworks 1238*43a90889SApple OSS Distributionsendif 1239*43a90889SApple OSS Distributions 1240*43a90889SApple OSS Distributionsifeq ($(EXCLAVECORE),1) 1241*43a90889SApple OSS Distributions EXCLAVECORESDKHEADERSROOT=$(EXCLAVECOREROOT) 1242*43a90889SApple OSS Distributions EXCLAVECOREFRAMEDIR = $(EXCLAVECOREROOT)/System/Library/Frameworks 1243*43a90889SApple OSS Distributionsendif 1244*43a90889SApple OSS Distributions 1245*43a90889SApple OSS DistributionsFRAMEDIR = $(SDKHEADERSROOT)/System/Library/Frameworks 1246*43a90889SApple OSS Distributions 1247*43a90889SApple OSS DistributionsIINCVERS = A 1248*43a90889SApple OSS DistributionsIINCFRAME = $(FRAMEDIR)/IOKit.framework 1249*43a90889SApple OSS DistributionsIINCDIR = $(IINCFRAME)/Versions/$(IINCVERS)/Headers 1250*43a90889SApple OSS DistributionsIPINCDIR = $(IINCFRAME)/Versions/$(IINCVERS)/PrivateHeaders 1251*43a90889SApple OSS DistributionsIRESDIR = $(IINCFRAME)/Versions/$(IINCVERS)/Resources 1252*43a90889SApple OSS Distributions 1253*43a90889SApple OSS DistributionsSINCVERS = B 1254*43a90889SApple OSS DistributionsSINCFRAME = $(FRAMEDIR)/System.framework 1255*43a90889SApple OSS DistributionsSINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers 1256*43a90889SApple OSS DistributionsSPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders 1257*43a90889SApple OSS DistributionsSRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources 1258*43a90889SApple OSS Distributions 1259*43a90889SApple OSS Distributionsifndef INCDIR 1260*43a90889SApple OSS Distributions INCDIR = $(SDKHEADERSROOT)/usr/include 1261*43a90889SApple OSS Distributionsendif 1262*43a90889SApple OSS Distributionsifndef DRIVERKITINCDIR 1263*43a90889SApple OSS Distributions DRIVERKITINCDIR = $(DRIVERKITSDKHEADERSROOT)/usr/include 1264*43a90889SApple OSS Distributionsendif 1265*43a90889SApple OSS Distributionsifndef EXCLAVEKITINCDIR 1266*43a90889SApple OSS Distributions EXCLAVEKITINCDIR = $(EXCLAVEKITSDKHEADERSROOT)/usr/include 1267*43a90889SApple OSS Distributionsendif 1268*43a90889SApple OSS Distributionsifndef EXCLAVECOREINCDIR 1269*43a90889SApple OSS Distributions EXCLAVECOREINCDIR = $(EXCLAVECORESDKHEADERSROOT)/usr/include 1270*43a90889SApple OSS Distributionsendif 1271*43a90889SApple OSS Distributionsifndef LCLDIR 1272*43a90889SApple OSS Distributions LCLDIR = $(SDKHEADERSROOT)/usr/local/include 1273*43a90889SApple OSS Distributionsendif 1274*43a90889SApple OSS Distributionsifndef DRIVERKITLCLDIR 1275*43a90889SApple OSS Distributions DRIVERKITLCLDIR = $(DRIVERKITSDKHEADERSROOT)/usr/local/include 1276*43a90889SApple OSS Distributionsendif 1277*43a90889SApple OSS Distributions 1278*43a90889SApple OSS DistributionsKINCVERS = A 1279*43a90889SApple OSS DistributionsKINCFRAME = $(FRAMEDIR)/Kernel.framework 1280*43a90889SApple OSS DistributionsKINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers 1281*43a90889SApple OSS DistributionsKPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders 1282*43a90889SApple OSS DistributionsKRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources 1283*43a90889SApple OSS Distributions 1284*43a90889SApple OSS DistributionsKLIBCXXDIR = $(KPINCDIR)/kernel_sdkroot 1285*43a90889SApple OSS DistributionsKLIBCXXINCDIR = $(KLIBCXXDIR)/usr/include 1286*43a90889SApple OSS Distributions 1287*43a90889SApple OSS DistributionsDKIT_INCFRAME = DriverKit.framework 1288*43a90889SApple OSS Distributions 1289*43a90889SApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 1290*43a90889SApple OSS DistributionsDKIT_INCVERS = A 1291*43a90889SApple OSS DistributionsDKIT_INCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/Headers 1292*43a90889SApple OSS DistributionsDKIT_PINCDIR = $(DKIT_INCFRAME)/Versions/$(DKIT_INCVERS)/PrivateHeaders 1293*43a90889SApple OSS Distributionselse 1294*43a90889SApple OSS Distributions# non-macOS SDK frameworks use shallow bundle structure 1295*43a90889SApple OSS DistributionsDKIT_INCDIR = $(DKIT_INCFRAME)/Headers 1296*43a90889SApple OSS DistributionsDKIT_PINCDIR = $(DKIT_INCFRAME)/PrivateHeaders 1297*43a90889SApple OSS Distributionsendif 1298*43a90889SApple OSS Distributions 1299*43a90889SApple OSS Distributions# DriverKit SDK frameworks use shallow bundle structure 1300*43a90889SApple OSS DistributionsDRIVERKIT_DKIT_INCDIR = $(DKIT_INCFRAME)/Headers 1301*43a90889SApple OSS DistributionsDRIVERKIT_DKIT_PINCDIR = $(DKIT_INCFRAME)/PrivateHeaders 1302*43a90889SApple OSS Distributions 1303*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF ?= 1304*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UMACH_KERNEL_PRIVATE 1305*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UBSD_KERNEL_PRIVATE 1306*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UIOKIT_KERNEL_PRIVATE 1307*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -ULIBKERN_KERNEL_PRIVATE 1308*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -ULIBSA_KERNEL_PRIVATE 1309*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UPEXPERT_KERNEL_PRIVATE 1310*43a90889SApple OSS DistributionsXNU_PRIVATE_UNIFDEF += -UXNU_KERNEL_PRIVATE 1311*43a90889SApple OSS Distributions 1312*43a90889SApple OSS Distributions 1313*43a90889SApple OSS DistributionsPLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DXNU_PLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UXNU_PLATFORM_$(x))) 1314*43a90889SApple OSS Distributions 1315*43a90889SApple OSS Distributions 1316*43a90889SApple OSS Distributions# Some header guards need to be present and checked in kernel headers but removed from userspace headers 1317*43a90889SApple OSS DistributionsKERNEL_ONLY_GUARDS_UNIFDEF = 1318*43a90889SApple OSS Distributions 1319*43a90889SApple OSS Distributions# Test-only guards should be stripped from all exported headers 1320*43a90889SApple OSS DistributionsTEST_ONLY_GUARDS_UNIFDEF = -USCHED_TEST_HARNESS 1321*43a90889SApple OSS Distributions 1322*43a90889SApple OSS DistributionsSPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -UDRIVERKIT -UEXCLAVEKIT -UEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1323*43a90889SApple OSS DistributionsSINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -UDRIVERKIT -UEXCLAVEKIT -UEXCLAVECORE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1324*43a90889SApple OSS DistributionsDKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -DDRIVERKIT -UEXCLAVEKIT -UEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1325*43a90889SApple OSS DistributionsDKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -DDRIVERKIT -UEXCLAVEKIT -UEXCLAVECORE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1326*43a90889SApple OSS DistributionsEKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -UDRIVERKIT -DEXCLAVEKIT -UEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1327*43a90889SApple OSS DistributionsEKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -UDRIVERKIT -DEXCLAVEKIT -UEXCLAVECORE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1328*43a90889SApple OSS DistributionsECPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -UDRIVERKIT -UEXCLAVEKIT -DEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1329*43a90889SApple OSS DistributionsECINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -UDRIVERKIT -UEXCLAVEKIT -DEXCLAVECORE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(KERNEL_ONLY_GUARDS_UNIFDEF) $(TEST_ONLY_GUARDS_UNIFDEF) 1330*43a90889SApple OSS DistributionsKPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DKERNEL -DPRIVATE -UDRIVERKIT -UXNU_LIBCXX_SDKROOT -UEXCLAVEKIT -UEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(TEST_ONLY_GUARDS_UNIFDEF) 1331*43a90889SApple OSS DistributionsLIBCXXINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DKERNEL -DPRIVATE -UDRIVERKIT -DXNU_LIBCXX_SDKROOT -UEXCLAVEKIT -UEXCLAVECORE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(TEST_ONLY_GUARDS_UNIFDEF) 1332*43a90889SApple OSS DistributionsKINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -DKERNEL -UPRIVATE -UDRIVERKIT -UEXCLAVEKIT -UEXCLAVECORE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(TEST_ONLY_GUARDS_UNIFDEF) 1333*43a90889SApple OSS DistributionsPDATA_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DPRIVATE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ $(TEST_ONLY_GUARDS_UNIFDEF) 1334*43a90889SApple OSS DistributionsDATA_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ $(TEST_ONLY_GUARDS_UNIFDEF) 1335*43a90889SApple OSS Distributions 1336*43a90889SApple OSS Distributions# 1337*43a90889SApple OSS Distributions# Compononent Header file destinations 1338*43a90889SApple OSS Distributions# 1339*43a90889SApple OSS DistributionsEXPDIR = EXPORT_HDRS/$(COMPONENT) 1340*43a90889SApple OSS Distributions 1341*43a90889SApple OSS Distributions# 1342*43a90889SApple OSS Distributions# Strip Flags 1343*43a90889SApple OSS Distributions# 1344*43a90889SApple OSS DistributionsSTRIP_FLAGS_RELEASE = -S -x 1345*43a90889SApple OSS DistributionsSTRIP_FLAGS_DEVELOPMENT = -S 1346*43a90889SApple OSS DistributionsSTRIP_FLAGS_KASAN = $(STRIP_FLAGS_DEVELOPMENT) 1347*43a90889SApple OSS DistributionsSTRIP_FLAGS_DEBUG = -S 1348*43a90889SApple OSS DistributionsSTRIP_FLAGS_SPTM = $(STRIP_FLAGS_DEVELOPMENT) 1349*43a90889SApple OSS DistributionsSTRIP_FLAGS_PROFILE = -S -x 1350*43a90889SApple OSS Distributions 1351*43a90889SApple OSS DistributionsSTRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_)) 1352*43a90889SApple OSS Distributions 1353*43a90889SApple OSS Distributions# 1354*43a90889SApple OSS Distributions# dsymutil flags 1355*43a90889SApple OSS Distributions# 1356*43a90889SApple OSS DistributionsDSYMUTIL_FLAGS_X86_64 = --arch=x86_64 1357*43a90889SApple OSS DistributionsDSYMUTIL_FLAGS_X86_64H = --arch=x86_64h 1358*43a90889SApple OSS DistributionsDSYMUTIL_FLAGS_ARM64 = 1359*43a90889SApple OSS Distributions 1360*43a90889SApple OSS DistributionsDSYMUTIL_FLAGS = $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_)) 1361*43a90889SApple OSS Distributions 1362*43a90889SApple OSS Distributions 1363*43a90889SApple OSS Distributions 1364*43a90889SApple OSS Distributions 1365*43a90889SApple OSS Distributions# 1366*43a90889SApple OSS Distributions# Man Page destination 1367*43a90889SApple OSS Distributions# 1368*43a90889SApple OSS DistributionsMANDIR = /usr/share/man 1369*43a90889SApple OSS Distributions 1370*43a90889SApple OSS Distributions# 1371*43a90889SApple OSS Distributions# DEBUG alias location 1372*43a90889SApple OSS Distributions# 1373*43a90889SApple OSS DistributionsDEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_$(CURRENT_KERNEL_CONFIG_LC) 1374*43a90889SApple OSS Distributions 1375*43a90889SApple OSS Distributions# 1376*43a90889SApple OSS Distributions# mach_kernel install location 1377*43a90889SApple OSS Distributions# 1378*43a90889SApple OSS DistributionsINSTALL_KERNEL_DIR = / 1379*43a90889SApple OSS Distributions 1380*43a90889SApple OSS Distributions# 1381*43a90889SApple OSS Distributions# new OS X install location 1382*43a90889SApple OSS Distributions# 1383*43a90889SApple OSS DistributionsSYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels 1384*43a90889SApple OSS Distributions 1385*43a90889SApple OSS Distributions# 1386*43a90889SApple OSS Distributions# File names in DSTROOT 1387*43a90889SApple OSS Distributions# 1388*43a90889SApple OSS Distributions 1389*43a90889SApple OSS Distributionsifeq ($(PLATFORM),MacOSX) 1390*43a90889SApple OSS DistributionsKERNEL_FILE_NAME_PREFIX = kernel 1391*43a90889SApple OSS Distributionselse 1392*43a90889SApple OSS DistributionsKERNEL_FILE_NAME_PREFIX = mach 1393*43a90889SApple OSS Distributionsendif 1394*43a90889SApple OSS Distributions 1395*43a90889SApple OSS Distributionsifeq ($(CURRENT_MACHINE_CONFIG),NONE) 1396*43a90889SApple OSS Distributionsifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) 1397*43a90889SApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX) 1398*43a90889SApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py 1399*43a90889SApple OSS Distributionselse 1400*43a90889SApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC) 1401*43a90889SApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py 1402*43a90889SApple OSS Distributionsendif 1403*43a90889SApple OSS Distributionselse 1404*43a90889SApple OSS DistributionsKERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_MACHINE_CONFIG_LC) 1405*43a90889SApple OSS DistributionsKERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py 1406*43a90889SApple OSS Distributionsendif 1407*43a90889SApple OSS Distributions 1408*43a90889SApple OSS DistributionsCURRENT_ALIAS_MACHINE_CONFIG = $(word 4,$(subst ^, ,$(CURRENT_BUILD_CONFIG))) 1409*43a90889SApple OSS DistributionsCURRENT_ALIAS_MACHINE_CONFIG_LC = $(shell printf "%s" "$(CURRENT_ALIAS_MACHINE_CONFIG)" | $(TR) A-Z a-z) 1410*43a90889SApple OSS Distributionsifneq ($(CURRENT_ALIAS_MACHINE_CONFIG),) 1411*43a90889SApple OSS DistributionsALIAS_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_ALIAS_MACHINE_CONFIG_LC) 1412*43a90889SApple OSS Distributionsendif 1413*43a90889SApple OSS Distributions 1414*43a90889SApple OSS Distributions# 1415*43a90889SApple OSS Distributions# System.kext pseudo-kext install location 1416*43a90889SApple OSS Distributions# 1417*43a90889SApple OSS DistributionsINSTALL_EXTENSIONS_DIR = /System/Library/Extensions 1418*43a90889SApple OSS DistributionsSYSTEM_KEXT_INFO_PLIST = $(addprefix $(INSTALL_EXTENSIONS_DIR),/System.kext/Info.plist) 1419*43a90889SApple OSS Distributions 1420*43a90889SApple OSS Distributions# 1421*43a90889SApple OSS Distributions# System.kext PlugIns install location 1422*43a90889SApple OSS Distributions# 1423*43a90889SApple OSS DistributionsDSTROOT_SYSTEM_KEXT_PATH = $(addprefix $(DSTROOT)$(INSTALL_EXTENSIONS_DIR),/System.kext/PlugIns) 1424*43a90889SApple OSS DistributionsSYMROOT_SYSTEM_KEXT_PATH = $(addprefix $(SYMROOT),/System.kext/PlugIns) 1425*43a90889SApple OSS Distributions 1426*43a90889SApple OSS Distributions# 1427*43a90889SApple OSS Distributions# KDK location 1428*43a90889SApple OSS Distributions# 1429*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK 1430*43a90889SApple OSS Distributions 1431*43a90889SApple OSS Distributions# 1432*43a90889SApple OSS Distributions# Misc. Etc. 1433*43a90889SApple OSS Distributions# 1434*43a90889SApple OSS DistributionsINSTALL_SHARE_MISC_DIR = /usr/share/misc 1435*43a90889SApple OSS DistributionsINSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace 1436*43a90889SApple OSS DistributionsINSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace 1437*43a90889SApple OSS DistributionsINSTALL_ARIADNE_PLISTS_DIR = /AppleInternal/Library/Ariadne/Plists 1438*43a90889SApple OSS Distributions# 1439*43a90889SApple OSS Distributions# Generated xnu version file 1440*43a90889SApple OSS Distributions# 1441*43a90889SApple OSS DistributionsXNU_VERSION = $(OBJROOT)/xnuVersion 1442*43a90889SApple OSS Distributions 1443*43a90889SApple OSS Distributions# 1444*43a90889SApple OSS Distributions# Overrides for XBS build aliases 1445*43a90889SApple OSS Distributions# 1446*43a90889SApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_headers_driverkit),) 1447*43a90889SApple OSS DistributionsUSE_BINARY_PLIST = 1 1448*43a90889SApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_debug),) 1449*43a90889SApple OSS DistributionsINSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR) 1450*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR) 1451*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = 1 1452*43a90889SApple OSS DistributionsINSTALL_XNU_DEBUG_FILES = 1 1453*43a90889SApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 1454*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = 1 1455*43a90889SApple OSS DistributionsUSE_BINARY_PLIST = 1 1456*43a90889SApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 1457*43a90889SApple OSS DistributionsUSE_BINARY_PLIST = 1 1458*43a90889SApple OSS Distributionselse ifeq ($(PLATFORM),MacOSX) 1459*43a90889SApple OSS DistributionsINSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) 1460*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) 1461*43a90889SApple OSS DistributionsINSTALL_KERNEL_SYM_TO_KDK = $(if $(filter YES,$(DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT)),1,0) 1462*43a90889SApple OSS Distributionsendif 1463*43a90889SApple OSS Distributions 1464*43a90889SApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_kasan),) 1465*43a90889SApple OSS DistributionsINSTALL_KASAN_ONLY = 1 1466*43a90889SApple OSS Distributionsendif 1467*43a90889SApple OSS Distributions 1468*43a90889SApple OSS Distributions# vim: set ft=make: 1469