summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/cmake
diff options
context:
space:
mode:
authorPhilip Lorenz <philip.lorenz@bmw.de>2024-11-05 15:01:07 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-11-06 12:18:05 +0000
commited82f9c0903777c4b9f337266d6862e29b739110 (patch)
treeb10cf7f8d4261a99e2bb76b4fe36f15df5b88c53 /meta/recipes-devtools/cmake
parentb94b85bef0b6375be71be6002521e147906080e5 (diff)
downloadpoky-ed82f9c0903777c4b9f337266d6862e29b739110.tar.gz
cmake: Fix sporadic issues when determining compiler internals
When `-pipe` is enabled, GCC passes data between its different executables using pipes instead of temporary files. This leads to issues when cmake attempts to infer compiler internals via the `-v` parameter as each executable will print to `stderr` in parallel. In turn this may lead to compilation issues down the line as for example the system include directories could not be determined properly which may then propagate to issues such as: recipe-sysroot/usr/include/c++/11.3.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory | 75 | #include_next <stdlib.h> | | ^~~~~~~~~~ | compilation terminated. | ninja: build stopped: subcommand failed. | WARNING: exit code 1 from a shell command. Fix this stripping `-pipe` from the command line used to determine compiler internals. (From OE-Core rev: 34fa8230163e5ed1c6668bf800c45a173c6490ca) Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/cmake')
-rw-r--r--meta/recipes-devtools/cmake/cmake.inc3
-rw-r--r--meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch63
2 files changed, 65 insertions, 1 deletions
diff --git a/meta/recipes-devtools/cmake/cmake.inc b/meta/recipes-devtools/cmake/cmake.inc
index 41f169e14c..1f1d63cad6 100644
--- a/meta/recipes-devtools/cmake/cmake.inc
+++ b/meta/recipes-devtools/cmake/cmake.inc
@@ -17,7 +17,8 @@ LIC_FILES_CHKSUM = "file://Copyright.txt;md5=718f05155941b33862726348d3cd46ce \
17CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" 17CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
18 18
19SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ 19SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \
20" 20 file://0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch \
21 "
21 22
22SRC_URI[sha256sum] = "9f55e1a40508f2f29b7e065fa08c29f82c402fa0402da839fffe64a25755a86d" 23SRC_URI[sha256sum] = "9f55e1a40508f2f29b7e065fa08c29f82c402fa0402da839fffe64a25755a86d"
23 24
diff --git a/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch b/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch
new file mode 100644
index 0000000000..47373c194e
--- /dev/null
+++ b/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch
@@ -0,0 +1,63 @@
1From 7fa115171a658d5358e15dcb40b233d049acae2f Mon Sep 17 00:00:00 2001
2From: Philip Lorenz <philip.lorenz@bmw.de>
3Date: Mon, 3 Jun 2024 13:19:24 +0200
4Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags
5
6When `-pipe` is enabled, GCC passes data between its different
7executables using pipes instead of temporary files. This leads to issues
8when cmake attempts to infer compiler internals via the `-v` parameter
9as each executable will print to `stderr` in parallel.
10
11For example we have observed the following outputs in our builds which
12sporadically lead to build failures as system include directories were
13not detected reliably:
14
15Parsed CXX implicit include dir info from above output: rv=done
16 found start of include info
17 found start of implicit include info
18 add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include]
19 add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include-fixed]
20 add: [.../usr/include/c++/11.4.0]
21 add: [.../usr/include/c++/11.4.0/x86_64-poky-linux]
22 add: [.../usr/include/c++/11.4.0/backward]
23 add: [.../usr/lib/x86_64-poky-linux/11.4.0/include]
24 add: [...GNU assembler version 2.38 (x86_64-poky-linux) using BFD version (GNU Binutils) 2.38.20220708]
25 add: [/usr/include]
26 end of search list found
27
28Fix this issue by stripping the `-pipe` parameter from the compilation
29flag when determining the toolchain configuration.
30
31Upstream-Status: Backport [3.32.0, 71be059f3f32b6791427893a48ba4815a19e2e78]
32Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de>
33---
34 Modules/CMakeDetermineCompilerABI.cmake | 9 ++++++++-
35 1 file changed, 8 insertions(+), 1 deletion(-)
36
37diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
38index 4a75e25a92..806f0b715d 100644
39--- a/Modules/CMakeDetermineCompilerABI.cmake
40+++ b/Modules/CMakeDetermineCompilerABI.cmake
41@@ -52,14 +52,21 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
42
43 __TestCompiler_setTryCompileTargetType()
44
45- # Avoid failing ABI detection on warnings.
46+ # Avoid failing ABI detection caused by non-functionally relevant
47+ # compiler arguments
48 if(CMAKE_TRY_COMPILE_CONFIGURATION)
49 string(TOUPPER "${CMAKE_TRY_COMPILE_CONFIGURATION}" _tc_config)
50 else()
51 set(_tc_config "DEBUG")
52 endif()
53 foreach(v CMAKE_${lang}_FLAGS CMAKE_${lang}_FLAGS_${_tc_config})
54+ # Avoid failing ABI detection on warnings.
55 string(REGEX REPLACE "(^| )-Werror([= ][^-][^ ]*)?( |$)" " " ${v} "${${v}}")
56+ # Avoid passing of "-pipe" when determining the compiler internals. With
57+ # "-pipe" GCC will use pipes to pass data between the involved
58+ # executables. This may lead to issues when their stderr output (which
59+ # contains the relevant compiler internals) becomes interweaved.
60+ string(REGEX REPLACE "(^| )-pipe( |$)" " " ${v} "${${v}}")
61 endforeach()
62
63 # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables