diff mbox series

um: fix stub exe build with CONFIG_GCOV

Message ID 20241025102700.9fbb9c34473f.I7f1537fe075638f8da64beb52ef6c9e5adc51bc3@changeid
State Accepted
Headers show
Series um: fix stub exe build with CONFIG_GCOV | expand

Commit Message

Johannes Berg Oct. 25, 2024, 8:27 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

CONFIG_GCOV is special and only in UML since it builds the
kernel with a "userspace" option. This is fine, but the stub
is even more special and not really a full userspace process,
so it then fails to link as reported.

For good measure, also remove the GPROF options, even though
they don't seem to cause build failures now.

To be able to do this, export the specific options (GCOV_OPT
and GPROF_OPT) but rename them so there's less chance of any
conflicts.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410242238.SXhs2kQ4-lkp@intel.com/
Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/Makefile-skas        | 14 +++++++-------
 arch/um/kernel/skas/Makefile |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Nathan Chancellor Oct. 27, 2024, 10:09 p.m. UTC | #1
On Fri, Oct 25, 2024 at 10:27:01AM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> CONFIG_GCOV is special and only in UML since it builds the
> kernel with a "userspace" option. This is fine, but the stub
> is even more special and not really a full userspace process,
> so it then fails to link as reported.
> 
> For good measure, also remove the GPROF options, even though
> they don't seem to cause build failures now.
> 
> To be able to do this, export the specific options (GCOV_OPT
> and GPROF_OPT) but rename them so there's less chance of any
> conflicts.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410242238.SXhs2kQ4-lkp@intel.com/
> Fixes: 32e8eaf263d9 ("um: use execveat to create userspace MMs")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/um/Makefile-skas        | 14 +++++++-------
>  arch/um/kernel/skas/Makefile |  2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas
> index 67323b028999..1a27e65bcb9c 100644
> --- a/arch/um/Makefile-skas
> +++ b/arch/um/Makefile-skas
> @@ -3,15 +3,15 @@
>  # Licensed under the GPL
>  #
>  
> -GPROF_OPT += -pg
> +export UM_GPROF_OPT += -pg
>  
>  ifdef CONFIG_CC_IS_CLANG
> -GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
> +export UM_GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
>  else
> -GCOV_OPT += -fprofile-arcs -ftest-coverage
> +export UM_GCOV_OPT += -fprofile-arcs -ftest-coverage
>  endif
>  
> -CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
> -CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
> -LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
> -LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
> +CFLAGS-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
> +CFLAGS-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
> +LINK-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
> +LINK-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
> diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
> index f6a219074772..3384be42691f 100644
> --- a/arch/um/kernel/skas/Makefile
> +++ b/arch/um/kernel/skas/Makefile
> @@ -24,7 +24,7 @@ $(obj)/stub_exe: $(obj)/stub_exe.dbg FORCE
>  
>  quiet_cmd_stub_exe = STUB_EXE $@
>        cmd_stub_exe = $(CC) -nostdlib -o $@ \
> -			   $(KBUILD_CFLAGS) $(STUB_EXE_LDFLAGS) \
> +			   $(filter-out $(UM_GPROF_OPT) $(UM_GCOV_OPT),$(KBUILD_CFLAGS)) $(STUB_EXE_LDFLAGS) \

Not that it matters much but it might be more readable to have
$(STUB_EXE_LDFLAGS) on its own line now.

>  			   $(filter %.o,$^)
>  
>  STUB_EXE_LDFLAGS = -Wl,-n -static
> -- 
> 2.47.0
>
diff mbox series

Patch

diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas
index 67323b028999..1a27e65bcb9c 100644
--- a/arch/um/Makefile-skas
+++ b/arch/um/Makefile-skas
@@ -3,15 +3,15 @@ 
 # Licensed under the GPL
 #
 
-GPROF_OPT += -pg
+export UM_GPROF_OPT += -pg
 
 ifdef CONFIG_CC_IS_CLANG
-GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
+export UM_GCOV_OPT += -fprofile-instr-generate -fcoverage-mapping
 else
-GCOV_OPT += -fprofile-arcs -ftest-coverage
+export UM_GCOV_OPT += -fprofile-arcs -ftest-coverage
 endif
 
-CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
-CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
-LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
-LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
+CFLAGS-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
+CFLAGS-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
+LINK-$(CONFIG_GCOV) += $(UM_GCOV_OPT)
+LINK-$(CONFIG_GPROF) += $(UM_GPROF_OPT)
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index f6a219074772..3384be42691f 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -24,7 +24,7 @@  $(obj)/stub_exe: $(obj)/stub_exe.dbg FORCE
 
 quiet_cmd_stub_exe = STUB_EXE $@
       cmd_stub_exe = $(CC) -nostdlib -o $@ \
-			   $(KBUILD_CFLAGS) $(STUB_EXE_LDFLAGS) \
+			   $(filter-out $(UM_GPROF_OPT) $(UM_GCOV_OPT),$(KBUILD_CFLAGS)) $(STUB_EXE_LDFLAGS) \
 			   $(filter %.o,$^)
 
 STUB_EXE_LDFLAGS = -Wl,-n -static