diff mbox series

[v5,5/5] sanity/utils: Directly use gcc instead of BUILD_CC in host_gcc_version

Message ID 20250702053220.4104358-5-raj.khem@gmail.com
State New
Headers show
Series [v5,1/5] clang-native: Add class to use clang as native compiler | expand

Commit Message

Khem Raj July 2, 2025, 5:32 a.m. UTC
This assumes GCC compiler, so feed it one, BUILD_CC might point to
clang as well in that case it fails.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/lib/oe/utils.py | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Antonin Godard July 2, 2025, 10:33 a.m. UTC | #1
On Wed Jul 2, 2025 at 7:32 AM CEST, Khem Raj via lists.openembedded.org wrote:
> This assumes GCC compiler, so feed it one, BUILD_CC might point to
> clang as well in that case it fails.
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/lib/oe/utils.py | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> index 27d304ec72d..d31f8c3db36 100644
> --- a/meta/lib/oe/utils.py
> +++ b/meta/lib/oe/utils.py
> @@ -446,21 +446,17 @@ def host_gcc_version(d, taskcontextonly=False):
>      if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
>          return
>  
> -    compiler = d.getVar("BUILD_CC")
> -    # Get rid of ccache since it is not present when parsing.
> -    if compiler.startswith('ccache '):
> -        compiler = compiler[7:]
>      try:
>          env = os.environ.copy()
>          env["PATH"] = d.getVar("PATH")
> -        output = subprocess.check_output("%s --version" % compiler, \
> +        output = subprocess.check_output("gcc --version", \
>                      shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
>      except subprocess.CalledProcessError as e:
> -        bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
> +        bb.fatal("Error running gcc --version: %s" % (e.output.decode("utf-8")))
>  
>      match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
>      if not match:
> -        bb.fatal("Can't get compiler version from %s --version output" % compiler)
> +        bb.fatal("Can't get compiler version from gcc --version output")
>  
>      version = match.group(1)
>      return "-%s" % version if version in ("4.8", "4.9") else ""

I can't apply this patch locally, isn't redundant with patch 4/5?

Antonin
Richard Purdie July 2, 2025, 10:37 a.m. UTC | #2
On Wed, 2025-07-02 at 12:33 +0200, Antonin Godard via
lists.openembedded.org wrote:
> On Wed Jul 2, 2025 at 7:32 AM CEST, Khem Raj via
> lists.openembedded.org wrote:
> > This assumes GCC compiler, so feed it one, BUILD_CC might point to
> > clang as well in that case it fails.
> > 
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  meta/lib/oe/utils.py | 10 +++-------
> >  1 file changed, 3 insertions(+), 7 deletions(-)
> > 
> > diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> > index 27d304ec72d..d31f8c3db36 100644
> > --- a/meta/lib/oe/utils.py
> > +++ b/meta/lib/oe/utils.py
> > @@ -446,21 +446,17 @@ def host_gcc_version(d,
> > taskcontextonly=False):
> >      if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
> >          return
> >  
> > -    compiler = d.getVar("BUILD_CC")
> > -    # Get rid of ccache since it is not present when parsing.
> > -    if compiler.startswith('ccache '):
> > -        compiler = compiler[7:]
> >      try:
> >          env = os.environ.copy()
> >          env["PATH"] = d.getVar("PATH")
> > -        output = subprocess.check_output("%s --version" %
> > compiler, \
> > +        output = subprocess.check_output("gcc --version", \
> >                      shell=True, env=env,
> > stderr=subprocess.STDOUT).decode("utf-8")
> >      except subprocess.CalledProcessError as e:
> > -        bb.fatal("Error running %s --version: %s" % (compiler,
> > e.output.decode("utf-8")))
> > +        bb.fatal("Error running gcc --version: %s" %
> > (e.output.decode("utf-8")))
> >  
> >      match = re.match(r".* (\d+\.\d+)\.\d+.*",
> > output.split('\n')[0])
> >      if not match:
> > -        bb.fatal("Can't get compiler version from %s --version
> > output" % compiler)
> > +        bb.fatal("Can't get compiler version from gcc --version
> > output")
> >  
> >      version = match.group(1)
> >      return "-%s" % version if version in ("4.8", "4.9") else ""
> 
> I can't apply this patch locally, isn't redundant with patch 4/5?

For the sanity gcc/c++ ones, go with what is in master-next as that
appears to be building ok at this point.

Cheers.

Richard
diff mbox series

Patch

diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 27d304ec72d..d31f8c3db36 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -446,21 +446,17 @@  def host_gcc_version(d, taskcontextonly=False):
     if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
         return
 
-    compiler = d.getVar("BUILD_CC")
-    # Get rid of ccache since it is not present when parsing.
-    if compiler.startswith('ccache '):
-        compiler = compiler[7:]
     try:
         env = os.environ.copy()
         env["PATH"] = d.getVar("PATH")
-        output = subprocess.check_output("%s --version" % compiler, \
+        output = subprocess.check_output("gcc --version", \
                     shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
     except subprocess.CalledProcessError as e:
-        bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
+        bb.fatal("Error running gcc --version: %s" % (e.output.decode("utf-8")))
 
     match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
     if not match:
-        bb.fatal("Can't get compiler version from %s --version output" % compiler)
+        bb.fatal("Can't get compiler version from gcc --version output")
 
     version = match.group(1)
     return "-%s" % version if version in ("4.8", "4.9") else ""