Bug 2022588 - gcc: Linking against libgcc_s should imply linking with libgcc (aarch64)
Summary: gcc: Linking against libgcc_s should imply linking with libgcc (aarch64)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.5
Hardware: aarch64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Marek Polacek
QA Contact: Václav Kadlčík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-12 05:11 UTC by Daniel Black
Modified: 2023-07-18 14:19 UTC (History)
4 users (show)

Fixed In Version: gcc-8.5.0-5.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 15:27:26 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
query_response_time.ii (from mariadb source) (2.12 MB, text/plain)
2021-11-12 05:11 UTC, Daniel Black
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1688766 1 None None None 2021-11-15 09:43:32 UTC
Red Hat Issue Tracker RHELPLAN-102573 0 None None None 2021-11-12 05:16:20 UTC
Red Hat Product Errata RHBA-2022:2072 0 None None None 2022-05-10 15:27:52 UTC

Description Daniel Black 2021-11-12 05:11:15 UTC
Created attachment 1841326 [details]
query_response_time.ii (from mariadb source)

Description of problem:

When compiling with -moutline-atomics, the loader cannot resolve __aarch64_ldadd[48]_relax symbols on non-LSE aarch64 hardware.

Version-Release number of selected component (if applicable):

$ rpm -qf /usr/bin/c++
gcc-c++-8.5.0-3.el8.aarch64

$ /usr/bin/c++ --version
c++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-3)

$ readelf -a /usr/lib64/libc-2.28.so | grep ldadd4
 35643: 000000000010d7c0    44 FUNC    LOCAL  DEFAULT   12 __aarch64_ldadd4_acq
$ readelf -a /usr/lib64/libc-2.28.so | grep ldadd8
 33489: 000000000010d820    44 FUNC    LOCAL  DEFAULT   12 __aarch64_ldadd8_acq
 33752: 000000000010d760    44 FUNC    LOCAL  DEFAULT   12 __aarch64_ldadd8_relax
 34144: 000000000010d880    44 FUNC    LOCAL  DEFAULT   12 __aarch64_ldadd8_rel

$ rpm -qf /usr/lib64/libc-2.28.so
glibc-2.28-164.el8.aarch64

How reproducible:

Always

Steps to Reproduce:
1.  c++  -pie -fPIC -fstack-protector --param=ssp-buffer-size=4   -O2 -g    -fno-omit-frame-pointer  -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -fPIC -std=gnu++11 -o /tmp/query_response_time.cc.o  -c  ./build/plugin/query_response_time/query_response_time.ii 
2. readelf -a /tmp/query_response_time.cc.o  |  grep -q ldadd  (returns no output)
3. include -moutline-atomics in cflags
4. __aarch64_ldadd[84]_relax references left in code at end of function:

Actual results:

0000000000000278 <_Z27query_response_time_collecty>:
 278:   90000004        adrp    x4, 0 <_Z24query_response_time_initv>
 27c:   91000081        add     x1, x4, #0x0
 280:   f940b821        ldr     x1, [x1, #368]
 284:   b9400c25        ldr     w5, [x1, #12]
 288:   710000bf        cmp     w5, #0x0
 28c:   540004ad        b.le    320 <_Z27query_response_time_collecty+0xa8>
 290:   a9bd7bfd        stp     x29, x30, [sp, #-48]!
 294:   910003fd        mov     x29, sp
 298:   f9400c22        ldr     x2, [x1, #24]
 29c:   a90153f3        stp     x19, x20, [sp, #16]
 2a0:   eb02001f        cmp     x0, x2
 2a4:   54000403        b.cc    324 <_Z27query_response_time_collecty+0xac>  // b.lo, b.ul, b.last
 2a8:   91004022        add     x2, x1, #0x10
 2ac:   d2800021        mov     x1, #0x1                        // #1
 2b0:   14000004        b       2c0 <_Z27query_response_time_collecty+0x48>
 2b4:   f8617846        ldr     x6, [x2, x1, lsl #3]
 2b8:   eb06001f        cmp     x0, x6
 2bc:   54000103        b.cc    2dc <_Z27query_response_time_collecty+0x64>  // b.lo, b.ul, b.last
 2c0:   6b0100bf        cmp     w5, w1
 2c4:   93407c23        sxtw    x3, w1
 2c8:   91000421        add     x1, x1, #0x1
 2cc:   54ffff4c        b.gt    2b4 <_Z27query_response_time_collecty+0x3c>
 2d0:   a94153f3        ldp     x19, x20, [sp, #16]
 2d4:   a8c37bfd        ldp     x29, x30, [sp], #48
 2d8:   d65f03c0        ret
 2dc:   91017861        add     x1, x3, #0x5e
 2e0:   91011463        add     x3, x3, #0x45
 2e4:   f90013f5        str     x21, [sp, #32]
 2e8:   d37ef421        lsl     x1, x1, #2
 2ec:   d37df073        lsl     x19, x3, #3
 2f0:   91000095        add     x21, x4, #0x0
 2f4:   aa0003f4        mov     x20, x0
 2f8:   8b0102a1        add     x1, x21, x1
 2fc:   52800020        mov     w0, #0x1                        // #1
 300:   94000000        bl      0 <__aarch64_ldadd4_relax>
 304:   8b1302a1        add     x1, x21, x19
 308:   aa1403e0        mov     x0, x20
 30c:   94000000        bl      0 <__aarch64_ldadd8_relax>
 310:   a94153f3        ldp     x19, x20, [sp, #16]
 314:   f94013f5        ldr     x21, [sp, #32]
 318:   a8c37bfd        ldp     x29, x30, [sp], #48
 31c:   d65f03c0        ret
 320:   d65f03c0        ret
 324:   d2804513        mov     x19, #0x228                     // #552
 328:   d2802f01        mov     x1, #0x178                      // #376
 32c:   f90013f5        str     x21, [sp, #32]
 330:   17fffff0        b       2f0 <_Z27query_response_time_collecty+0x78>
 334:   d503201f        nop


Expected results:

A linked .so, with all functions with symbols that resolve on loading.

Additional info:

origin bug report: https://jira.mariadb.org/browse/MDEV-27008

hardware:

LD_SHOW_AUXV=1 /bin/true                                                                                             AT_SYSINFO_EHDR:      0xffffbdb8f000                                                                                                   AT_??? (0x33): 0x1270                                                                                                                  AT_HWCAP:             10119fff                                                                                                         AT_PAGESZ:            4096                                                                                                             AT_CLKTCK:            100                                                                                                              AT_PHDR:              0xaaaac6d90040                                                                                                   AT_PHENT:             56                                                                                                               AT_PHNUM:             9                                                                                                                AT_BASE:              0xffffbdb5f000                                                                                                  AT_FLAGS:             0x0                                                                                                              AT_ENTRY:             0xaaaac6d91710                                                                                                   AT_UID:               1000
AT_EUID:              1000                                                                                                             
AT_GID:               1000                                                                                                             
AT_EGID:              1000                                                                                                             AT_SECURE:            0                                                                                                                AT_RANDOM:            0xffffc2bc38f8                                                                                                   AT_HWCAP2:            0x0 
AT_EXECFN:            /bin/true   
AT_PLATFORM:          aarch64

/proc/cpu

processor       : 1
BogoMIPS        : 50.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer : 0x41
CPU architecture: 8                                                                                                                    
CPU variant     : 0x3                                                                                                                  
CPU part        : 0xd0c
CPU revision    : 1


Looking at:

$ readelf -a /lib64/libresolv-2.28.so | grep  __aarch64_ldadd4_relax
   801: 000000000000ed90    44 FUNC    LOCAL  DEFAULT   13 __aarch64_ldadd4_relax
$ readelf -a /lib64/libpthread-2.28.so | grep __aarch64_ldadd4_relax
  4950: 0000000000014940    44 FUNC    LOCAL  DEFAULT   13 __aarch64_ldadd4_relax

Maybe the compiler is mean to link these functions to the shared library generated?

Creating the final shared object doesn't include the LOCAL function:

[100%] Linking CXX shared module query_response_time.so
cd /home/buildbot/build/plugin/query_response_time && /usr/bin/cmake -E cmake_link_script CMakeFiles/query_response_time.dir/link.txt --verbose=1
/usr/lib64/ccache/c++ -fPIC  -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -moutline-atomics -O2 -g -DNDEBUG -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings  -Wl,-z,relro,-z,now -shared  -o query_response_time.so CMakeFiles/query_response_time.dir/query_response_time.cc.o CMakeFiles/query_response_time.dir/plugin.cc.o  -pthread ../../libservices/libmysqlservices.a -pthread 
gmake[3]: Leaving directory '/home/buildbot/build'
[100%] Built target query_response_time
gmake[2]: Leaving directory '/home/buildbot/build'
/usr/bin/cmake -E cmake_progress_start /home/buildbot/build/CMakeFiles 0
gmake[1]: Leaving directory '/home/buildbot/build'


$  readelf -a  query_response_time.so | grep ldadd
00000001ff10  000300000402 R_AARCH64_JUMP_SL 0000000000000000 __aarch64_ldadd4_relax + 0
00000001ff58  000a00000402 R_AARCH64_JUMP_SL 0000000000000000 __aarch64_ldadd8_relax + 0
     3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd4_relax
    10: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd8_relax
   102: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd4_relax
   121: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd8_relax

Comment 1 Florian Weimer 2021-11-12 09:32:39 UTC
The functions are provided by libgcc, not libatomic:

# nm /usr/lib/gcc/aarch64-redhat-linux/8/libgcc.a | grep ldadd4
0000000000000000 T __aarch64_ldadd4_relax
0000000000000000 T __aarch64_ldadd4_acq
0000000000000000 T __aarch64_ldadd4_rel
0000000000000000 T __aarch64_ldadd4_acq_rel

Unlike libatomic, libgcc is linked implicitly by default. Since this happens only on some of your aarch64 systems, I would assume a system misconfiguration.

The next step is to reproduce this without ccache, and discover the full linker command line (using g++ -v).

Comment 2 Daniel Black 2021-11-15 03:16:00 UTC
[buildbot@8f69ebcb2426 build]$  cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_CXX_FLAGS=-v .
...
[buildbot@8f69ebcb2426 build]$ cmake --build . --target  query_response_time -v
Consolidate compiler generated dependencies of target query_response_time
gmake[3]: Leaving directory '/home/buildbot/build'
/usr/bin/gmake  -f plugin/query_response_time/CMakeFiles/query_response_time.dir/build.make plugin/query_response_time/CMakeFiles/query_response_time.dir/build
gmake[3]: Entering directory '/home/buildbot/build'
[100%] Building CXX object plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o
cd /home/buildbot/build/plugin/query_response_time && /usr/bin/g++ -DDBUG_TRACE -DHAVE_CONFIG_H -DHAVE_RESPONSE_TIME_DISTRIBUTION -DMYSQL_DYNAMIC_PLUGIN -D_FILE_OFFSET_BITS=64 -Dquery_response_time_EXPORTS -I/source/wsrep-lib/include -I/source/wsrep-lib/wsrep-API/v26 -I/home/buildbot/build/include -I/source/include/providers -I/source/include -I/source/sql -v -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -moutline-atomics -O2 -g -DNDEBUG -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -fPIC -std=gnu++11 -MD -MT plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o -MF CMakeFiles/query_response_time.dir/query_response_time.cc.o.d -o CMakeFiles/query_response_time.dir/query_response_time.cc.o -c /source/plugin/query_response_time/query_response_time.cc
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC) 
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
 /usr/libexec/gcc/aarch64-redhat-linux/8/cc1plus -quiet -v -I /source/wsrep-lib/include -I /source/wsrep-lib/wsrep-API/v26 -I /home/buildbot/build/include -I /source/include/providers -I /source/include -I /source/sql -MD CMakeFiles/query_response_time.dir/query_response_time.cc.d -MF CMakeFiles/query_response_time.dir/query_response_time.cc.o.d -MT plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o -D_GNU_SOURCE -D DBUG_TRACE -D HAVE_CONFIG_H -D HAVE_RESPONSE_TIME_DISTRIBUTION -D MYSQL_DYNAMIC_PLUGIN -D _FILE_OFFSET_BITS=64 -D query_response_time_EXPORTS -D NDEBUG -D _FORTIFY_SOURCE=2 -D DBUG_OFF /source/plugin/query_response_time/query_response_time.cc -quiet -dumpbase query_response_time.cc -moutline-atomics -mlittle-endian -mabi=lp64 -auxbase-strip CMakeFiles/query_response_time.dir/query_response_time.cc.o -g -O2 -Wall -Wextra -Wformat-truncation=0 -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -std=gnu++11 -version -fstack-protector -fno-omit-frame-pointer -fPIC --param ssp-buffer-size=4 -o /tmp/ccTpHxT3.s
GNU C++11 (GCC) version 8.5.0 20210514 (Red Hat 8.5.0-3) (aarch64-redhat-linux)
	compiled by GNU C version 8.5.0 20210514 (Red Hat 8.5.0-3), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/aarch64-redhat-linux/8/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/aarch64-redhat-linux/8/../../../../aarch64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /source/wsrep-lib/include
 /source/wsrep-lib/wsrep-API/v26
 /home/buildbot/build/include
 /source/include/providers
 /source/include
 /source/sql
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8/aarch64-redhat-linux
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8/backward
 /usr/lib/gcc/aarch64-redhat-linux/8/include
 /usr/local/include
 /usr/include
End of search list.
GNU C++11 (GCC) version 8.5.0 20210514 (Red Hat 8.5.0-3) (aarch64-redhat-linux)
	compiled by GNU C version 8.5.0 20210514 (Red Hat 8.5.0-3), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 15324aab02465443882f9c779bb84a58
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
 as -v -I /source/wsrep-lib/include -I /source/wsrep-lib/wsrep-API/v26 -I /home/buildbot/build/include -I /source/include/providers -I /source/include -I /source/sql -EL -mabi=lp64 -o CMakeFiles/query_response_time.dir/query_response_time.cc.o /tmp/ccTpHxT3.s
GNU assembler version 2.30 (aarch64-redhat-linux) using BFD version version 2.30-108.el8
COMPILER_PATH=/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/:/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/query_response_time.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
[100%] Building CXX object plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o
cd /home/buildbot/build/plugin/query_response_time && /usr/bin/g++ -DDBUG_TRACE -DHAVE_CONFIG_H -DHAVE_RESPONSE_TIME_DISTRIBUTION -DMYSQL_DYNAMIC_PLUGIN -D_FILE_OFFSET_BITS=64 -Dquery_response_time_EXPORTS -I/source/wsrep-lib/include -I/source/wsrep-lib/wsrep-API/v26 -I/home/buildbot/build/include -I/source/include/providers -I/source/include -I/source/sql -v -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -moutline-atomics -O2 -g -DNDEBUG -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -fPIC -std=gnu++11 -MD -MT plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o -MF CMakeFiles/query_response_time.dir/plugin.cc.o.d -o CMakeFiles/query_response_time.dir/plugin.cc.o -c /source/plugin/query_response_time/plugin.cc
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC) 
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/plugin.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/plugin.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
 /usr/libexec/gcc/aarch64-redhat-linux/8/cc1plus -quiet -v -I /source/wsrep-lib/include -I /source/wsrep-lib/wsrep-API/v26 -I /home/buildbot/build/include -I /source/include/providers -I /source/include -I /source/sql -MD CMakeFiles/query_response_time.dir/plugin.cc.d -MF CMakeFiles/query_response_time.dir/plugin.cc.o.d -MT plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o -D_GNU_SOURCE -D DBUG_TRACE -D HAVE_CONFIG_H -D HAVE_RESPONSE_TIME_DISTRIBUTION -D MYSQL_DYNAMIC_PLUGIN -D _FILE_OFFSET_BITS=64 -D query_response_time_EXPORTS -D NDEBUG -D _FORTIFY_SOURCE=2 -D DBUG_OFF /source/plugin/query_response_time/plugin.cc -quiet -dumpbase plugin.cc -moutline-atomics -mlittle-endian -mabi=lp64 -auxbase-strip CMakeFiles/query_response_time.dir/plugin.cc.o -g -O2 -Wall -Wextra -Wformat-truncation=0 -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -std=gnu++11 -version -fstack-protector -fno-omit-frame-pointer -fPIC --param ssp-buffer-size=4 -o /tmp/ccrWtIPp.s
GNU C++11 (GCC) version 8.5.0 20210514 (Red Hat 8.5.0-3) (aarch64-redhat-linux)
	compiled by GNU C version 8.5.0 20210514 (Red Hat 8.5.0-3), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/aarch64-redhat-linux/8/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/aarch64-redhat-linux/8/../../../../aarch64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /source/wsrep-lib/include
 /source/wsrep-lib/wsrep-API/v26
 /home/buildbot/build/include
 /source/include/providers
 /source/include
 /source/sql
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8/aarch64-redhat-linux
 /usr/lib/gcc/aarch64-redhat-linux/8/../../../../include/c++/8/backward
 /usr/lib/gcc/aarch64-redhat-linux/8/include
 /usr/local/include
 /usr/include
End of search list.
GNU C++11 (GCC) version 8.5.0 20210514 (Red Hat 8.5.0-3) (aarch64-redhat-linux)
	compiled by GNU C version 8.5.0 20210514 (Red Hat 8.5.0-3), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 15324aab02465443882f9c779bb84a58
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/plugin.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/plugin.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
 as -v -I /source/wsrep-lib/include -I /source/wsrep-lib/wsrep-API/v26 -I /home/buildbot/build/include -I /source/include/providers -I /source/include -I /source/sql -EL -mabi=lp64 -o CMakeFiles/query_response_time.dir/plugin.cc.o /tmp/ccrWtIPp.s
GNU assembler version 2.30 (aarch64-redhat-linux) using BFD version version 2.30-108.el8
COMPILER_PATH=/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/:/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-D' 'DBUG_TRACE' '-D' 'HAVE_CONFIG_H' '-D' 'HAVE_RESPONSE_TIME_DISTRIBUTION' '-D' 'MYSQL_DYNAMIC_PLUGIN' '-D' '_FILE_OFFSET_BITS=64' '-D' 'query_response_time_EXPORTS' '-I' '/source/wsrep-lib/include' '-I' '/source/wsrep-lib/wsrep-API/v26' '-I' '/home/buildbot/build/include' '-I' '/source/include/providers' '-I' '/source/include' '-I' '/source/sql' '-v' '-pie' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-fPIC' '-std=gnu++11' '-MD' '-MT' 'plugin/query_response_time/CMakeFiles/query_response_time.dir/plugin.cc.o' '-MF' 'CMakeFiles/query_response_time.dir/plugin.cc.o.d' '-o' 'CMakeFiles/query_response_time.dir/plugin.cc.o' '-c' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
[100%] Linking CXX shared module query_response_time.so
cd /home/buildbot/build/plugin/query_response_time && /usr/bin/cmake -E cmake_link_script CMakeFiles/query_response_time.dir/link.txt --verbose=1
/usr/bin/g++ -fPIC -v -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -moutline-atomics -O2 -g -DNDEBUG -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings  -Wl,-z,relro,-z,now -shared  -o query_response_time.so CMakeFiles/query_response_time.dir/query_response_time.cc.o CMakeFiles/query_response_time.dir/plugin.cc.o  -pthread ../../libservices/libmysqlservices.a -pthread 
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC) 
COMPILER_PATH=/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/8/:/usr/libexec/gcc/aarch64-redhat-linux/:/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/8/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/aarch64-redhat-linux/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-fPIC' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-shared' '-o' 'query_response_time.so' '-pthread' '-pthread' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
 /usr/libexec/gcc/aarch64-redhat-linux/8/collect2 -plugin /usr/libexec/gcc/aarch64-redhat-linux/8/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper -plugin-opt=-fresolution=/tmp/ccEaptrM.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -shared -X -EL -maarch64linux -o query_response_time.so /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crti.o /usr/lib/gcc/aarch64-redhat-linux/8/crtbeginS.o -L/usr/lib/gcc/aarch64-redhat-linux/8 -L/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/aarch64-redhat-linux/8/../../.. -z relro -z now CMakeFiles/query_response_time.dir/query_response_time.cc.o CMakeFiles/query_response_time.dir/plugin.cc.o ../../libservices/libmysqlservices.a -lstdc++ -lm -lgcc_s -lpthread -lc -lgcc_s /usr/lib/gcc/aarch64-redhat-linux/8/crtendS.o /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crtn.o
COLLECT_GCC_OPTIONS='-v' '-fPIC' '-fstack-protector' '--param' 'ssp-buffer-size=4' '-moutline-atomics' '-O2' '-g' '-D' 'NDEBUG' '-fno-omit-frame-pointer' '-D' '_FORTIFY_SOURCE=2' '-D' 'DBUG_OFF' '-Wall' '-Wextra' '-Wformat-truncation=0' '-Wno-init-self' '-Wno-nonnull-compare' '-Wno-unused-parameter' '-Woverloaded-virtual' '-Wnon-virtual-dtor' '-Wvla' '-Wwrite-strings' '-shared' '-o' 'query_response_time.so' '-pthread' '-pthread' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
gmake[3]: Leaving directory '/home/buildbot/build'
[100%] Built target query_response_time
gmake[2]: Leaving directory '/home/buildbot/build'
/usr/bin/cmake -E cmake_progress_start /home/buildbot/build/CMakeFiles 0
gmake[1]: Leaving directory '/home/buildbot/build'

[buildbot@8f69ebcb2426 build]$ readelf -a  plugin/query_response_time/CMakeFiles/query_response_time.dir/query_response_time.cc.o | grep ldadd
000000000300  00240000011b R_AARCH64_CALL26  0000000000000000 __aarch64_ldadd4_relax + 0
00000000030c  00250000011b R_AARCH64_CALL26  0000000000000000 __aarch64_ldadd8_relax + 0
    36: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd4_relax
    37: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __aarch64_ldadd8_relax


[buildbot@8f69ebcb2426 build]$ readelf -d  plugin/query_response_time/query_response_time.so 

Dynamic section at offset 0xfcc8 contains 31 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-aarch64.so.1]

So the shared libgcc.

[buildbot@8f69ebcb2426 build]$ rpm -qf /usr/lib64/libgcc_s.so.1
libgcc-8.5.0-3.el8.aarch64

[buildbot@8f69ebcb2426 build]$ readelf -a  /usr/lib64/libgcc_s.so.1 | grep ldadd
[buildbot@8f69ebcb2426 build]$ 

Without __aarch64_ldadd{4,8}_relax symbols.

Comment 3 Florian Weimer 2021-11-15 09:43:32 UTC
libgcc_s.so is not a linker script:

# ls -l /usr/lib/gcc/aarch64-redhat-linux/8/libgcc_s.so
lrwxrwxrwx. 1 root root 20 Jul 14 09:16 /usr/lib/gcc/aarch64-redhat-linux/8/libgcc_s.so -> /lib64/libgcc_s.so.1

The -moutline-atomics backport on the upstream branch gets it right, but the gcc.spec file overrides it. aarch64 is missing from %ifarch:

mkdir -p %{buildroot}/%{_lib}
mv -f %{buildroot}%{_prefix}/%{_lib}/libgcc_s.so.1 %{buildroot}/%{_lib}/libgcc_s-%{gcc_major}-%{DATE}.so.1
chmod 755 %{buildroot}/%{_lib}/libgcc_s-%{gcc_major}-%{DATE}.so.1
ln -sf libgcc_s-%{gcc_major}-%{DATE}.so.1 %{buildroot}/%{_lib}/libgcc_s.so.1
%ifarch %{ix86} x86_64 ppc ppc64 ppc64p7 ppc64le %{arm}
rm -f $FULLPATH/libgcc_s.so
echo '/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT('`gcc -Wl,--print-output-format -nostdlib -r -o /dev/null`')
GROUP ( /%{_lib}/libgcc_s.so.1 libgcc.a )' > $FULLPATH/libgcc_s.so
%else
ln -sf /%{_lib}/libgcc_s.so.1 $FULLPATH/libgcc_s.so
%endif

Comment 7 Daniel Black 2021-12-01 04:22:29 UTC
Thank you.

I think I omitted to say that this affects RHEL7 too.

Comment 18 errata-xmlrpc 2022-05-10 15:27:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gcc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2072


Note You need to log in before you can comment on or make changes to this bug.