sanity/utils: Directly use gcc, not BUILD_CC

The test/helper is written assuming gcc, so just call that and stop
accessing BUILD_CC which may be set to clang.

(From OE-Core rev: 0a165a93693a293f08cb0d7e2dfa1016803a917a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2025-07-01 22:28:21 +01:00
parent 204653a519
commit 8624474277
2 changed files with 9 additions and 17 deletions

View File

@ -514,10 +514,7 @@ def check_userns():
# built buildtools-extended-tarball) # built buildtools-extended-tarball)
# #
def check_gcc_version(sanity_data): def check_gcc_version(sanity_data):
import subprocess version = oe.utils.get_host_gcc_version(sanity_data)
build_cc, version = oe.utils.get_host_compiler_version(sanity_data)
if build_cc.strip() == "gcc":
if bb.utils.vercmp_string_op(version, "8.0", "<"): if bb.utils.vercmp_string_op(version, "8.0", "<"):
return "Your version of gcc is older than 8.0 and will break builds. Please install a newer version of gcc (you could use the project's buildtools-extended-tarball or use scripts/install-buildtools).\n" return "Your version of gcc is older than 8.0 and will break builds. Please install a newer version of gcc (you could use the project's buildtools-extended-tarball or use scripts/install-buildtools).\n"
return None return None

View File

@ -415,34 +415,29 @@ def format_pkg_list(pkg_dict, ret_format=None, pkgdata_dir=None):
return output_str return output_str
# Helper function to get the host compiler version # Helper function to get the host gcc version
# Do not assume the compiler is gcc def get_host_gcc_version(d, taskcontextonly=False):
def get_host_compiler_version(d, taskcontextonly=False):
import re, subprocess import re, subprocess
if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1': if taskcontextonly and d.getVar('BB_WORKERCONTEXT') != '1':
return 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: try:
env = os.environ.copy() env = os.environ.copy()
# datastore PATH does not contain session PATH as set by environment-setup-... # datastore PATH does not contain session PATH as set by environment-setup-...
# this breaks the install-buildtools use-case # this breaks the install-buildtools use-case
# env["PATH"] = d.getVar("PATH") # 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") shell=True, env=env, stderr=subprocess.STDOUT).decode("utf-8")
except subprocess.CalledProcessError as e: 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]) match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
if not match: 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) version = match.group(1)
return compiler, version return version
@bb.parse.vardepsexclude("DEFAULTTUNE_MULTILIB_ORIGINAL", "OVERRIDES") @bb.parse.vardepsexclude("DEFAULTTUNE_MULTILIB_ORIGINAL", "OVERRIDES")
def get_multilib_datastore(variant, d): def get_multilib_datastore(variant, d):