Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/argus/Makefile # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / argus / Makefile` 234 lines ยท 11145 bytes Raw Blame History 1 # ARGUS-0 defensive plane, in C. No outside library; hosted libc + pthreads 2 # only for tests and benchmarks (the library objects import no heap, I/O or clock). 3 # 4 # make build out/libargus.a 5 # make test every lane test (B event/fuzz/ring, D core/determinism, 6 # E detectors plain + UBSan) + the integration gates + the 7 # hostile review (lane G; exit code counts: nonzero only on an 8 # UNEXPECTED failure, EXPECTED-FAIL and N/A-v1 are reported) 9 # make bench ring push/pop bench (lane B) + real-core ingest bench 10 # make sanitize integration gates and hostile review under ASan+UBSan, the 11 # integration gates under TSan, the ring under TSan (lane B) 12 # and the detectors under ASan (lane E); Linux only 13 # make clean 14 # 15 # Lane makefiles are invoked as sub-makes, never included: they each define 16 # their own `clean`/`all` targets and their own OUT variables (lane D's default 17 # out-d sat outside out/ and would be read by the recursive secret-negative 18 # scan). Every lane's output is redirected under out/ from here; no lane .mk 19 # file is edited. 20 # 21 # macOS (Apple clang 17, macOS 26.6): the ASan and TSan runtimes hang at 22 # start-up, so there `make test` runs lane B's fuzz under UBSan only and 23 # `make sanitize` is Linux-only. 24 25 CC ?= cc 26 AR ?= ar 27 CFLAGS ?= -std=gnu11 -O2 -Wall -Wextra -Werror -fstack-protector-strong 28 OUT ?= out 29 UNAME_S := $(shell uname -s) 30 31 SANFLAGS_ASAN = -fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all -g 32 SANFLAGS_TSAN = -fsanitize=thread -fno-omit-frame-pointer -g 33 # TSan on Linux aarch64 needs ASLR off (same rule as lane_b.mk). 34 TSAN_RUN := $(shell [ "$$(uname -s)" = Linux ] && command -v setarch >/dev/null 2>&1 && echo setarch $$(uname -m) -R) 35 36 LIB_SRC = argus_event.c argus_ring.c argus_core.c argus_detect.c sha256.c 37 LIB_HDR = argus_abi.h argus_core.h argus_detect.h sha256.h 38 LIB_OBJ = $(OUT)/obj/argus_event.o $(OUT)/obj/argus_ring.o $(OUT)/obj/argus_core.o \ 39 $(OUT)/obj/argus_detect.o $(OUT)/obj/sha256.o 40 LIB = $(OUT)/libargus.a 41 42 # ---- ARGUS-1 lanes (docs/ARGUS1_PLAN.md) ------------------------------------ 43 # Lanes drop their files in without editing this Makefile. Every ARGUS-1 target is 44 # guarded by $(wildcard ...): until its sources exist it prints "skipped" and passes. 45 # Lane C: argus_contain.c/.h join libargus (and so the nm -u memory check, G7). 46 CONTAIN_SRC := $(wildcard argus_contain.c) 47 CONTAIN_HDR := $(wildcard argus_contain.h) 48 LIB_SRC += $(CONTAIN_SRC) 49 LIB_HDR += $(CONTAIN_HDR) 50 LIB_OBJ += $(patsubst %.c,$(OUT)/obj/%.o,$(CONTAIN_SRC)) 51 # Lane G gate (native/capability) + lane X bridge: never part of libargus (the 52 # hostile review links the archive alone and must not see any aienos_cap_* symbol). 53 CAP_DIR = ../capability 54 AUTH_SRC := $(wildcard $(CAP_DIR)/aienos_capability.c) 55 GATE_SRC := $(wildcard $(CAP_DIR)/aienos_contain.c) 56 BRIDGE_SRC := $(wildcard bridge/argus_aegis_bridge.c) 57 BRIDGE_HDR := $(wildcard bridge/argus_aegis_bridge.h $(CAP_DIR)/aienos_contain.h $(CAP_DIR)/aienos_capability.h) 58 # The full containment stack: present only when authority, gate and bridge all exist. 59 STACK_SRC := $(if $(and $(AUTH_SRC),$(GATE_SRC),$(BRIDGE_SRC)),$(BRIDGE_SRC) $(GATE_SRC) $(AUTH_SRC)) 60 STACK_INC = -I. -Itests -Ibridge -I$(CAP_DIR) 61 62 CONTAIN_TEST_SRC := $(wildcard tests/test_argus_contain.c) 63 E2E_SRC := $(wildcard tests/test_argus_containment_e2e.c) 64 CHOSTILE_SRC := $(wildcard tests/test_argus_contain_hostile.c) 65 CBENCH_SRC := $(wildcard tests/bench_argus_contain.c) 66 CONTAIN_TEST = $(OUT)/test_argus_contain 67 E2E = $(OUT)/test_argus_containment_e2e 68 CHOSTILE = $(OUT)/test_argus_contain_hostile 69 CBENCH = $(OUT)/bench_argus_contain 70 71 INT_SRC = tests/test_argus_integration.c tests/stub_state.c 72 INT_HDR = tests/stub_state.h 73 INT = $(OUT)/test_argus_integration 74 75 # Hostile review: links the library archive only. It must never link the 76 # capability authority (G-1: any aienos_cap_* reference would fail this link). 77 HOSTILE_SRC = tests/test_argus_hostile.c 78 HOSTILE = $(OUT)/test_argus_hostile 79 80 SUBMAKE_VARS = CC="$(CC)" CFLAGS="$(CFLAGS)" 81 ifeq ($(UNAME_S),Darwin) 82 LANE_B_SAN = SANFLAGS="-fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" 83 else 84 LANE_B_SAN = 85 endif 86 87 .PHONY: all lib test test-lanes test-integration test-hostile bench sanitize clean \ 88 test-argus1 test-contain test-e2e test-contain-hostile test-contain-fp bench-contain sanitize-argus1 89 90 all: lib 91 lib: $(LIB) 92 93 $(OUT)/obj: 94 mkdir -p $(OUT)/obj 95 96 $(OUT)/obj/%.o: %.c $(LIB_HDR) | $(OUT)/obj 97 $(CC) $(CFLAGS) -c -o $@ $< 98 99 $(LIB): $(LIB_OBJ) 100 rm -f $@ 101 $(AR) rcs $@ $(LIB_OBJ) 102 103 $(INT): $(INT_SRC) $(INT_HDR) $(LIB) 104 $(CC) $(CFLAGS) -I. -Itests -pthread -o $@ $(INT_SRC) $(LIB) 105 106 $(HOSTILE): $(HOSTILE_SRC) $(LIB) 107 $(CC) $(CFLAGS) -I. -o $@ $(HOSTILE_SRC) $(LIB) 108 109 $(OUT)/test_argus_hostile_asan: $(HOSTILE_SRC) $(LIB_SRC) $(LIB_HDR) | $(OUT)/obj 110 $(CC) $(CFLAGS) $(SANFLAGS_ASAN) -I. -o $@ $(HOSTILE_SRC) $(LIB_SRC) 111 112 $(OUT)/test_argus_integration_asan: $(INT_SRC) $(INT_HDR) $(LIB_SRC) $(LIB_HDR) | $(OUT)/obj 113 $(CC) $(CFLAGS) $(SANFLAGS_ASAN) -I. -Itests -pthread -o $@ $(INT_SRC) $(LIB_SRC) 114 115 $(OUT)/test_argus_integration_tsan: $(INT_SRC) $(INT_HDR) $(LIB_SRC) $(LIB_HDR) | $(OUT)/obj 116 $(CC) $(CFLAGS) $(SANFLAGS_TSAN) -I. -Itests -pthread -o $@ $(INT_SRC) $(LIB_SRC) 117 118 # ---- ARGUS-1 executables and targets (skipped until the lane's files exist) ---- 119 ifneq ($(CONTAIN_TEST_SRC),) 120 $(CONTAIN_TEST): $(CONTAIN_TEST_SRC) tests/stub_state.c $(INT_HDR) $(LIB) 121 $(CC) $(CFLAGS) -I. -Itests -o $@ $(CONTAIN_TEST_SRC) tests/stub_state.c $(LIB) 122 test-contain: $(CONTAIN_TEST) 123 ./$(CONTAIN_TEST) 124 else 125 test-contain: 126 @echo "test-contain: skipped (tests/test_argus_contain.c not present yet, lane C)" 127 endif 128 129 ifneq ($(and $(E2E_SRC),$(STACK_SRC)),) 130 $(E2E): $(E2E_SRC) $(STACK_SRC) $(BRIDGE_HDR) tests/stub_state.c $(INT_HDR) $(LIB) 131 $(CC) $(CFLAGS) $(STACK_INC) -pthread -o $@ $(E2E_SRC) $(STACK_SRC) tests/stub_state.c $(LIB) 132 test-e2e: $(E2E) 133 ./$(E2E) 134 else 135 test-e2e: 136 @echo "test-e2e: skipped (needs tests/test_argus_containment_e2e.c + bridge + gate, lanes X/G)" 137 endif 138 139 ifneq ($(and $(CHOSTILE_SRC),$(STACK_SRC)),) 140 $(CHOSTILE): $(CHOSTILE_SRC) $(STACK_SRC) $(BRIDGE_HDR) tests/stub_state.c $(INT_HDR) $(LIB) 141 $(CC) $(CFLAGS) $(STACK_INC) -pthread -o $@ $(CHOSTILE_SRC) $(STACK_SRC) tests/stub_state.c $(LIB) 142 test-contain-hostile: $(CHOSTILE) 143 ./$(CHOSTILE) 144 else 145 test-contain-hostile: 146 @echo "test-contain-hostile: skipped (needs tests/test_argus_contain_hostile.c + bridge + gate, lanes H/X/G)" 147 endif 148 149 # Bench (lane F): never part of `make test`. Lane F takes ~/workspace/.argus-bench.lock and 150 # refuses to start while ~/workspace/.spark-quiet exists. 151 ifneq ($(and $(CBENCH_SRC),$(STACK_SRC)),) 152 $(CBENCH): $(CBENCH_SRC) $(STACK_SRC) $(BRIDGE_HDR) tests/stub_state.c $(INT_HDR) $(LIB) 153 $(CC) $(CFLAGS) $(STACK_INC) -pthread -o $@ $(CBENCH_SRC) $(STACK_SRC) tests/stub_state.c $(LIB) 154 test-contain-fp: $(CBENCH) 155 ./$(CBENCH) --gate-only 156 bench-contain: $(CBENCH) 157 ./tests/run_argus1_bench.sh "./$(CBENCH)" contain "$(OUT)/test_argus_integration" "$(OUT)/lane_b" 158 else 159 test-contain-fp: 160 @echo "test-contain-fp: skipped (needs tests/bench_argus_contain.c + bridge + gate, lane F)" 161 bench-contain: 162 @echo "bench-contain: skipped (needs tests/bench_argus_contain.c + bridge + gate, lane F)" 163 endif 164 165 test-argus1: test-contain test-e2e test-contain-hostile test-contain-fp test-containment-authority test-contain-symbols 166 167 # The AEGIS gate tests live with the capability authority; keep them in the 168 # one ARGUS-1 regression command so G12 cannot silently omit the authority path. 169 test-containment-authority: 170 $(MAKE) -C ../capability test-contain 171 172 # G11/I4: low-level event/ring code and the authority must not depend upward on 173 # detection, containment, or the bridge. The gate has its own checks in the 174 # capability Makefile; this checks the other direction across the three objects. 175 test-contain-symbols: $(LIB) test-containment-authority 176 $(MAKE) -C ../capability out/aienos_capability.o 177 ./tests/check_argus1_symbols.sh $(OUT)/obj/argus_event.o $(OUT)/obj/argus_ring.o ../capability/out/aienos_capability.o 178 179 # Linux only (called from `sanitize`): lane C unit test under ASan+UBSan, e2e under 180 # ASan+UBSan and TSan, containment hostile under ASan+UBSan. Library sources are 181 # recompiled with the sanitizer, as for the ARGUS-0 integration binaries. 182 sanitize-argus1: 183 ifneq ($(CONTAIN_TEST_SRC),) 184 $(CC) $(CFLAGS) $(SANFLAGS_ASAN) -I. -Itests -o $(OUT)/test_argus_contain_asan $(CONTAIN_TEST_SRC) tests/stub_state.c $(LIB_SRC) 185 ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./$(OUT)/test_argus_contain_asan 186 endif 187 ifneq ($(and $(E2E_SRC),$(STACK_SRC)),) 188 $(CC) $(CFLAGS) $(SANFLAGS_ASAN) $(STACK_INC) -pthread -o $(OUT)/test_argus_containment_e2e_asan $(E2E_SRC) $(STACK_SRC) tests/stub_state.c $(LIB_SRC) 189 ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./$(OUT)/test_argus_containment_e2e_asan 190 $(CC) $(CFLAGS) $(SANFLAGS_TSAN) $(STACK_INC) -pthread -o $(OUT)/test_argus_containment_e2e_tsan $(E2E_SRC) $(STACK_SRC) tests/stub_state.c $(LIB_SRC) 191 TSAN_OPTIONS=halt_on_error=1 $(TSAN_RUN) ./$(OUT)/test_argus_containment_e2e_tsan 192 endif 193 ifneq ($(and $(CHOSTILE_SRC),$(STACK_SRC)),) 194 $(CC) $(CFLAGS) $(SANFLAGS_ASAN) $(STACK_INC) -pthread -o $(OUT)/test_argus_contain_hostile_asan $(CHOSTILE_SRC) $(STACK_SRC) tests/stub_state.c $(LIB_SRC) 195 ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./$(OUT)/test_argus_contain_hostile_asan 196 endif 197 $(MAKE) -C ../capability sanitize 198 @echo "sanitize-argus1: done (targets whose sources are absent were skipped)" 199 200 test: test-lanes test-integration test-hostile test-argus1 201 202 test-lanes: 203 $(MAKE) -f lane_b.mk $(SUBMAKE_VARS) $(LANE_B_SAN) LANE_B_OUT=$(OUT)/lane_b test-event fuzz-event test-ring 204 $(MAKE) -f lane_d.mk $(SUBMAKE_VARS) OUT=$(OUT)/lane_d test-core test-determinism 205 $(MAKE) -f lane_e.mk $(SUBMAKE_VARS) OUT=$(OUT)/lane_e test-detect 206 207 test-integration: $(INT) 208 ./$(INT) $(LIB_OBJ) 209 210 test-hostile: $(HOSTILE) 211 ./$(HOSTILE) 212 213 bench: $(INT) $(CBENCH) 214 ./tests/run_argus1_bench.sh "./$(CBENCH)" full "$(OUT)/test_argus_integration" "$(OUT)/lane_b" 215 216 ifeq ($(UNAME_S),Darwin) 217 sanitize: 218 @echo "sanitize: skipped on macOS (ASan/TSan runtimes hang at start-up); run on Linux" 219 else 220 sanitize: $(OUT)/test_argus_integration_asan $(OUT)/test_argus_integration_tsan $(OUT)/test_argus_hostile_asan $(LIB) 221 ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \ 222 ./$(OUT)/test_argus_integration_asan $(LIB_OBJ) 223 ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \ 224 ./$(OUT)/test_argus_hostile_asan 225 TSAN_OPTIONS=halt_on_error=1 $(TSAN_RUN) ./$(OUT)/test_argus_integration_tsan $(LIB_OBJ) 226 $(MAKE) -f lane_b.mk $(SUBMAKE_VARS) LANE_B_OUT=$(OUT)/lane_b test-ring-tsan 227 $(MAKE) -f lane_e.mk $(SUBMAKE_VARS) OUT=$(OUT)/lane_e test-detect-asan 228 $(MAKE) sanitize-argus1 229 endif 230 231 clean: 232 rm -rf $(OUT) 233 234 .PHONY: test-argus1 test-containment-authority test-contain-symbols sanitize-argus1