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

Unified · Split

4 files
  1. Makefile +0 −1
  2. scripts/Makefile.kasan +2 −0
  3. scripts/Makefile.kcsan +1 −1
  4. scripts/Makefile.ubsan +3 −0
Makefile+0−1
@@ -516,7 +516,6 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE · 515 unmodified lines
516516
517517 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
518518 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
519−export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN
520519 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
521520 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
522521 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t