[v2] elf: Use a temporary file to generate Makefile fragments [BZ #28550]

Message ID 20211116131418.2070092-1-hjl.tools@gmail.com
State Superseded
Headers
Series [v2] 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

H.J. Lu Nov. 16, 2021, 1:14 p.m. UTC
  1. Use a temporary file to generate Makefile fragments for DSO sorting
tests and use -include on them.
2. Add Makefile fragments to postclean-generated so that a "make clean"
removes the autogenerated fragments and a subsequent "make" regenerates
them.

This partially fixes BZ #28550.
---
 elf/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Comments

Adhemerval Zanella Nov. 16, 2021, 1:16 p.m. UTC | #1
On 16/11/2021 10:14, H.J. Lu wrote:
> 1. Use a temporary file to generate Makefile fragments for DSO sorting
> tests and use -include on them.
> 2. Add Makefile fragments to postclean-generated so that a "make clean"
> removes the autogenerated fragments and a subsequent "make" regenerates
> them.
> 
> This partially fixes BZ #28550.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/Makefile | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/elf/Makefile b/elf/Makefile
> index a311c3e23c..525f302d1a 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
> @@ -498,9 +499,14 @@ 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
> +endif
> +
> +postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
> +		       $(objpfx)/dso-sort-tests-2.generated-makefile
>  
>  # Generate from each testcase description file
>  ifeq (yes,$(have-tunables))
>
  
Florian Weimer Nov. 17, 2021, 1:49 p.m. UTC | #2
I still see

  /builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/dso-sort-tests-2.def.generated-makefile:1067: warning: overriding recipe for target '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/tst-redhat-1162810-dir/tst-redhat-1162810-M22X17.os'

and eventually a build failure:

  make[2]: Leaving directory '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/elf'
  make[1]: *** [Makefile:483: elf/tests] Error 2
  make: *** [Makefile:9: check] Error 2

There's no error before that, or other message indicating which make
target is failing.

The full build log is here:

  <https://koji.fedoraproject.org/koji/taskinfo?taskID=78987342>
  <https://kojipkgs.fedoraproject.org//work/tasks/7342/78987342/build.log>

The make error messages are not very helpful to me though.

Thanks,
Florian
  
H.J. Lu Nov. 17, 2021, 1:56 p.m. UTC | #3
On Wed, Nov 17, 2021 at 5:49 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> I still see
>
>   /builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/dso-sort-tests-2.def.generated-makefile:1067: warning: overriding recipe for target '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/tst-redhat-1162810-dir/tst-redhat-1162810-M22X17.os'
>
> and eventually a build failure:
>
>   make[2]: Leaving directory '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/elf'
>   make[1]: *** [Makefile:483: elf/tests] Error 2
>   make: *** [Makefile:9: check] Error 2
>
> There's no error before that, or other message indicating which make
> target is failing.
>
> The full build log is here:
>
>   <https://koji.fedoraproject.org/koji/taskinfo?taskID=78987342>
>   <https://kojipkgs.fedoraproject.org//work/tasks/7342/78987342/build.log>
>
> The make error messages are not very helpful to me though.
>

It also happened to me in a build directory whose path contains a
symbolic linked directory.  Make was confused to include the generated
makefile twice, which could be reached with 2 different pathnames.
After removing the symbolic linked directory, the generated makefile
can be reached with a single pathname, the make error went away.
  
Florian Weimer Nov. 17, 2021, 3:29 p.m. UTC | #4
* H. J. Lu:

> On Wed, Nov 17, 2021 at 5:49 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> I still see
>>
>>   /builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/dso-sort-tests-2.def.generated-makefile:1067: warning: overriding recipe for target '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/tst-redhat-1162810-dir/tst-redhat-1162810-M22X17.os'
>>
>> and eventually a build failure:
>>
>>   make[2]: Leaving directory '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/elf'
>>   make[1]: *** [Makefile:483: elf/tests] Error 2
>>   make: *** [Makefile:9: check] Error 2
>>
>> There's no error before that, or other message indicating which make
>> target is failing.
>>
>> The full build log is here:
>>
>>   <https://koji.fedoraproject.org/koji/taskinfo?taskID=78987342>
>>   <https://kojipkgs.fedoraproject.org//work/tasks/7342/78987342/build.log>
>>
>> The make error messages are not very helpful to me though.
>>
>
> It also happened to me in a build directory whose path contains a
> symbolic linked directory.  Make was confused to include the generated
> makefile twice, which could be reached with 2 different pathnames.
> After removing the symbolic linked directory, the generated makefile
> can be reached with a single pathname, the make error went away.

This is a standard Koji build environment.  The build directory is not a
symbolic link:

+ readlink -f .
/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux

And we reach that via /builddir/build/BUILD.

So I still don't know what's going on there.

Thanks,
Florian
  
H.J. Lu Nov. 17, 2021, 3:39 p.m. UTC | #5
On Wed, Nov 17, 2021 at 7:29 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Wed, Nov 17, 2021 at 5:49 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> I still see
> >>
> >>   /builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/dso-sort-tests-2.def.generated-makefile:1067: warning: overriding recipe for target '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux/elf/tst-redhat-1162810-dir/tst-redhat-1162810-M22X17.os'
> >>
> >> and eventually a build failure:
> >>
> >>   make[2]: Leaving directory '/builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/elf'
> >>   make[1]: *** [Makefile:483: elf/tests] Error 2
> >>   make: *** [Makefile:9: check] Error 2
> >>
> >> There's no error before that, or other message indicating which make
> >> target is failing.
> >>
> >> The full build log is here:
> >>
> >>   <https://koji.fedoraproject.org/koji/taskinfo?taskID=78987342>
> >>   <https://kojipkgs.fedoraproject.org//work/tasks/7342/78987342/build.log>
> >>
> >> The make error messages are not very helpful to me though.
> >>
> >
> > It also happened to me in a build directory whose path contains a
> > symbolic linked directory.  Make was confused to include the generated
> > makefile twice, which could be reached with 2 different pathnames.
> > After removing the symbolic linked directory, the generated makefile
> > can be reached with a single pathname, the make error went away.
>
> This is a standard Koji build environment.  The build directory is not a
> symbolic link:
>
> + readlink -f .
> /builddir/build/BUILD/glibc-2.34.9000-294-ga43c0b5483/build-x86_64-redhat-linux
>
> And we reach that via /builddir/build/BUILD.
>
> So I still don't know what's going on there.
>

In my case, the same makefile fragment was included twice.   Can you try

https://sourceware.org/pipermail/libc-alpha/2021-November/132795.html
  
Florian Weimer Nov. 17, 2021, 3:52 p.m. UTC | #6
* H. J. Lu:

> In my case, the same makefile fragment was included twice.   Can you try
>
> https://sourceware.org/pipermail/libc-alpha/2021-November/132795.html

Do you have an updated version?  It doesn't apply anymore.

Thanks,
Florian
  
H.J. Lu Nov. 17, 2021, 4:02 p.m. UTC | #7
On Wed, Nov 17, 2021 at 7:52 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > In my case, the same makefile fragment was included twice.   Can you try
> >
> > https://sourceware.org/pipermail/libc-alpha/2021-November/132795.html
>
> Do you have an updated version?  It doesn't apply anymore.
>

Here it is.
  
Florian Weimer Nov. 17, 2021, 4:41 p.m. UTC | #8
* H. J. Lu:

> On Wed, Nov 17, 2021 at 7:52 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > In my case, the same makefile fragment was included twice.   Can you try
>> >
>> > https://sourceware.org/pipermail/libc-alpha/2021-November/132795.html
>>
>> Do you have an updated version?  It doesn't apply anymore.
>>
>
> Here it is.

The build finished with the patch:

  <https://koji.fedoraproject.org/koji/taskinfo?taskID=78992550>

I haven't looked at the logs yet.

Thanks,
Florian
  

Patch

diff --git a/elf/Makefile b/elf/Makefile
index a311c3e23c..525f302d1a 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
@@ -498,9 +499,14 @@  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
+endif
+
+postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
+		       $(objpfx)/dso-sort-tests-2.generated-makefile
 
 # Generate from each testcase description file
 ifeq (yes,$(have-tunables))