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