ld: a.out: hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc |
Fix Released
|
Medium
|
|||
gcc-5 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
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:/
In
https://<email address hidden>
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_
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_
}
::::::::::::::
bug.sh
::::::::::::::
#!/bin/sh
set -x
echo Demonstrate gotcha in __builtin_
echo See https://<email address hidden>
echo Maybe caused by https:/
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/
# /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
Changed in gcc: | |
importance: | Unknown → Medium |
status: | Unknown → Fix Released |
On Linux/x86, r221732 gave
FAIL: g++.dg/ext/mv14.C -std=gnu++11 execution test
FAIL: g++.dg/ext/mv14.C -std=gnu++14 execution test
FAIL: g++.dg/ext/mv14.C -std=gnu++98 execution test
FAIL: g++.dg/ext/mv15.C -std=gnu++11 execution test
FAIL: g++.dg/ext/mv15.C -std=gnu++14 execution test
FAIL: g++.dg/ext/mv15.C -std=gnu++98 execution test
FAIL: g++.dg/ext/mv1.C -std=gnu++11 execution test
FAIL: g++.dg/ext/mv1.C -std=gnu++14 execution test
FAIL: g++.dg/ext/mv1.C -std=gnu++98 execution test
when compiled with -fPIE -pie.