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