Resolved an issue related to the inaccurate detection of the Clang compiler // Resolve #4897

This commit is contained in:
Ivan Kravets
2024-04-24 23:08:00 +03:00
parent 591b377e4a
commit cdac7d497c
2 changed files with 9 additions and 4 deletions

View File

@ -22,6 +22,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.
~~~~~~~~~~~~~~~~~~~
* Resolved an issue where the |LDF| couldn't locate a library dependency declared via version control system repository (`issue #4885 <https://github.com/platformio/platformio-core/issues/4885>`_)
* Resolved an issue related to the inaccurate detection of the Clang compiler (`pull #4897 <https://github.com/platformio/platformio-core/pull/4897>`_)
6.1.14 (2024-03-21)
~~~~~~~~~~~~~~~~~~~

View File

@ -20,19 +20,23 @@ from platformio.proc import exec_command
@util.memoized()
def GetCompilerType(env):
if env.subst("$CC").endswith("-gcc"):
def GetCompilerType(env): # pylint: disable=too-many-return-statements
CC = env.subst("$CC")
if CC.endswith("-gcc"):
return "gcc"
if os.path.basename(CC) == "clang":
return "clang"
try:
sysenv = os.environ.copy()
sysenv["PATH"] = str(env["ENV"]["PATH"])
result = exec_command([env.subst("$CC"), "-v"], env=sysenv)
result = exec_command([CC, "-v"], env=sysenv)
except OSError:
return None
if result["returncode"] != 0:
return None
output = "".join([result["out"], result["err"]]).lower()
if "clang" in output and "LLVM" in output:
if "clang version" in output:
return "clang"
if "gcc" in output:
return "gcc"