All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] insane: Check if the C++ toolchain supports --std=gnu++20
@ 2025-03-19 18:20 Yoann Congal
  2025-03-19 19:19 ` [OE-core] " Richard Purdie
  2025-03-20  8:36 ` Antonin Godard
  0 siblings, 2 replies; 3+ messages in thread
From: Yoann Congal @ 2025-03-19 18:20 UTC (permalink / raw)
  To: openembedded-core; +Cc: Yoann Congal

From: Yoann Congal <yoann.congal@smile.fr>

This is needed to build nodejs from meta-oe. Check this early to avoid
an error later in the build.

Fixes [YOCTO #15804]

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
WARNING: as discussed in previous threads [0][1], this will disqualify
builds on Ubuntu 20.04 (its g++ does not support the option)
[0]: https://lists.openembedded.org/g/openembedded-devel/topic/111740469
[1]: https://lists.yoctoproject.org/g/yocto-patches/topic/yocto_autobuilder2_patch/111757761
---
 meta/classes-global/sanity.bbclass | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 1bae998f74..5783b92b26 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -629,6 +629,28 @@ def check_cpp_toolchain(d):
     except subprocess.CalledProcessError as e:
         return f"An unexpected issue occurred during the C++ toolchain check: {str(e)}"
 
+def check_cpp_stdgnupp20_toolchain(d):
+    """
+    Checks if the C++ toolchain support the '--std=gnu++20' option
+    """
+    import shlex
+    import subprocess
+
+    cpp_code = """
+    #include <iostream>
+    int main() {
+        std::cout << "Hello, World!" << std::endl;
+        return 0;
+    }
+    """
+
+    cmd = shlex.split(d.getVar("BUILD_CXX")) + ["-x", "c++","-", "-o", "/dev/null", "--std=gnu++20"]
+    try:
+        subprocess.run(cmd, input=cpp_code, capture_output=True, text=True, check=True)
+        return None
+    except subprocess.CalledProcessError as e:
+        return f"An unexpected issue occurred during the C++ 'std=gnu++20' toolchain check: {str(e)}"
+
 def sanity_handle_abichanges(status, d):
     #
     # Check the 'ABI' of TMPDIR
@@ -804,6 +826,9 @@ def check_sanity_version_change(status, d):
     # Check if linking with lstdc++ is failing
     status.addresult(check_cpp_toolchain(d))
 
+    # Check if the C++ toolchain supports --std=gnu++20
+    status.addresult(check_cpp_stdgnupp20_toolchain(d))
+
 def sanity_check_locale(d):
     """
     Currently bitbake switches locale to en_US.UTF-8 so check that this locale actually exists.


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-20  8:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 18:20 [PATCH] insane: Check if the C++ toolchain supports --std=gnu++20 Yoann Congal
2025-03-19 19:19 ` [OE-core] " Richard Purdie
2025-03-20  8:36 ` Antonin Godard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.