Public bug reported:

On Ubuntu 16.04 beta 2, there is a regression in
g++ 4:5.3.1-1ubuntu1
g++ (Ubuntu 5.3.1-13ubuntu3) 5.3.1 20160330
relative to Ubuntu 15.10 and before.
This came to light while compiling an app that uses stb_image.h, see
https://github.com/nothings/stb/issues/280

In 
https://lists.fedoraproject.org/archives/list/de...@lists.fedoraproject.org/thread/ZM2L65WIZEEQHHLFERZYD5FAG7QY2OGB/
Jakub Jelinek suggested a workaround (add  -lgcc_s -lgcc at the end of the g++ 
command that links the shared library)
and a real fix 
"on ppc32 I remember libgcc_s.so is a linker script which links in -lgcc_s 
-lgcc, perhaps we need it on x86_64/i686 too".
His workaround helped me.
I don't know if a gcc has been filed yet; I couldn't find one, but at least 
Jakub is aware of the problem.

To reproduce, use __builtin_cpu_supports from a shared library, and link with 
g++.
Example:

::::::::::::::
bugapp.c
::::::::::::::
#include <stdio.h>
extern int foo();

int main(int argc, char **argv) {
    printf("foo is %d\n", foo());
}
::::::::::::::
buglib.c
::::::::::::::
int foo(void) {
    return __builtin_cpu_supports("sse2");
}
::::::::::::::
bug.sh
::::::::::::::
#!/bin/sh
set -x
echo Demonstrate gotcha in __builtin_cpu_supports on Ubuntu 16.04 and rawhide / 
f24 
echo See 
https://lists.fedoraproject.org/archives/list/de...@lists.fedoraproject.org/thread/ZM2L65WIZEEQHHLFERZYD5FAG7QY2OGB/
echo Maybe caused by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61309

echo Linking with gcc works:
gcc -fPIC -shared  buglib.c -o buglib.so
gcc bugapp.c buglib.so

echo Linking with g++ fails:
g++ -fPIC -shared  buglib.c -o buglib.so
g++ bugapp.c buglib.so
# /usr/bin/ld: a.out: hidden symbol `__cpu_model' in 
/usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO
# /usr/bin/ld: final link failed: Bad value
# collect2: error: ld returned 1 exit status
g++ --version

echo Rescue by linking libgcc explicitly into shared library:
g++ -fPIC -shared  buglib.c -lgcc_s -lgcc -o buglib.so
g++ bugapp.c buglib.so

** Affects: gcc-5 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1568899

Title:
  ld: a.out: hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-
  gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to