[PATCH] ld: pass -g for ld-elf tests

Alan Modra amodra@gmail.com
Sat Jun 29 10:23:04 GMT 2024


On Sat, Jun 29, 2024 at 11:11:31AM +0100, Sam James wrote:
> The "DWARF parse during linker error" and "Build warn libbar.so" tests
> require debug information.
> 
> configure defaults to "-O2 -g" but if overriding *FLAGS when building
> tests, this might be lost. Explicitly pass -g given these tests require
> it.
> 
> Originally reported downstream in Gentoo at https://bugs.gentoo.org/934149.
> 
> ld/
> 	* ld/testsuite/ld-elf/dwarf.exp: Pass -g for "DWARD parse during linker error".

typo, and leave off "ld/" from filename.

> 	* ld/testsuite/ld-elf/shared.exp: Ditto for "Build warn libbar.so".
> ---
>  ld/testsuite/ld-elf/dwarf.exp  | 2 +-
>  ld/testsuite/ld-elf/shared.exp | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp
> index a4748a47c98..667020c6a2f 100644
> --- a/ld/testsuite/ld-elf/dwarf.exp
> +++ b/ld/testsuite/ld-elf/dwarf.exp
> @@ -50,7 +50,7 @@ set build_tests {
>     "-s -shared" "-fPIC -g -feliminate-dwarf2-dups"
>     {dwarf1.c} {} "libdwarf1.so"}
>    {"DWARF parse during linker error"
> -   "" "-fno-toplevel-reorder"
> +   "" "-g" "-fno-toplevel-reorder"

I think you'll need
  "" "-g -fno-toplevel-reorder"
otherwise you'll mess up run_cc_link_tests args.

>     {dwarf2a.c dwarf2b.c} {{error_output "dwarf2.err"}} "dwarf2.x"}
>  }
>  
> diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
> index 9e89077af89..0e1bab706e3 100644
> --- a/ld/testsuite/ld-elf/shared.exp
> +++ b/ld/testsuite/ld-elf/shared.exp
> @@ -552,7 +552,7 @@ set build_tests {
>     "-shared" "-fPIC"
>     {begin.c end.c} {} "libbar.so"}
>    {"Build warn libbar.so"
> -   "-shared" "-fPIC"
> +   "-shared" "-fPIC" "-g"

Similarly
  "-shared" "-fPIC -g"

OK with those fixed.

>    {beginwarn.c end.c}
>    {{readelf {-S --wide} libbarw.rd}
>     {warning {^.*beginwarn.c:7:\(.*\): warning: function foo is deprecated\n?$}}}
> -- 
> 2.45.2

-- 
Alan Modra


More information about the Binutils mailing list