Re: [PATCH v2 1/5] x86/boot/compressed: prefer cc-option for CFLAGS additions

From: Nathan Chancellor
Date: Wed Aug 31 2022 - 15:41:55 EST


On Wed, Aug 31, 2022 at 11:44:04AM -0700, Nick Desaulniers wrote:
> We have an issue where as-option is testing new options with accumulated
> CFLAGS. This makes it so that we can't use as-option to update AFLAGS
> since many CFLAGS aren't valid AFLAGS. This is being fixed in a follow
> up patch. Before doing so, move the assembler test for
> -Wa,-mrelax-relocations=no from using as-option to cc-option.

I think the first couple of sentences might sound clearer without the
"we". Maybe something like the following?

"as-option tests new options using KBUILD_CFLAGS, which causes problems
when using as-option to update KBUILD_AFLAGS because many compiler
options are not valid assembler options."

> Cc: Arvind Sankar <nivedita@xxxxxxxxxxxx>
> Cc: x86@xxxxxxxxxx
> Link: https://lore.kernel.org/llvm/CAK7LNATcHt7GcXZ=jMszyH=+M_LC9Qr6yeAGRCBbE6xriLxtUQ@xxxxxxxxxxxxxx/
> Suggested-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>

Regardless of the commit message:

Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>

Additionally, I did verify that '-Wa,-mrelax-relocations=no' still shows
up in arch/x86/boot/compressed so:

Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>

> ---
> Changes v1 -> v2:
> * Split off of v1 [1/3].
> * Use cc-option to update CFLAGS, as per Masahiro.
> * Add Masahiro's Suggested-by, Cc Arvind.
>
> arch/x86/boot/compressed/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index 35ce1a64068b..85934204d905 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -49,7 +49,7 @@ KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
> KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
> KBUILD_CFLAGS += -D__DISABLE_EXPORTS
> # Disable relocation relaxation in case the link is not PIE.
> -KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no)
> +KBUILD_CFLAGS += $(call cc-option,-Wa$(comma)-mrelax-relocations=no)
> KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h
>
> # sev.c indirectly inludes inat-table.h which is generated during
> --
> 2.37.2.672.g94769d06f0-goog
>