From 53c8ebc287fe627fa59123cf6b92c405efcb2fb5 Mon Sep 17 00:00:00 2001 From: Jan Henke Date: Sun, 11 Dec 2022 17:01:41 +0100 Subject: [PATCH] dist/tools/compile_commands: Fix interoperability with localized GCC GCC supports localized outputs, depending on the currently set locale. This broke the compile-commands target, as the regexes only match the English output. By invoking the compiler explicitly with the C locale, it ensures the expected English language output. --- dist/tools/compile_commands/compile_commands.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/tools/compile_commands/compile_commands.py b/dist/tools/compile_commands/compile_commands.py index 8d6d693e28..94fd7950d7 100755 --- a/dist/tools/compile_commands/compile_commands.py +++ b/dist/tools/compile_commands/compile_commands.py @@ -27,9 +27,11 @@ def detect_includes_and_version_gcc(compiler): :rtype: tuple """ try: + process_env = dict(os.environ) + process_env["LC_MESSAGES"] = "C" with subprocess.Popen([compiler, "-v", "-E", "-"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) as proc: + stderr=subprocess.PIPE, env=process_env) as proc: inputdata = b"typedef int dont_be_pedantic;" _, stderrdata = proc.communicate(input=inputdata) except FileNotFoundError: