All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set
@ 2019-04-30 14:23 kai.kang
  2019-04-30 14:46 ` Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: kai.kang @ 2019-04-30 14:23 UTC (permalink / raw)
  To: raj.khem; +Cc: openembedded-core

From: Kai Kang <kai.kang@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@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"
-- 
2.20.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set
  2019-04-30 14:23 [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set kai.kang
@ 2019-04-30 14:46 ` Richard Purdie
  2019-05-06  1:56   ` Kang Kai
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2019-04-30 14:46 UTC (permalink / raw)
  To: kai.kang, raj.khem; +Cc: openembedded-core

On Tue, 2019-04-30 at 10:23 -0400, kai.kang@windriver.com wrote:
> From: Kai Kang <kai.kang@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@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?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set
  2019-04-30 14:46 ` Richard Purdie
@ 2019-05-06  1:56   ` Kang Kai
  0 siblings, 0 replies; 3+ messages in thread
From: Kang Kai @ 2019-05-06  1:56 UTC (permalink / raw)
  To: Richard Purdie, raj.khem; +Cc: openembedded-core

On 2019/4/30 下午10:46, Richard Purdie wrote:
> On Tue, 2019-04-30 at 10:23 -0400, kai.kang@windriver.com wrote:
>> From: Kai Kang <kai.kang@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@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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-06  1:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 14:23 [PATCH v2] virglrenderer: use gold linker for x86 if cflag -fvisibility=default set kai.kang
2019-04-30 14:46 ` Richard Purdie
2019-05-06  1:56   ` Kang Kai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.