-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommon.mk
More file actions
49 lines (44 loc) · 1.19 KB
/
common.mk
File metadata and controls
49 lines (44 loc) · 1.19 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
# ======================================
# common.mk - shared compiler flags
# ======================================
CXX := g++
OPTFLAGS ?= -O1 -g # Safe for ASAN/TSAN (default)
# --------------------------
# Sanitizer selection
# --------------------------
# Default: AddressSanitizer
SANITIZE ?= address
ifeq ($(SANITIZE),address)
SAN_FLAGS := -fsanitize=address
else ifeq ($(SANITIZE),thread)
SAN_FLAGS := -fsanitize=thread
else ifeq ($(SANITIZE),undefined)
SAN_FLAGS := -fsanitize=undefined
else ifeq ($(SANITIZE),)
SAN_FLAGS :=
else
$(error Unknown SANITIZE=$(SANITIZE))
endif
# --------------------------
# Compiler / Linker flags
# --------------------------
CXX := g++-14
CXXFLAGS := -std=c++23 -Wall -Wextra -Werror $(OPTFLAGS) $(SAN_FLAGS)
LDFLAGS := $(SAN_FLAGS)
# --------------------------
# Usage notes
# --------------------------
# Local build (default): ASAN enabled
# $ make
#
# Override for ThreadSanitizer:
# $ make SANITIZE=thread
#
# Override for UBSAN:
# $ make SANITIZE=undefined
#
# Disable sanitizers (rare):
# $ make SANITIZE=
#
# LDFLAGS are automatically applied in example Makefiles:
# $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS) $(LDFLAGS)