https://github.com/UzixLS created 
https://github.com/llvm/llvm-project/pull/169976

It fails on windows 10 otherwise with:
```
Traceback (most recent call last):
 ...
  File "C:\Dev\LLVM\lib\libscanbuild\analyze.py", line 567, in
report_failure
    handle.write(" ".join(os.uname()) + os.linesep)
                          ^^^^^^^^
AttributeError: module 'os' has no attribute 'uname'. Did you mean:
'name'?
```

There was also a problem identifying the actual compiler on Windows because the 
program name have an ".exe" suffix.

>From 2548c532372a95e9ab87ce52802ad82c92b30a35 Mon Sep 17 00:00:00 2001
From: Eugene Lozovoy <[email protected]>
Date: Sat, 29 Nov 2025 10:38:50 +0300
Subject: [PATCH] [analyzer][scan-build-py] Fix windows compatibility

It fails on windows 10 otherwise with:
```
Traceback (most recent call last):
 ...
  File "C:\Dev\LLVM\lib\libscanbuild\analyze.py", line 567, in
report_failure
    handle.write(" ".join(os.uname()) + os.linesep)
                          ^^^^^^^^
AttributeError: module 'os' has no attribute 'uname'. Did you mean:
'name'?
```

There was also a problem identifying the actual compiler on Windows
because the program name have an ".exe" suffix.
---
 clang/tools/scan-build-py/lib/libscanbuild/analyze.py     | 3 ++-
 clang/tools/scan-build-py/lib/libscanbuild/compilation.py | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py 
b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
index 72aac8f545240..91d3089154a9d 100644
--- a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
+++ b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
@@ -23,6 +23,7 @@
 import datetime
 import shutil
 import glob
+import platform
 from collections import defaultdict
 
 from libscanbuild import (
@@ -563,7 +564,7 @@ def destination():
         handle.write(opts["file"] + os.linesep)
         handle.write(error.title().replace("_", " ") + os.linesep)
         handle.write(" ".join(cmd) + os.linesep)
-        handle.write(" ".join(os.uname()) + os.linesep)
+        handle.write(" ".join(platform.uname()) + os.linesep)
         handle.write(get_version(opts["clang"]))
         handle.close()
     # write the captured output too
diff --git a/clang/tools/scan-build-py/lib/libscanbuild/compilation.py 
b/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
index 6b9e3cabae309..e1226b338ff35 100644
--- a/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
+++ b/clang/tools/scan-build-py/lib/libscanbuild/compilation.py
@@ -135,7 +135,7 @@ def compiler_language(command):
     cplusplus = re.compile(r"^(.+)(\+\+)(-.+|)$")
 
     if command:
-        executable = os.path.basename(command[0])
+        executable = os.path.basename(command[0]).removesuffix('.exe')
         if any(pattern.match(executable) for pattern in COMPILER_PATTERNS):
             return "c++" if cplusplus.match(executable) else "c"
     return None

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to