Skip to content

[CUDA][HIP] Linker warnings #7300

@krasznaa

Description

@krasznaa

Describe the bug

We have been living with various warnings from the compiler (or more from the linker) in our projects since a while. I thought it may be time to get rid of them.

  • Since I don't remember when exactly, we've been getting such warnings while building source files for either a CUDA or HIP backend:
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc' is 'nvptx64-unknown-nvidiacl' whereas 'library.cxx' is 'nvptx64-nvidia-cuda'
 [-Wlinker-warnings]
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc' is 'amdgcn-unknown-amdhsa' whereas 'main.cxx' is 'amdgcn-amd-amdhsa'
 [-Wlinker-warnings]
  • With 2022-09 I came across this new one as well:
clang-16: warning: linked binaries do not contain expected 'nvptx64-nvidia-cuda' target; found targets: 'nvptx64-nvidia-cuda-sm_50' [-Wsycl-target]
clang-16: warning: linked binaries do not contain expected 'amdgcn-amd-amdhsa' target; found targets: 'amdgcn-amd-amdhsa-gfx803' [-Wsycl-target]

To Reproduce

The "first type of warnings" can be triggered by compiling literally any source file. Like:

[bash][pcadp04]:sycl-link > more main.cxx 
#include <CL/sycl.hpp>

int main() { return 0; }
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda main.cxx 
clang-16: warning: CUDA version is newer than the latest supported version 11.5 [-Wunknown-cuda-version]
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc' is 'nvptx64-unknown-nvidiacl' whereas 'main.cxx' is 'nvptx64-nvidia-cuda'
 [-Wlinker-warnings]
1 warning generated.
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx803 main.cxx
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc' is 'amdgcn-unknown-amdhsa' whereas 'main.cxx' is 'amdgcn-amd-amdhsa'
 [-Wlinker-warnings]
1 warning generated.
[bash][pcadp04]:sycl-link >

The "second one" is a bit more tricky to trigger. In our builds it shows up when linking shared libraries. Like:

[bash][pcadp04]:sycl-link > more library.cxx 
#include <CL/sycl.hpp>

int foo() {
   return 5;
}
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda -c -o library.o library.cxx 
clang-16: warning: CUDA version is newer than the latest supported version 11.5 [-Wunknown-cuda-version]
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc' is 'nvptx64-unknown-nvidiacl' whereas 'library.cxx' is 'nvptx64-nvidia-cuda'
 [-Wlinker-warnings]
1 warning generated.
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda -shared -o library.so library.o
clang-16: warning: linked binaries do not contain expected 'nvptx64-nvidia-cuda' target; found targets: 'nvptx64-nvidia-cuda-sm_50' [-Wsycl-target]
clang-16: warning: CUDA version is newer than the latest supported version 11.5 [-Wunknown-cuda-version]
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx803 -c -o library.o library.cxx 
warning: linking module '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc': Linking two modules of different target triples: '/mnt/hdd1/software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/lib/clang/16.0.0/../../clc/remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc' is 'amdgcn-unknown-amdhsa' whereas 'library.cxx' is 'amdgcn-amd-amdhsa'
 [-Wlinker-warnings]
1 warning generated.
[bash][pcadp04]:sycl-link > clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx803 -shared -o library.so library.o
clang-16: warning: linked binaries do not contain expected 'amdgcn-amd-amdhsa' target; found targets: 'amdgcn-amd-amdhsa-gfx803' [-Wsycl-target]
[bash][pcadp04]:sycl-link >

Environment

  • OS: Linux (Seen both on Ubuntu 20.04 and CentOS Stream 9. The exact Linux version shouldn't matter.)
  • Target device and vendor: AMD and NVIDIA GPU, but the problem is not a runtime one
  • DPC++ version:
[bash][pcadp04]:sycl-link > clang++ -v
clang version 16.0.0 (https://github.com/intel/llvm.git 0f579bae55c48d810e1ed76db29229c854e61d5e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /software/intel/clang-2022-09/x86_64-centos9-gcc11-opt/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/11
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /mnt/hdd1/software/cuda/11.7.1/x86_64, version 
Found HIP installation: /opt/rocm, version 5.3.22061
[bash][pcadp04]:sycl-link >
  • Dependencies version: Not important.

Additional context

The warnings don't seem to have any negative effect, but it's not nice that we need to explicitly hide them with -Wno-linker-warnings and -Wno-sycl-target if we don't want to see them all the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghipIssues related to execution on HIP backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions