Skip to contentSkip to conversation

package/spirv-tools: fix build issue

PATCH Superseded Maciej Grela 3 participants 12 messages Oct 27, 2023 – Nov 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/spirv-tools: fix build issue

spirv-tools requires a C++ toolchain with shared libs, add flag dependency and comment.

---
 package/spirv-tools/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
package/spirv-tools/Config.in +5 -0
index e2f46253a9..f1ae11bd09 100644
@@ -1,6 +1,11 @@
+comment "spirv-tools needs a toolchain w/ C++, dynamic library"
+	depends on !BR2_INSTALL_LIBSTDCPP || ( !BR2_SHARED_LIBS && !BR2_SHARED_STATIC_LIBS )
+
 config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	select BR2_PACKAGE_SPIRV_HEADERS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_SHARED_LIBS || BR2_SHARED_STATIC_LIBS
 	help
 	  The SPIR-V Tools project provides an API and commands for
 	  processing SPIR-V modules.
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Maciej, All,

On 2023-10-27 11:15 +0200, Maciej Grela spake thusly:

Quoted 1 line

spirv-tools requires a C++ toolchain with shared libs, add flag dependency and comment.

Fabrice had already sent a patch adding C++ requirement, and since it also was more strict in requiring C++17, I applied his patch.

Quoted 10 lines

AFAICS, none of those relate to shared libraries, but only to C++.

Can you point to a build failure that is explicitly about shared libs?

Quoted 10 lines
---
 package/spirv-tools/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
package/spirv-tools/Config.in +0 -0
index e2f46253a9..f1ae11bd09 100644

package/spirv-tools/Config.in line 8

Quoted 8 lines
package/spirv-tools/Config.in +5 -0
@@ -1,6 +1,11 @@
+comment "spirv-tools needs a toolchain w/ C++, dynamic library"
+	depends on !BR2_INSTALL_LIBSTDCPP || ( !BR2_SHARED_LIBS && !BR2_SHARED_STATIC_LIBS )
+
 config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	select BR2_PACKAGE_SPIRV_HEADERS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_SHARED_LIBS || BR2_SHARED_STATIC_LIBS

Also this is technically correct (and I would thinkg semantically the best), we usally use the shorter dependnecy on !static:

depends on !BR2_STATIC_LIBS

You also forgot to add a comment for when the condition is not met.

So, if sahred libs is really required, can you respin a patch with the above fixed, please?

Regards,
Yann E. MORIN.

Quoted 10 lines
package/spirv-tools/Config.in +0 -0
 	help
 	  The SPIR-V Tools project provides an API and commands for
 	  processing SPIR-V modules.
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 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.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author
#2 lore raw

PATCH v2 1/1 package/spirv-tools: fix build issue

In reply to Maciej Grela
Quoted 1 line

Maciej, All,

Sorry for not replying to your email directly but instead mashing this response out of the original email as I seem to have deleted the thread somehow :/.

Quoted 17 lines

On 2023-10-27 11:15 +0200, Maciej Grela spake thusly:

Quoted 1 line

spirv-tools requires a C++ toolchain with shared libs, add flag dependency and comment.

Fabrice had already sent a patch adding C++ requirement, and since it also was more strict in requiring C++17, I applied his patch.

Quoted 10 lines
Quoted 4 lines

AFAICS, none of those relate to shared libraries, but only to C++.

Can you point to a build failure that is explicitly about shared libs?

Consider a1f615d2410bffb6fdacc8586761c9def05aafa9, when you try download the config and try to build spirv-tools with just enabling the C++ toolchain it fails with the following error:

[ 54%] Building CXX object source/opt/CMakeFiles/SPIRV-Tools-opt.dir/dataflow.cpp.o
[ 55%] Building CXX object source/opt/CMakeFiles/SPIRV-Tools-opt.dir/dead_branch_elim_pass.cpp.o
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libc.a(__uClibc_main.os): in function `__uClibc_fini':
__uClibc_main.c:(.text+0x140): undefined reference to `__fini_array_start'
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x144): undefined reference to `__fini_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x148): undefined reference to `__fini_array_start' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libc.a(__uClibc_main.os): in function `__uClibc_main':
__uClibc_main.c:(.text+0x430): undefined reference to `__preinit_array_start'
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x434): undefined reference to `__preinit_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x438): undefined reference to `__init_array_start' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x43c): undefined reference to `__init_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: libSPIRV-Tools-shared.so: hidden symbol `__preinit_array_start' isn't defined /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

As far as my research about these errors suggested this is a result of trying to do a dynamic link with a static library. After enabling BR2_SHARED_LIBS and rebuilding the entire toolchain (make clean + make spirv-tools again) the build succeeds:

[ 99%] Building CXX object tools/CMakeFiles/spirv-reduce.dir/util/cli_consumer.cpp.o [ 99%] Building CXX object tools/CMakeFiles/spirv-reduce.dir/reduce/reduce.cpp.o [ 99%] Linking CXX executable spirv-link
[ 99%] Built target spirv-link
[100%] Linking CXX executable spirv-diff
[100%] Built target spirv-diff
[100%] Linking CXX executable spirv-reduce
[100%] Built target spirv-reduce

Quoted 1 line
Quoted 1 line
Quoted 1 line

spirv-tools 1.3.261.1 Installing to staging directory

PATH="/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/bin:/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/sbin:/home/enki/.local/bin:/home/enki/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" DESTDIR=/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/armeb-buildroot-linux-uclibcgnueabi/sysroot /usr/bin/cmake --install /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/build/spirv-tools-1.3.261.1/

The failure mode here might be caused by the fact that the .mk file explicitly disables static builds for spirv-tools:

➜ buildroot git:(75fa573ef9) ✗ cat package/spirv-tools/spirv-tools.mk # Keep in sync with spirv-headers version
SPIRV_TOOLS_VERSION = 1.3.261.1
SPIRV_TOOLS_SITE = $(call github,KhronosGroup,SPIRV-Tools,sdk-$(SPIRV_TOOLS_VERSION)) SPIRV_TOOLS_LICENSE = Apache-2.0
SPIRV_TOOLS_LICENSE_FILES = LICENSE
SPIRV_TOOLS_DEPENDENCIES = spirv-headers
SPIRV_TOOLS_INSTALL_STAGING = YES

SPIRV_TOOLS_CONF_OPTS = \
        -DSPIRV-Headers_SOURCE_DIR=$(STAGING_DIR)/usr \
***        -DSPIRV_TOOLS_BUILD_STATIC=OFF \   ****
        -DSPIRV_SKIP_TESTS=ON \
        -DSPIRV_WERROR=OFF
Quoted 22 lines
Quoted 10 lines
Signed-off-by Maciej Grela <enki at fsck.pl>
---
 package/spirv-tools/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
package/spirv-tools/Config.in +0 -0
index e2f46253a9..f1ae11bd09 100644

package/spirv-tools/Config.in line 8

Quoted 8 lines
package/spirv-tools/Config.in +5 -0
@@ -1,6 +1,11 @@
+comment "spirv-tools needs a toolchain w/ C++, dynamic library"
+	depends on !BR2_INSTALL_LIBSTDCPP || ( !BR2_SHARED_LIBS && !BR2_SHARED_STATIC_LIBS )
+
 config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	select BR2_PACKAGE_SPIRV_HEADERS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_SHARED_LIBS || BR2_SHARED_STATIC_LIBS

Also this is technically correct (and I would thinkg semantically the best), we usally use the shorter dependnecy on !static:

Quoted 6 lines

depends on !BR2_STATIC_LIBS

You also forgot to add a comment for when the condition is not met.

So, if sahred libs is really required, can you respin a patch with the above fixed, please?

Yes, one sec.

Signature · 6 lines
enki

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH v3 1/1 package/spirv-tools: fix build issue

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

---
 package/spirv-tools/Config.in | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
package/spirv-tools/Config.in +5 -2
index 39fdb80b86..c1d3a4f9bc 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++17
+	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_SPIRV_HEADERS
 	help
 	  The SPIR-V Tools project provides an API and commands for
@@ -9,6 +10,8 @@ config BR2_PACKAGE_SPIRV_TOOLS
 
 	  https://github.com/KhronosGroup/SPIRV-Tools
 
-comment "spirv-tools needs a toolchain w/ C++, gcc >= 7"
+comment "spirv-tools needs a toolchain w/ C++, gcc >= 7, dynamic library"
 	depends on !BR2_INSTALL_LIBSTDCPP || \
-		!BR2_TOOLCHAIN_GCC_AT_LEAST_7
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
+		BR2_STATIC_LIBS
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Hello,

Quoted 3 lines · On Mon, 30 Oct 2023 14:28:40 +0100 Maciej Grela <[email protected]> wrote:

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

This first build issue is a configuration with BR2_SHARED_STATIC_LIBS=y, so this patch definitely cannot fix it.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

PATCH v4 1/1 package/spirv-tools: fix build issue

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

---
 package/spirv-tools/Config.in | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
package/spirv-tools/Config.in +5 -2
index 39fdb80b86..c1d3a4f9bc 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++17
+	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_SPIRV_HEADERS
 	help
 	  The SPIR-V Tools project provides an API and commands for
@@ -9,6 +10,8 @@ config BR2_PACKAGE_SPIRV_TOOLS
 
 	  https://github.com/KhronosGroup/SPIRV-Tools
 
-comment "spirv-tools needs a toolchain w/ C++, gcc >= 7"
+comment "spirv-tools needs a toolchain w/ C++, gcc >= 7, dynamic library"
 	depends on !BR2_INSTALL_LIBSTDCPP || \
-		!BR2_TOOLCHAIN_GCC_AT_LEAST_7
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
+		BR2_STATIC_LIBS
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author
#6 lore raw
In reply to Thomas Petazzoni via buildroot

---- On Sat, 04 Nov 2023 14:35:27 +0100 Thomas Petazzoni via buildroot wrote ---

Quoted 14 lines

Hello,

On Mon, 30 Oct 2023 14:28:40 +0100

Quoted 3 lines · Maciej Grela [email protected]> wrote:

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

Quoted 8 lines
Quoted 1 line

This first build issue is a configuration with

BR2_SHARED_STATIC_LIBS=y, so this patch definitely cannot fix it.

Right, the initial patch also added a dependency on the C++ compiler. I reworked it after Yann's reply to be applied on top of the already applied C++17 requirement patch. I forgot to adjust the list of Fixed: builds.
This should now be ok only referencing BR2_STATIC_LIBS cases.

Signature · 5 lines
enki
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw
Quoted 3 lines · On Sun, 05 Nov 2023 20:45:45 +0100 enki <[email protected]> wrote:

Right, the initial patch also added a dependency on the C++ compiler. I reworked it after Yann's reply to be applied on top of the already applied C++17 requirement patch. I forgot to adjust the list of Fixed: builds.
This should now be ok only referencing BR2_STATIC_LIBS cases.

Thanks for the feedback. Could you send an updated patch, with an improved/update commit log?

Thanks a lot,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw

PATCH v4 1/1 package/spirv-tools: fix build issue

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

---
 package/spirv-tools/Config.in | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
package/spirv-tools/Config.in +5 -2
index 39fdb80b86..c1d3a4f9bc 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++17
+	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_SPIRV_HEADERS
 	help
 	  The SPIR-V Tools project provides an API and commands for
@@ -9,6 +10,8 @@ config BR2_PACKAGE_SPIRV_TOOLS
 
 	  https://github.com/KhronosGroup/SPIRV-Tools
 
-comment "spirv-tools needs a toolchain w/ C++, gcc >= 7"
+comment "spirv-tools needs a toolchain w/ C++, gcc >= 7, dynamic library"
 	depends on !BR2_INSTALL_LIBSTDCPP || \
-		!BR2_TOOLCHAIN_GCC_AT_LEAST_7
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
+		BR2_STATIC_LIBS
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#9 lore raw

Maciej, All,

On 2023-11-06 14:08 +0100, Maciej Grela spake thusly:

Quoted 4 lines

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

Sorry, but I still don't understansd how those two build failures relate to static builds.

Both failed build logs are about a broken C++ compiler:

-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++ -- Check for working CXX compiler: /usr/bin/clang++ - broken

And indeed, it is not surprising that the host C++ compiler be broken when doing cross-compilation, as it is used to tentatively build taget code:

/usr/bin/clang++ --sysroot=/home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot -O3 -DNDEBUG -static CMakeFiles/cmTC_faefe.dir/testCXXCompiler.cxx.o -o cmTC_faefe /usr/bin/ld: /home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crt1.o: relocations in generic ELF (EM: 40) /usr/bin/ld: /home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crt1.o: error adding symbols: file in wrong format
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So, if it really is about a static linking issue, we need more details...

Regards,
Yann E. MORIN.

Quoted 35 lines
---
 package/spirv-tools/Config.in | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
package/spirv-tools/Config.in +5 -2
index 39fdb80b86..c1d3a4f9bc 100644
@@ -2,6 +2,7 @@ config BR2_PACKAGE_SPIRV_TOOLS
 	bool "spirv-tools"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++17
+	depends on !BR2_STATIC_LIBS
 	select BR2_PACKAGE_SPIRV_HEADERS
 	help
 	  The SPIR-V Tools project provides an API and commands for
@@ -9,6 +10,8 @@ config BR2_PACKAGE_SPIRV_TOOLS
 
 	  https://github.com/KhronosGroup/SPIRV-Tools
 
-comment "spirv-tools needs a toolchain w/ C++, gcc >= 7"
+comment "spirv-tools needs a toolchain w/ C++, gcc >= 7, dynamic library"
 	depends on !BR2_INSTALL_LIBSTDCPP || \
-		!BR2_TOOLCHAIN_GCC_AT_LEAST_7
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
+		BR2_STATIC_LIBS
+
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 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.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author
#10 lore raw

---- On Mon, 06 Nov 2023 14:30:12 +0100 Yann E. MORIN wrote ---

Quoted 50 lines

Maciej, All,

On 2023-11-06 14:08 +0100, Maciej Grela spake thusly:

Quoted 7 lines

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.

Sorry, but I still don't understansd how those two build failures relate

to static builds.

Both failed build logs are about a broken C++ compiler:

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - failed

-- Check for working CXX compiler: /usr/bin/clang++

-- Check for working CXX compiler: /usr/bin/clang++ - broken

And indeed, it is not surprising that the host C++ compiler be broken

when doing cross-compilation, as it is used to tentatively build taget

code:

/usr/bin/clang++ --sysroot=/home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot -O3 -DNDEBUG -static CMakeFiles/cmTC_faefe.dir/testCXXCompiler.cxx.o -o cmTC_faefe

/usr/bin/ld: /home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crt1.o: relocations in generic ELF (EM: 40)

/usr/bin/ld: /home/thomas/autobuild/instance-1/output-1/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/crt1.o: error adding symbols: file in wrong format

Quoted 9 lines

clang: error: linker command failed with exit code 1 (use -v to see invocation)

So, if it really is about a static linking issue, we need more

details...

If you take (as an example) the config from a1f615d2410bffb6fdacc8586761c9def05aafa9, enable the C++ support and try to build you get the failure caused by ld trying to do a dynamic link with a static library:

[ 54%] Building CXX object source/opt/CMakeFiles/SPIRV-Tools-opt.dir/dataflow.cpp.o
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libc.a(__uClibc_main.os): in function `__uClibc_fini':
__uClibc_main.c:(.text+0x140): undefined reference to `__fini_array_start'
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x144): undefined reference to `__fini_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x148): undefined reference to `__fini_array_start' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/armeb-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libc.a(__uClibc_main.os): in function `__uClibc_main':
__uClibc_main.c:(.text+0x430): undefined reference to `__preinit_array_start'
/home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x434): undefined reference to `__preinit_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x438): undefined reference to `__init_array_start' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: __uClibc_main.c:(.text+0x43c): undefined reference to `__init_array_end' /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: libSPIRV-Tools-shared.so: hidden symbol `__preinit_array_start' isn't defined /home/enki/a1f615d2410bffb6fdacc8586761c9def05aafa9/output/host/lib/gcc/armeb-buildroot-linux-uclibcgnueabi/12.3.0/../../../../armeb-buildroot-linux-uclibcgnueabi/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[4]: *** [source/CMakeFiles/SPIRV-Tools-shared.dir/build.make:1223: source/libSPIRV-Tools-shared.so] Błąd 1
make[3]: *** [CMakeFiles/Makefile2:1091: source/CMakeFiles/SPIRV-Tools-shared.dir/all] Błąd 2

Enabling the shared libs and rebuilding the toolchain fixes this. In other words those two builds fail *both* because of missing C++ support as well as a static-only toolchain. It's just that the missing C++ makes it fail early.

Signature · 5 lines
enki
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#11 lore raw

Maciej, All,

On 2023-11-06 22:00 +0100, enki spake thusly:

Quoted 9 lines

---- On Mon, 06 Nov 2023 14:30:12 +0100 Yann E. MORIN wrote ---

Quoted 6 lines

On 2023-11-06 14:08 +0100, Maciej Grela spake thusly:

Quoted 3 lines

spirv-tools requires a toolchain w/ shared libs, add flag dependency and comment.
Fixes: http://autobuild.buildroot.net/results/a1f615d2410bffb6fdacc8586761c9def05aafa9
Fixes: http://autobuild.buildroot.net/results/294ade8c9aa3d650fa5ab6cc34701c4176bc197f

Sorry, but I still don't understansd how those two build failures relate to static builds.

If you take (as an example) the config from a1f615d2410bffb6fdacc8586761c9def05aafa9, enable the C++ support and try to build you get the failure caused by ld trying to do a dynamic link with a static library:

[--SNIP--]

Quoted 4 lines

Enabling the shared libs and rebuilding the toolchain fixes this. In other words those two builds fail *both* because of missing C++ support as well as a static-only toolchain. It's just that the missing C++ makes it fail early.

Here is a minimalist defconfig with static-libs:

    BR2_arm=y
    BR2_cortex_a7=y
    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
    BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7_EABIHF_MUSL_BLEEDING_EDGE=y
    BR2_STATIC_LIBS=y
    BR2_PACKAGE_SPIRV_TOOLS=y

And with this, spirv-tools does build successfully;

    $ make spirv-tools-configure
    [...]
    -- The C compiler identification is GNU 13.2.0
    -- The CXX compiler identification is GNU 13.2.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /home/ymorin/dev/buildroot/O/master/host/bin/arm-linux-gcc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /home/ymorin/dev/buildroot/O/master/host/bin/arm-linux-g++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter
    -- Configuring done (0.4s)
    -- Generating done (0.1s)
    CMake Warning:
      Manually-specified variables were not used by the project:

BUILD_DOC
BUILD_DOCS
BUILD_EXAMPLE
BUILD_EXAMPLES
BUILD_TEST
BUILD_TESTING
BUILD_TESTS

-- Build files have been written to: /home/ymorin/dev/buildroot/O/master/build/spirv-tools-1.3.261.1

$ make spirv-tools-build
[...]
[ 99%] Linking CXX static library libSPIRV-Tools-reduce.a
[ 99%] Built target SPIRV-Tools-reduce
[100%] Building CXX object tools/CMakeFiles/spirv-reduce.dir/util/flags.cpp.o [100%] Building CXX object tools/CMakeFiles/spirv-reduce.dir/reduce/reduce.cpp.o [100%] Building CXX object tools/CMakeFiles/spirv-reduce.dir/util/cli_consumer.cpp.o [100%] Linking CXX executable spirv-reduce
[100%] Built target spirv-reduce

$ make spirv-tools-install
[...]
$ file target/usr/bin/spirv-*
target/usr/bin/spirv-as: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-cfg: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-dis: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-lesspipe.sh: a /usr/bin/env sh script, ASCII text executable
target/usr/bin/spirv-link: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-lint: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-objdump: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-opt: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-reduce: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
target/usr/bin/spirv-val: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

So, strictly speaking, spirv-tools do not require shared libs, and do build OK with static-only.

So, if there is an issue with static-only, there is a hidden condition as well. Can you investigate a bit further, please?

Regards,
Yann E. MORIN.

Signature · 10 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.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot