elf: Use a temporary file to generate Makefile fragments [BZ #28550]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
On Mon, Nov 15, 2021 at 12:18 PM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 15/11/2021 16:51, H.J. Lu wrote:
> > On Mon, Nov 15, 2021 at 10:59 AM Adhemerval Zanella
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >>
> >> On 08/11/2021 12:42, H.J. Lu via Libc-alpha wrote:
> >>> Generate Makefile fragment for DSO sorting tests at configure time.
> >>>
> >>> This partially fixes BZ #28550.
> >>
> >> I am not sure if configure.ac is the right place to generate the Makefile
> >> fragment required for tests. Can we use 'avoid-generated' instead?
> >>
> >>
> >> diff --git a/elf/Makefile b/elf/Makefile
> >> index a311c3e23c..8556105a20 100644
> >> --- a/elf/Makefile
> >> +++ b/elf/Makefile
> >> @@ -491,6 +491,7 @@ tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
> >> $(objpfx)tst-unused-dep-cmp.out
> >> endif
> >>
> >> +ifndef avoid-generated
> >> # DSO sorting tests:
> >> # The dso-ordering-test.py script generates testcase source files in $(objpfx),
> >> # creating a $(objpfx)<testcase-name>-dir for each testcase, and creates a
> >> @@ -507,6 +508,7 @@ ifeq (yes,$(have-tunables))
> >> $(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
> >> $(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
> >> endif
> >> +endif
> >
> > It doesn't work. "make check -j28" on a machine with 112 cores failed:
> >
> > /export/users/hjl/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/dso-sort-tests-1.def.generated-makefile:938:
> > warning: ignoring old recipe for target
> > '/export/users/hjl/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dso-ordering9-dir/tst-dso-ordering9_25-bacde-b.so'
> > ...
> > make[3]: *** [Makefile:483: elf/tests] Error 2
> >
> > I couldn't find the exact error message in a very long make log file.
> This is usual way to create other auto-generated Makefile fragments, such as
> sysd-sycalls and time64-compat.mk. Maybe the below helps (I forgot to use
> '-include' and add the fragments on postclean-generated).
>
>
> diff --git a/elf/Makefile b/elf/Makefile
> index a311c3e23c..0e6d7ffb51 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -491,6 +491,7 @@ tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
> $(objpfx)tst-unused-dep-cmp.out
> endif
>
> +ifndef avoid-generated
> # DSO sorting tests:
> # The dso-ordering-test.py script generates testcase source files in $(objpfx),
> # creating a $(objpfx)<testcase-name>-dir for each testcase, and creates a
> @@ -499,7 +500,7 @@ define include_dsosort_tests
> $(objpfx)$(1).generated-makefile: $(1)
> $(PYTHON) $(..)scripts/dso-ordering-test.py \
> --description-file $$< --objpfx $(objpfx) --output-makefile $$@
> -include $(objpfx)$(1).generated-makefile
> +-include $(objpfx)$(1).generated-makefile
> endef
>
> # Generate from each testcase description file
> @@ -507,6 +508,10 @@ ifeq (yes,$(have-tunables))
> $(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
> $(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
> endif
> +endif
> +
> +postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
> + $(objpfx)/dso-sort-tests-2.generated-makefile
>
> check-abi: $(objpfx)check-abi-ld.out
> tests-special += $(objpfx)check-abi-ld.out
This works for me.
Thanks.
Comments
On 16/11/2021 01:48, H.J. Lu wrote:
>
> This works for me.
>
> Thanks.
>
> From a928b52c036bb888797b3e81014f441f0d876b65 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Mon, 15 Nov 2021 16:28:39 -0800
> Subject: [PATCH] elf: Use a temporary file to generate Makefile fragments [BZ
> #28550]
>
> Use a temporary file to generate Makefile fragments for DSO sorting tests
> and use -include on them.
>
> This partially fixes BZ #28550.
> ---
> elf/Makefile | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/elf/Makefile b/elf/Makefile
> index a311c3e23c..57374fc690 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -498,8 +498,9 @@ endif
> define include_dsosort_tests
> $(objpfx)$(1).generated-makefile: $(1)
> $(PYTHON) $(..)scripts/dso-ordering-test.py \
> - --description-file $$< --objpfx $(objpfx) --output-makefile $$@
> -include $(objpfx)$(1).generated-makefile
> + --description-file $$< --objpfx $(objpfx) --output-makefile $$@T
> + mv $$@T $$@
> +-include $(objpfx)$(1).generated-makefile
> endef
>
> # Generate from each testcase description file
> --
> 2.33.1
I think you need the below on top of your patch. The 'avoid-generated' and
'postclean-generated' are required so a 'make clean' removes the autogenerated
fragments so a subsequent 'make' regenerates them.
diff --git a/elf/Makefile b/elf/Makefile
index 57374fc690..31759279d4 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -491,6 +491,7 @@ tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
$(objpfx)tst-unused-dep-cmp.out
endif
+ifndef avoid-generated
# DSO sorting tests:
# The dso-ordering-test.py script generates testcase source files in $(objpfx),
# creating a $(objpfx)<testcase-name>-dir for each testcase, and creates a
@@ -508,6 +509,9 @@ ifeq (yes,$(have-tunables))
$(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
$(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
endif
+endif
+postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
+ $(objpfx)/dso-sort-tests-2.generated-makefile
check-abi: $(objpfx)check-abi-ld.out
tests-special += $(objpfx)check-abi-ld.out
On Tue, Nov 16, 2021 at 4:52 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 16/11/2021 01:48, H.J. Lu wrote:
> >
> > This works for me.
> >
> > Thanks.
> >
>
> > From a928b52c036bb888797b3e81014f441f0d876b65 Mon Sep 17 00:00:00 2001
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Mon, 15 Nov 2021 16:28:39 -0800
> > Subject: [PATCH] elf: Use a temporary file to generate Makefile fragments [BZ
> > #28550]
> >
> > Use a temporary file to generate Makefile fragments for DSO sorting tests
> > and use -include on them.
> >
> > This partially fixes BZ #28550.
> > ---
> > elf/Makefile | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/elf/Makefile b/elf/Makefile
> > index a311c3e23c..57374fc690 100644
> > --- a/elf/Makefile
> > +++ b/elf/Makefile
> > @@ -498,8 +498,9 @@ endif
> > define include_dsosort_tests
> > $(objpfx)$(1).generated-makefile: $(1)
> > $(PYTHON) $(..)scripts/dso-ordering-test.py \
> > - --description-file $$< --objpfx $(objpfx) --output-makefile $$@
> > -include $(objpfx)$(1).generated-makefile
> > + --description-file $$< --objpfx $(objpfx) --output-makefile $$@T
> > + mv $$@T $$@
> > +-include $(objpfx)$(1).generated-makefile
> > endef
> >
> > # Generate from each testcase description file
> > --
> > 2.33.1
>
> I think you need the below on top of your patch. The 'avoid-generated' and
> 'postclean-generated' are required so a 'make clean' removes the autogenerated
> fragments so a subsequent 'make' regenerates them.
Fixed in the v2 patch.
Thanks.
> diff --git a/elf/Makefile b/elf/Makefile
> index 57374fc690..31759279d4 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -491,6 +491,7 @@ tests-special += $(objpfx)order-cmp.out $(objpfx)tst-array1-cmp.out \
> $(objpfx)tst-unused-dep-cmp.out
> endif
>
> +ifndef avoid-generated
> # DSO sorting tests:
> # The dso-ordering-test.py script generates testcase source files in $(objpfx),
> # creating a $(objpfx)<testcase-name>-dir for each testcase, and creates a
> @@ -508,6 +509,9 @@ ifeq (yes,$(have-tunables))
> $(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
> $(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
> endif
> +endif
> +postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
> + $(objpfx)/dso-sort-tests-2.generated-makefile
>
> check-abi: $(objpfx)check-abi-ld.out
> tests-special += $(objpfx)check-abi-ld.out
From a928b52c036bb888797b3e81014f441f0d876b65 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 15 Nov 2021 16:28:39 -0800
Subject: [PATCH] elf: Use a temporary file to generate Makefile fragments [BZ
#28550]
Use a temporary file to generate Makefile fragments for DSO sorting tests
and use -include on them.
This partially fixes BZ #28550.
---
elf/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -498,8 +498,9 @@ endif
define include_dsosort_tests
$(objpfx)$(1).generated-makefile: $(1)
$(PYTHON) $(..)scripts/dso-ordering-test.py \
- --description-file $$< --objpfx $(objpfx) --output-makefile $$@
-include $(objpfx)$(1).generated-makefile
+ --description-file $$< --objpfx $(objpfx) --output-makefile $$@T
+ mv $$@T $$@
+-include $(objpfx)$(1).generated-makefile
endef
# Generate from each testcase description file
--
2.33.1