Bug#1010467: clang: cannot use hip from /usr
Cordell Bloor
cgmb-deb at slerp.xyz
Mon May 2 04:58:48 BST 2022
Package: clang
Version: 1:13.0-54
Severity: normal
Dear Maintainer,
The upstream versions of clang-13 and clang-14 fulfill the minimum
requirements to build HIP language programs, but contain a bug that
prevents them from functioning correctly when the HIP library is
installed in /usr.
This problem was fixed in upstream llvm, and the change is expected to
land in clang-15. The change is very minimal and only affects the HIP
language. It can be found here:
https://github.com/llvm/llvm-project/commit/6730b44480fcce18bfbbae0c46719250e9eae425
This problem is important to address to help the packaging of ROCm
proceed, as the Debian native package will install HIP into /usr.
To reproduce the problem:
# install HIP to /usr
https://gist.github.com/cgmb/edb7b790ab55681fb2ba5385ee02489b
# create a HIP language program
cat > example.cpp << 'EOF'
#include <hip/hip_runtime.h>
__global__ void square(int *array, int n) {
int tid = blockIdx.x;
if (tid < n)
array[tid] = array[tid] * array[tid];
}
EOF
# compile it
clang++ \
-v \
-std=c++11 \
--offload-arch=gfx908 \
-mllvm -amdgpu-early-inline-all=true \
-mllvm -amdgpu-function-calls=false \
--hip-device-lib-path="/usr/lib/x86_64-linux-gnu/amdgcn/bitcode" \
--rocm-path="/usr" \
-fhip-new-launch-api \
-D__HIP_PLATFORM_AMD__=1 -D__HIP_PLATFORM_HCC__=1 \
-mf16c \
-O3 -DNDEBUG \
-x hip \
-o example.o \
-c example.cpp
# see output
Debian clang version 13.0.1-3+b2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found HIP installation: /usr, version 3.5.0
"/usr/lib/llvm-13/bin/clang" -cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-linux-gnu -emit-obj --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model pic -pic-level 1 -fhalf-no-semantic-interposition -mframe-pointer=none -fno-rounding-math -aux-target-cpu x86-64 -aux-target-feature +f16c -fcuda-is-device -mllvm -amdgpu-internalize-symbols -fcuda-allow-variadic-functions -fvisibility hidden -fapply-global-visibility-to-externs -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/hip.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/ocml.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/ockl.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_daz_opt_off.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_unsafe_math_off.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_finite_only_off.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_wavefrontsize64_on.bc -mlink-builtin-bitcode /usr/lib/x86_64-linux-gnu/amdgcn/bitcode/oclc_isa_version_908.bc -target-cpu gfx908 -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-13/lib/clang/13.0.1 -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.1 -internal-isystem /usr/include -D __HIP_PLATFORM_AMD__=1 -D __HIP_PLATFORM_HCC__=1 -D NDEBUG -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/lib/llvm-13/lib/clang/13.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=c++11 -fdeprecated-macro -fno-autolink -fdebug-compilation-dir=/home/cgmb -ferror-limit 19 -fhip-new-launch-api -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false -cuid=9b98635caacf7494 -fcuda-allow-variadic-functions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-4e3c77.o -x hip example.cpp
clang -cc1 version 13.0.1 based upon LLVM 13.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11"
ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11"
ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "/usr/lib/llvm-13/lib/clang/13.0.1/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/lib/llvm-13/lib/clang/13.0.1/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/llvm-13/lib/clang/13.0.1
/usr/include
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward
/usr/lib/llvm-13/lib/clang/13.0.1/include
/usr/local/include
/usr/include/x86_64-linux-gnu
End of search list.
In file included from example.cpp:1:
In file included from /usr/include/hip/hip_runtime.h:62:
In file included from /usr/include/hip/amd_detail/amd_hip_runtime.h:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/cmath:45:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated when compiling for gfx908.
When the upstream patch
https://github.com/llvm/llvm-project/commit/6730b44480fcce18bfbbae0c46719250e9eae425.patch
is applied, the system headers will no longer be set up in an incorrect
order, and the clang++ build command should succeed.
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.13.0-40-generic (SMP w/32 CPU threads)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: unable to detect
Versions of packages clang depends on:
ii clang-13 1:13.0.1-3+b2
clang recommends no packages.
clang suggests no packages.
-- no debconf information
More information about the Pkg-llvm-team
mailing list