diff options
| author | Philip Lorenz <philip.lorenz@bmw.de> | 2024-11-05 15:01:07 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-06 12:18:05 +0000 |
| commit | ed82f9c0903777c4b9f337266d6862e29b739110 (patch) | |
| tree | b10cf7f8d4261a99e2bb76b4fe36f15df5b88c53 /meta/recipes-devtools/cmake | |
| parent | b94b85bef0b6375be71be6002521e147906080e5 (diff) | |
| download | poky-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.inc | 3 | ||||
| -rw-r--r-- | meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch | 63 |
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 \ | |||
| 17 | CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" | 17 | CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}" |
| 18 | 18 | ||
| 19 | SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \ | 19 | SRC_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 | ||
| 22 | SRC_URI[sha256sum] = "9f55e1a40508f2f29b7e065fa08c29f82c402fa0402da839fffe64a25755a86d" | 23 | SRC_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 @@ | |||
| 1 | From 7fa115171a658d5358e15dcb40b233d049acae2f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Philip Lorenz <philip.lorenz@bmw.de> | ||
| 3 | Date: Mon, 3 Jun 2024 13:19:24 +0200 | ||
| 4 | Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags | ||
| 5 | |||
| 6 | When `-pipe` is enabled, GCC passes data between its different | ||
| 7 | executables using pipes instead of temporary files. This leads to issues | ||
| 8 | when cmake attempts to infer compiler internals via the `-v` parameter | ||
| 9 | as each executable will print to `stderr` in parallel. | ||
| 10 | |||
| 11 | For example we have observed the following outputs in our builds which | ||
| 12 | sporadically lead to build failures as system include directories were | ||
| 13 | not detected reliably: | ||
| 14 | |||
| 15 | Parsed 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 | |||
| 28 | Fix this issue by stripping the `-pipe` parameter from the compilation | ||
| 29 | flag when determining the toolchain configuration. | ||
| 30 | |||
| 31 | Upstream-Status: Backport [3.32.0, 71be059f3f32b6791427893a48ba4815a19e2e78] | ||
| 32 | Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> | ||
| 33 | --- | ||
| 34 | Modules/CMakeDetermineCompilerABI.cmake | 9 ++++++++- | ||
| 35 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
| 36 | |||
| 37 | diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake | ||
| 38 | index 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 | ||
