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

Matthias Klose doko at ubuntu.com
Tue Apr 12 11:09:54 UTC 2016


fixed upstream. however it looks like backporting this patch to the
gcc-5-branch will add a dependency on new symbols, which are not found
on other GCC 5 builds.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-5 in 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

Status in gcc:
  Unknown
Status in gcc-5 package in Ubuntu:
  New

Bug description:
  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/devel@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/devel@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

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



More information about the foundations-bugs mailing list