Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
675 lines (614 loc) · 24.7 KB
/
Copy pathMakefile
File metadata and controls
675 lines (614 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
# cppgm starter makefile
include scripts/test_run_id.mk
GNUMAKE = $(firstword $(wildcard /opt/homebrew/opt/make/libexec/gnubin/make /usr/local/opt/make/libexec/gnubin/make))
ifneq ($(GNUMAKE),)
MAKE := $(GNUMAKE)
endif
DEFAULT_BUILD_JOBS = $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
HOST_UNAME_S = $(shell uname -s)
ifeq ($(findstring -j,$(MAKEFLAGS)),)
MAKEFLAGS += -j$(DEFAULT_BUILD_JOBS)
endif
ifeq ($(MAKELEVEL),0)
CPPGM_MAKE_JOB_FLAGS := $(filter -j% --jobs=%,$(MAKEFLAGS))
CPPGM_MAKE_JOB_LIMIT := $(patsubst --jobs=%,%,$(patsubst -j%,%,$(lastword $(CPPGM_MAKE_JOB_FLAGS))))
ifneq ($(CPPGM_MAKE_JOB_LIMIT),)
CPPGM_MAKE_LOW_JOB_LIMIT = $(shell \
limit='$(CPPGM_MAKE_JOB_LIMIT)'; cpus='$(DEFAULT_BUILD_JOBS)'; \
if [ "$$limit" -gt 0 ] 2>/dev/null && [ "$$cpus" -gt "$$limit" ] 2>/dev/null; then echo 1; else echo 0; fi)
ifeq ($(CPPGM_MAKE_LOW_JOB_LIMIT),1)
ifeq ($(filter test-report%,$(MAKECMDGOALS)),)
$(warning make is limited to -j$(CPPGM_MAKE_JOB_LIMIT) on a $(DEFAULT_BUILD_JOBS)-core machine; large compiler builds, especially self-host and PA35/inception builds, will be very slow. Omit -j or use -j$(DEFAULT_BUILD_JOBS).)
endif
endif
endif
endif
MAKEFLAGS += --no-print-directory
LLVM_CXX_LOCAL = /usr/local/opt/llvm/bin/clang++
LLVM_CXX_HOMEBREW = /opt/homebrew/opt/llvm/bin/clang++
ifeq ($(HOST_UNAME_S),Darwin)
ifeq ($(wildcard $(LLVM_CXX_LOCAL)),)
ifneq ($(wildcard $(LLVM_CXX_HOMEBREW)),)
LLVM_CXX_DEFAULT = $(LLVM_CXX_HOMEBREW)
endif
else
LLVM_CXX_DEFAULT = $(LLVM_CXX_LOCAL)
endif
ifdef LLVM_CXX_DEFAULT
HOST_CXX_DEFAULT = $(LLVM_CXX_DEFAULT)
else
HOST_CXX_DEFAULT = clang++
endif
else
HOST_CXX_DEFAULT = g++
endif
ifeq ($(origin CXX), default)
CXX := $(HOST_CXX_DEFAULT)
endif
export CXX
export CPPGM_STDLIB_FLAGS ?=
ifeq ($(origin CPPGM_HOST_CXX), undefined)
CPPGM_HOST_CXX := $(CXX)
endif
export CPPGM_HOST_CXX
export CPPGM_TEST_RUNNER ?= 1
export CPPGM_TEXT_TEST_TIMEOUT_SEC ?= 10
export CPPGM_BUILD_TEST_TIMEOUT_SEC ?= 30
export CPPGM_PROGRAM_TEST_TIMEOUT_SEC ?= 10
DEBUGINFO_TEST_PAS ?= pa8 pa33 pa34
ALL_PAS = $(patsubst %/Makefile,%,$(wildcard pa*/Makefile))
EXPERIMENTAL_PAS ?= pa35 pa36 pa38 pa39 pa40
PAS = $(filter-out $(EXPERIMENTAL_PAS),$(ALL_PAS))
SORTED_PAS = $(shell printf '%s\n' $(PAS) | sort -t a -k 2,2n)
TEST_REPORT_PAS ?= $(SORTED_PAS)
ACTIVE_TEST_REPORT_PAS ?= $(TEST_REPORT_PAS)
# Start the expensive backends first; display order still follows ACTIVE_TEST_REPORT_PAS.
TEST_REPORT_SCHEDULE_PAS = $(foreach pa,pa37 pa34 pa33,$(filter $(pa),$(ACTIVE_TEST_REPORT_PAS))) $(filter-out pa37 pa34 pa33,$(ACTIVE_TEST_REPORT_PAS))
REF_TEST_PAS ?= $(SORTED_PAS)
# One assignment at a time gets the whole machine: there is nothing else to
# share it with, unlike test-report where assignments run side by side.
SINGLE_ASSIGNMENT_SUBTEST_JOBS ?= $(DEFAULT_BUILD_JOBS)
DEV_BUILD_LOCK = obj/.dev-build.lock
# Assignment costs are heavily skewed: the largest is many seconds of work at
# two workers while most finish in well under a second. Two workers per
# assignment leaves the machine idle waiting on the few big ones once the short
# ones drain, so scale the per-assignment width with the core count instead.
# The cap keeps assignments x subtests within the core count (see
# TEST_REPORT_ASSIGNMENT_JOBS below), and the floor of 2 preserves the previous
# behaviour on small hosts.
TEST_REPORT_SUBTEST_JOBS ?= $(shell jobs=$$(( $(DEFAULT_BUILD_JOBS) / 8 )); if [ "$$jobs" -lt 2 ]; then jobs=2; fi; if [ "$$jobs" -gt 8 ]; then jobs=8; fi; echo $$jobs)
TEST_REPORT_ASSIGNMENT_JOBS ?= $(shell subjobs=$(TEST_REPORT_SUBTEST_JOBS); if [ -z "$$subjobs" ] || [ "$$subjobs" -lt 1 ] 2>/dev/null; then subjobs=1; fi; jobs=$$(( $(DEFAULT_BUILD_JOBS) / $$subjobs )); if [ "$$jobs" -lt 1 ]; then jobs=1; fi; echo $$jobs)
TEST_REPORT_BUILD_TIMEOUT_SEC ?= 60
ORDERED ?= true
SUBMAKE_OBJ_ARG = $(if $(strip $(OBJ)),OBJ=$(OBJ))
SUBMAKE_GENERATED_ARG = $(if $(strip $(GENERATED)),GENERATED=$(GENERATED))
SUBMAKE_CC_FLAGS_ARG = $(if $(strip $(CC_FLAGS)),CC_FLAGS="$(CC_FLAGS)")
.PHONY: all build build-telemetry-off test test-telemetry-off audit-student-documents audit-cwg-references audit-lowir-contract audit-compiler-layout audit-compiler-exceptions audit-frontend-source-sets audit-builtin-registry-tables audit-scaffold-usage audit-scaffold-spellings audit-ir-expectations audit-clang-format ref-test ref-test-debuginfo \
test-debuginfo test-debuginfo-nobuild \
test-wasm-inception test-wasm-inception-nobuild \
test-target-features test-target-features-nobuild \
require-clang require-clang-libcxx asan-build test-cells \
test-report inception clean run-cppgm run-cppgm-nobuild \
test-report-nobuild test-report-through-% test-report-through-%-nobuild \
ref-test-% \
test-% \
$(ALL_PAS)
.NOTPARALLEL: ref-test ref-test-debuginfo
all: build
# Optional maintainer lane; dependencies and frozen results are described in
# scripts/experimental/README.md. This is independent of the student report.
test-wasm-inception: build
@$(MAKE) test-wasm-inception-nobuild WASM_INCEPTION_ARGS='$(WASM_INCEPTION_ARGS)'
test-wasm-inception-nobuild:
python3 scripts/experimental/run_inception.py $(WASM_INCEPTION_ARGS)
audit-student-documents:
@perl scripts/audit_student_documents.pl
audit-cwg-references:
@python3 scripts/audit_cwg_references.py
audit-lowir-contract:
@perl scripts/audit_lowir_contract.pl
audit-compiler-layout:
@perl scripts/audit_compiler_layout.pl
audit-compiler-exceptions:
@perl scripts/audit_compiler_exceptions.pl $(if $(filter 1,$(CPPGM_REPORT_QUIET)),--quiet)
audit-frontend-source-sets:
@perl scripts/audit_frontend_source_sets.pl
audit-builtin-registry-tables:
@perl scripts/audit_builtin_registry_tables.pl
# Reads the build's dependency files (the build's OBJ is relative to dev/),
# so it builds the tools first.
audit-scaffold-usage: build
@perl scripts/audit_scaffold_usage.pl --deps $(if $(strip $(OBJ)),$(if $(filter /%,$(OBJ)),$(OBJ),dev/$(OBJ)),obj)/dev/.d
audit-scaffold-spellings:
@perl scripts/audit_scaffold_spellings.pl
# Compiles the behavior fixtures with the reference backend, so it builds the
# tools first.
audit-ir-expectations: build
@perl scripts/audit_ir_expectations.pl --backend dev/lowir2native-ref
# The C++ sources under dev/ and scripts/ follow .clang-format (clang-format
# 19 or newer; CI installs 21.1.8; CLANG_FORMAT selects the binary).
audit-clang-format:
@perl scripts/audit_clang_format.pl
build:
@mkdir -p obj
@lockdir=$(DEV_BUILD_LOCK); \
while ! mkdir $$lockdir 2>/dev/null; do sleep 1; done; \
output=$$(mktemp); \
trap 'rm -f "$$output"; rmdir "$$lockdir" 2>/dev/null || true' EXIT HUP INT TERM; \
if [ "$(CPPGM_REPORT_QUIET)" = "1" ]; then \
$(MAKE) -s -C dev all > "$$output" 2>&1; status=$$?; \
if [ "$$status" -ne 0 ]; then cat "$$output"; fi; \
exit "$$status"; \
else \
$(MAKE) -s -C dev all; \
fi
build-telemetry-off:
@mkdir -p obj
@lockdir=$(DEV_BUILD_LOCK); \
while ! mkdir $$lockdir 2>/dev/null; do sleep 1; done; \
trap 'rmdir "$$lockdir" 2>/dev/null || true' EXIT HUP INT TERM; \
$(MAKE) -s -C dev cppgm-telemetry-off
test-telemetry-off: build build-telemetry-off
@python3 scripts/tests/test_telemetry_off_build.py \
dev/cppgm dev/cppgm-telemetry-off
test: build
@for dir in $(SORTED_PAS); do \
echo "===== $$dir ====="; \
$(MAKE) -C $$dir \
CXX=$(CXX) \
CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) \
CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) \
$(SUBMAKE_GENERATED_ARG) \
$(SUBMAKE_CC_FLAGS_ARG) \
CPPGM_SKIP_DEV_REBUILD=1 test || exit 1; \
done
@echo "===== ALL TESTS PASSED SUCCESSFULLY! ====="
ref-test:
@for dir in $(REF_TEST_PAS); do \
echo "===== $$dir (ref-test) ====="; \
$(MAKE) -C $$dir \
CXX=$(CXX) \
CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) \
CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) \
$(SUBMAKE_GENERATED_ARG) \
$(SUBMAKE_CC_FLAGS_ARG) \
ref-test || exit 1; \
done
@echo "===== ALL REFS REGENERATED SUCCESSFULLY! ====="
ref-test-debuginfo:
@if [ -z "$(strip $(DEBUGINFO_TEST_PAS))" ]; then \
echo "No debuginfo assignments configured"; \
exit 0; \
fi
@for dir in $(DEBUGINFO_TEST_PAS); do \
echo "===== $$dir (ref-test-debuginfo) ====="; \
$(MAKE) -C $$dir \
CXX=$(CXX) \
CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) \
CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) \
$(SUBMAKE_GENERATED_ARG) \
$(SUBMAKE_CC_FLAGS_ARG) \
ref-test-debuginfo || exit 1; \
done
@echo "===== ALL DEBUGINFO REFS REGENERATED SUCCESSFULLY! ====="
test-debuginfo: build
@$(MAKE) test-debuginfo-nobuild \
DEBUGINFO_TEST_PAS='$(DEBUGINFO_TEST_PAS)'
test-debuginfo-nobuild:
@if [ -z "$(strip $(DEBUGINFO_TEST_PAS))" ]; then \
echo "===== NO DEBUG-INFO TESTS CONFIGURED ====="; \
exit 0; \
fi
@status=0; failed=""; \
for dir in $(DEBUGINFO_TEST_PAS); do \
echo "===== $$dir (debug info) ====="; \
$(MAKE) -C $$dir \
CXX=$(CXX) \
CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) \
CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) \
$(SUBMAKE_GENERATED_ARG) \
$(SUBMAKE_CC_FLAGS_ARG) \
CPPGM_SKIP_DEV_REBUILD=1 test-debuginfo || { status=1; failed="$$failed $$dir"; }; \
done; \
if [ $$status -ne 0 ]; then \
echo "===== DEBUG-INFO TESTS FAILED IN:$${failed} ====="; \
exit $$status; \
fi; \
echo "===== DEBUG-INFO TESTS PASSED SUCCESSFULLY! ====="
# Optional language and target extensions stay separate from the course report.
test-target-features: build
@$(MAKE) test-target-features-nobuild
test-target-features-nobuild:
@$(MAKE) -C pa30 CXX=$(CXX) CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) $(SUBMAKE_GENERATED_ARG) $(SUBMAKE_CC_FLAGS_ARG) \
CPPGM_SKIP_DEV_REBUILD=1 test-target-features
inception: build
@$(MAKE) -C pa35 \
CXX=../dev/cppgm \
CPPGM_HOST_CXX="$(CPPGM_HOST_CXX)" \
CPPGM_STDLIB_FLAGS="$(CPPGM_STDLIB_FLAGS)" \
compare-cppgm-inception
# Toolchain cells. Each supported (host compiler, standard library) pair keeps
# its own object roots, so switching cells relinks the tools in dev/ but does
# not throw away the objects the other cell compiled. Prefix any target to run
# it in a cell, for example `make with-clang-test-report-through-pa34` or
# `make with-clang-libcxx-inception`. The supported cells are the default
# g++/libstdc++, clang/libstdc++, and clang/libc++; g++ with libc++ is not
# supported and has no cell.
CLANG_CXX ?= clang++
CLANG_CELL_OBJ ?= obj-clang
CLANG_LIBCXX_CELL_OBJ ?= obj-clang-libcxx
# Every cell in one command. Each is a lane in its own right -- prefixing any
# target runs it in one cell -- but a single command that walks all three is
# what makes "does this change hold everywhere" one thing to type. It keeps
# going after a failing cell and names which ones failed at the end, because
# the useful answer is the whole set, not the first one to break.
test-cells:
@status=0; failed=""; \
for cell in default clang clang-libcxx; do \
echo "===== cell: $$cell ====="; \
case $$cell in \
default) target=test-report-through-pa34 ;; \
*) target=with-$$cell-test-report-through-pa34 ;; \
esac; \
$(MAKE) $$target || { status=1; failed="$$failed $$cell"; }; \
done; \
if [ $$status -ne 0 ]; then \
echo "===== failing cells:$$failed"; \
else \
echo "===== all cells passed"; \
fi; \
exit $$status
# The harness unit tests: the comparison, the workers, the audits and the
# export, each a self-contained python unittest file under scripts/tests.
HARNESS_TESTS = \
scripts/tests/test_wasi_heap.py \
scripts/tests/test_wasi_export.py \
scripts/tests/test_release_source.py \
scripts/tests/test_package_release.py \
scripts/tests/test_wasm_check_cache.py \
scripts/tests/test_wasm_checker.py \
scripts/tests/test_wasm_module.py \
scripts/tests/test_wasm_quality.py \
scripts/tests/test_native_source_lto.py \
scripts/tests/test_wasi_inception.py \
scripts/tests/test_wasm_generators.py \
scripts/tests/test_machine_boundary.py \
scripts/tests/test_wasm_benchmarks.py \
scripts/tests/test_wasm_selfbuild_benchmarks.py \
scripts/tests/test_benchmark_report.py \
scripts/tests/test_benchmark_freshness.py \
scripts/tests/test_benchmark_publication.py \
scripts/tests/test_internal_cpp_benchmarks.py \
scripts/tests/test_intel_benchmarks.py \
scripts/tests/test_simdjson_ci.py \
scripts/tests/test_godot_ci.py \
scripts/tests/test_llvm_ci.py \
scripts/tests/test_index_cpp_ci.py \
scripts/tests/test_index_cpp_benchmarks.py \
scripts/tests/test_boost_ci.py \
scripts/tests/test_boost_benchmarks.py \
scripts/tests/test_public_benchmarks.py \
scripts/tests/test_library_benchmark_badges.py \
scripts/tests/test_internal_test_badges.py \
scripts/tests/test_audit_pa_feature_placement.py \
scripts/tests/test_cwg_html_text.py \
scripts/tests/test_batch_timeout_harness.py \
scripts/tests/test_command_resources.py \
scripts/tests/test_check_controls.py \
scripts/tests/test_audit_ir_expectations.py \
scripts/tests/test_check_object_expectations.py \
scripts/tests/test_compare_lowir_results.py \
scripts/tests/test_lowir_finalizer_contract.py \
scripts/tests/test_lowir_emission_contract.py \
scripts/tests/test_lowir_function_bindings.py \
scripts/tests/test_compare_results_common.py \
scripts/tests/test_cppgm_cmake_wrapper.py \
scripts/tests/test_dev_makefile_obj_isolation.py \
scripts/tests/test_host_headers.py \
scripts/tests/test_lowir_library_extensions.py \
scripts/tests/test_lowir_library_records.py \
scripts/tests/test_warning_policy.py \
scripts/tests/test_test_platform.py \
scripts/tests/test_dump_host_eh_object_facts_pl.py \
scripts/tests/test_exported_dev_makefile.py \
scripts/tests/test_lowir_library_export.py \
scripts/tests/test_fixture_lanes.py \
scripts/tests/test_language_references.py \
scripts/tests/test_lowir_program_harness.py \
scripts/tests/test_cppgm_file_audit.py \
scripts/tests/test_machine_object_host_eh_roundtrip.py \
scripts/tests/test_pa24_mir_modes.py \
scripts/tests/test_pa34_course.py \
scripts/tests/test_optimization_quality.py \
scripts/tests/test_pa36_harness.py \
scripts/tests/test_pending_audit_regressions.py \
scripts/tests/test_report_elf_code_shape.py \
scripts/tests/test_scaffold_audits.py \
scripts/tests/test_test_report_output.py \
scripts/tests/test_report_isolation.py \
scripts/tests/test_run_ab_compile_benchmark.py \
scripts/tests/test_upstream_dg.py \
scripts/tests/test_upstream_dg_campaign.py \
scripts/tests/test_upstream_language_outcomes.py \
scripts/tests/test_c_conformance.py \
scripts/tests/test_upstream_clang_lit_metadata.py \
scripts/tests/test_upstream_clang_language.py \
scripts/tests/test_cxx11_ci_suite.py \
scripts/tests/test_gcc_cxx11_ci_manifest.py \
scripts/tests/test_build_clang_cxx11_ci_manifest.py \
scripts/tests/test_validate_perf_regression.py
test-harness:
@set -e; for test in $(HARNESS_TESTS); do echo "== $$test"; env -u CPPGM_TEST_RUN_ID python3 $$test; done
# GNU make prefers the pattern rule that yields the shortest stem, so
# `with-clang-libcxx-<target>` selects the libc++ cell rather than the
# libstdc++ one with a `libcxx-` prefixed stem.
with-clang-%: require-clang
@$(MAKE) $* \
CXX=$(CLANG_CXX) \
CPPGM_HOST_CXX=$(CLANG_CXX) \
OBJ=$(CLANG_CELL_OBJ) \
INCEPTION_OBJ_ROOT_BASE=../$(CLANG_CELL_OBJ)/pa35
with-clang-libcxx-%: require-clang-libcxx
@$(MAKE) $* \
CXX=$(CLANG_CXX) \
CPPGM_HOST_CXX=$(CLANG_CXX) \
CPPGM_STDLIB_FLAGS=-stdlib=libc++ \
OBJ=$(CLANG_LIBCXX_CELL_OBJ) \
INCEPTION_OBJ_ROOT_BASE=../$(CLANG_LIBCXX_CELL_OBJ)/pa35
# A sanitizer build of the compiler itself. The bug class this catches -- a
# reference into a container that a nested analysis then grows -- is invisible
# to the ordinary lanes, because whether it corrupts anything depends on
# allocator behaviour: the same source passed under g++ and failed under
# clang++. ASan reports it deterministically under either. Build it, then run
# the compiler by hand on the input under suspicion.
ASAN_CELL_OBJ ?= obj-asan
ASAN_CC_FLAGS ?= -std=gnu++11 -O1 -g -fno-omit-frame-pointer -fsanitize=address
asan-build: require-clang
@$(MAKE) -C dev cppgm \
CXX=$(CLANG_CXX) \
CPPGM_HOST_CXX=$(CLANG_CXX) \
OBJ=../$(ASAN_CELL_OBJ) \
CC_FLAGS="$(ASAN_CC_FLAGS)"
require-clang:
@command -v $(CLANG_CXX) >/dev/null 2>&1 || { \
echo "$(CLANG_CXX) not found; set CLANG_CXX to the clang++ to use" >&2; \
exit 1; }
require-clang-libcxx: require-clang
@printf '#include <version>\nint main() { return 0; }\n' > obj/.libcxx-probe.cpp 2>/dev/null || \
{ mkdir -p obj && printf '#include <version>\nint main() { return 0; }\n' > obj/.libcxx-probe.cpp; }
@$(CLANG_CXX) -std=gnu++11 -stdlib=libc++ -fsyntax-only obj/.libcxx-probe.cpp 2>/dev/null || { \
echo "$(CLANG_CXX) cannot compile against libc++; install libc++-dev and libc++abi-dev" >&2; \
rm -f obj/.libcxx-probe.cpp; exit 1; }
@rm -f obj/.libcxx-probe.cpp
test-report test-report-through-% test-report-nobuild: CPPGM_REPORT_QUIET=1
test-report: build
@$(MAKE) test-report-nobuild \
ACTIVE_TEST_REPORT_PAS='$(ACTIVE_TEST_REPORT_PAS)' \
TEST_REPORT_ASSIGNMENT_JOBS='$(TEST_REPORT_ASSIGNMENT_JOBS)' \
TEST_REPORT_SUBTEST_JOBS='$(TEST_REPORT_SUBTEST_JOBS)' \
ORDERED='$(ORDERED)'
test-report-through-%-nobuild:
@target='$*'; \
max=$${target#pa}; \
pas=''; \
for dir in $(SORTED_PAS); do \
num=$${dir#pa}; \
if [ "$$num" -le "$$max" ]; then \
pas="$$pas $$dir"; \
fi; \
done; \
$(MAKE) test-report-nobuild \
ACTIVE_TEST_REPORT_PAS="$$pas" \
TEST_REPORT_ASSIGNMENT_JOBS='$(TEST_REPORT_ASSIGNMENT_JOBS)' \
TEST_REPORT_SUBTEST_JOBS='$(TEST_REPORT_SUBTEST_JOBS)' \
ORDERED='$(ORDERED)'
test-report-through-%: build
@target='$*'; \
max=$${target#pa}; \
pas=''; \
for dir in $(SORTED_PAS); do \
num=$${dir#pa}; \
if [ "$$num" -le "$$max" ]; then \
pas="$$pas $$dir"; \
fi; \
done; \
$(MAKE) test-report-nobuild \
ACTIVE_TEST_REPORT_PAS="$$pas" \
TEST_REPORT_ASSIGNMENT_JOBS='$(TEST_REPORT_ASSIGNMENT_JOBS)' \
TEST_REPORT_SUBTEST_JOBS='$(TEST_REPORT_SUBTEST_JOBS)' \
ORDERED='$(ORDERED)'
# Each assignment's suite runs with make -i: a failing lane is recorded from
# make's "(ignored)" error line instead of stopping the lanes after it, so
# the report shows every failure, not only the first of each recipe.
test-report-nobuild: audit-compiler-exceptions
@export KEEP_GOING=1; \
export CPPGM_REPORT_QUIET=1; \
if [ "$(CPPGM_TEST_RUNNER)" = "1" ]; then \
export CPPGM_BATCH_TESTS=1; \
export WRAPPED_BATCH_STDIN=1; \
else \
unset CPPGM_BATCH_TESTS; \
unset WRAPPED_BATCH_STDIN; \
fi; \
export CPPGM_TEST_JOBS=$(TEST_REPORT_SUBTEST_JOBS); \
export CPPGM_BUILD_TEST_TIMEOUT_SEC=$(TEST_REPORT_BUILD_TIMEOUT_SEC); \
ordered="$(ORDERED)"; \
tmpdir=$$(mktemp -d); \
parent_counts_file="$${CPPGM_TEST_COUNTS_FILE-}"; \
export CPPGM_TEST_COUNTS_FILE="$$tmpdir/counts"; \
export CPPGM_TEST_SKIPS_FILE="$$tmpdir/skips"; \
cleanup() { rm -f pa*/"$$CPPGM_TEST_FAILURE_MARKER"; rm -rf "$$tmpdir"; }; \
interrupt() { \
if [ -n "$$output_pid" ]; then \
kill -TERM "$$output_pid" 2>/dev/null || true; \
wait "$$output_pid" 2>/dev/null || true; \
fi; \
if [ -n "$$xargs_pid" ]; then \
pkill -TERM -P "$$xargs_pid" 2>/dev/null || true; \
kill -TERM "$$xargs_pid" 2>/dev/null || true; \
wait "$$xargs_pid" 2>/dev/null || true; \
fi; \
cleanup; \
exit 130; \
}; \
trap 'cleanup' EXIT; \
trap 'interrupt' INT TERM; \
rm -f pa*/"$$CPPGM_TEST_FAILURE_MARKER"; \
printf '%s\n' $(TEST_REPORT_SCHEDULE_PAS) > "$$tmpdir/pas.list"; \
xargs -P$(TEST_REPORT_ASSIGNMENT_JOBS) -I{} /bin/bash -c '\
dir="$$1"; \
echo "===== $$dir =====" > "$$2/$$dir.out"; \
status=0; \
env MAKEFLAGS= $(MAKE) --no-print-directory -j1 -i -C "$$dir" \
CXX="$$CXX" \
CPPGM_HOST_CXX="$$CPPGM_HOST_CXX" \
CPPGM_PROGRESS_FILE="$$2/$$dir.progress" \
CPPGM_STDLIB_FLAGS="$$CPPGM_STDLIB_FLAGS" \
CPPGM_TEST_RUNNER="$$CPPGM_TEST_RUNNER" \
CPPGM_TEST_JOBS="$$CPPGM_TEST_JOBS" \
$(if $(strip $(OBJ)),OBJ="$(OBJ)") \
$(if $(strip $(GENERATED)),GENERATED="$(GENERATED)") \
$(if $(strip $(CC_FLAGS)),CC_FLAGS="$(CC_FLAGS)") \
CPPGM_SKIP_DEV_REBUILD=1 \
test >> "$$2/$$dir.out" 2>&1 || status=$$?; \
if [ "$$dir" = pa11 ] && [ -d "$$dir/tests/general" ]; then \
if ! $(MAKE) -s -C "$$dir" test-seams > "$$2/$$dir.seams" 2>&1; then \
cat "$$2/$$dir.seams" >> "$$2/$$dir.out"; \
status=1; \
fi; \
fi; \
if grep -q "\] Error [0-9][0-9]* (ignored)" "$$2/$$dir.out"; then status=1; fi; \
printf "%s\n" "$$status" > "$$2/$$dir.status"; \
: > "$$2/$$dir.done"; \
exit "$$status"' _ {} "$$tmpdir" < "$$tmpdir/pas.list" & \
xargs_pid=$$!; \
emit_completed_output() { \
dir="$$1"; \
if [ -f "$$tmpdir/$$dir.out" ] && [ ! -f "$$tmpdir/$$dir.printed" ]; then \
if [ ! -f "$$tmpdir/$$dir.status" ] || \
[ "$$(cat "$$tmpdir/$$dir.status")" -ne 0 ] || \
[ -f "$$dir/$$CPPGM_TEST_FAILURE_MARKER" ]; then \
cat "$$tmpdir/$$dir.out"; \
fi; \
: > "$$tmpdir/$$dir.printed"; \
fi; \
}; \
stream_completed_outputs() { \
while kill -0 "$$xargs_pid" 2>/dev/null; do \
sleep 1; \
for dir in $(ACTIVE_TEST_REPORT_PAS); do \
if [ -f "$$tmpdir/$$dir.done" ]; then \
emit_completed_output "$$dir"; \
fi; \
done; \
done; \
for dir in $(ACTIVE_TEST_REPORT_PAS); do \
emit_completed_output "$$dir"; \
done; \
}; \
if [ "$$ordered" = "false" ]; then \
stream_completed_outputs & \
output_pid=$$!; \
fi; \
wait "$$xargs_pid"; \
xargs_status=$$?; \
if [ -n "$$output_pid" ]; then \
kill -TERM "$$output_pid" 2>/dev/null || true; \
wait "$$output_pid" 2>/dev/null || true; \
fi; \
for dir in $(ACTIVE_TEST_REPORT_PAS); do \
emit_completed_output "$$dir"; \
done; \
passed=$$(awk '{s+=$$1} END {print s}' "$$CPPGM_TEST_COUNTS_FILE" 2>/dev/null || echo 0); \
total=$$(awk '{s+=$$2} END {print s}' "$$CPPGM_TEST_COUNTS_FILE" 2>/dev/null || echo 0); \
if [ -n "$$parent_counts_file" ]; then \
printf '%s %s\n' "$$passed" "$$total" >> "$$parent_counts_file"; \
fi; \
if [ -s "$$CPPGM_TEST_SKIPS_FILE" ]; then \
perl scripts/test_platform.pl --summary "$$CPPGM_TEST_SKIPS_FILE"; \
fi; \
if [ "$$passed" -ne "$$total" ] || ls pa*/"$$CPPGM_TEST_FAILURE_MARKER" 1>/dev/null 2>&1; then \
echo "===== TEST SUMMARY: $$passed / $$total TESTS PASSED ====="; \
exit 1; \
elif [ "$$xargs_status" -ne 0 ]; then \
echo "===== TEST SUMMARY: $$passed / $$total TESTS PASSED ====="; \
exit "$$xargs_status"; \
else \
echo "===== ALL TESTS PASSED SUCCESSFULLY! ($$passed / $$total) ====="; \
fi
run-cppgm:
@if [ -z "$(strip $(CPPGM_ARGS))" ]; then \
echo "usage: make run-cppgm CPPGM_ARGS='...'" >&2; \
exit 2; \
fi
@$(MAKE) build
@$(MAKE) run-cppgm-nobuild CPPGM_ARGS='$(CPPGM_ARGS)'
run-cppgm-nobuild:
@if [ -z "$(strip $(CPPGM_ARGS))" ]; then \
echo "usage: make run-cppgm-nobuild CPPGM_ARGS='...'" >&2; \
exit 2; \
fi
@./dev/cppgm $(CPPGM_ARGS)
clean:
-$(MAKE) -C dev clean
@for dir in $(sort $(ALL_PAS)); do \
$(MAKE) -C $$dir clean || exit 1; \
done
-rm -f pa*/.test_failed* .test_counts*
-rmdir $(DEV_BUILD_LOCK) 2>/dev/null || true
$(ALL_PAS):
@$(MAKE) test-$@
ref-test-%:
@if [ ! -f "$*/Makefile" ]; then \
echo "unknown assignment: $*" >&2; \
exit 2; \
fi
@$(MAKE) -C $* \
CXX=$(CXX) \
CPPGM_HOST_CXX=$(CPPGM_HOST_CXX) \
CPPGM_STDLIB_FLAGS=$(CPPGM_STDLIB_FLAGS) \
CPPGM_TEST_RUNNER=$(CPPGM_TEST_RUNNER) \
$(SUBMAKE_OBJ_ARG) \
$(SUBMAKE_GENERATED_ARG) \
$(SUBMAKE_CC_FLAGS_ARG) \
$(if $(strip $(TEST)),TEST=$(patsubst $*/%,%,$(TEST)),) \
ref-test
test-%:
@if [ ! -f "$*/Makefile" ]; then \
echo "unknown assignment: $*" >&2; \
exit 2; \
fi
@$(MAKE) build
@$(MAKE) test-report-nobuild \
ACTIVE_TEST_REPORT_PAS='$*' \
TEST_REPORT_SUBTEST_JOBS='$(SINGLE_ASSIGNMENT_SUBTEST_JOBS)' \
ORDERED='$(ORDERED)'
reference-binaries:
@scripts/ensure_reference_binaries.pl
setup: reference-binaries
.PHONY: reference-binaries setup
# Optional typed producer/library lane; independent of the assignment report.
.PHONY: lowir-library test-lowir-library test-lowir-library-nobuild
lowir-library:
$(MAKE) -C dev lowir-library CXX="$(CXX)" CPPGM_HOST_CXX="$(CPPGM_HOST_CXX)" CPPGM_STDLIB_FLAGS="$(CPPGM_STDLIB_FLAGS)" $(SUBMAKE_OBJ_ARG)
test-lowir-library: build lowir-library
$(MAKE) test-lowir-library-nobuild
test-lowir-library-nobuild:
$(MAKE) -C pa27 test-lowir-library CPPGM_SKIP_DEV_REBUILD=1 CXX="$(CXX)" CPPGM_HOST_CXX="$(CPPGM_HOST_CXX)" CPPGM_STDLIB_FLAGS="$(CPPGM_STDLIB_FLAGS)"
$(MAKE) -C pa33 test-lowir-library CPPGM_SKIP_DEV_REBUILD=1 CXX="$(CXX)" CPPGM_HOST_CXX="$(CPPGM_HOST_CXX)" CPPGM_STDLIB_FLAGS="$(CPPGM_STDLIB_FLAGS)"
# Optional C frontend assignment; outside the standard C++ report.
.PHONY: test-c test-c-wasm
test-c:
@$(MAKE) test-pa38
test-c-wasm:
@$(MAKE) -C pa38 test-wasm CXX="$(CXX)" CPPGM_HOST_CXX="$(CPPGM_HOST_CXX)"