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
516 516
517export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS517export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
518export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE518export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
519export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN
520export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE519export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
521export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE520export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
522export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL521export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
scripts/Makefile.kasan+2−0
@@ -47,3 +47,5 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ · 46 unmodified lines
47 $(instrumentation_flags)47 $(instrumentation_flags)
48 48
49endif # CONFIG_KASAN_SW_TAGS49endif # CONFIG_KASAN_SW_TAGS
50
51export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
scripts/Makefile.kcsan+1−1
@@ -9,7 +9,7 @@ endif · 8 unmodified lines
9 9
10# Keep most options here optional, to allow enabling more compilers if absence10# 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.
12CFLAGS_KCSAN := -fsanitize=thread \12export 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)
scripts/Makefile.ubsan+3−0
@@ -1,4 +1,7 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2
3export CFLAGS_UBSAN :=
4
2ifdef CONFIG_UBSAN_ALIGNMENT5ifdef CONFIG_UBSAN_ALIGNMENT
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)6 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
4endif7endif

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