* [PATCH 1/2] kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan
@ 2020-09-10 13:44 Masahiro Yamada
2020-09-10 13:44 ` [PATCH 2/2] kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles Masahiro Yamada
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2020-09-10 13:44 UTC (permalink / raw)
To: linux-kbuild
Cc: Ingo Molnar, Masahiro Yamada, Alexander Potapenko,
Andrey Ryabinin, Dmitry Vyukov, Michal Marek, kasan-dev,
linux-kernel
Since commit e0fe0bbe57b8 ("kbuild: include scripts/Makefile.* only
when relevant CONFIG is enabled"), this file is included only when
CONFIG_KASAN=y.
This ifdef is redundant.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.kasan | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index f4beee1b0013..1532f1a41a8f 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
-ifdef CONFIG_KASAN
CFLAGS_KASAN_NOSANITIZE := -fno-builtin
KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
-endif
ifdef CONFIG_KASAN_GENERIC
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles
2020-09-10 13:44 [PATCH 1/2] kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan Masahiro Yamada
@ 2020-09-10 13:44 ` Masahiro Yamada
2020-09-10 14:12 ` Marco Elver
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2020-09-10 13:44 UTC (permalink / raw)
To: linux-kbuild
Cc: Ingo Molnar, Masahiro Yamada, Alexander Potapenko,
Andrey Ryabinin, Dmitry Vyukov, Marco Elver, Michal Marek,
kasan-dev, linux-kernel
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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 1 -
scripts/Makefile.kasan | 2 ++
scripts/Makefile.kcsan | 2 +-
scripts/Makefile.ubsan | 3 +++
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index ec2330ce0fc5..4b5a305e30d2 100644
--- a/Makefile
+++ b/Makefile
@@ -517,7 +517,6 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
-export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index 1532f1a41a8f..1e000cc2e7b4 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -47,3 +47,5 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
$(instrumentation_flags)
endif # CONFIG_KASAN_SW_TAGS
+
+export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
diff --git a/scripts/Makefile.kcsan b/scripts/Makefile.kcsan
index c50f27b3ac56..cec50d74e0d0 100644
--- a/scripts/Makefile.kcsan
+++ b/scripts/Makefile.kcsan
@@ -9,7 +9,7 @@ endif
# Keep most options here optional, to allow enabling more compilers if absence
# of some options does not break KCSAN nor causes false positive reports.
-CFLAGS_KCSAN := -fsanitize=thread \
+export CFLAGS_KCSAN := -fsanitize=thread \
$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
$(call cc-param,tsan-distinguish-volatile=1)
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
index 27348029b2b8..c661484ee01f 100644
--- a/scripts/Makefile.ubsan
+++ b/scripts/Makefile.ubsan
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+
+export CFLAGS_UBSAN :=
+
ifdef CONFIG_UBSAN_ALIGNMENT
CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
endif
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles
2020-09-10 13:44 ` [PATCH 2/2] kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles Masahiro Yamada
@ 2020-09-10 14:12 ` Marco Elver
0 siblings, 0 replies; 3+ messages in thread
From: Marco Elver @ 2020-09-10 14:12 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Ingo Molnar, Alexander Potapenko,
Andrey Ryabinin, Dmitry Vyukov, Michal Marek, kasan-dev, LKML,
Paul E. McKenney
On Thu, 10 Sep 2020 at 15:45, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Makefile | 1 -
> scripts/Makefile.kasan | 2 ++
> scripts/Makefile.kcsan | 2 +-
> scripts/Makefile.ubsan | 3 +++
> 4 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index ec2330ce0fc5..4b5a305e30d2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -517,7 +517,6 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
>
> export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
> export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
> -export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN
> export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
> export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
> export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
> diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
> index 1532f1a41a8f..1e000cc2e7b4 100644
> --- a/scripts/Makefile.kasan
> +++ b/scripts/Makefile.kasan
> @@ -47,3 +47,5 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
> $(instrumentation_flags)
>
> endif # CONFIG_KASAN_SW_TAGS
> +
> +export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE
> diff --git a/scripts/Makefile.kcsan b/scripts/Makefile.kcsan
> index c50f27b3ac56..cec50d74e0d0 100644
> --- a/scripts/Makefile.kcsan
> +++ b/scripts/Makefile.kcsan
> @@ -9,7 +9,7 @@ endif
>
> # Keep most options here optional, to allow enabling more compilers if absence
> # of some options does not break KCSAN nor causes false positive reports.
> -CFLAGS_KCSAN := -fsanitize=thread \
> +export CFLAGS_KCSAN := -fsanitize=thread \
> $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
> $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
> $(call cc-param,tsan-distinguish-volatile=1)
This doesn't apply to -next, which has some KCSAN changes for the next
merge window. Although it seems git-merge figures out the resolution
for the conflict automatically.
Other than that,
Acked-by: Marco Elver <elver@google.com>
Thank you!
> diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
> index 27348029b2b8..c661484ee01f 100644
> --- a/scripts/Makefile.ubsan
> +++ b/scripts/Makefile.ubsan
> @@ -1,4 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
> +
> +export CFLAGS_UBSAN :=
> +
> ifdef CONFIG_UBSAN_ALIGNMENT
> CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
> endif
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-10 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-10 13:44 [PATCH 1/2] kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan Masahiro Yamada
2020-09-10 13:44 ` [PATCH 2/2] kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles Masahiro Yamada
2020-09-10 14:12 ` Marco Elver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox