https://github.com/haampie created
https://github.com/llvm/llvm-project/pull/133263
There is special logic to detect the hip runtime when llvm is installed
with Spack. It works by matching the install prefix of llvm against
`llvm-amdgpu-*` followed by effectively globbing for
```
/../hip-x.y.z-*/
```
and checking there is exactly one such directory.
I would suggest to remove autodetection for the following reasons:
1. In the Spack ecosystem it's by design that every packages lives in
its own prefix, and can only know where its dependencies are
installed, it has no clue what its dependents are and where they are
installed. This heuristic detection breaks that invariant, and is
rather surprising to Spack users.
2. The detection can lead to false positives, since users can be using
an llvm installed "upstream" with their own build of hip locally, and
they may not realize that clang is picking up upstream hip instead of
their local copy.
3. It only works if the directory name is `llvm-amdgpu-*` which happens
to be the name of AMD's fork of `llvm`, so it makes no sense that
this code lives in the main LLVM repo for which the Spack package
name is `llvm`.
4. Users can change the install directory structure, meaning that this
detection is not robust under config changes in Spack.
>From 1b80fbf40282790367c8e83b73f18ae683ab8b82 Mon Sep 17 00:00:00 2001
From: Harmen Stoppels
Date: Thu, 27 Mar 2025 15:41:00 +0100
Subject: [PATCH] [AMDGPU] Remove detection of hip runtime for Spack
There is special logic to detect the hip runtime when llvm is installed
with Spack. It works by matching the install prefix of llvm against
`llvm-amdgpu-*` followed by effectively globbing for
```
/../hip-x.y.z-*/
```
and checking there is exactly one such directory.
I would suggest to remove autodetection for the following reasons:
1. In the Spack ecosystem it's by design that every packages lives in
its own prefix, and can only know where its dependencies are
installed, it has no clue what its dependents are and where they are
installed. This heuristic detection breaks that invariant, and is
rather surprising to Spack users.
2. The detection can lead to false positives, since users can be using
an llvm installed "upstream" with their own build of hip locally, and
they may not realize that clang is picking up upstream hip instead of
their local copy.
3. It only works if the directory name is `llvm-amdgpu-*` which happens
to be the name of AMD's fork of `llvm`, so it makes no sense that
this code lives in the main LLVM repo for which the Spack package
name is `llvm`.
4. Users can change the install directory structure, meaning that this
detection is not robust under config changes in Spack.
---
clang/lib/Driver/ToolChains/AMDGPU.cpp| 67 +--
.../bin/.hipVersion | 5 --
.../include/hip/hip_runtime.h | 0
.../amdgcn/bitcode/asanrtl.bc | 0
.../amdgcn/bitcode/hip.bc | 0
.../amdgcn/bitcode/ockl.bc| 0
.../amdgcn/bitcode/oclc_abi_version_400.bc| 0
.../amdgcn/bitcode/oclc_abi_version_500.bc| 0
.../amdgcn/bitcode/oclc_abi_version_600.bc| 0
.../oclc_correctly_rounded_sqrt_off.bc| 0
.../bitcode/oclc_correctly_rounded_sqrt_on.bc | 0
.../amdgcn/bitcode/oclc_daz_opt_off.bc| 0
.../amdgcn/bitcode/oclc_daz_opt_on.bc | 0
.../amdgcn/bitcode/oclc_finite_only_off.bc| 0
.../amdgcn/bitcode/oclc_finite_only_on.bc | 0
.../amdgcn/bitcode/oclc_isa_version_1010.bc | 0
.../amdgcn/bitcode/oclc_isa_version_1011.bc | 0
.../amdgcn/bitcode/oclc_isa_version_1012.bc | 0
.../amdgcn/bitcode/oclc_isa_version_803.bc| 0
.../amdgcn/bitcode/oclc_isa_version_900.bc| 0
.../amdgcn/bitcode/oclc_isa_version_908.bc| 0
.../amdgcn/bitcode/oclc_unsafe_math_off.bc| 0
.../amdgcn/bitcode/oclc_unsafe_math_on.bc | 0
.../bitcode/oclc_wavefrontsize64_off.bc | 0
.../amdgcn/bitcode/oclc_wavefrontsize64_on.bc | 0
.../amdgcn/bitcode/ocml.bc| 0
.../amdgcn/bitcode/opencl.bc | 0
.../bin/.keep | 0
clang/test/Driver/rocm-detect.hip | 47 -
29 files changed, 1 insertion(+), 118 deletions(-)
delete mode 100644
clang/test/Driver/Inputs/rocm-spack/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/bin/.hipVersion
delete mode 100644
clang/test/Driver/Inputs/rocm-spack/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include/hip/hip_runtime.h
delete mode 100644
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/asanrtl.bc
delete mode 100644
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc
delete mode 100644
clang/test/Driver/Inputs/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z