File pytorch-amd-build-check-clang.patch of Package python-torch
diff --git a/tools/amd_build/build_amd.py b/tools/amd_build/build_amd.py
index 967f63ae2..2ec5ca84f 100755
--- a/tools/amd_build/build_amd.py
+++ b/tools/amd_build/build_amd.py
@@ -3,6 +3,7 @@
import argparse
import os
+import subprocess
import sys
@@ -147,8 +148,17 @@ ignores = [os.path.join(proj_dir, ignore) for ignore in ignores]
def is_hip_clang() -> bool:
try:
hip_path = os.getenv("HIP_PATH", "/opt/rocm/hip")
- with open(hip_path + "/lib/.hipInfo") as f:
- return "HIP_COMPILER=clang" in f.read()
+ hipinfo_path = hip_path + "/lib/.hipInfo"
+ if os.path.exists(hipinfo_path):
+ with open(hipinfo_path) as f:
+ return "HIP_COMPILER=clang" in f.read
+ else:
+ result = subprocess.run(["hipconfig", "--compiler"],
+ capture_output=True, text=True)
+ if result.stdout.strip() == "clang":
+ print("build_amd: HIPCC is Clang")
+ return True
+ return False
except OSError:
return False