public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Yoann Congal <yoann.congal@smile.fr>
To: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH v2] sanity: test for c toolchain
Date: Wed, 15 Jan 2025 22:07:44 +0100	[thread overview]
Message-ID: <69dd2cc8-0ec0-475a-a526-5b68325b4ddd@smile.fr> (raw)
In-Reply-To: <20250115193917.8133-1-gavrosc@yahoo.com>

Hi Christos,

This look like a solid v2 :)

Le 15/01/2025 à 20:39, Christos Gavros via lists.openembedded.org a écrit :
> Users reported issues caused by missing the right libstdc++-version-dev.
> A new function 'check_c_toolchain' added in sanity.bbclass to test linking libstdc++
> Fixes [YOCTO #<15712>]
Proper way to tag this bugzilla ticket is "Fixes [YOCTO #15712]"

See
https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html#implement-and-commit-changes
(or any of the previous commits including this tag.

Now, I notice that the patchtest message is a bit misleading.

With the tag fixed, you can add my reviewed-by tag:
Reviewed-by: Yoann Congal <yoann.congal@smile.fr>

> Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
> ---
> v1->v2
> * use shortlog
> * drop the meta-oe prefix
> * fix format for bug reference
> * change function description including libstdc++
> * use BUILD_CC instead of specific compiler
> * lines in comments are removed
> * patch message less than 200 char
> * bb.fatal is removed
> * follow pattern of other functions in class
> * use docstring instead of # in functions description
> * make the print out message more clear
> * fix comment style where the function is called
> * change "hello world" from C++ to C program
> * use gcc instead of g++
> ---
>  meta/classes-global/sanity.bbclass | 40 ++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
> index 7b8a497d5a..3a5a1f5d66 100644
> --- a/meta/classes-global/sanity.bbclass
> +++ b/meta/classes-global/sanity.bbclass
> @@ -780,6 +780,43 @@ def sanity_check_locale(d):
>      except locale.Error:
>          raise_sanity_error("Your system needs to support the en_US.UTF-8 locale.", d)
>  
> +def check_c_toolchain(d):
> +    """
> +    it checks if the c compiling and linking to libstdc++ works properly in the native system
> +    """
> +    import os
> +    import subprocess
> +    from tempfile import NamedTemporaryFile
> +    
> +    try:
> +        with NamedTemporaryFile(delete=False, suffix=".c") as c_file:
> +            c_code = """
> +            #include <stdio.h>
> +            int main() {
> +                printf(\"Hello, World!\\n\");
> +                return 0;
> +            }
> +            """
> +            c_file.write(c_code.encode('utf-8'))
> +            c_file_name = c_file.name
> +
> +        build_cc = d.getVar('BUILD_CC').strip()
> +        output_binary = c_file_name + ".out"
> +        compile_command = [build_cc, c_file_name, '-o', output_binary,'-lstdc++']
> +        result = subprocess.run(compile_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> +
> +        if result.returncode == 0:
> +            return None
> +        else:
> +            return f"C toolchain check failed to link against libstdc++. Please ensure libstdc++ and headers are installed. Error:\n{result.stderr.decode()}"
> +    except Exception as e:
> +        return f"An unexpected issue occurred during the C toolchain check: {str(e)}"
> +    finally:
> +        if c_file_name and os.path.exists(c_file_name):
> +            os.remove(c_file_name)
> +        if output_binary and os.path.exists(output_binary):
> +            os.remove(output_binary)
> +
>  def check_sanity_everybuild(status, d):
>      import os, stat
>      # Sanity tests which test the users environment so need to run at each build (or are so cheap
> @@ -976,6 +1013,9 @@ def check_sanity_everybuild(status, d):
>          if '/dash' not in real_sh and '/bash' not in real_sh:
>              status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh)
>  
> +    # Check if linking with lstdc++ is failing 
> +    status.addresult(check_c_toolchain(d))
> +
>  def check_sanity(sanity_data):
>      class SanityStatus(object):
>          def __init__(self):
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#209924): https://lists.openembedded.org/g/openembedded-core/message/209924
> Mute This Topic: https://lists.openembedded.org/mt/110634330/4316185
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
> 

-- 
Yoann Congal
Smile ECS - Tech Expert



  parent reply	other threads:[~2025-01-15 21:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250115193917.8133-1-gavrosc.ref@yahoo.com>
2025-01-15 19:39 ` [PATCH v2] sanity: test for c toolchain Christos Gavros
2025-01-15 19:46   ` Patchtest results for " patchtest
2025-01-15 21:07   ` Yoann Congal [this message]
2025-01-15 21:18   ` [OE-core] " Yoann Congal

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=69dd2cc8-0ec0-475a-a526-5b68325b4ddd@smile.fr \
    --to=yoann.congal@smile.fr \
    --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