History

kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles

Move CFLAGS_KASAN*, CFLAGS_UBSAN, CFLAGS_KCSAN to Makefile.kasan, Makefile.ubsan, Makefile.kcsan, respectively. This commit also avoids the same -fsanitize=* flags being added to CFLAGS_UBSAN multiple times. Prior to this commit, the ubsan flags were appended by the '+=' operator, without any initialization. Some build targets such as 'make bindeb-pkg' recurses to the top Makefile, and ended up with adding the same flags to CFLAGS_UBSAN twice. Clear CFLAGS_UBSAN with ':=' to make it a simply expanded variable. This is better than a recursively expanded variable, which evaluates $(call cc-option, ...) multiple times before Kbuild starts descending to subdirectories.

Masahiro Yamada committed 6 years ago

Commit bb273211 parent 9909b764 files · +6 −2Browse files

Showing the changes to scripts (3 of 4 files). Show all

Unified · Split

3 files
  1. scripts/Makefile.kasan +2 −0
  2. scripts/Makefile.kcsan +1 −1
  3. scripts/Makefile.ubsan +3 −0
scripts/Makefile.kasan+2−0
@@ -47,3 +47,5 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ · 46 unmodified lines
4747 $(instrumentation_flags)
4848
4949 endif # CONFIG_KASAN_SW_TAGS
50+
51+export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
scripts/Makefile.kcsan+1−1
@@ -9,7 +9,7 @@ endif · 8 unmodified lines
99
1010 # Keep most options here optional, to allow enabling more compilers if absence
1111 # of some options does not break KCSAN nor causes false positive reports.
12−CFLAGS_KCSAN := -fsanitize=thread \
12+export CFLAGS_KCSAN := -fsanitize=thread \
1313 $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
1414 $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
1515 $(call cc-param,tsan-distinguish-volatile=1)
scripts/Makefile.ubsan+3−0
@@ -1,4 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
2+
3+export CFLAGS_UBSAN :=
4+
25 ifdef CONFIG_UBSAN_ALIGNMENT
36 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
47 endif