virglrenderer: use gold linker for x86 if cflag -fvisibility=default set
PATCH v2 1/1 virglrenderer: use gold linker for x86 if cflag -fvisibility=default set
From: Kai Kang <[email protected]>
When gcc compile options '-fvisibility=default' is set in CFLAGS, it fails to compile virglrenderer for x86:
| i586-wrs-linux-libtool: link: i586-wrs-linux-gcc -m32 -march=i586 ...
-Wl,--whole-archive ./.libs/libvrend.a gallium/auxiliary/.libs/libgallium.a -Wl,--no-whole-archive ... -Wl,-Bsymbolic -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
-fstack-protector-strong -Wl,-z -Wl,relro -Wl,-z -Wl,now -pthread
-Wl,-soname -Wl,libvirglrenderer.so.0 -o .libs/libvirglrenderer.so.0.2.0
| ld: gallium/auxiliary/.libs/libgallium.a(u_cpu_detect.o): relocation
R_386_GOTOFF against undefined symbol `util_cpu_caps' can not be used when making a shared object
| ld: final link failed: bad value
| collect2: error: ld returned 1 exit status
It seems GNU bfd linker doesn't work well to handle option '-Bsymbolic' and gcc option '-fvisibility=default'. Use gold instead under this circumstance.
--- meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb +2 -0
@@ -15,6 +15,8 @@ S = "${WORKDIR}/git" inherit autotools pkgconfig distro_features_check +EXTRA_OEMAKE_x86 = "${@bb.utils.contains('CFLAGS', '-fvisibility=default', 'GM_LDFLAGS+=-fuse-ld=gold', '', d)}" + BBCLASSEXTEND = "native nativesdk" REQUIRED_DISTRO_FEATURES = "opengl"
Signature · 1 line
2.20.0
Quoted 31 lines · On Tue, 2019-04-30 at 10:23 -0400, [email protected] wrote:
From: Kai Kang <[email protected]>
When gcc compile options '-fvisibility=default' is set in CFLAGS, it fails to compile virglrenderer for x86:
Quoted 1 line
i586-wrs-linux-libtool: link: i586-wrs-linux-gcc -m32 -march=i586 ...
-Wl,--whole-archive ./.libs/libvrend.a gallium/auxiliary/.libs/libgallium.a -Wl,--no-whole-archive ... -Wl,-Bsymbolic -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
-fstack-protector-strong -Wl,-z -Wl,relro -Wl,-z -Wl,now -pthread
-Wl,-soname -Wl,libvirglrenderer.so.0 -o .libs/libvirglrenderer.so.0.2.0Quoted 1 line
ld: gallium/auxiliary/.libs/libgallium.a(u_cpu_detect.o): relocation
R_386_GOTOFFagainst undefined symbol `util_cpu_caps' can not be used when making a shared objectQuoted 2 lines
ld: final link failed: bad value
collect2: error: ld returned 1 exit statusIt seems GNU bfd linker doesn't work well to handle option '-Bsymbolic' and gcc option '-fvisibility=default'. Use gold instead under this circumstance.
Signed-off-by Kai Kang <[email protected]>--- meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb | 2 ++ 1 file changed, 2 insertions(+)meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb +0
-0
meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb S = "${WORKDIR}/git" · line 22
Quoted 8 lines
meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb +2
-0@@ -15,6 +15,8 @@ S = "${WORKDIR}/git" inherit autotools pkgconfig distro_features_check +EXTRA_OEMAKE_x86 = "${@bb.utils.contains('CFLAGS', '-fvisibility=default', 'GM_LDFLAGS+=-fuse-ld=gold', '', d)}" + BBCLASSEXTEND = "native nativesdk" REQUIRED_DISTRO_FEATURES = "opengl"
Do we really want to start adding hacks to recipes to work around linker bugs like this?
Has the bug been reported upstream? Why doesn't this happen on non-x86?
Cheers,
Richard
Quoted 38 lines · Richard Purdie
Quoted 37 lines · On Tue, 2019-04-30 at 10:23 -0400, [email protected] wrote:
From: Kai Kang <[email protected]>
When gcc compile options '-fvisibility=default' is set in CFLAGS, it fails to compile virglrenderer for x86:
Quoted 1 line
i586-wrs-linux-libtool: link: i586-wrs-linux-gcc -m32 -march=i586 ...
-Wl,--whole-archive ./.libs/libvrend.a gallium/auxiliary/.libs/libgallium.a -Wl,--no-whole-archive ... -Wl,-Bsymbolic -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
-fstack-protector-strong -Wl,-z -Wl,relro -Wl,-z -Wl,now -pthread
-Wl,-soname -Wl,libvirglrenderer.so.0 -o .libs/libvirglrenderer.so.0.2.0Quoted 1 line
ld: gallium/auxiliary/.libs/libgallium.a(u_cpu_detect.o): relocation
R_386_GOTOFFagainst undefined symbol `util_cpu_caps' can not be used when making a shared objectQuoted 2 lines
ld: final link failed: bad value
collect2: error: ld returned 1 exit statusIt seems GNU bfd linker doesn't work well to handle option '-Bsymbolic' and gcc option '-fvisibility=default'. Use gold instead under this circumstance.
Signed-off-by Kai Kang <[email protected]>--- meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb | 2 ++ 1 file changed, 2 insertions(+)meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb +2
-0@@ -15,6 +15,8 @@ S = "${WORKDIR}/git" inherit autotools pkgconfig distro_features_check +EXTRA_OEMAKE_x86 = "${@bb.utils.contains('CFLAGS', '-fvisibility=default', 'GM_LDFLAGS+=-fuse-ld=gold', '', d)}" + BBCLASSEXTEND = "native nativesdk"
Quoted 5 lines
meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb S = "${WORKDIR}/git" · line 22
Quoted 1 line
meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb +0
-0REQUIRED_DISTRO_FEATURES = "opengl"Do we really want to start adding hacks to recipes to work around linker bugs like this?
Has the bug been reported upstream? Why doesn't this happen on non-x86?
I have sent the v1 patch to virglrenderer upstream
https://gitlab.freedesktop.org/virgl/virglrenderer/merge_requests/213
And they said that link option '-Bsymbolic' " just checks that all symbols are available, and if they are not you should hit a run-time error when the symbol is used, in summary, the flag is there to make sure that we don't hit this kind of run-time error."
It also doesn't fail on x86-64. I suspect there is something wrong in gnu bfd linker for x86.
Regards,
Kai
Quoted 6 lines
Cheers,
Richard
Signature · 1 line
Kai Kang