diff mbox series

[v2,04/13] kbuild: factor out OBJECT_FILES_NON_STANDARD check into a macro

Message ID 20210831074004.3195284-5-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series kbuild: second round of Clang LTO refactoring | expand

Commit Message

Masahiro Yamada Aug. 31, 2021, 7:39 a.m. UTC
The OBJECT_FILES_NON_STANDARD check is quite long.

Factor it out into a new macro, objtool-enabled, to not repeat it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.build | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Nick Desaulniers Aug. 31, 2021, 5:25 p.m. UTC | #1
On Tue, Aug 31, 2021 at 12:40 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The OBJECT_FILES_NON_STANDARD check is quite long.
>
> Factor it out into a new macro, objtool-enabled, to not repeat it.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>
>  scripts/Makefile.build | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 021ae0146913..720a86642f48 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -241,12 +241,12 @@ ifndef CONFIG_LTO_CLANG
>  # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
>  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
>  # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
> -cmd_objtool = $(if $(patsubst y%,, \
> -       $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
> -       ; $(objtool) $(objtool_args) $@)
> -objtool_obj = $(if $(patsubst y%,, \
> -       $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
> -       $(objtool))
> +
> +objtool-enabled = $(if $(filter-out y%, \
> +       $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
> +
> +cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
> +objtool_obj = $(if $(objtool-enabled), $(objtool))
>
>  endif # CONFIG_LTO_CLANG
>  endif # CONFIG_STACK_VALIDATION
> --
> 2.30.2
>
Kees Cook Aug. 31, 2021, 5:31 p.m. UTC | #2
On Tue, Aug 31, 2021 at 04:39:55PM +0900, Masahiro Yamada wrote:
> The OBJECT_FILES_NON_STANDARD check is quite long.
> 
> Factor it out into a new macro, objtool-enabled, to not repeat it.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Looks right to me.

Reviewed-by: Kees Cook <keescook@chromium.org>
Josh Poimboeuf Sept. 4, 2021, 6:59 p.m. UTC | #3
On Tue, Aug 31, 2021 at 04:39:55PM +0900, Masahiro Yamada wrote:
> The OBJECT_FILES_NON_STANDARD check is quite long.
> 
> Factor it out into a new macro, objtool-enabled, to not repeat it.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
diff mbox series

Patch

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 021ae0146913..720a86642f48 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -241,12 +241,12 @@  ifndef CONFIG_LTO_CLANG
 # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
-cmd_objtool = $(if $(patsubst y%,, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
-	; $(objtool) $(objtool_args) $@)
-objtool_obj = $(if $(patsubst y%,, \
-	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
-	$(objtool))
+
+objtool-enabled = $(if $(filter-out y%, \
+	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
+
+cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
+objtool_obj = $(if $(objtool-enabled), $(objtool))
 
 endif # CONFIG_LTO_CLANG
 endif # CONFIG_STACK_VALIDATION