Project

General

Profile

Bug #492

Linking fails on i686 with -fstack-protector-strong

Added by Thomas Lange over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Minor
Assignee:
-
Category:
-
Target version:
-
Start date:
December 15, 2014
Due date:
% Done:

0%

Estimated time:
Affects version:

Description

Several plugins cannot be linked on a i686 system
with the compiler flag "-fstack-protector-strong".

Originally reported on the Arch Linux AUR page.
Reproduced on Arch Linux i686 with g++ 4.9.2.

Affected plugins:
- cairo-spectrum
- gl-spectrum
- statusicon

The error message and config.log are attached.

config.log (71.8 KB) config.log Thomas Lange, December 15, 2014 20:41
error.txt (722 Bytes) error.txt Thomas Lange, December 15, 2014 20:41
makepkg.log (39.6 KB) makepkg.log Thomas Lange, December 16, 2014 19:13
verbose.log (6.08 KB) verbose.log Thomas Lange, December 17, 2014 00:47

History

#1 Updated by John Lindgren over 9 years ago

An undefined reference in libc doesn't seem like a bug in Audacious. Do you have any reason for supposing it to be one, or a proposed fix?

#2 Updated by Michael Schwendt over 9 years ago

The error.txt is truncated. What are the preceeding lines that show how the compiler was invoked?

-fstack-protector-strong is also used by Fedora builds, and the build of 3.6-alpha1 succeeds for i686.

#3 Updated by Thomas Lange over 9 years ago

@Michael:
The compiler was invoked by the tool "makepkg" of Arch Linux, its complete log file is attached.

The flags are the defaults for Arch Linux:

CPPFLAGS="-D_FORTIFY_SOURCE=2" 
CFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4" 
CXXFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4" 
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro" 

@John:
If "-lc" is added to LDFLAGS it links successfully.

#4 Updated by John Lindgren over 9 years ago

Thomas Lange wrote:

If "-lc" is added to LDFLAGS it links successfully.

"-lc" shouldn't be necessary since we use "g++" for the link command. It should link in the C and C++ runtime libraries automatically, I would think.

#5 Updated by Michael Schwendt over 9 years ago

The default build output is "silent". When the configure script doesn't handle --disable-silent-rules option, something like

sed -i '\,^.SILENT:,d' buildsys.mk.in

to get verbose build output. Only in verbose build output one gets to see compiler/linker warnings which may be relevant.

#6 Updated by Thomas Lange over 9 years ago

Thanks, new verbose output file is attached.

glibc on Arch is compiled without fstack-protector-strong.
https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/glibc#n59
Could this be related? How does Fedora compile it?

#7 Updated by John Lindgren over 9 years ago

Maybe -fstack-protector-strong needs to be in LDFLAGS as well as CFLAGS?

#8 Updated by Michael Schwendt over 9 years ago

It doesn't need to be present in LDFLAGS.

$ objdump -tT /usr/lib64/libc.so.6 |grep stack_chk
0000000000000000 l    df *ABS*    0000000000000000              stack_chk_fail.c
00000000001122c0 g     F .text    0000000000000010              __stack_chk_fail
00000000001122c0 g    DF .text    0000000000000010  GLIBC_2.4   __stack_chk_fail

How does Fedora compile it?

glibc build logs: http://koji.fedoraproject.org/koji/buildinfo?buildID=581316

Audacious 3.6-alpha1 i686 build log for a private Fedora 21 build:
https://copr-be.cloud.fedoraproject.org/results/mschwendt/audacious-next/fedora-21-i386/audacious-plugins-3.6-0.3.alpha1.fc21/build.log

$ rpm -E %configure

  CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic}" ; export CFLAGS ; 
  CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic}" ; export CXXFLAGS ; 
  FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -I/usr/lib64/gfortran/modules}" ; export FFLAGS ; 
  FCFLAGS="${FCFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -I/usr/lib64/gfortran/modules}" ; export FCFLAGS ; 
  LDFLAGS="${LDFLAGS:--Wl,-z,relro }"; export LDFLAGS; 
  [ "1" = 1 ] && for i in $(find . -name config.guess -o -name config.sub) ; do 
      [ -f /usr/lib/rpm/redhat/$(basename $i) ] && /usr/bin/rm -f $i && /usr/bin/cp -fv /usr/lib/rpm/redhat/$(basename $i) $i ; 
  done ; 
  [ "1" = 1 ] && [ x != "x" ] && 
      for i in $(find . -name ltmain.sh) ; do 
        /usr/bin/sed -i.backup -e 's~compiler_flags=$~compiler_flags=""~' $i 
      done ; 
  ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
    --program-prefix= \
    --disable-dependency-tracking \
    --prefix=/usr \
    --exec-prefix=/usr \
    --bindir=/usr/bin \
    --sbindir=/usr/sbin \
    --sysconfdir=/etc \
    --datadir=/usr/share \
    --includedir=/usr/include \
    --libdir=/usr/lib64 \
    --libexecdir=/usr/libexec \
    --localstatedir=/var \
    --sharedstatedir=/var/lib \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info

#9 Updated by John Lindgren over 9 years ago

So can we say:
1. Compiling with -fstack-protector-strong works fine on Fedora, so there's something different about the Arch Linux makepkg environment that is (directly or indirectly) causing the problem.
2. A workaround for makepkg is to link with "-lc", but this is only a workaround, not a proper fix, since libc ought to be linked in automatically.

... and close this report?

#10 Updated by Michael Schwendt about 9 years ago

1. Agreed. It seems the toolchain is broken with Arch Linux.
2. True. It's g++'s responsibility to link with the C/C++/GCC/Math libs as needed, not Audacious'.

#11 Updated by Thomas Lange about 9 years ago

  • Status changed from New to Closed

All right, marking as closed.

#12 Updated by Thomas Lange about 9 years ago

The issue was solved by the lastest updates.
binutils 2.25 and GCC 4.9.2 20141224 now link successfully.

Also available in: Atom PDF