[OE-core] [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set

Kang Kai Kai.Kang at windriver.com
Mon May 6 01:56:39 UTC 2019


On 2019/4/30 下午10:46, Richard Purdie wrote:
> On Tue, 2019-04-30 at 10:23 -0400, kai.kang at windriver.com wrote:
>> From: Kai Kang <kai.kang at windriver.com>
>>
>> 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.
>>
>> Signed-off-by: Kai Kang <kai.kang at windriver.com>
>> ---
>>   meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb b/meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb
>> index 225a0b8b0c..f72cfbd9b4 100644
>> --- a/meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb
>> +++ b/meta/recipes-graphics/virglrenderer/virglrenderer_0.7.0.bb
>> @@ -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?

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


>
> Cheers,
>
> Richard
>
>

-- 
Kai Kang



More information about the Openembedded-core mailing list