Skip to content

[SYCL][Driver][libdevice] Link libspirv in -fsycl-device-only mode #19136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: review/Maetveis/libspirv-unused-argument
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ const char *SYCLInstallationDetector::findLibspirvPath(
void SYCLInstallationDetector::addLibspirvLinkArgs(
const llvm::Triple &DeviceTriple, const llvm::opt::ArgList &DriverArgs,
const llvm::Triple &HostTriple, llvm::opt::ArgStringList &CC1Args) const {
DriverArgs.claimAllArgs(options::OPT_fno_sycl_libspirv);

if (D.offloadDeviceOnly())
return;

if (DriverArgs.hasArg(options::OPT_fno_sycl_libspirv)) {
// -fno-sycl-libspirv flag is reserved for very unusual cases where the
// libspirv library is not linked when required by the device: so output appropriate
Expand Down
3 changes: 1 addition & 2 deletions clang/test/Driver/sycl-libspirv-toolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
//
// RUN: %clang -### -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
// RUN: | FileCheck %s --check-prefixes=CHECK-DEVICE-ONLY
// CHECK-DEVICE-ONLY: "-cc1"{{.*}} "-fsycl-is-device"
// CHECK-DEVICE-ONLY-NOT: "-mlink-builtin-bitcode" "{{.*}}.libspirv-{{.*}}.bc"
// CHECK-DEVICE-ONLY: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
//
// Only link libspirv in SYCL language mode, `-fno-sycl-libspirv` should result in a warning
// RUN: %clang -### -x cu -fno-sycl-libspirv -nocudainc -nocudalib %s 2>&1 | FileCheck %s --check-prefixes=CHECK-CUDA
Expand Down
4 changes: 2 additions & 2 deletions libdevice/cmake/modules/SYCLLibdevice.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ set(devicelib_arch)
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND devicelib_arch nvptx64-nvidia-cuda)
set(compile_opts_nvptx64-nvidia-cuda "-fsycl-targets=nvptx64-nvidia-cuda"
"-Xsycl-target-backend" "--cuda-gpu-arch=sm_50" "-nocudalib")
"-Xsycl-target-backend" "--cuda-gpu-arch=sm_50" "-nocudalib" "-fno-sycl-libspirv" "-Wno-unsafe-libspirv-not-linked")
set(opt_flags_nvptx64-nvidia-cuda "-O3" "--nvvm-reflect-enable=false")
endif()
if("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND devicelib_arch amdgcn-amd-amdhsa)
set(compile_opts_amdgcn-amd-amdhsa "-nogpulib" "-fsycl-targets=amdgcn-amd-amdhsa"
"-Xsycl-target-backend" "--offload-arch=gfx942")
"-Xsycl-target-backend" "--offload-arch=gfx942" "-fno-sycl-libspirv" "-Wno-unsafe-libspirv-not-linked")
set(opt_flags_amdgcn-amd-amdhsa "-O3" "--amdgpu-oclc-reflect-enable=false")
endif()

Expand Down