From cdac7d497c68a1e196ba8ac121adf6de3fe261d2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 24 Apr 2024 23:08:00 +0300 Subject: [PATCH] Resolved an issue related to the inaccurate detection of the Clang compiler // Resolve #4897 --- HISTORY.rst | 1 + platformio/builder/tools/piomisc.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4013392e..b6b5a980 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 `_) +* Resolved an issue related to the inaccurate detection of the Clang compiler (`pull #4897 `_) 6.1.14 (2024-03-21) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 47496fe5..9652c400 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -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"