[PATCH v1 1/6] tools/build: Don't pass test log files to linker

Ian Rogers posted 6 patches 1 year, 3 months ago
There is a newer version of this series
[PATCH v1 1/6] tools/build: Don't pass test log files to linker
Posted by Ian Rogers 1 year, 3 months ago
Separate test log files from object files. Depend on test log output
but don't pass to the linker.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/build/Makefile.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
index 5fb3fb3d97e0..ffe988867703 100644
--- a/tools/build/Makefile.build
+++ b/tools/build/Makefile.build
@@ -149,6 +149,10 @@ objprefix    := $(subst ./,,$(OUTPUT)$(dir)/)
 obj-y        := $(addprefix $(objprefix),$(obj-y))
 subdir-obj-y := $(addprefix $(objprefix),$(subdir-obj-y))
 
+# Separate out test log files from real build objects.
+test-y       := $(filter %_log, $(obj-y))
+obj-y        := $(filter-out %_log, $(obj-y))
+
 # Final '$(obj)-in.o' object
 in-target := $(objprefix)$(obj)-in.o
 
@@ -159,7 +163,7 @@ $(subdir-y):
 
 $(sort $(subdir-obj-y)): $(subdir-y) ;
 
-$(in-target): $(obj-y) FORCE
+$(in-target): $(obj-y) $(test-y) FORCE
 	$(call rule_mkdir)
 	$(call if_changed,$(host)ld_multi)
 
-- 
2.47.0.163.g1226f6d8fa-goog
Re: [PATCH v1 1/6] tools/build: Don't pass test log files to linker
Posted by Namhyung Kim 1 year ago
On Fri, Oct 25, 2024 at 10:22:58AM -0700, Ian Rogers wrote:
> Separate test log files from object files. Depend on test log output
> but don't pass to the linker.

I don't know why $(obj-y) contains log files in the first place.  It's
supposed to have .o files only, right?

Thanks,
Namhyung

> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/build/Makefile.build | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
> index 5fb3fb3d97e0..ffe988867703 100644
> --- a/tools/build/Makefile.build
> +++ b/tools/build/Makefile.build
> @@ -149,6 +149,10 @@ objprefix    := $(subst ./,,$(OUTPUT)$(dir)/)
>  obj-y        := $(addprefix $(objprefix),$(obj-y))
>  subdir-obj-y := $(addprefix $(objprefix),$(subdir-obj-y))
>  
> +# Separate out test log files from real build objects.
> +test-y       := $(filter %_log, $(obj-y))
> +obj-y        := $(filter-out %_log, $(obj-y))
> +
>  # Final '$(obj)-in.o' object
>  in-target := $(objprefix)$(obj)-in.o
>  
> @@ -159,7 +163,7 @@ $(subdir-y):
>  
>  $(sort $(subdir-obj-y)): $(subdir-y) ;
>  
> -$(in-target): $(obj-y) FORCE
> +$(in-target): $(obj-y) $(test-y) FORCE
>  	$(call rule_mkdir)
>  	$(call if_changed,$(host)ld_multi)
>  
> -- 
> 2.47.0.163.g1226f6d8fa-goog
>
Re: [PATCH v1 1/6] tools/build: Don't pass test log files to linker
Posted by Ian Rogers 1 year ago
On Fri, Jan 24, 2025 at 3:31 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Fri, Oct 25, 2024 at 10:22:58AM -0700, Ian Rogers wrote:
> > Separate test log files from object files. Depend on test log output
> > but don't pass to the linker.
>
> I don't know why $(obj-y) contains log files in the first place.  It's
> supposed to have .o files only, right?

There's context here:
https://lore.kernel.org/all/20231129213428.2227448-1-irogers@google.com/
$(obj-y) is the set of the dependencies from Build files, generally
directories or .o files. Perf added the test logs as the alternative
is to duplicate all the directory scanning and other logic for a
$(test-y) but it isn't clear how you'd even name targets for a test in
the Build files. Rather than reinvent Makefile.build the choice was
made to work with what we had.

Thanks,
Ian
Re: [PATCH v1 1/6] tools/build: Don't pass test log files to linker
Posted by Namhyung Kim 1 year ago
On Fri, Jan 24, 2025 at 05:58:37PM -0800, Ian Rogers wrote:
> On Fri, Jan 24, 2025 at 3:31 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Fri, Oct 25, 2024 at 10:22:58AM -0700, Ian Rogers wrote:
> > > Separate test log files from object files. Depend on test log output
> > > but don't pass to the linker.
> >
> > I don't know why $(obj-y) contains log files in the first place.  It's
> > supposed to have .o files only, right?
> 
> There's context here:
> https://lore.kernel.org/all/20231129213428.2227448-1-irogers@google.com/
> $(obj-y) is the set of the dependencies from Build files, generally
> directories or .o files. Perf added the test logs as the alternative
> is to duplicate all the directory scanning and other logic for a
> $(test-y) but it isn't clear how you'd even name targets for a test in
> the Build files. Rather than reinvent Makefile.build the choice was
> made to work with what we had.

Thanks for the explanation.  I'm ok with it for now but I'll take a look
if there's a better way later.

Thanks,
Namhyung