public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][kirkstone 07/19] cmake: Fix sporadic issues when determining compiler internals
Date: Tue, 12 Nov 2024 19:16:00 -0800	[thread overview]
Message-ID: <8e2233fd0509b9f20c19d5006dd7ef0c2260bdba.1731467662.git.steve@sakoman.com> (raw)
In-Reply-To: <cover.1731467662.git.steve@sakoman.com>

From: Philip Lorenz <philip.lorenz@bmw.de>

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.

Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 meta/recipes-devtools/cmake/cmake.inc         |  1 +
 ...mpilerABI-Strip-pipe-from-compile-fl.patch | 52 +++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch

diff --git a/meta/recipes-devtools/cmake/cmake.inc b/meta/recipes-devtools/cmake/cmake.inc
index d500321138..3811aae9c4 100644
--- a/meta/recipes-devtools/cmake/cmake.inc
+++ b/meta/recipes-devtools/cmake/cmake.inc
@@ -17,6 +17,7 @@ LIC_FILES_CHKSUM = "file://Copyright.txt;md5=31023e1d3f51ca90a58f55bcee8e2339 \
 CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
 
 SRC_URI = "https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/cmake-${PV}.tar.gz \
+           file://0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch \
            file://0003-cmake-support-OpenEmbedded-Qt4-tool-binary-names.patch \
            file://0004-Fail-silently-if-system-Qt-installation-is-broken.patch \
 "
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..a30273458f
--- /dev/null
+++ b/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineCompilerABI-Strip-pipe-from-compile-fl.patch
@@ -0,0 +1,52 @@
+From dab7ba34f87be0172f6586325656ee962de0029e Mon Sep 17 00:00:00 2001
+From: Philip Lorenz <philip.lorenz@bmw.de>
+Date: Mon, 3 Jun 2024 13:19:24 +0200
+Subject: [PATCH] CMakeDetermineCompilerABI: Strip -pipe from compile flags
+
+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.
+
+For example we have observed the following outputs in our builds which
+sporadically lead to build failures as system include directories were
+not detected reliably:
+
+Parsed CXX implicit include dir info from above output: rv=done
+  found start of include info
+  found start of implicit include info
+    add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include]
+    add: [.../usr/bin/x86_64-poky-linux/../../lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.4.0/include-fixed]
+    add: [.../usr/include/c++/11.4.0]
+    add: [.../usr/include/c++/11.4.0/x86_64-poky-linux]
+    add: [.../usr/include/c++/11.4.0/backward]
+    add: [.../usr/lib/x86_64-poky-linux/11.4.0/include]
+    add: [...GNU assembler version 2.38 (x86_64-poky-linux) using BFD version (GNU Binutils) 2.38.20220708]
+    add: [/usr/include]
+  end of search list found
+
+Fix this issue by stripping the `-pipe` parameter from the compilation
+flag when determining the toolchain configuration.
+
+Upstream-Status: Backport [3.32.0, 71be059f3f32b6791427893a48ba4815a19e2e78]
+Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de>
+---
+ Modules/CMakeDetermineCompilerABI.cmake | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
+index 8191d819bf..ae4c9ee44e 100644
+--- a/Modules/CMakeDetermineCompilerABI.cmake
++++ b/Modules/CMakeDetermineCompilerABI.cmake
+@@ -35,6 +35,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
+ 
+     # Avoid failing ABI detection on warnings.
+     string(REGEX REPLACE "(^| )-Werror([= ][^ ]*)?( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
++    # Avoid passing of "-pipe" when determining the compiler internals. With
++    # "-pipe" GCC will use pipes to pass data between the involved
++    # executables.  This may lead to issues when their stderr output (which
++    # contains the relevant compiler internals) becomes interweaved.
++    string(REGEX REPLACE "(^| )-pipe( |$)" " " CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
+ 
+     # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
+     # and set them to "C" that way GCC's "search starts here" text is in
-- 
2.34.1



  parent reply	other threads:[~2024-11-13  3:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13  3:15 [OE-core][kirkstone 00/19] Patch review Steve Sakoman
2024-11-13  3:15 ` [OE-core][kirkstone 01/19] ghostscript: fix CVE-2023-46361 Steve Sakoman
2024-11-13  3:15 ` [OE-core][kirkstone 02/19] curl: patch CVE-2024-9681 Steve Sakoman
2024-11-13  3:15 ` [OE-core][kirkstone 03/19] gstreamer1.0: ignore CVE-2024-0444 Steve Sakoman
2024-11-13  3:15 ` [OE-core][kirkstone 04/19] expat: patch CVE-2024-50602 Steve Sakoman
2024-11-13  3:15 ` [OE-core][kirkstone 05/19] glib-2.0: patch regression of CVE-2023-32665 Steve Sakoman
2024-11-13  3:39   ` Patchtest results for " patchtest
2024-11-13  3:15 ` [OE-core][kirkstone 06/19] patch.py: Use shlex instead of deprecated pipe Steve Sakoman
2024-11-13  3:16 ` Steve Sakoman [this message]
2024-11-13  3:16 ` [OE-core][kirkstone 08/19] pseudo: Update to pull in linux-libc-headers race fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 09/19] pseudo: Disable LFS on 32bit arches Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 10/19] pseudo: Switch back to the master branch Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 11/19] pseudo: Update to include logic fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 12/19] pseudo: Update to pull in fd leak fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 13/19] pseudo: Update to pull in syncfs probe fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 14/19] pseudo: Update to pull in gcc14 fix and missing statvfs64 intercept Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 15/19] pseudo: Update to pull in fchmodat fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 16/19] pseudo: Update to pull in python 3.12+ fix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 17/19] pseudo: Fix to work with glibc 2.40 Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 18/19] pseudo: Update to include open symlink handling bugfix Steve Sakoman
2024-11-13  3:16 ` [OE-core][kirkstone 19/19] pseudo: Fix envp bug and add posix_spawn wrapper Steve Sakoman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e2233fd0509b9f20c19d5006dd7ef0c2260bdba.1731467662.git.steve@sakoman.com \
    --to=steve@sakoman.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox