Skip to contentSkip to conversation

package/mesa3d: disable --as-needed linker flag for Codesourcery ARM 2014.05 toolchain

PATCH New Romain Naour 3 participants 4 messages Jun 13, 2020 – Jul 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/mesa3d: disable --as-needed linker flag for Codesourcery ARM 2014.05 toolchain

Meson build system enable by default -Wl,--as-needed [1][2] in the linker command line and due to this the libmesa_dri_drivers.so build fail with the Codesourcery ARM and Aarch64 2014.05 toolchain:

/home/buildroot/autobuild/run/instance-1/output-1/host/bin/arm-none-linux-gnueabi-g++
-o src/mesa/drivers/dri/libmesa_dri_drivers.so
-Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libmesa_dri_drivers.so -Wl,--whole-archive src/mesa/drivers/dri/radeon/libr100.a src/mesa/drivers/dri/nouveau/libnouveau_vieux.a -Wl,--no-whole-archive
src/mesa/drivers/dri/common/libmegadriver_stub.a src/mesa/drivers/dri/common/libdricommon.a src/mapi/shared-glapi/libglapi.so.0.0.0
src/mesa/libmesa_classic.a src/mesa/libmesa_common.a src/compiler/glsl/libglsl.a src/compiler/glsl/glcpp/libglcpp.a src/util/libmesa_util.a src/util/format/libmesa_format.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/util/libxmlconfig.a
[...]

src/mesa/drivers/dri/common/libmegadriver_stub.a(megadriver_stub.c.o): In function `megadriver_stub_init':
megadriver_stub.c:(.text.startup+0x20): undefined reference to dladdr' megadriver_stub.c:(.text.startup+0xbc): undefined reference to dlsym'
collect2: error: ld returned 1 exit status

This problem seems to be specific to this toolchain release (ARM and aarch64) CodeSourcery 2014.05: gcc 4.8.3-prerelease; binutils 2.24.51.20140217; glibc 2.18

The following prebuilt toolchain has been tested and doesn't trigger this issue:
Linaro 4.9-4.9-2014.11: gcc 4.9.3; binutils 2.24.0; glibc 2.19 CodeSourcery 2014.11: gcc 4.9.1; binutils 2.24.51.20140217; glibc 2.20

Older toolchains doesn't have a recent enough glibc or linux-headers version to breaking the build with mesa3d 20.1.0 or libdrm 2.4.102.

In order to build mesa3d with the CodeSourcery 2014.05 using --as-needed would be reorder the static librairies:

diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build index b09ca16e38a..9ac6731c522 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -59,7 +59,7 @@ if _dri_drivers != []
[],
link_whole : _dri_drivers,
link_with : [
- libmegadriver_stub, libdricommon, libglapi,
+ libdricommon, libmegadriver_stub, libglapi,

        libmesa_classic,
      ],

Instead, we can disable --as-needed from the meson build system using "-Db_asneeded=false" only for this toolchain.

[1] https://mesonbuild.com/Builtin-options.html
[2] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed

Fixes:
http://autobuild.buildroot.net/results/eec39a4fbfbfaa58980fab36f2fd902a16eecf0f/build-end.log

Cc Thomas Petazzoni <[email protected]>
Cc Bernd Kuhls <[email protected]>
---
 package/mesa3d/mesa3d.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/mesa3d/mesa3d.mk +6 -0
index e726bd33b3..59d96fe7c2 100644
@@ -27,6 +27,12 @@ MESA3D_CONF_OPTS = \
 	-Dgallium-omx=disabled \
 	-Dpower8=false
 
+# Codesourcery ARM 2014.05 fail to link libmesa_dri_drivers.so with --as-needed linker
+# flag due to a linker bug between binutils 2.24 and 2.25 (2.24.51.20140217).
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM),y)
+MESA3D_CONF_OPTS += -Db_asneeded=false
+endif
+
 ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
 MESA3D_DEPENDENCIES += host-llvm llvm
 MESA3D_MESON_EXTRA_BINARIES += llvm-config='$(STAGING_DIR)/usr/bin/llvm-config'
Signature · 1 line
2.25.4
#1 lore raw

PATCH 1/1 package/mesa3d: disable --as-needed linker flag for Codesourcery ARM 2014.05 toolchain

Romain, All,

On 2020-06-13 12:47 +0200, Romain Naour spake thusly:

Quoted 3 lines

Meson build system enable by default -Wl,--as-needed [1][2] in the linker command line and due to this the libmesa_dri_drivers.so build fail with the Codesourcery ARM and Aarch64 2014.05 toolchain:

What about removing this old toolchain, now?

Ditto other old toolchains?

Quoted 13 lines

In order to build mesa3d with the CodeSourcery 2014.05 using --as-needed would be reorder the static librairies:

diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build index b09ca16e38a..9ac6731c522 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -59,7 +59,7 @@ if _dri_drivers != []
[],
link_whole : _dri_drivers,
link_with : [
- libmegadriver_stub, libdricommon, libglapi,
+ libdricommon, libmegadriver_stub, libglapi,

Quoted 2 lines
        libmesa_classic,
      ],

That might make sense to push upstream, no?

Quoted 6 lines

Instead, we can disable --as-needed from the meson build system using "-Db_asneeded=false" only for this toolchain.

[1] https://mesonbuild.com/Builtin-options.html
[2] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed

Quoted 6 lines

Fixes:
http://autobuild.buildroot.net/results/eec39a4fbfbfaa58980fab36f2fd902a16eecf0f/build-end.log

Cc Thomas Petazzoni <[email protected]>
Cc Bernd Kuhls <[email protected]>

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 28 lines
---
 package/mesa3d/mesa3d.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/mesa3d/mesa3d.mk +6 -0
index e726bd33b3..59d96fe7c2 100644
@@ -27,6 +27,12 @@ MESA3D_CONF_OPTS = \
 	-Dgallium-omx=disabled \
 	-Dpower8=false
 
+# Codesourcery ARM 2014.05 fail to link libmesa_dri_drivers.so with --as-needed linker
+# flag due to a linker bug between binutils 2.24 and 2.25 (2.24.51.20140217).
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM),y)
+MESA3D_CONF_OPTS += -Db_asneeded=false
+endif
+
 ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
 MESA3D_DEPENDENCIES += host-llvm llvm
 MESA3D_MESON_EXTRA_BINARIES += llvm-config='$(STAGING_DIR)/usr/bin/llvm-config'
Signature · 6 lines
2.25.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 package/mesa3d: disable --as-needed linker flag for Codesourcery ARM 2014.05 toolchain

Hi Yann,

Le 14/06/2020 ? 09:40, Yann E. MORIN a ?crit?:

Quoted 10 lines

Romain, All,

On 2020-06-13 12:47 +0200, Romain Naour spake thusly:

Quoted 3 lines

Meson build system enable by default -Wl,--as-needed [1][2] in the linker command line and due to this the libmesa_dri_drivers.so build fail with the Codesourcery ARM and Aarch64 2014.05 toolchain:

What about removing this old toolchain, now?

Ditto other old toolchains?

I agree, I doesn't make sense to continue to build such bleeding edge package with old toolchains and spend time to investigate this kind of issue.

Also this CodeSourcery is special since it use a development version of binutils.

Note: We should stop testing with Linaro toolchain and use the ARM toolchain instead. ARM toolchain supersede the Linaro toolchain.

Quoted 17 lines
Quoted 14 lines

In order to build mesa3d with the CodeSourcery 2014.05 using --as-needed would be reorder the static librairies:

diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build index b09ca16e38a..9ac6731c522 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -59,7 +59,7 @@ if _dri_drivers != []
[],
link_whole : _dri_drivers,
link_with : [
- libmegadriver_stub, libdricommon, libglapi,
+ libdricommon, libmegadriver_stub, libglapi,

Quoted 2 lines
        libmesa_classic,
      ],
Quoted 1 line

That might make sense to push upstream, no?

I'm not sure.

Best regards,
Romain

Quoted 48 lines
Quoted 7 lines

Instead, we can disable --as-needed from the meson build system using "-Db_asneeded=false" only for this toolchain.

[1] https://mesonbuild.com/Builtin-options.html
[2] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed

Quoted 6 lines

Fixes:
http://autobuild.buildroot.net/results/eec39a4fbfbfaa58980fab36f2fd902a16eecf0f/build-end.log

Cc Thomas Petazzoni <[email protected]>
Cc Bernd Kuhls <[email protected]>

Applied to master, thanks.

Regards,
Yann E. MORIN.

Quoted 28 lines
---
 package/mesa3d/mesa3d.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/mesa3d/mesa3d.mk +6 -0
index e726bd33b3..59d96fe7c2 100644
@@ -27,6 +27,12 @@ MESA3D_CONF_OPTS = \
 	-Dgallium-omx=disabled \
 	-Dpower8=false
 
+# Codesourcery ARM 2014.05 fail to link libmesa_dri_drivers.so with --as-needed linker
+# flag due to a linker bug between binutils 2.24 and 2.25 (2.24.51.20140217).
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM),y)
+MESA3D_CONF_OPTS += -Db_asneeded=false
+endif
+
 ifeq ($(BR2_PACKAGE_MESA3D_LLVM),y)
 MESA3D_DEPENDENCIES += host-llvm llvm
 MESA3D_MESON_EXTRA_BINARIES += llvm-config='$(STAGING_DIR)/usr/bin/llvm-config'
Signature · 6 lines
2.25.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

PATCH 1/1 package/mesa3d: disable --as-needed linker flag for Codesourcery ARM 2014.05 toolchain

In reply to Romain Naour
Quoted 59 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Romain" == Romain Naour <[email protected]> writes:

Meson build system enable by default -Wl,--as-needed [1][2] in the linker command line and due to this the libmesa_dri_drivers.so build fail with the Codesourcery ARM and Aarch64 2014.05 toolchain:

/home/buildroot/autobuild/run/instance-1/output-1/host/bin/arm-none-linux-gnueabi-g++
-o src/mesa/drivers/dri/libmesa_dri_drivers.so
-Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libmesa_dri_drivers.so -Wl,--whole-archive src/mesa/drivers/dri/radeon/libr100.a src/mesa/drivers/dri/nouveau/libnouveau_vieux.a -Wl,--no-whole-archive
src/mesa/drivers/dri/common/libmegadriver_stub.a src/mesa/drivers/dri/common/libdricommon.a src/mapi/shared-glapi/libglapi.so.0.0.0
src/mesa/libmesa_classic.a src/mesa/libmesa_common.a src/compiler/glsl/libglsl.a src/compiler/glsl/glcpp/libglcpp.a src/util/libmesa_util.a src/util/format/libmesa_format.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/util/libxmlconfig.a
[...]

src/mesa/drivers/dri/common/libmegadriver_stub.a(megadriver_stub.c.o): In function `megadriver_stub_init':
megadriver_stub.c:(.text.startup+0x20): undefined reference to dladdr' megadriver_stub.c:(.text.startup+0xbc): undefined reference to dlsym'
collect2: error: ld returned 1 exit status

This problem seems to be specific to this toolchain release (ARM and aarch64) CodeSourcery 2014.05: gcc 4.8.3-prerelease; binutils 2.24.51.20140217; glibc 2.18

The following prebuilt toolchain has been tested and doesn't trigger this issue:
Linaro 4.9-4.9-2014.11: gcc 4.9.3; binutils 2.24.0; glibc 2.19 CodeSourcery 2014.11: gcc 4.9.1; binutils 2.24.51.20140217; glibc 2.20

Older toolchains doesn't have a recent enough glibc or linux-headers version to breaking the build with mesa3d 20.1.0 or libdrm 2.4.102.

In order to build mesa3d with the CodeSourcery 2014.05 using --as-needed would be reorder the static librairies:

diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build index b09ca16e38a..9ac6731c522 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -59,7 +59,7 @@ if _dri_drivers != []
[],
link_whole : _dri_drivers,
link_with : [
- libmegadriver_stub, libdricommon, libglapi,
+ libdricommon, libmegadriver_stub, libglapi,

        libmesa_classic,
      ],

Instead, we can disable --as-needed from the meson build system using "-Db_asneeded=false" only for this toolchain.

[1] https://mesonbuild.com/Builtin-options.html
[2] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed

Quoted 6 lines

Fixes:
http://autobuild.buildroot.net/results/eec39a4fbfbfaa58980fab36f2fd902a16eecf0f/build-end.log

Cc Thomas Petazzoni <[email protected]>
Cc Bernd Kuhls <[email protected]>

Committed to 2020.02.x and 2020.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard