Bug 31644 - [Regression] libstdc++prettyprinters/debug.[cc|cxx11.cc] failing to build - linker error
Summary: [Regression] libstdc++prettyprinters/debug.[cc|cxx11.cc] failing to build - l...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.43 (HEAD)
: P2 normal
Target Milestone: 2.43
Assignee: H.J. Lu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-15 18:03 UTC by Carlos Eduardo Seo
Modified: 2024-04-17 00:51 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2024-04-16 00:00:00


Attachments
A testcase (595 bytes, application/octet-stream)
2024-04-16 22:33 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Eduardo Seo 2024-04-15 18:03:05 UTC
The following tests are failing to build:

		=== libstdc++ tests ===

Running libstdc++:libstdc++-prettyprinters/prettyprinters.exp ...
UNRESOLVED: libstdc++-prettyprinters/debug.cc compilation failed to produce executable
UNRESOLVED: libstdc++-prettyprinters/debug_cxx11.cc compilation failed to produce executable

Possible culprit, according to the post-commit CI is:

https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=c0419c024bf922128131671e40de0aed736e38ed

CI logs:

https://git-us.linaro.org/toolchain/ci/interesting-commits.git/plain/binutils/sha1/c0419c024bf922128131671e40de0aed736e38ed/tcwg_gnu_native_check_gcc/master-aarch64/details.txt

https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/1047/artifact/artifacts
Comment 1 Sam James 2024-04-16 02:53:04 UTC
-> ccing hj
Comment 2 Andrew Pinski 2024-04-16 03:02:01 UTC
Note also the jenkins does not keep around the .log files from the testsuite is it is not very useful info except something failed ...
Comment 3 H.J. Lu 2024-04-16 03:28:17 UTC
I can't reproduce it on Linux/x86-64.  If it still fails with master branch,
please find a testcase which can be reproduced on Linux/x86-64.
Comment 4 Carlos Eduardo Seo 2024-04-16 17:12:15 UTC
(In reply to Andrew Pinski from comment #2)
> Note also the jenkins does not keep around the .log files from the testsuite
> is it is not very useful info except something failed ...

Yes it does: https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/1047/artifact/artifacts/00-sumfiles/

I agree it's very convoluted to find, though.

(In reply to H.J. Lu from comment #3)
> I can't reproduce it on Linux/x86-64.  If it still fails with master branch,
> please find a testcase which can be reproduced on Linux/x86-64.

AFAIK, this is only broken in aarch64-linux.
Comment 5 Andrew Pinski 2024-04-16 17:18:14 UTC
Oh note it is with -flto .
Comment 6 Andrew Pinski 2024-04-16 17:21:12 UTC
It looks like the link against libstdc++v3.so is not happening ...
Comment 7 H.J. Lu 2024-04-16 18:08:59 UTC
(In reply to Carlos Eduardo Seo from comment #4)
> (In reply to H.J. Lu from comment #3)
> > I can't reproduce it on Linux/x86-64.  If it still fails with master branch,
> > please find a testcase which can be reproduced on Linux/x86-64.
> 
> AFAIK, this is only broken in aarch64-linux.

Does it still fail with the current master branch?
Comment 8 Carlos Eduardo Seo 2024-04-16 18:15:21 UTC
(In reply to H.J. Lu from comment #7)
> (In reply to Carlos Eduardo Seo from comment #4)
> > (In reply to H.J. Lu from comment #3)
> > > I can't reproduce it on Linux/x86-64.  If it still fails with master branch,
> > > please find a testcase which can be reproduced on Linux/x86-64.
> > 
> > AFAIK, this is only broken in aarch64-linux.
> 
> Does it still fail with the current master branch?

Yesterday, when I opened the bug, yes.
Comment 9 H.J. Lu 2024-04-16 18:19:14 UTC
(In reply to Carlos Eduardo Seo from comment #8)
> (In reply to H.J. Lu from comment #7)
> > (In reply to Carlos Eduardo Seo from comment #4)
> > > (In reply to H.J. Lu from comment #3)
> > > > I can't reproduce it on Linux/x86-64.  If it still fails with master branch,
> > > > please find a testcase which can be reproduced on Linux/x86-64.
> > > 
> > > AFAIK, this is only broken in aarch64-linux.
> > 
> > Does it still fail with the current master branch?
> 
> Yesterday, when I opened the bug, yes.

If you can provide ALL linker inputs which can be used to reproduce the issue
on Linux/x86-64 with a cross linker, I will take a look.
Comment 10 Sam James 2024-04-16 18:32:07 UTC
I had a build where this might have happened on amd64. I will look but I can't promise to spend hours on it. I'll include the files if I can repro.
Comment 11 H.J. Lu 2024-04-16 20:00:59 UTC
I can reproduce it.
Comment 12 H.J. Lu 2024-04-16 22:33:25 UTC
Created attachment 15469 [details]
A testcase

[hjl@gnu-cfl-3 31644]$ make
gcc -B./ -g -flto   -c -o x.o x.c
gcc -B./ -g   -c -o foo.o foo.c
ar -rv libfoo.a foo.o
ar: creating libfoo.a
a - foo.o
gcc -B./ -g -fPIC   -c -o bar.o bar.c
gcc -B./ -shared -o libbar.so bar.o
gcc -B./  -o x x.o libfoo.a libbar.so -Wl,-R,.
./ld: libfoo.a(foo.o): in function `foo':
/export/home/hjl/bugs/binutils/31644/foo.c:6:(.text+0x5): undefined reference to `bar'
collect2: error: ld returned 1 exit status
make: *** [Makefile:15: x] Error 1
rm foo.o
[hjl@gnu-cfl-3 31644]$ gcc -c x.c
[hjl@gnu-cfl-3 31644]$ make
gcc -B./  -o x x.o libfoo.a libbar.so -Wl,-R,.
./x
[hjl@gnu-cfl-3 31644]$
Comment 13 H.J. Lu 2024-04-16 22:49:06 UTC
A patch is posted at

https://sourceware.org/pipermail/binutils/2024-April/133632.html
Comment 14 Sourceware Commits 2024-04-17 00:51:16 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c2fbf57864a2da2ceda81706a54d125ef3fce0a7

commit c2fbf57864a2da2ceda81706a54d125ef3fce0a7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Apr 16 15:48:21 2024 -0700

    elf: Skip the archive if the symbol isn't referenced
    
    Also skip the archive if the symbol isn't referenced by a regular object.
    
    bfd/
    
            PR ld/31644
            * elflink.c (elf_link_add_archive_symbols): Also skip the archive
            if the symbol isn't referenced by a regular object.
    
    ld/
    
            PR ld/31644
            * testsuite/ld-plugin/lto.exp: Run PR ld/31644 tests.
            * testsuite/ld-plugin/pr31644a.c: New test.
            * testsuite/ld-plugin/pr31644b.c: Likewise.
            * testsuite/ld-plugin/pr31644c.c: Likewise.
Comment 15 H.J. Lu 2024-04-17 00:51:47 UTC
Fixed.