Bug 30698 - ld test 'Run pr23169b' fails
Summary: ld test 'Run pr23169b' fails
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.41
: P2 normal
Target Milestone: 2.42
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-30 18:01 UTC by Sam James
Modified: 2023-12-20 02:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
ld.log.xz (234.76 KB, application/x-xz)
2023-07-30 18:01 UTC, Sam James
Details
A patch (226 bytes, patch)
2023-08-03 20:45 UTC, H.J. Lu
Details | Diff
ld.log.xz (with patch) (234.73 KB, application/x-xz)
2023-08-04 00:46 UTC, Sam James
Details
A patch (280 bytes, patch)
2023-08-04 17:55 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2023-07-30 18:01:33 UTC
Created attachment 15021 [details]
ld.log.xz

Originally reported downstream in Gentoo at https://bugs.gentoo.org/885617 but I can reproduce it myself now.

```
$ grep FAIL: /var/tmp/portage/sys-devel/binutils-2.41/temp/build.log
FAIL: tmpdir/gp-collect-app_F
FAIL: --only-keep-debug for ELF relocatables
FAIL: Run pr23169b
```

(I'll file other bugs for the other 2 failures, so just worrying about 'Run pr23169b' here.)

From `ld.log`:
```
Running: tmpdir/pr23169b > tmpdir/pr23169b.out
tmpdir/pr23169b: IFUNC symbol 'func' referenced in 'tmpdir/libpr23169a.so' is defined in the executable and creates an unsatisfiable circular dependency.
FAIL: Run pr23169b
x86_64-pc-linux-gnu-gcc  -B/var/tmp/portage/sys-devel/binutils-2.41/work/build/ld/tmpdir/ld/ -I/var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc -g -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -Wreturn-type -ggdb3   -c -fno-lto -fPIE -O2 -g -c /var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc/pr23169b.c -o tmpdir/pr23169b.o
```

```
$ ld.so --version | head -1
ld.so (Gentoo 2.37-r4 (patchset 6)) stable release version 2.37.
```
Comment 1 H.J. Lu 2023-08-03 20:37:13 UTC
Is lazy binding disabled by default?
Comment 2 Sam James 2023-08-03 20:39:31 UTC
Ah, yes, we're using -z now by default.
Comment 3 H.J. Lu 2023-08-03 20:45:58 UTC
Created attachment 15036 [details]
A patch

Try this.
Comment 4 Sam James 2023-08-04 00:46:51 UTC
Created attachment 15037 [details]
ld.log.xz (with patch)

Huh. Surprisingly, no?

spawn [open ...]
Running: tmpdir/pr23169b > tmpdir/pr23169b.out
tmpdir/pr23169b: IFUNC symbol 'func' referenced in 'tmpdir/libpr23169a.so' is defined in the executable and creates an unsatisfiable circular dependency.
FAIL: Run pr23169b
x86_64-pc-linux-gnu-gcc  -B/var/tmp/portage/sys-devel/binutils-2.41/work/build/ld/tmpdir/ld/ -I/var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc -g -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -Wreturn-type -ggdb3   -c -fno-lto -fPIE -O2 -g -c /var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc/pr23169b.c -o tmpdir/pr23169b.o
Executing on host: sh -c {x86_64-pc-linux-gnu-gcc  -B/var/tmp/portage/sys-devel/binutils-2.41/work/build/ld/tmpdir/ld/ -I/var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc -g -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -Wreturn-type -ggdb3   -c -fno-lto -fPIE -O2 -g -c /var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/ld/testsuite/ld-ifunc/pr23169b.c -o tmpdir/pr23169b.o 2>&1}  /dev/null ld.tmp (timeout = 300)

Attached the full ld.log.
Comment 5 H.J. Lu 2023-08-04 17:55:45 UTC
Created attachment 15039 [details]
A patch

Try this one.
Comment 6 Sam James 2023-08-04 22:05:24 UTC
(In reply to H.J. Lu from comment #5)
> Created attachment 15039 [details]
> A patch
> 
> Try this one.

That works, thank you!

I've also filed PR30722 for the remaining test failures I hit.
Comment 7 Sourceware Commits 2023-08-14 15:53:39 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=51dd9e7c4cab13748f31f6575aed0672f03d6710

commit 51dd9e7c4cab13748f31f6575aed0672f03d6710
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 7 10:23:16 2023 -0700

    ld: Build libpr23169a.so with -z lazy
    
    pr23169b test only works with lazy binding.  To work with linker which
    disables lazy binding by default, build pr23169b binaries with -z lazy.
    
            PR ld/30698
            * ld-ifunc/ifunc.exp: Build pr23169b binaries with -z lazy.
Comment 8 Sam James 2023-08-15 03:27:49 UTC
Thank you!
Comment 9 Sourceware Commits 2023-12-20 02:38:01 UTC
The binutils-2_41-branch branch has been updated by Sam James <sjames@sourceware.org>:

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

commit 34d8c9d5b4e4fc62bea212b6bd046f26a177df4c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 7 10:23:16 2023 -0700

    ld: Build libpr23169a.so with -z lazy
    
    pr23169b test only works with lazy binding.  To work with linker which
    disables lazy binding by default, build pr23169b binaries with -z lazy.
    
            PR ld/30698
            * ld-ifunc/ifunc.exp: Build pr23169b binaries with -z lazy.
    
    (cherry picked from commit 51dd9e7c4cab13748f31f6575aed0672f03d6710)