diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index e70c35a4f526b..8aa632f9fffc7 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -210,11 +210,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 diff --git a/clang/test/Driver/sycl-libspirv-toolchain.cpp b/clang/test/Driver/sycl-libspirv-toolchain.cpp index 3c0888e795506..eac98ad9b17c2 100644 --- a/clang/test/Driver/sycl-libspirv-toolchain.cpp +++ b/clang/test/Driver/sycl-libspirv-toolchain.cpp @@ -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 diff --git a/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index 747717de66166..3f6465b3cd45f 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -90,13 +90,13 @@ set(full_build_archs) if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD) list(APPEND full_build_archs 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 full_build_archs 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() @@ -430,7 +430,8 @@ if("native_cpu" IN_LIST SYCL_ENABLE_BACKENDS) # libsycl-nativecpu_utils is only needed as BC file by NativeCPU. add_custom_command( OUTPUT ${bc_binary_dir}/nativecpu_utils.bc - COMMAND ${clang_exe} ${compile_opts} ${bc_device_compile_opts} -fsycl-targets=native_cpu + COMMAND ${clang_exe} ${compile_opts} ${bc_device_compile_opts} + -fsycl-targets=native_cpu -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked -I ${NATIVE_CPU_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/nativecpu_utils.cpp -o ${bc_binary_dir}/nativecpu_utils.bc diff --git a/sycl/test/check_device_code/math-builtins/cmath-spirv-mapping.cpp b/sycl/test/check_device_code/math-builtins/cmath-spirv-mapping.cpp index 1da771bfc1861..e5e40d88aae1e 100644 --- a/sycl/test/check_device_code/math-builtins/cmath-spirv-mapping.cpp +++ b/sycl/test/check_device_code/math-builtins/cmath-spirv-mapping.cpp @@ -2,7 +2,8 @@ // Note: This isn't really target specific and should be switched to spir when // it's enabled for it. -// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda -S -Xclang -emit-llvm -fsycl-device-only %s -o - | FileCheck %s +// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda -S -Xclang -emit-llvm \ +// RUN: -fsycl-device-only -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked %s -o - | FileCheck %s #include diff --git a/sycl/test/check_device_code/native_cpu/kernelhandler-scalar.cpp b/sycl/test/check_device_code/native_cpu/kernelhandler-scalar.cpp index f26a966803948..9b75dc4379ea6 100644 --- a/sycl/test/check_device_code/native_cpu/kernelhandler-scalar.cpp +++ b/sycl/test/check_device_code/native_cpu/kernelhandler-scalar.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu -Xclang -sycl-std=2020 -mllvm -sycl-opt -S -emit-llvm -o %t_temp.ll %s +// RUN: %clangxx -fsycl-device-only -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked -fsycl-targets=native_cpu -Xclang -sycl-std=2020 -mllvm -sycl-opt -S -emit-llvm -o %t_temp.ll %s // RUN: %clangxx -mllvm -sycl-native-cpu-backend -S -emit-llvm -o - %t_temp.ll | FileCheck %s #include diff --git a/sycl/test/check_device_code/native_cpu/native_cpu_subhandler.cpp b/sycl/test/check_device_code/native_cpu/native_cpu_subhandler.cpp index 112cfa625cc67..27f7f4ee84c08 100644 --- a/sycl/test/check_device_code/native_cpu/native_cpu_subhandler.cpp +++ b/sycl/test/check_device_code/native_cpu/native_cpu_subhandler.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl-device-only -O2 -g -fexceptions -fsycl-targets=native_cpu -Xclang -sycl-std=2020 -mllvm -sycl-opt -S -emit-llvm -o %t_temp.ll %s +// RUN: %clangxx -fsycl-device-only -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked -O2 -g -fexceptions -fsycl-targets=native_cpu -Xclang -sycl-std=2020 -mllvm -sycl-opt -S -emit-llvm -o %t_temp.ll %s // RUN: %clangxx -mllvm -sycl-native-cpu-backend -S -emit-llvm -o - %t_temp.ll | FileCheck %s // Checks that the subhandler is correctly emitted in the module diff --git a/sycl/test/check_device_code/native_cpu/offload-wrapper.cpp b/sycl/test/check_device_code/native_cpu/offload-wrapper.cpp index 98d4ce88e623f..ae2c9ef36e1bc 100644 --- a/sycl/test/check_device_code/native_cpu/offload-wrapper.cpp +++ b/sycl/test/check_device_code/native_cpu/offload-wrapper.cpp @@ -1,6 +1,6 @@ // This test checks the output for the clang-offload-wrapper for the Native CPU // target: -// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu %s -o %t.bc +// RUN: %clangxx -fsycl-device-only -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked -fsycl-targets=native_cpu %s -o %t.bc // RUN: sycl-post-link -properties -emit-param-info -symbols -emit-exported-symbols -O2 -spec-const=native -device-globals -o %t.table %t.bc // RUN: clang-offload-wrapper -o=%t_wrap.bc -host=x86_64-unknown-linux-gnu -target=native_cpu -kind=sycl -batch %t.table // RUN: llvm-dis %t_wrap.bc -o - | FileCheck %s