Make clang environment temporary
Pushing to the global environment has the unintended effect of running
sanitizers in clang. Moving to gcc-15 had some unintended consequences
where that broke in some cases with an error of:
ld.lld: error: undefined symbol: __asan_stack_malloc_1
Move the clang variables to a dict and pass it into the appropriate
calls so that it can be destroyed afterward.
Change-Id: I8d4e2b50156e285d7a569dfa1aa8831828c5f480
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 17d6bb0..bf81c01 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -1061,23 +1061,37 @@
# Run clang-tidy only if the project has a configuration
if os.path.isfile(".clang-tidy"):
- os.environ["CC"] = "clang"
- os.environ["CXX"] = "clang++"
+ clang_env = os.environ.copy()
+ clang_env["CC"] = "clang"
+ clang_env["CXX"] = "clang++"
# Clang-20 currently has some issue with libstdcpp's
# std::forward_like which results in a bunch of compile errors.
# Adding -fno-builtin-std-forward_like causes them to go away.
- os.environ["CXXFLAGS"] = "-fno-builtin-std-forward_like"
- os.environ["CC_LD"] = "lld"
- os.environ["CXX_LD"] = "lld"
+ clang_env["CXXFLAGS"] = "-fno-builtin-std-forward_like"
+ clang_env["CC_LD"] = "lld"
+ clang_env["CXX_LD"] = "lld"
with TemporaryDirectory(prefix="build", dir=".") as build_dir:
- check_call_cmd("meson", "setup", build_dir)
+ check_call_cmd("meson", "setup", build_dir, env=clang_env)
if not os.path.isfile(".openbmc-no-clang"):
- check_call_cmd("meson", "compile", "-C", build_dir)
+ check_call_cmd(
+ "meson", "compile", "-C", build_dir, env=clang_env
+ )
try:
- check_call_cmd("ninja", "-C", build_dir, "clang-tidy-fix")
+ check_call_cmd(
+ "ninja",
+ "-C",
+ build_dir,
+ "clang-tidy-fix",
+ env=clang_env,
+ )
except subprocess.CalledProcessError:
check_call_cmd(
- "git", "-C", CODE_SCAN_DIR, "--no-pager", "diff"
+ "git",
+ "-C",
+ CODE_SCAN_DIR,
+ "--no-pager",
+ "diff",
+ env=clang_env,
)
raise
# Run the basic clang static analyzer otherwise