diff mbox series

libstdc++-v3: testsuite: Prune uncapitalized "in function" linker warning

Message ID 20240814170028.4421D2044C@pchp3.se.axis.com
State New
Headers show
Series libstdc++-v3: testsuite: Prune uncapitalized "in function" linker warning | expand

Commit Message

Hans-Peter Nilsson Aug. 14, 2024, 5 p.m. UTC
(CC to the dejagnu project as a heads-up)

Regtested cris-elf with a fresh newlib checkout where 2640
libstdc++-v3 tests otherwise fail due to the stubbed newlib
_getentropy.  Ok to commit?

-- >8 --
Newer newlib trigger warnings about certain functions not implemented
(_getentropy) when testing libstdc++-v3.

Since 2018 (circa binutils-2.10) the "in function" prefix isn't
capitalized for those "not implemented" warnings when generated from
the linker (a GNU ld feature used by newlib).  Dejagnu up to and
including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a
capital "In function", leaving that part unpruned, and boom we have
thousands of "excess errors" from the libstdc++-v3 testsuite.

While gcc/testsuite/lib/prune.exp:prune_gcc_output already deals with
this quirk with a vastly more generic pattern, I choose this simpler
tweak.

libstdc++-v3:
	* testsuite/lib/prune.exp (libstdc++-dg-prune): Prune
	uncapitalized "in function" warning from linker.
---
 libstdc++-v3/testsuite/lib/prune.exp | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jacob Bachmeyer Aug. 15, 2024, 1:58 a.m. UTC | #1
Hans-Peter Nilsson wrote:
> (CC to the dejagnu project as a heads-up)
>
> Regtested cris-elf with a fresh newlib checkout where 2640
> libstdc++-v3 tests otherwise fail due to the stubbed newlib
> _getentropy.  Ok to commit?
>
> -- >8 --
> Newer newlib trigger warnings about certain functions not implemented
> (_getentropy) when testing libstdc++-v3.
>
> Since 2018 (circa binutils-2.10) the "in function" prefix isn't
> capitalized for those "not implemented" warnings when generated from
> the linker (a GNU ld feature used by newlib).  Dejagnu up to and
> including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a
> capital "In function", leaving that part unpruned, and boom we have
> thousands of "excess errors" from the libstdc++-v3 testsuite.
>   

To confirm:  newer binutils drops capitalization in a message "in 
function FOO\nBAR is not implemented and will always fail".  DejaGnu 
expects GNU ld to say "In function FOO..." and fails to recognize the 
new form.

If this is correct, I will fix it in Git master.  (The fix is trivial: 
change the "I" to "[Ii]" to accept both forms.)

(You may still want to add the patch to the testsuite, for compatibility 
with older versions of DejaGnu.)


-- Jacob
Hans-Peter Nilsson Aug. 15, 2024, 2:46 a.m. UTC | #2
> Date: Wed, 14 Aug 2024 20:58:04 -0500
> From: Jacob Bachmeyer <jcb62281@gmail.com>
> Reply-To: jcb62281@gmail.com

> Hans-Peter Nilsson wrote:
> > (CC to the dejagnu project as a heads-up)
> >
> > Regtested cris-elf with a fresh newlib checkout where 2640
> > libstdc++-v3 tests otherwise fail due to the stubbed newlib
> > _getentropy.  Ok to commit?
> >
> > -- >8 --
> > Newer newlib trigger warnings about certain functions not implemented
> > (_getentropy) when testing libstdc++-v3.
> >
> > Since 2018 (circa binutils-2.10) the "in function" prefix isn't
> > capitalized for those "not implemented" warnings when generated from
> > the linker (a GNU ld feature used by newlib).  Dejagnu up to and
> > including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a
> > capital "In function", leaving that part unpruned, and boom we have
> > thousands of "excess errors" from the libstdc++-v3 testsuite.
> >   
> 
> To confirm:  newer binutils drops capitalization in a message "in 
> function FOO\nBAR is not implemented and will always fail".  DejaGnu 
> expects GNU ld to say "In function FOO..." and fails to recognize the 
> new form.

Correctly understood.

I see I managed to goof the version corresponding to the
binutils commit (the "git tag --contains df5f2391f7b2e"). To
wit, the first release containing the miniscule "in
function" seems to be not binutils-2.10 but binutils-2.31
(modulo back-ports that I didn't check).

> If this is correct, I will fix it in Git master.  (The fix is trivial: 
> change the "I" to "[Ii]" to accept both forms.)

Yes, thanks; just don't forget to escape the []. :)

> (You may still want to add the patch to the testsuite, for compatibility 
> with older versions of DejaGnu.)

Definitely; gcc development doesn't require top-of-the-tree tools.

brgds, H-P
Jacob Bachmeyer Aug. 15, 2024, 3:12 a.m. UTC | #3
Hans-Peter Nilsson wrote:
>> Date: Wed, 14 Aug 2024 20:58:04 -0500
>> From: Jacob Bachmeyer <jcb62281@gmail.com>
>> Reply-To: jcb62281@gmail.com
>>     
> [...]
>> If this is correct, I will fix it in Git master.  (The fix is trivial: 
>> change the "I" to "[Ii]" to accept both forms.)
>>     
>
> Yes, thanks; just don't forget to escape the []. :)
>   

Of course; I followed the escaping elsewhere in those patterns.  (I 
probably should change them to {} strings at some point, since no 
variables are interpolated.)

Done and pushed to Savannah as commit 
ed301dbd6a3d769670503ccfda1ea31b58d02547.  Please confirm that this 
solves the problem.

(Also note that you can now run DejaGnu from a Git checkout, simply use 
the "runtest" in the Git working directory.  Any problems with this are 
bugs and will be fixed.)


-- Jacob
Jonathan Wakely Aug. 15, 2024, 8:06 a.m. UTC | #4
On Wed, 14 Aug 2024, 18:00 Hans-Peter Nilsson, <hp@axis.com> wrote:

> (CC to the dejagnu project as a heads-up)
>
> Regtested cris-elf with a fresh newlib checkout where 2640
> libstdc++-v3 tests otherwise fail due to the stubbed newlib
> _getentropy.  Ok to commit?
>

OK for trunk and release branches too if you want. Thanks.



> -- >8 --
> Newer newlib trigger warnings about certain functions not implemented
> (_getentropy) when testing libstdc++-v3.
>
> Since 2018 (circa binutils-2.10) the "in function" prefix isn't
> capitalized for those "not implemented" warnings when generated from
> the linker (a GNU ld feature used by newlib).  Dejagnu up to and
> including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a
> capital "In function", leaving that part unpruned, and boom we have
> thousands of "excess errors" from the libstdc++-v3 testsuite.
>
> While gcc/testsuite/lib/prune.exp:prune_gcc_output already deals with
> this quirk with a vastly more generic pattern, I choose this simpler
> tweak.
>
> libstdc++-v3:
>         * testsuite/lib/prune.exp (libstdc++-dg-prune): Prune
>         uncapitalized "in function" warning from linker.
> ---
>  libstdc++-v3/testsuite/lib/prune.exp | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/lib/prune.exp
> b/libstdc++-v3/testsuite/lib/prune.exp
> index 071dcf34c1e8..4250e2d39e7d 100644
> --- a/libstdc++-v3/testsuite/lib/prune.exp
> +++ b/libstdc++-v3/testsuite/lib/prune.exp
> @@ -80,6 +80,15 @@ proc libstdc++-dg-prune { system text } {
>      # Ignore dsymutil warning (tool bug is actually in the linker)
>      regsub -all "(^|\n)\[^\n\]*could not find object file symbol for
> symbol\[^\n\]*" $text "" text
>
> +    # This pattern, except requiring a capitalized "In" and with a
> +    # sub-pattern matching a subsequent line "is not implemented and will
> +    # always fail", is part of the standard dejagnu prune_warnings
> function.
> +    # There's also a separate single-line pattern pruning the "is not
> +    # implemented and will always fail".  Since that pattern is processed
> +    # before this ${tool}-dg-prune function is called, we have to handle
> +    # the single uncapitalized "in function" line.
> +    regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text
> +
>      # If exceptions are disabled, mark tests expecting exceptions to be
> enabled
>      # as unsupported.
>      if { ![check_effective_target_exceptions_enabled] } {
> --
> 2.30.2
>
>
Hans-Peter Nilsson Aug. 15, 2024, 3:32 p.m. UTC | #5
> Date: Wed, 14 Aug 2024 22:12:23 -0500
> From: Jacob Bachmeyer <jcb62281@gmail.com>

> Done and pushed to Savannah as commit 
> ed301dbd6a3d769670503ccfda1ea31b58d02547.  Please confirm that this 
> solves the problem.

Confirmed*...

> (Also note that you can now run DejaGnu from a Git checkout, simply use 
> the "runtest" in the Git working directory.  Any problems with this are 
> bugs and will be fixed.)

...using this setup.  Really nice!

(* Confirmed that the commit fixes the problem, also as a
sanity-check, verified that the combination with my patch
does not mess things up.)

As an aside for the gcc project only: by dejagnu now
properly handling this issue, it also showed that there's a
pruning-flaw with the g++ part testsuite (to wit, not
intended to be covered by my patch which was only for
libstdc++).  This means that either
gcc/testsuite/lib/prune.exp:prune_gcc_output has a flaw or
is not applied for e.g. g++.dg/modules/global-3,
g++.dg/modules/hello-1, g++.dg/modules/hello-2 and
g++.dg/modules/iostream-1.  I'll look into that.

brgds, H-P
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp
index 071dcf34c1e8..4250e2d39e7d 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -80,6 +80,15 @@  proc libstdc++-dg-prune { system text } {
     # Ignore dsymutil warning (tool bug is actually in the linker)
     regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text
 
+    # This pattern, except requiring a capitalized "In" and with a
+    # sub-pattern matching a subsequent line "is not implemented and will
+    # always fail", is part of the standard dejagnu prune_warnings function.
+    # There's also a separate single-line pattern pruning the "is not
+    # implemented and will always fail".  Since that pattern is processed
+    # before this ${tool}-dg-prune function is called, we have to handle
+    # the single uncapitalized "in function" line.
+    regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text
+
     # If exceptions are disabled, mark tests expecting exceptions to be enabled
     # as unsupported.
     if { ![check_effective_target_exceptions_enabled] } {