Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (42 loc) · 1.68 KB
/
Copy pathMakefile
File metadata and controls
54 lines (42 loc) · 1.68 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
# Makefile — Thread Pool (no CMake required)
# Requires only: g++ (GCC 10+ or Clang 11+)
#
# Targets:
# make — build tests + benchmark (Release)
# make test — build and run all tests
# make bench — build and run benchmark
# make tsan — build with ThreadSanitizer and run tests
# make asan — build with AddressSanitizer and run tests
# make clean — remove all build artifacts
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -Wpedantic -pthread
INC := -Iinclude
BUILD := build
TEST_BIN := $(BUILD)/test_thread_pool
BENCH_BIN:= $(BUILD)/benchmark
.PHONY: all test bench tsan asan clean
all: $(TEST_BIN) $(BENCH_BIN)
$(BUILD):
mkdir -p $(BUILD)
$(TEST_BIN): tests/test_thread_pool_standalone.cpp include/thread_pool.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -O2 $(INC) $< -o $@
$(BENCH_BIN): bench/benchmark.cpp include/thread_pool.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -O3 -march=native $(INC) $< -o $@
test: $(TEST_BIN)
@echo "\n=== Running Tests ==="
./$(TEST_BIN)
bench: $(BENCH_BIN)
@echo "\n=== Running Benchmark ==="
./$(BENCH_BIN)
tsan: tests/test_thread_pool_standalone.cpp include/thread_pool.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -g -O1 -fsanitize=thread $(INC) \
tests/test_thread_pool_standalone.cpp -o $(BUILD)/test_tsan
@echo "\n=== Running with ThreadSanitizer ==="
./$(BUILD)/test_tsan
asan: tests/test_thread_pool_standalone.cpp include/thread_pool.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -g -O1 -fsanitize=address,undefined $(INC) \
tests/test_thread_pool_standalone.cpp -o $(BUILD)/test_asan
@echo "\n=== Running with AddressSanitizer ==="
./$(BUILD)/test_asan
clean:
rm -rf $(BUILD)