diff mbox series

[1/2] sanity: Refactor "C++ toolchain support this flag" check

Message ID 20250320133946.2631311-1-yoann.congal@smile.fr
State Accepted, archived
Commit 42d012e8414736d89618422fb6f9bce9e4a2a391
Headers show
Series [1/2] sanity: Refactor "C++ toolchain support this flag" check | expand

Commit Message

Yoann Congal March 20, 2025, 1:39 p.m. UTC
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(-)

Comments

Yoann Congal March 20, 2025, 1:47 p.m. UTC | #1
That should have been a "v2". Resent.
Sorry for the noise.

Le 20/03/2025 à 14:39, Yoann Congal a écrit :
> 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):
>      """
diff mbox series

Patch

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):
     """