[clang] Compiler messages on HIP SDK for Windows (PR #97668)
https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/97668 When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 >From eb83f777e5e15f2602b34b0ba48d1cf5ac803d16 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Compiler messages on HIP SDK for Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 18 ++ clang/lib/Driver/ToolChains/ROCm.h | 5 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..e2492b1630238 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows();} + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668 >From 803e3939a726bed2f1c43a3199850d580251c6d2 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Remove Linux path names in ROCm search paths on Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 24 +-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/HIPAMD.cpp| 2 +- clang/lib/Driver/ToolChains/MSVC.cpp | 4 clang/lib/Driver/ToolChains/ROCm.h| 9 - clang/test/Driver/rocm-detect-windows.hip | 9 + 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..1bd891498ca0d 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,23 +306,25 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } RocmInstallationDetector::RocmInstallationDetector( -const Driver &D, const llvm::Triple &HostTriple, +const Driver &D, const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), TargetTriple(TargetTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = @@ -820,8 +822,10 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index 7e70dae8ce152..870230b3093df 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -129,7 +129,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain { public: ROCMToolChain(const Driver &D, const llvm::Triple &Triple, -const llvm::opt::ArgList &Args); +const llvm::opt::ArgList &Args, bool isHostTCMSVC=false); void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index c35b0febb262d..4fe7e75360726 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -250,7 +250,7 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA, HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const ArgList &Args) -: ROCMToolChain(D, Triple, Args), HostTC(HostTC) { +: ROCMToolChain(D, Triple, Args, HostTC.getTriple().isWindowsMSVCEnvironment()), HostTC(HostTC) { // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index ca266e3e1d1d3..7526c6613f4dd 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -428,6 +428,9 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args),
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668 >From e9722655b4fd32b3128ba10b69b1b498e507d437 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Compiler messages on HIP SDK for Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 18 +-- clang/lib/Driver/ToolChains/ROCm.h| 5 + clang/test/Driver/rocm-detect-windows.hip | 167 ++ 3 files changed, 182 insertions(+), 8 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..242e84a32e8d0 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows(); } + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; diff --git a/clang/test/Driver/rocm-detect-windows.hip b/clang/test/Driver/rocm-detect-windows.hip new file mode 100644 index 0..4aafeb97c00b5 --- /dev/null +++ b/clang/test/Driver/rocm-detect-windows.hip @@ -0,0 +1,167 @@ +// UNSUPPORTED: system-windows + +// Make sure the appropriate device specific library is available. + +// We don't include every target in the test directory, so just pick a valid +// target not included in the test. + +// RUN: not %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=gfx902 \ +// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s + +// Should not interpret -nostdlib as disabling offload libraries. +// RUN: not %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \ +// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s + +// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nogpulib \ +// RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s + +// Test environment variable ROCM_PATH. +// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --target=x86_64-linux-gnu \ +// RUN: --print-rocm-search-dirs --offload-arch=gfx1010 %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=ROCM-ENV %s + +// Test interaction between environment variables HIP_PATH and ROCM_PATH. +// Device libs are found under ROCM_PATH. HIP include files and HIP runtime library +// are found under HIP_PATH. + +// RUN: rm -rf %t/myhip +// RUN: mkdir -p %t/myhip +// RUN: cp -r %S/Inputs/rocm/bin %t/myhip + +// Test HIP_PATH overrides ROCM_PATH. +// RUN: env ROCM_PATH
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668 >From 970b1e696b77216f326fb7d8dcad5b55a82db489 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Compiler messages on HIP SDK for Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 18 ++ clang/lib/Driver/ToolChains/ROCm.h| 5 + clang/test/Driver/rocm-detect-windows.hip | 7 +++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..242e84a32e8d0 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows(); } + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; diff --git a/clang/test/Driver/rocm-detect-windows.hip b/clang/test/Driver/rocm-detect-windows.hip new file mode 100644 index 0..7f7c34efb5fd4 --- /dev/null +++ b/clang/test/Driver/rocm-detect-windows.hip @@ -0,0 +1,7 @@ +// UNSUPPORTED: system-linux + +// RUN: %clang -### -nogpulib -nogpuinc \ +// RUN: --print-rocm-search-dirs %s 2>&1 \ +// RUN: | FileCheck %s + +// CHECK-NOT: ROCm installation search path: [[ROCM_PATH:.*/usr$]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668 >From 838ea93f30e9e421ad9948618cfcb61703d94029 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Remove Linux path names in ROCm search paths on Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 18 ++ clang/lib/Driver/ToolChains/ROCm.h| 5 + clang/test/Driver/rocm-detect-windows.hip | 8 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..242e84a32e8d0 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows(); } + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; diff --git a/clang/test/Driver/rocm-detect-windows.hip b/clang/test/Driver/rocm-detect-windows.hip new file mode 100644 index 0..e8a940862c6ec --- /dev/null +++ b/clang/test/Driver/rocm-detect-windows.hip @@ -0,0 +1,8 @@ +// REQUIRES: system-windows + +// Test to ensure that on Windows, we do not include linux sesrch paths +// RUN: %clang -### -nogpulib -nogpuinc \ +// RUN: --print-rocm-search-dirs %s 2>&1 \ +// RUN: | FileCheck %s + +// CHECK-NOT: ROCm installation search path: [[ROCM_PATH:.*/usr$]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
https://github.com/david-salinas edited https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
@@ -0,0 +1,7 @@ +// UNSUPPORTED: system-linux david-salinas wrote: changed to REQUIRES: system-windows in latest patch https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
david-salinas wrote: > > Compiler messages on HIP SDK for Windows > > Please rewrite this to say what the patch does or what problem it fixes. Changed the PR (and commit) subject to something more meaningful/accurate. https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Rocm instal detect windows work (PR #113225)
https://github.com/david-salinas closed https://github.com/llvm/llvm-project/pull/113225 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Rocm instal detect windows work (PR #113225)
https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/113225 None >From 803e3939a726bed2f1c43a3199850d580251c6d2 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH 1/3] Remove Linux path names in ROCm search paths on Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 24 +-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/HIPAMD.cpp| 2 +- clang/lib/Driver/ToolChains/MSVC.cpp | 4 clang/lib/Driver/ToolChains/ROCm.h| 9 - clang/test/Driver/rocm-detect-windows.hip | 9 + 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5b..1bd891498ca0d4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,23 +306,25 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } RocmInstallationDetector::RocmInstallationDetector( -const Driver &D, const llvm::Triple &HostTriple, +const Driver &D, const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), TargetTriple(TargetTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = @@ -820,8 +822,10 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index 7e70dae8ce152e..870230b3093df3 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -129,7 +129,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain { public: ROCMToolChain(const Driver &D, const llvm::Triple &Triple, -const llvm::opt::ArgList &Args); +const llvm::opt::ArgList &Args, bool isHostTCMSVC=false); void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index c35b0febb262da..4fe7e75360726d 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -250,7 +250,7 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA, HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const ArgList &Args) -: ROCMToolChain(D, Triple, Args), HostTC(HostTC) { +: ROCMToolChain(D, Triple, Args, HostTC.getTriple().isWindowsMSVCEnvironment()), HostTC(HostTC) { // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index ca266e3e1d1d3c..7526c6613f4dd7 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -428,6 +428,9 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : ToolChain(D, Triple, Args), CudaInstallation(
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From 44f610ead0ec6e497f16771234067e7d96460666 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 6 ++--- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 8 +- clang/lib/Driver/ToolChains/MSVC.cpp | 5 clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..2be0d04d1c5ddf 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, Target.isWindowsMSVCEnvironment()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6582,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..07f340ea425127 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,18 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } + + if (!isHostWindows()) { if (!LatestROCm.empty()) ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); - +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } + DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -376,10 +379,10 @@ RocmInstallationDetector::RocmInstallationDetector( .str(); } - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); + // Windows needs to exclude linux style paths from the list of paths to search, + // so delay these detection functions until after the constructor + + } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +706,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +839,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..db08529f955168 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/113628 Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d >From 2bcd8608ca1e00893692f1d1f8b1734204abbd15 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 6 ++-- clang/lib/Driver/ToolChains/AMDGPU.cpp | 34 ++-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +- clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 +- clang/lib/Driver/ToolChains/MSVC.cpp | 5 +++ clang/lib/Driver/ToolChains/ROCm.h | 12 +++ clang/test/Driver/rocm-detect-linux.hip | 9 ++ clang/test/Driver/rocm-detect-windows.hip| 9 ++ 9 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..2be0d04d1c5ddf 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, Target.isWindowsMSVCEnvironment()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6582,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..c6ff2717d9853b 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,18 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } + + if (!isHostWindows()) { if (!LatestROCm.empty()) ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); - +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } + DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -376,10 +379,15 @@ RocmInstallationDetector::RocmInstallationDetector( .str(); } - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); + // Windows needs to exclude linux style paths from the list of paths to search, + // so delay these detection functions until after the constructor + if (!isHostWindows() && !HostTriple.isWindowsMSVCEnvironment()) { +if (DetectHIPRuntime) + detectHIPRuntime(); +if (DetectDeviceLib) + detectDeviceLibrary(); +} + } void RocmInstallationDetector::detectDeviceLibrary() { @@ -835,8 +843,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } @@ -1048,6 +1059,9 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs, options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true); bool Wave64 = isWave64(DriverArgs, Kind); + /* SALINASif (getTriple().isWindowsMSVCEnvironment()) +RocmInstallation->init(true,true); */ + return RocmInstallation->getCommonBitcodeLibs( DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt, FastRelaxedMath, CorrectSqrt, ABIVer, isOpe
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
https://github.com/david-salinas closed https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From 307e0abed8387b0bffa4b7e24e995ad7ec402749 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 7 ++--- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 ++-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 3 ++- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 ++- clang/lib/Driver/ToolChains/MSVC.cpp | 6 + clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..6fb743a8349fae 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6583,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..969c2e289f7fa0 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +700,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +833,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMD
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From ee17fe072310a55e004134bb793a18b8089b4020 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 6 ++--- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 ++-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 ++- clang/lib/Driver/ToolChains/MSVC.cpp | 6 + clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..d9b75c814c6bc5 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6582,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..f150abd2b5c285 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { + if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); + ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", + /*StrictChecking=*/true); + ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", + /*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +700,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +833,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..db08529f955168 100644 --- a/clang/l
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From 2ab5bea395fce329be6bbcd8c04f9a9bd9da05df Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 3 ++- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 ++-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 3 ++- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 ++- clang/lib/Driver/ToolChains/MSVC.cpp | 6 + clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..19f465b7dab08a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..969c2e289f7fa0 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +700,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +833,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..db08529f955168 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -135,7 +135,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain { public: ROCMToolChain(const Driver &D, const llvm::Triple &Triple, -const llvm::opt::ArgList &Args); +const llvm::opt::ArgList &Args, bool isHostTCMSVC); void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, diff --git a/clang/lib/Driver/ToolChai
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From dd7037436d90e51927fd0b7cb6f822980393a867 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 6 ++--- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 8 +- clang/lib/Driver/ToolChains/MSVC.cpp | 5 clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..2be0d04d1c5ddf 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, Target.isWindowsMSVCEnvironment()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6582,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..07f340ea425127 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,18 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } + + if (!isHostWindows()) { if (!LatestROCm.empty()) ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); - +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } + DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -376,10 +379,10 @@ RocmInstallationDetector::RocmInstallationDetector( .str(); } - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); + // Windows needs to exclude linux style paths from the list of paths to search, + // so delay these detection functions until after the constructor + + } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +706,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +839,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..db08529f955168 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From 80d3a80534482d9cc13b6a50e5c8026b1a9c0d11 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 6 ++--- clang/lib/Driver/ToolChains/AMDGPU.cpp | 27 clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 1 + clang/lib/Driver/ToolChains/HIPAMD.cpp | 8 +- clang/lib/Driver/ToolChains/MSVC.cpp | 5 clang/lib/Driver/ToolChains/ROCm.h | 12 + clang/test/Driver/rocm-detect-linux.hip | 9 +++ clang/test/Driver/rocm-detect-windows.hip| 9 +++ 10 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..2be0d04d1c5ddf 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, Target.isWindowsMSVCEnvironment()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: @@ -6582,8 +6582,8 @@ const ToolChain &Driver::getOffloadingDeviceToolChain( TC = std::make_unique(*this, Target, HostTC, Args); else if (Target.getArch() == llvm::Triple::spirv64 && - Target.getVendor() == llvm::Triple::UnknownVendor && - Target.getOS() == llvm::Triple::UnknownOS) + Target.getVendor() == llvm::Triple::UnknownVendor && + Target.getOS() == llvm::Triple::UnknownOS) TC = std::make_unique(*this, Target, HostTC, Args); break; diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..07f340ea425127 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,18 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } + + if (!isHostWindows()) { if (!LatestROCm.empty()) ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); - +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } + DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -376,10 +379,10 @@ RocmInstallationDetector::RocmInstallationDetector( .str(); } - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); + // Windows needs to exclude linux style paths from the list of paths to search, + // so delay these detection functions until after the constructor + + } void RocmInstallationDetector::detectDeviceLibrary() { @@ -703,6 +706,7 @@ AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +839,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..db08529f955168 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/
[clang] Remove Linux path names in ROCm search paths on Windows (PR #97668)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/97668 >From 803e3939a726bed2f1c43a3199850d580251c6d2 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Remove Linux path names in ROCm search paths on Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp| 24 +-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 +- clang/lib/Driver/ToolChains/HIPAMD.cpp| 2 +- clang/lib/Driver/ToolChains/MSVC.cpp | 4 clang/lib/Driver/ToolChains/ROCm.h| 9 - clang/test/Driver/rocm-detect-windows.hip | 9 + 6 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5b..1bd891498ca0d4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,23 +306,25 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } RocmInstallationDetector::RocmInstallationDetector( -const Driver &D, const llvm::Triple &HostTriple, +const Driver &D, const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), TargetTriple(TargetTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = @@ -820,8 +822,10 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation->setHostWindows(isHostTCMSVC); + RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index 7e70dae8ce152e..870230b3093df3 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -129,7 +129,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain { public: ROCMToolChain(const Driver &D, const llvm::Triple &Triple, -const llvm::opt::ArgList &Args); +const llvm::opt::ArgList &Args, bool isHostTCMSVC=false); void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index c35b0febb262da..4fe7e75360726d 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -250,7 +250,7 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA, HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const ArgList &Args) -: ROCMToolChain(D, Triple, Args), HostTC(HostTC) { +: ROCMToolChain(D, Triple, Args, HostTC.getTriple().isWindowsMSVCEnvironment()), HostTC(HostTC) { // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index ca266e3e1d1d3c..7526c6613f4dd7 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -428,6 +428,9 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : ToolChain(D, Triple, Args), CudaInstallation(D, Triple,
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From a5a84991fd605630e4c37cc92518fb8dee42ab61 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 3 +- clang/lib/Driver/ToolChains/AMDGPU.cpp | 32 +++- clang/lib/Driver/ToolChains/AMDGPU.h | 4 +-- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 3 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++ clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 +- clang/lib/Driver/ToolChains/MSVC.cpp | 6 clang/lib/Driver/ToolChains/ROCm.h | 12 clang/test/Driver/rocm-detect-linux.hip | 9 ++ clang/test/Driver/rocm-detect-windows.hip| 9 ++ clang/test/Driver/rocm-detect.hip| 4 +-- 11 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..19f465b7dab08a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..8a746c3b1359b4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -699,10 +696,12 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, /// AMDGPU Toolchain AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + if (!isHostTCMSVC) +RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +834,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) -: AMDGPUToolChain(D, Triple, Args) { + const ArgList &Args, bool isHostTCMSVC) +: AMDGPUToolChain(D, Triple, Args, isHostTCMSVC) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..c0e9727ebf56a2 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -59,7 +59,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { public: AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, -
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas ready_for_review https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From 4fad2d64582471816adc18f78294288bcaee0d63 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 3 +- clang/lib/Driver/ToolChains/AMDGPU.cpp | 32 +++- clang/lib/Driver/ToolChains/AMDGPU.h | 4 +-- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 3 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++ clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 +- clang/lib/Driver/ToolChains/MSVC.cpp | 6 clang/lib/Driver/ToolChains/ROCm.h | 12 clang/test/Driver/rocm-detect-linux.hip | 9 ++ clang/test/Driver/rocm-detect-windows.hip| 9 ++ 10 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..19f465b7dab08a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..8a746c3b1359b4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -699,10 +696,12 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, /// AMDGPU Toolchain AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + if (!isHostTCMSVC) +RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +834,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) -: AMDGPUToolChain(D, Triple, Args) { + const ArgList &Args, bool isHostTCMSVC) +: AMDGPUToolChain(D, Triple, Args, isHostTCMSVC) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..c0e9727ebf56a2 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -59,7 +59,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { public: AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, - const llvm::opt::ArgList &Args); + con
[clang] Remove Linux search paths on Windows (PR #113628)
david-salinas wrote: > Is there an issue with simply using the `HostTC` for everything? I feel like > that's the solution to this mess, since the `HostTC` would always know > whether or not the target is Windows without us needing to forward a bunch of > stuff. Yes, that would work too. But currently the HostTC is only available/accessible in HIPAMDToolChain. With the way we instantiate the RID, we need to tell the RID ctor to hold off on creating the Search Paths if the HostTC is Windows. And the RID ctor is called all the way up in the Generic_GCC ctor. We would still have to pass the HostTC all the way through class hierarchy (HIPAMDToolChain -> ROCMToolChin -> AMDGPUToolChain -> Generic_ELF). My thinking was that passing a bool would be a little less intrusive/heavy of a change. Though, we would only be passing a reference to the HostTC. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
https://github.com/david-salinas updated https://github.com/llvm/llvm-project/pull/113628 >From c86922536a3ef02967efbaeccd522ff8a34bafc0 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Tue, 22 Oct 2024 18:58:47 + Subject: [PATCH] Remove Linux search paths on Windows Change-Id: Ia0b44eb1069fa631a6d5156cf5881c978e23b62d --- clang/lib/Driver/Driver.cpp | 3 +- clang/lib/Driver/ToolChains/AMDGPU.cpp | 32 +++- clang/lib/Driver/ToolChains/AMDGPU.h | 4 +-- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 3 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++ clang/lib/Driver/ToolChains/HIPAMD.cpp | 9 +- clang/lib/Driver/ToolChains/MSVC.cpp | 6 clang/lib/Driver/ToolChains/ROCm.h | 12 clang/test/Driver/rocm-detect-linux.hip | 9 ++ clang/test/Driver/rocm-detect-windows.hip| 9 ++ clang/test/Driver/rocm-detect.hip| 4 +-- 11 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 clang/test/Driver/rocm-detect-linux.hip create mode 100644 clang/test/Driver/rocm-detect-windows.hip diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..19f465b7dab08a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); break; case llvm::Triple::AMDPAL: case llvm::Triple::Mesa3D: diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 2c85d21ebd738c..8a746c3b1359b4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,15 +306,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); + if (!isHostWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; } @@ -375,11 +377,6 @@ RocmInstallationDetector::RocmInstallationDetector( Twine(DefaultVersionMinor) + "." + VersionPatch) .str(); } - - if (DetectHIPRuntime) -detectHIPRuntime(); - if (DetectDeviceLib) -detectDeviceLibrary(); } void RocmInstallationDetector::detectDeviceLibrary() { @@ -699,10 +696,12 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, /// AMDGPU Toolchain AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) + const ArgList &Args, bool isHostTCMSVC) : Generic_ELF(D, Triple, Args), OptionsDefault( {{options::OPT_O, "3"}, {options::OPT_cl_std_EQ, "CL1.2"}}) { + if (!isHostTCMSVC) +RocmInstallation->init(); // Check code object version options. Emit warnings for legacy options // and errors for the last invalid code object version options. // It is done here to avoid repeated warning or error messages for @@ -835,8 +834,11 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args) -: AMDGPUToolChain(D, Triple, Args) { + const ArgList &Args, bool isHostTCMSVC) +: AMDGPUToolChain(D, Triple, Args, isHostTCMSVC) { + RocmInstallation->setHostWindows(isHostTCMSVC); + if (isHostTCMSVC) +RocmInstallation->init(true, false); RocmInstallation->detectDeviceLibrary(); } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index a9b4552a1f91a4..c0e9727ebf56a2 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -59,7 +59,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { public: AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, -
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); david-salinas wrote: Right, we call it "HostTriple", but in the case for a Device side ToolChain, the triple passed to the TC's ctor (which is the same triple passed to the RID ctor) is going to be the device triple, which is always (I think) amdgcn-amd-amdhsa, or at least definitely not Windows. We can use the TC's triple for removing the linux search paths for Host side. But the problem is that this doesn't work when we create the Device TC, and it's RID. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -0,0 +1,9 @@ +// REQUIRES: system-linux david-salinas wrote: agreed. Will change to use target. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -272,6 +277,13 @@ class RocmInstallationDetector { return Loc->second; } + void init(bool DetectHIPRuntime = true, bool DetectDeviceLib = false) { david-salinas wrote: Yes. We are basically just trying to avoid adding "linux like paths" on Windows. It's cosmetic. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); david-salinas wrote: "_I need to wrap my head around this more_" Yup, the class hierarchy we have created for our tool chains is ... frustrating, for this case. And I've tried a few different variations just to be able to tell the Device's ToolChain's RocmInstallationDetector to hold off on adding these search paths. "_what's stopping you from just saving that triple inside the class and using it when we do our detection_" That was one of my attempts. I first tried just adding it to the RocmInstallationDetector (RID) class. But because we use the LazyDetector template, I couldn't change the RID constructor without changing the LazyDetector template, and I didn't want to mess around with any of the other Detectors. So, then I tried just adding a Triple member to the ROCMToolChain class for the Host Triple, and initializing it in its constructor. Which works. But it is essentially ends up being the same (or nearly the same) as just passing a flag, and doing the "work" in the ROCMToolChain constructor. If I use a member Triple for Host, I would still need to check it in the ROCMToolChain ctor, and tell its RID that the Host is Windows, before having the RID generate the search paths. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -0,0 +1,9 @@ +// REQUIRES: system-windows david-salinas wrote: ok, I was just basing this off of existing tests. But I see that recently there has been support for targets in the REQUIRES statements. I'll change these for both the Windows and Linux tests. Also, for the .cl version of the test, I'm not sure if it would change much in how we create and use the ToolChains in the Driver. But, better to be safe. I'll add .cl versions for both tests. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); david-salinas wrote: The reason we need to pass this is primarily/solely because when we create the Offloading Device ToolChain (in "Driver::getOffloadingDeviceToolChain()", we pass the Device's triple to the toolchain constructor as the target triple; which as you mentioned will not be Windows. Then the Device side toolchain, has it's own RocmInstallationDetector, which will add the linux paths. And I need a way to tell the RocmInstallationDetector, on the device side ToolChain, that the Host TC is actually Windows. I tried a couple of different approaches to handle this case, but this is the least intrusive so far. The RocmInstallationDetector sets the search paths in its constructor, and all of the ToolChains that have a Rocm Detector call its constructor in their respective initialize list in their constructors. I need a way to tell that detector instance (for a device side toolchain) that it's Host ToolChain is windows and to not add the linux search paths. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -0,0 +1,9 @@ +// REQUIRES: system-windows david-salinas wrote: ah ok. :-) https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); david-salinas wrote: @jhuber6 So I spent some time trying to rework this to do just what you suggested (have the HIPAMDToolChain, just use the HostTC's RocmInstallation), because it is a good idea :-) But ... I ran into design issues. The member "HostTC" of HIPAMDToolChain, is a "const ToolChain &". And the "ToolChain" class does not have a "RocmInstallation" member, it is a member of the child class "Generic_GCC". We could cast "HostTC" reference to a Generic_GCC object reference (just in the HIPAMDToolClass), but that solution doesn't feel very pretty either. https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Remove Linux search paths on Windows (PR #113628)
@@ -6440,7 +6440,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = std::make_unique(*this, Target, Args); break; case llvm::Triple::AMDHSA: - TC = std::make_unique(*this, Target, Args); + TC = std::make_unique(*this, Target, Args, + Target.isOSWindows()); david-salinas wrote: ah ... ok. :-) https://github.com/llvm/llvm-project/pull/113628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits