Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build from source, aarch64, got /usr/bin/ld: ../src/.libs/libunwind.so: undefined reference to `__aarch64_cas8_acq_rel' #693

Open
jiridanek opened this issue Jan 2, 2024 · 8 comments · May be fixed by #732

Comments

@jiridanek
Copy link

Full compilation log: https://download.copr.fedorainfracloud.org/results/packit/skupperproject-skupper-router-1014/fedora-rawhide-aarch64/06847035-skupper-router/builder-live.log.gz

Making install in tests
make[1]: Entering directory '/builddir/build/BUILD/libunwind-1.8.0-rc1/tests'
  CC       forker.o
  CCLD     forker
  CC       Gperf-simple.o
  CCLD     Gperf-simple
/usr/bin/ld: ../src/.libs/libunwind.so: undefined reference to `__aarch64_cas8_acq_rel'
/usr/bin/ld: ../src/.libs/libunwind.so: undefined reference to `__aarch64_swp1_acq_rel'
/usr/bin/ld: ../src/.libs/libunwind.so: undefined reference to `__aarch64_ldadd8_acq_rel'
/usr/bin/ld: ../src/.libs/libunwind.so: undefined reference to `__aarch64_ldadd4_acq_rel'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1204: Gperf-simple] Error 1
make[1]: Leaving directory '/builddir/build/BUILD/libunwind-1.8.0-rc1/tests'
make: *** [Makefile:618: install-recursive] Error 1
@jiridanek
Copy link
Author

Tried to do

+ ./configure --prefix=/builddir/build/BUILD/libunwind-install CFLAGS=-latomic LDFLAGS=-latomic

and then I got

In file included from aarch64/Los-linux.c:4:
aarch64/Gos-linux.c: In function ‘_ULaarch64_local_resume’:
aarch64/Gos-linux.c:41:7: error: ‘asm’ operand has impossible constraints
   41 |       __asm__ __volatile__ (
      |       ^~~~~~~
make[2]: *** [Makefile:4381: aarch64/Los-linux.lo] Error 1
make[2]: Leaving directory '/builddir/build/BUILD/libunwind-1.8.0-rc1/src'
make[1]: *** [Makefile:4527: install] Error 2
make[1]: Leaving directory '/builddir/build/BUILD/libunwind-1.8.0-rc1/src'
make: *** [Makefile:618: install-recursive] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.UIEGPW (%build)

full log at https://download.copr.fedorainfracloud.org/results/packit/skupperproject-skupper-router-1014/fedora-39-aarch64/06847997-skupper-router/builder-live.log.gz

@bregma
Copy link
Member

bregma commented Jan 2, 2024

I can't comment on the atomic symbols missing (maybe adding libatomic in your environment is the right fix for that) but it looks like there may be a problem with GCC 13 and inline assembly for aarch64, but only at -O0. The default is -O2 but setting CFLAGS at configure time clobbers that (which is wrong and a separate issue and configure.ac or Makefile.am probably needs to be fixed), revealing the bug. It's not clear whether the bug is in the compiler or in the libunwind code. Needs investigation.

If you set CFLAGS="-latomic -O2" does it resolve your issue?

@jiridanek
Copy link
Author

Yes, I got a successful build with

+ ./configure --prefix=/builddir/build/BUILD/libunwind-install CFLAGS=-O2 LDFLAGS=-latomic

(https://download.copr.fedorainfracloud.org/results/packit/skupperproject-skupper-router-1014/epel-9-aarch64/06850522-skupper-router/builder-live.log.gz)

The -latomic was a guess on my part. Apparently that's really what fedora on aarch64 needed. I also googled up -mno-outline-atomics, that's what I'd be trying next if -latomic did not help.

@bregma
Copy link
Member

bregma commented Jan 2, 2024

The -latomic thing is apparently because fedora turns on -foutline-atomic by default when it builds libgcc and uses the sneaky hack of making libgcc_s.so a linker file instead of a shared library, silently pulling in libgcc.a. Unfortunately, libunwind uses -nostdlib to avoid possible circular dependencies, and that option means libgcc_s.so does not get linked into the library so the sneaky hack just doesn't work.

I guess the bug is really that using -nostdlib may no longer be necessary on all (any?) target OSes and in fact causes a problem on some. This is something I can investigate.

@ggardet
Copy link

ggardet commented Feb 1, 2024

I have a similar issue on openSUSE Tumbleweed aarch64:

[   79s] libtool: link: gcc -fno-optimize-sibling-calls -mbranch-protection=standard -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -flto=auto -o .libs/Lperf-trace Lperf-trace.o  ../src/.libs/libunwind.so -lc -llzma -Wl,-rpath -Wl,/usr/lib64
[   79s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: .libs/Lperf-trace: hidden symbol `__aarch64_cas8_acq_rel' in /usr/lib64/gcc/aarch64-suse-linux/13/libgcc.a(cas_8_4.o) is referenced by DSO
[   79s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: final link failed: bad value
[   79s] collect2: error: ld returned 1 exit status
[   79s] make[1]: *** [Makefile:1323: Lperf-trace] Error 1

@ggardet
Copy link

ggardet commented Feb 12, 2024

I have a similar issue on openSUSE Tumbleweed aarch64:

[   79s] libtool: link: gcc -fno-optimize-sibling-calls -mbranch-protection=standard -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -flto=auto -o .libs/Lperf-trace Lperf-trace.o  ../src/.libs/libunwind.so -lc -llzma -Wl,-rpath -Wl,/usr/lib64
[   79s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: .libs/Lperf-trace: hidden symbol `__aarch64_cas8_acq_rel' in /usr/lib64/gcc/aarch64-suse-linux/13/libgcc.a(cas_8_4.o) is referenced by DSO
[   79s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: final link failed: bad value
[   79s] collect2: error: ld returned 1 exit status
[   79s] make[1]: *** [Makefile:1323: Lperf-trace] Error 1

As a workaround, we can disable LTO.

@bregma bregma linked a pull request Mar 18, 2024 that will close this issue
@bregma
Copy link
Member

bregma commented Mar 18, 2024

@jiridanek @ggardet please check to see if #732 resolves the issue of failing to find the atomic symbols for you.

@ggardet
Copy link

ggardet commented Mar 18, 2024

@jiridanek @ggardet please check to see if #732 resolves the issue of failing to find the atomic symbols for you.

For openSUSE Tumbleweed with #732 and LTO disbaled, it still fails:

[  137s] checking if -latomic is required... no
[  159s] /usr/bin/bash ../libtool  --tag=CC   --mode=link gcc -fno-optimize-sibling-calls -mbranch-protection=standard -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__  -flto=auto -o Lperf-trace Lperf-trace.o ../src/libunwind.la 
[  159s] libtool: link: gcc -fno-optimize-sibling-calls -mbranch-protection=standard -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -flto=auto -o .libs/Lperf-trace Lperf-trace.o  ../src/.libs/libunwind.so -lc -llzma -Wl,-rpath -Wl,/usr/lib64
[  159s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: .libs/Lperf-trace: hidden symbol `__aarch64_cas8_acq_rel' in /usr/lib64/gcc/aarch64-suse-linux/13/libgcc.a(cas_8_4.o) is referenced by DSO
[  159s] /usr/lib64/gcc/aarch64-suse-linux/13/../../../../aarch64-suse-linux/bin/ld: final link failed: bad value
[  159s] collect2: error: ld returned 1 exit status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants