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.
Showing the changes to scripts (3 of 4 files). Show all
Unified · Split
| @@ -47,3 +47,5 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ · 46 unmodified lines | |||
| 47 | $(instrumentation_flags) | 47 | $(instrumentation_flags) |
| 48 | 48 | ||
| 49 | endif # CONFIG_KASAN_SW_TAGS | 49 | endif # CONFIG_KASAN_SW_TAGS |
| 50 | |||
| 51 | export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE | ||
| @@ -9,7 +9,7 @@ endif · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | # Keep most options here optional, to allow enabling more compilers if absence | 10 | # Keep most options here optional, to allow enabling more compilers if absence |
| 11 | # of some options does not break KCSAN nor causes false positive reports. | 11 | # of some options does not break KCSAN nor causes false positive reports. |
| 12 | CFLAGS_KCSAN := -fsanitize=thread \ | 12 | export CFLAGS_KCSAN := -fsanitize=thread \ |
| 13 | $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \ | 13 | $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \ |
| 14 | $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \ | 14 | $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \ |
| 15 | $(call cc-param,tsan-distinguish-volatile=1) | 15 | $(call cc-param,tsan-distinguish-volatile=1) |
| @@ -1,4 +1,7 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | |||
| 3 | export CFLAGS_UBSAN := | ||
| 4 | |||
| 2 | ifdef CONFIG_UBSAN_ALIGNMENT | 5 | ifdef CONFIG_UBSAN_ALIGNMENT |
| 3 | CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) | 6 | CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) |
| 4 | endif | 7 | endif |