* [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* Re: [OE-core] [PATCH] insane: Check if the C++ toolchain supports --std=gnu++20
2025-03-19 18:20 [PATCH] insane: Check if the C++ toolchain supports --std=gnu++20 Yoann Congal
@ 2025-03-19 19:19 ` Richard Purdie
2025-03-20 8:36 ` Antonin Godard
1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2025-03-19 19:19 UTC (permalink / raw)
To: yoann.congal, openembedded-core
On Wed, 2025-03-19 at 19:20 +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>
> ---
> 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)}"
> +
>
I did test this:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/68/builds/1281
I'm wondering if we should add:
". Please use a g++ compiler that supports C++20 (e.g. g++ version 10 onwards)."
In the meantime, since we're going to do this, I will take the
opportunity to bump the python version minimum to 3.9 and install
buildtools on the 20.04 ubuntu workers from now on.
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [OE-core] [PATCH] insane: Check if the C++ toolchain supports --std=gnu++20
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
1 sibling, 0 replies; 3+ messages in thread
From: Antonin Godard @ 2025-03-20 8:36 UTC (permalink / raw)
To: yoann.congal, openembedded-core
Hi Yoann,
On Wed Mar 19, 2025 at 7:20 PM CET, 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>
> ---
> 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))
The code in check_cpp_stdgnupp20_toolchain is very similar to
check_cpp_toolchain, maybe an opportunity to do something like
check_cpp_toolchain(d, flag)?
Antonin
--
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [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.