Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2 1/2] sanity: Refactor "C++ toolchain support this flag" check
@ 2025-03-20 13:40 Yoann Congal
  2025-03-20 13:40 ` [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20 Yoann Congal
  0 siblings, 1 reply; 4+ messages in thread
From: Yoann Congal @ 2025-03-20 13:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: Yoann Congal

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

This can be use to check for other flags.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/classes-global/sanity.bbclass | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 1bae998f74..dc317e846d 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -607,9 +607,9 @@ def drop_v14_cross_builds(d):
                 bb.utils.remove(stamp + "*")
                 bb.utils.remove(workdir, recurse = True)
 
-def check_cpp_toolchain(d):
+def check_cpp_toolchain_flag(d, flag, error_message=None):
     """
-    it checks if the c++ compiling and linking to libstdc++ works properly in the native system
+    Checks if the C++ toolchain support the given flag
     """
     import shlex
     import subprocess
@@ -622,12 +622,12 @@ def check_cpp_toolchain(d):
     }
     """
 
-    cmd = shlex.split(d.getVar("BUILD_CXX")) + ["-x", "c++","-", "-o", "/dev/null", "-lstdc++"]
+    cmd = shlex.split(d.getVar("BUILD_CXX")) + ["-x", "c++","-", "-o", "/dev/null", flag]
     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++ toolchain check: {str(e)}"
+        return error_message or f"An unexpected issue occurred during the C++ toolchain check: {str(e)}"
 
 def sanity_handle_abichanges(status, d):
     #
@@ -802,7 +802,7 @@ def check_sanity_version_change(status, d):
     status.addresult(check_case_sensitive(tmpdir, "TMPDIR"))
 
     # Check if linking with lstdc++ is failing
-    status.addresult(check_cpp_toolchain(d))
+    status.addresult(check_cpp_toolchain_flag(d, "-lstdc++"))
 
 def sanity_check_locale(d):
     """


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

* [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20
  2025-03-20 13:40 [PATCH v2 1/2] sanity: Refactor "C++ toolchain support this flag" check Yoann Congal
@ 2025-03-20 13:40 ` Yoann Congal
  2025-03-20 14:13   ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Yoann Congal @ 2025-03-20 13:40 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

v1->v2:
* Changed error message
* Refactor C++ toolchain flag check
---
 meta/classes-global/sanity.bbclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index dc317e846d..ce52bcdf90 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -804,6 +804,11 @@ def check_sanity_version_change(status, d):
     # Check if linking with lstdc++ is failing
     status.addresult(check_cpp_toolchain_flag(d, "-lstdc++"))
 
+    # Check if the C++ toochain support the "--std=gnu++20" flag
+    status.addresult(check_cpp_toolchain_flag(d, "--std=gnu++20",
+        "An error occurred during checking the C++ toolchain for '--std=gnu++20' support. "
+        "Please use a g++ compiler that supports C++20 (e.g. g++ version 10 onwards)."))
+
 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] 4+ messages in thread

* Re: [OE-core] [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20
  2025-03-20 13:40 ` [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20 Yoann Congal
@ 2025-03-20 14:13   ` Richard Purdie
  2025-03-20 14:37     ` Yoann Congal
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2025-03-20 14:13 UTC (permalink / raw)
  To: yoann.congal, openembedded-core

On Thu, 2025-03-20 at 14:40 +0100, Yoann Congal via lists.openembedded.org wrote:
> 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>

Subject should be sanity: as insane is something different. I tweaked
on master-next though, no need to resend.

Cheers,

Richard


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

* Re: [OE-core] [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20
  2025-03-20 14:13   ` [OE-core] " Richard Purdie
@ 2025-03-20 14:37     ` Yoann Congal
  0 siblings, 0 replies; 4+ messages in thread
From: Yoann Congal @ 2025-03-20 14:37 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core



Le 20/03/2025 à 15:13, Richard Purdie a écrit :
> On Thu, 2025-03-20 at 14:40 +0100, Yoann Congal via lists.openembedded.org wrote:
>> 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>
> 
> Subject should be sanity: as insane is something different. I tweaked
> on master-next though, no need to resend.

d'oh! Sorry, and thanks!

> 
> Cheers,
> 
> Richard

-- 
Yoann Congal
Smile ECS - Tech Expert



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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 13:40 [PATCH v2 1/2] sanity: Refactor "C++ toolchain support this flag" check Yoann Congal
2025-03-20 13:40 ` [PATCH v2 2/2] insane: Check if the C++ toolchain supports --std=gnu++20 Yoann Congal
2025-03-20 14:13   ` [OE-core] " Richard Purdie
2025-03-20 14:37     ` Yoann Congal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox