Skip to content

Commit 84a2cf0

Browse files
author
Maxim Egorushkin
committed
Run unit-tests with address sanitizer too.
1 parent 48abca2 commit 84a2cf0

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ jobs:
4242
- name: Build and run unit tests
4343
run: make -rj2 TOOLSET=${{ matrix.toolset }} example run_tests
4444

45+
- name: Build and run unit tests with address sanitizer
46+
run: make -rj2 TOOLSET=${{ matrix.toolset }} BUILD=sanitize2 run_tests
47+
4548
- name: Build and run unit tests with thread sanitizer
4649
run: make -rj2 TOOLSET=${{ matrix.toolset }} BUILD=sanitize run_tests

Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,31 @@ AR := $(call toolset_exe,ar,ar)
4545

4646
# uname_m := $(shell uname -m)
4747

48-
cxxflags.gcc.debug := -Og -march=native -fstack-protector-all -fno-omit-frame-pointer # -D_GLIBCXX_DEBUG
49-
cxxflags.gcc.release := -O3 -march=native -mtune=native -falign-{functions,loops}=64 -DNDEBUG
50-
cxxflags.gcc.sanitize := ${cxxflags.gcc.release} -fsanitize=thread
51-
cxxflags.gcc := -g -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-{array-bounds,maybe-uninitialized,unused-variable,unused-function,unused-local-typedefs}} ${cxxflags.gcc.${BUILD}}
52-
ldflags.gcc.sanitize := ${ldflags.gcc.release} -fsanitize=thread
53-
ldflags.gcc := -g ${ldflags.gcc.${BUILD}}
48+
cxxflags.gcc.debug := -Og -f{stack-protector-all,no-omit-frame-pointer} # -D_GLIBCXX_DEBUG
49+
cxxflags.gcc.release := -O3 -mtune=native -falign-{functions,loops}=64 -DNDEBUG
50+
cxxflags.gcc.sanitize := ${cxxflags.gcc.debug} -fsanitize=thread
51+
cxxflags.gcc.sanitize2 := ${cxxflags.gcc.debug} -fsanitize=undefined,address
52+
cxxflags.gcc := -march=native -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-{array-bounds,maybe-uninitialized,unused-variable,unused-function,unused-local-typedefs}} ${cxxflags.gcc.${BUILD}}
53+
ldflags.gcc.sanitize := ${ldflags.gcc.debug} -fsanitize=thread
54+
ldflags.gcc.sanitize2 := ${ldflags.gcc.debug} -fsanitize=undefined,address
55+
ldflags.gcc := -fuse-ld=gold ${ldflags.gcc.${BUILD}}
5456

5557
# clang-14 for arm doesn't support -march=native.
5658
has_native := $(if $(and $(findstring clang,${CXX}), $(findstring aarch64,$(shell uname -m)), $(shell ${CXX} -march=native -c -xc++ -o/dev/null /dev/null 2>&1)),,1)
5759
cxxflags.clang.debug := -O0 -fstack-protector-all $(and ${has_native},-march=native)
5860
cxxflags.clang.release := -O3 -falign-functions=64 -DNDEBUG $(and ${has_native},-march=native -mtune=native)
59-
cxxflags.clang.sanitize := ${cxxflags.clang.release} -fsanitize=thread
60-
cxxflags.clang := -g -stdlib=libstdc++ -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-{unused-variable,unused-function,unused-local-typedefs}} ${cxxflags.clang.${BUILD}}
61-
ldflags.clang.sanitize := ${ldflags.clang.release} -fsanitize=thread
61+
cxxflags.clang.sanitize := ${cxxflags.clang.debug} -fsanitize=thread
62+
cxxflags.clang.sanitize2 := ${cxxflags.clang.debug} -fsanitize=undefined,address
63+
cxxflags.clang := -stdlib=libstdc++ -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-{unused-variable,unused-function,unused-local-typedefs}} ${cxxflags.clang.${BUILD}}
6264
ldflags.clang.debug := -latomic # A work-around for clang bug.
63-
ldflags.clang := -g -stdlib=libstdc++ ${ldflags.clang.${BUILD}}
65+
ldflags.clang.sanitize := ${ldflags.clang.debug} -fsanitize=thread
66+
ldflags.clang.sanitize2 := ${ldflags.clang.debug} -fsanitize=undefined,address
67+
ldflags.clang := -stdlib=libstdc++ ${ldflags.clang.${BUILD}}
6468

6569
# Additional CPPFLAGS, CXXFLAGS, LDLIBS, LDFLAGS can come from the command line, e.g. make CPPFLAGS='-I<my-include-dir>', or from environment variables.
66-
cxxflags := -std=c++14 -pthread $(call toolset_flags,cxxflags) ${CXXFLAGS}
70+
cxxflags := -std=c++14 -pthread -g $(call toolset_flags,cxxflags) ${CXXFLAGS}
6771
cppflags := -Iinclude ${CPPFLAGS}
68-
ldflags := -fuse-ld=gold -pthread $(call toolset_flags,ldflags) ${LDFLAGS}
72+
ldflags := -pthread -g $(call toolset_flags,ldflags) ${LDFLAGS}
6973
ldlibs := -lrt ${LDLIBS}
7074

7175
cppflags.tbb :=

0 commit comments

Comments
 (0)