1 PROJECT := xnu/darwintests
3 # When building as part of xnu_tests, we get passed a DSTROOT that's got the
4 # unit test path in it already. But, BASEDSTROOT doesn't, so use that instead.
6 override DSTROOT = $(BASEDSTROOT)
11 OTHER_LTE_INCLUDE_FILES += \
12 /System/Library/PrivateFrameworks/LoggingSupport.framework, \
13 /System/Library/PrivateFrameworks/MobileKeyBag.framework, \
14 /usr/local/lib/libdarwintest_utils.dylib, \
15 /usr/lib/libapple_crypto.dylib,
17 DEVELOPER_DIR ?= $(shell xcode-select -p)
19 # the xnu build system will only ever call us with the default target
20 .DEFAULT_GOAL := install
22 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
24 OTHER_CFLAGS = -Weverything -Wno-gnu-union-cast -Wno-missing-field-initializers -Wno-partial-availability
25 OTHER_CFLAGS += -Wno-missing-noreturn -Wno-vla -Wno-reserved-id-macro -Wno-documentation-unknown-command
26 OTHER_CFLAGS += -Wno-padded -Wno-used-but-marked-unused -Wno-covered-switch-default -Wno-nullability-extension
27 OTHER_CFLAGS += -Wno-gnu-empty-initializer -Wno-unused-macros -Wno-undef
28 OTHER_CFLAGS += --std=gnu11 -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
29 OTHER_CFLAGS += -UT_NAMESPACE_PREFIX -DT_NAMESPACE_PREFIX=xnu
30 OTHER_CFLAGS += -F $(SDKROOT)/System/Library/PrivateFrameworks
32 CODESIGN:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign)
33 CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(TARGETSDK)" -find codesign_allocate)
35 # to have custom compiler flags to
36 # target: OTHER_CFLAGS += <my flags>
38 atm_diagnostic_flag: OTHER_CFLAGS += drop_priv.c
40 testposixshm: INVALID_ARCHS = i386
42 avx: INVALID_ARCHS = i386
43 avx: OTHER_CFLAGS += -mavx512f -mavx512bw -mavx512vl
44 avx: OTHER_CFLAGS += -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
45 avx: CONFIG_FLAGS := $(filter-out -O%,$(CONFIG_FLAGS))
46 # Level 2 optimization must be used to prevent compiler from generating
47 # invalid instructions when compiling with AVX-512 flags.
48 avx: CONFIG_FLAGS += -O2
49 # Disable vzeroupper insertion to work around rdar://problem/35035096
50 avx: CONFIG_FLAGS += -mllvm -x86-use-vzeroupper=0
51 ifneq (osx,$(TARGET_NAME))
52 EXCLUDED_SOURCES += avx.c
55 backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
57 data_protection: OTHER_LDFLAGS += -ldarwintest_utils -framework IOKit
59 kdebug: INVALID_ARCHS = i386
60 kdebug: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils -framework kperf
62 EXCLUDED_SOURCES += drop_priv.c kperf_helpers.c xnu_quick_test_helpers.c
64 ifneq ($(PLATFORM),iPhoneOS)
65 EXCLUDED_SOURCES += jumbo_va_spaces_28530648.c perf_compressor.c memorystatus_freeze_test.c
68 perf_compressor: OTHER_LDFLAGS += -ldarwintest_utils
69 perf_compressor: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
71 memorystatus_freeze_test: OTHER_LDFLAGS += -ldarwintest_utils
73 stackshot: OTHER_CFLAGS += -Wno-objc-messaging-id
74 stackshot: OTHER_LDFLAGS += -lkdd -framework Foundation
75 stackshot: INVALID_ARCHS = i386
77 telemetry: OTHER_LDFLAGS = -framework ktrace -framework CoreFoundation
78 telemetry: INVALID_ARCHS = i386
80 memorystatus_zone_test: INVALID_ARCHS = i386
81 memorystatus_zone_test: OTHER_CFLAGS += -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
82 memorystatus_zone_test: OTHER_LDFLAGS += -framework ktrace
83 memorystatus_zone_test: OTHER_LDFLAGS += -ldarwintest_utils
85 kpc: OTHER_LDFLAGS += -framework kperf
87 kperf: INVALID_ARCHS = i386
88 kperf: OTHER_CFLAGS += kperf_helpers.c
89 kperf: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace -ldarwintest_utils
91 kperf_backtracing: INVALID_ARCHS = i386
92 kperf_backtracing: OTHER_CFLAGS += kperf_helpers.c
93 kperf_backtracing: OTHER_LDFLAGS += -framework kperf -framework kperfdata -framework ktrace
94 kperf_backtracing: OTHER_LDFLAGS += -framework CoreSymbolication
96 kevent_qos: OTHER_CFLAGS += -Wno-unused-macros
97 kevent_qos: OTHER_CFLAGS += -I $(OBJROOT)/
99 mach_get_times: OTHER_LDFLAGS += -ldarwintest_utils
101 monotonic_core: OTHER_LDFLAGS += -framework ktrace
102 monotonic_core: INVALID_ARCHS = i386
104 perf_exit: perf_exit_proc
105 perf_exit: OTHER_LDFLAGS = -framework ktrace -ldarwintest_utils
106 perf_exit: INVALID_ARCHS = i386
107 perf_exit: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
109 perf_spawn_fork: CODE_SIGN_ENTITLEMENTS=./private_entitlement.plist
111 os_thread_self_restrict: os_thread_self_restrict.c os_thread_self_restrict-entitlements.plist
112 os_thread_self_restrict: CODE_SIGN_ENTITLEMENTS=os_thread_self_restrict-entitlements.plist
114 task_inspect: CODE_SIGN_ENTITLEMENTS = task_inspect.entitlements
115 task_inspect: OTHER_CFLAGS += -DENTITLED=1
117 turnstile_multihop: OTHER_CFLAGS += -Wno-unused-macros
118 turnstile_multihop: OTHER_CFLAGS += -I $(OBJROOT)/
120 CUSTOM_TARGETS += perf_exit_proc
123 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) perf_exit_proc.c -o $(SYMROOT)/perf_exit_proc
125 install-perf_exit_proc: perf_exit_proc
126 mkdir -p $(INSTALLDIR)
127 cp $(SYMROOT)/perf_exit_proc $(INSTALLDIR)/
129 perf_kdebug: INVALID_ARCHS = i386
131 stackshot_idle_25570396: INVALID_ARCHS = i386
132 stackshot_idle_25570396: OTHER_LDFLAGS += -lkdd -framework Foundation
134 stackshot_block_owner_14362384: INVALID_ARCHS = i386
135 stackshot_block_owner_14362384: OTHER_LDFLAGS += -framework Foundation -lpthread -lkdd
136 ifeq ($(PLATFORM),MacOSX)
137 stackshot_block_owner_14362384: OTHER_LDFLAGS += -lpcre
140 all: $(DSTROOT)/usr/local/bin/kcdata
142 $(DSTROOT)/usr/local/bin/kcdata: $(SRCROOT)/../tools/lldbmacros/kcdata.py
147 xnu_quick_test: OTHER_CFLAGS += xnu_quick_test_helpers.c
149 xnu_quick_test_entitled: CODE_SIGN_ENTITLEMENTS = xnu_quick_test.entitlements
151 CUSTOM_TARGETS += vm_set_max_addr_helper
153 vm_set_max_addr_helper: vm_set_max_addr_helper.c
154 $(CC) $(OTHER_CFLAGS) $(CFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) vm_set_max_addr_helper.c -o $(SYMROOT)/vm_set_max_addr_helper; \
155 echo $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@; \
156 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) $(CODESIGN) --force --sign - --timestamp=none $(SYMROOT)/$@;
158 install-vm_set_max_addr_helper: vm_set_max_addr_helper
159 mkdir -p $(INSTALLDIR)
160 cp $(SYMROOT)/vm_set_max_addr_helper $(INSTALLDIR)/
162 ifeq ($(PLATFORM),iPhoneOS)
163 OTHER_TEST_TARGETS += jumbo_va_spaces_28530648_unentitled
164 jumbo_va_spaces_28530648: CODE_SIGN_ENTITLEMENTS = jumbo_va_spaces_28530648.entitlements
165 jumbo_va_spaces_28530648: OTHER_CFLAGS += -DENTITLED=1
166 jumbo_va_spaces_28530648: OTHER_LDFLAGS += -ldarwintest_utils
168 jumbo_va_spaces_28530648_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
169 jumbo_va_spaces_28530648_unentitled: jumbo_va_spaces_28530648.c
170 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
173 task_info_28439149: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
175 proc_info: CODE_SIGN_ENTITLEMENTS = ./task_for_pid_entitlement.plist
176 proc_info: OTHER_LDFLAGS += -ldarwintest_utils
178 proc_info_list_kthreads: CODE_SIGN_ENTITLEMENTS = ./proc_info_list_kthreads.entitlements
180 disk_mount_conditioner: disk_mount_conditioner*
181 disk_mount_conditioner: CODE_SIGN_ENTITLEMENTS=./disk_mount_conditioner-entitlements.plist
182 disk_mount_conditioner: OTHER_LDFLAGS += -ldarwintest_utils
184 OTHER_TEST_TARGETS += disk_mount_conditioner_unentitled
185 disk_mount_conditioner_unentitled: OTHER_CFLAGS += -DTEST_UNENTITLED
186 disk_mount_conditioner_unentitled: OTHER_LDFLAGS += -ldarwintest_utils
187 disk_mount_conditioner_unentitled: disk_mount_conditioner.c
188 $(CC) $(DT_CFLAGS) $(OTHER_CFLAGS) $(CFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) $(LDFLAGS) $< -o $(SYMROOT)/$@
190 work_interval_test: CODE_SIGN_ENTITLEMENTS = work_interval_test.entitlements
191 work_interval_test: OTHER_CFLAGS += -DENTITLED=1
193 settimeofday_29193041: OTHER_CFLAGS += drop_priv.c
195 settimeofday_29193041_entitled: CODE_SIGN_ENTITLEMENTS = settimeofday_29193041.entitlements
196 settimeofday_29193041_entitled: OTHER_CFLAGS += drop_priv.c
198 thread_group_set_32261625: OTHER_LDFLAGS = -framework ktrace
199 thread_group_set_32261625: INVALID_ARCHS = i386
201 task_info: CODE_SIGN_ENTITLEMENTS = task_for_pid_entitlement.plist
203 socket_bind_35243417: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
204 socket_bind_35685803: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
206 net_tuntests: CODE_SIGN_ENTITLEMENTS = network_entitlements.plist
208 ifneq (osx,$(TARGET_NAME))
209 EXCLUDED_SOURCES += no32exec_35914211.c no32exec_35914211_helper.c
212 no32exec_35914211_helper: INVALID_ARCHS = x86_64
213 no32exec_35914211: INVALID_ARCHS = i386
215 MIG:=SDKROOT=$(SDKROOT) $(shell xcrun -sdk "$(TARGETSDK)" -find mig)
217 CUSTOM_TARGETS += excserver
221 -sheader $(OBJROOT)/excserver.h \
222 -server $(OBJROOT)/excserver.c \
223 -header /dev/null -user /dev/null \
227 exc_resource_threads: excserver
228 exc_resource_threads: OTHER_CFLAGS += $(OBJROOT)/excserver.c -I $(OBJROOT)
230 ifneq (osx,$(TARGET_NAME))
231 EXCLUDED_SOURCES += ldt_code32.s ldt.c
233 $(OBJROOT)/ldt_mach_exc_server.c:
236 -server $(OBJROOT)/ldt_mach_exc_server.c \
237 -header $(OBJROOT)/ldt_mach_exc.h \
240 ldt: INVALID_ARCHS = i386
241 ldt: $(OBJROOT)/ldt_mach_exc_server.c
242 ldt: OTHER_CFLAGS += -I $(OBJROOT) $(SRCROOT)/ldt_code32.s -Wl,-pagezero_size,0x1000
245 ifneq ($(PLATFORM),BridgeOS)
246 EXCLUDED_SOURCES += remote_time.c
248 remote_time: INVALID_ARCHS = armv7 armv7s arm64_32
251 vm_phys_footprint: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
252 vm_phys_footprint_legacy: legacy_footprint.entitlement
253 vm_phys_footprint_legacy: OTHER_LDFLAGS += -framework CoreFoundation -framework IOSurface
254 vm_phys_footprint_legacy: CODE_SIGN_ENTITLEMENTS=./legacy_footprint.entitlement
256 include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets