Index: clang/lib/Driver/ToolChains/AMDGPU.cpp =================================================================== --- clang/lib/Driver/ToolChains/AMDGPU.cpp +++ clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -251,7 +251,12 @@ if (ParentPath != InstallDir) ROCmSearchDirs.emplace_back(DeduceROCmPath(ParentPath)); - // Device library may be installed in clang resource directory. + // Device library may be installed in clang or resource directory. + auto ClangRoot = llvm::sys::path::parent_path(InstallDir); + auto RealClangRoot = llvm::sys::path::parent_path(ParentPath); + ROCmSearchDirs.emplace_back(ClangRoot.str(), /*StrictChecking=*/true); + if (RealClangRoot != ClangRoot) + ROCmSearchDirs.emplace_back(RealClangRoot.str(), /*StrictChecking=*/true); ROCmSearchDirs.emplace_back(D.ResourceDir, /*StrictChecking=*/true); @@ -409,10 +414,7 @@ // Make a path by appending sub-directories to InstallPath. auto MakePath = [&](const llvm::ArrayRef &SubDirs) { - // Device library built by SPACK is installed to - // /rocm-device-libs-- directory. - auto SPACKPath = findSPACKPackage(Candidate, "rocm-device-libs"); - auto Path = SPACKPath.empty() ? CandidatePath : SPACKPath; + auto Path = CandidatePath; for (auto SubDir : SubDirs) llvm::sys::path::append(Path, SubDir); return Path; Index: clang/test/Driver/rocm-detect.hip =================================================================== --- clang/test/Driver/rocm-detect.hip +++ clang/test/Driver/rocm-detect.hip @@ -50,21 +50,19 @@ // and --rocm-device-lib-path can be used to specify them. // RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd -// RUN: cp -r %T/rocm-spack/rocm-device-libs-* %T/rocm-spack/rocm-device-libs-4.0.0-efgh // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \ // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \ // RUN: | FileCheck -check-prefixes=SPACK-MULT %s // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \ // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \ // RUN: --hip-path=%T/rocm-spack/hip-4.0.0-abcd \ -// RUN: --rocm-device-lib-path=%T/rocm-spack/rocm-device-libs-4.0.0-efgh/amdgcn/bitcode \ // RUN: %s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s // Test invalid SPACK ROCm installation missing hip and rocm-device-libs packages. // The message about SPACK is emitted only if -v is specified. // RUN: rm -rf %T/rocm-spack/hip-* -// RUN: rm -rf %T/rocm-spack/rocm-device-libs-* +// RUN: rm -rf %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \ // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \ // RUN: | FileCheck -check-prefixes=SPACK-MISS %s @@ -84,34 +82,30 @@ // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR:.*]] // SPACK: ROCm installation search path: [[CLANG:.*]] +// SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z // SPACK: ROCm installation search path: [[CLANG]]/{{(llvm/)?}}lib{{[0-9]*}}/clang/{{[0-9.]+}} // SPACK: ROCm installation search path: /opt/rocm // SPACK: InstalledDir: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd // SPACK: "-triple" "amdgcn-amd-amdhsa" -// SPACK-SAME: "-mlink-builtin-bitcode" "[[DIR]]/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/hip.bc" +// SPACK-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc" // SPACK-SAME: "-internal-isystem" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include" // SPACK-MULT: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin // SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to multiple installations for the same version -// SPACK-MULT-DAG: Cannot use SPACK package rocm-device-libs-4.0.0 at [[DIR]] due to multiple installations for the same version // SPACK-MULT-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd -// SPACK-MULT-NOT: "-mlink-builtin-bitcode" "[[DIR]]/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/hip.bc" // SPACK-MULT-NOT: "-internal-isystem" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include" // SPACK-SET: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin // SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 4.0.20214-a2917cd // SPACK-SET: "-triple" "amdgcn-amd-amdhsa" -// SPACK-SET-SAME: "-mlink-builtin-bitcode" "[[DIR]]/rocm-device-libs-4.0.0-efgh/amdgcn/bitcode/hip.bc" +// SPACK-SET-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc" // SPACK-SET-SAME: "-internal-isystem" "[[DIR]]/hip-4.0.0-abcd/include" // SPACK-MISS: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin // SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]] -// SPACK-MISS-DAG: SPACK package rocm-device-libs-4.0.0 not found at [[DIR]] // SPACK-MISS-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd -// SPACK-MISS-NOT: "-mlink-builtin-bitcode" "[[DIR]]/rocm-device-libs-4.0.0-6wnyzz4hgl3hr7uswasnagt7j2adctbs/amdgcn/bitcode/hip.bc" // SPACK-MISS-NOT: "-internal-isystem" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include" // SPACK-MISS-SILENT-NOT: SPACK package hip-{{.*}} not found at -// SPACK-MISS-SILENT-NOT: SPACK package rocm-device-libs-{{.*}} not found at // SPACK-MISS-SILENT-NOT: Found HIP installation