diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index c051255ab7f9c..dc189e2b3be7e 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -75,15 +75,8 @@ const char *SYCLInstallationDetector::findLibspirvPath( return nullptr; }; - for (const auto &IC : InstallationCandidates) { - // Expected path w/out install. - if (const char *R = searchAt(IC, "lib", "clc")) - return R; - - // Expected path w/ install. - if (const char *R = searchAt(IC, "share", "clc")) - return R; - } + if (const char *R = searchAt(D.ResourceDir, "lib", "libclc")) + return R; return nullptr; } diff --git a/clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc b/clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc similarity index 100% rename from clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc rename to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc diff --git a/clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc b/clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc similarity index 100% rename from clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc rename to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc diff --git a/clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc b/clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc similarity index 100% rename from clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc rename to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc diff --git a/clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc b/clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc similarity index 100% rename from clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc rename to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc diff --git a/clang/test/Driver/sycl-cuda-rdc.cpp b/clang/test/Driver/sycl-cuda-rdc.cpp index 79072a5babbfa..3e0411f7cd8f4 100644 --- a/clang/test/Driver/sycl-cuda-rdc.cpp +++ b/clang/test/Driver/sycl-cuda-rdc.cpp @@ -4,7 +4,8 @@ // UNSUPPORTED: system-windows -// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_61 -fgpu-rdc -nocudalib -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc %s 2>&1 \ +// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_61 -fgpu-rdc -nocudalib \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-SYCL_RDC_NVPTX // Verify that ptxas does not pass "-c" diff --git a/clang/test/Driver/sycl-device-obj-asm.cpp b/clang/test/Driver/sycl-device-obj-asm.cpp index 6a4090672db92..a23e994fba845 100644 --- a/clang/test/Driver/sycl-device-obj-asm.cpp +++ b/clang/test/Driver/sycl-device-obj-asm.cpp @@ -30,10 +30,10 @@ /// -fsycl-device-obj=asm should always be accompanied by -fsycl-device-only /// and -S, check that the compiler issues a correct warning message: -// RUN: %clang -### -nocudalib -fsycl-device-only -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_50 -fsycl-device-obj=asm %s 2>&1 -o - -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc | FileCheck %s --check-prefix=CHECK-NO-DEV-ONLY-NO-S +// RUN: %clang -### -nocudalib -fsycl-device-only -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_50 -fsycl-device-obj=asm %s 2>&1 -o - -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc | FileCheck %s --check-prefix=CHECK-NO-DEV-ONLY-NO-S // CHECK-NO-DEV-ONLY-NO-S: warning: -fsycl-device-obj=asm flag has an effect only when compiling device code and emitting assembly, make sure both -fsycl-device-only and -S flags are present; will be ignored [-Wunused-command-line-argument] /// -fsycl-device-obj=asm will finish at generating assembly stage, hence /// inform users that generating library will not be possible (ignore -c) -// RUN: %clang -### -nocudalib -fsycl-device-only -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_50 -fsycl-device-obj=asm %s 2>&1 -fsycl-device-only -S -c -o - -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc | FileCheck %s --check-prefix=CHECK-DASH-C-IGNORE +// RUN: %clang -### -nocudalib -fsycl-device-only -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_50 -fsycl-device-obj=asm %s 2>&1 -fsycl-device-only -S -c -o - -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc | FileCheck %s --check-prefix=CHECK-DASH-C-IGNORE // CHECK-DASH-C-IGNORE: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument] diff --git a/clang/test/Driver/sycl-libspirv-toolchain.cpp b/clang/test/Driver/sycl-libspirv-toolchain.cpp index 64f64d7f2260f..15ed431b4734c 100644 --- a/clang/test/Driver/sycl-libspirv-toolchain.cpp +++ b/clang/test/Driver/sycl-libspirv-toolchain.cpp @@ -1,27 +1,26 @@ // Test the search logic for the libspirv bitcode library in the offloading toolchains that need it. -// DEFINE: %{install_dir} = %/S/Inputs/SYCL/bin // DEFINE: %{resource_dir} = %/S/Inputs/SYCL/lib/clang/resource_dir -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2>&1 \ -// RUN: | FileCheck %s --check-prefixes=CHECK-WINDOWS -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-gnu %s 2>&1 \ -// RUN: | FileCheck %s --check-prefixes=CHECK-WINDOWS -// CHECK-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc" -// -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2>&1 \ -// RUN: | FileCheck %s --check-prefixes=CHECK-LINUX -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-cygnus %s 2>&1 \ -// RUN: | FileCheck %s --check-prefixes=CHECK-LINUX -// CHECK-LINUX: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc" -// -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib -target x86_64-unknown-windows-msvc %s 2>&1 \ -// RUN: | FileCheck %s --check-prefixes=CHECK-AMDGCN-WINDOWS -// CHECK-AMDGCN-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc" -// -// RUN: %clang -### -ccc-install-dir %{install_dir} -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"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc" +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-WINDOWS +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-gnu %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-WINDOWS +// CHECK-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc" +// +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-LINUX +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-cygnus %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-LINUX +// CHECK-LINUX: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc" +// +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib -target x86_64-unknown-windows-msvc %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-AMDGCN-WINDOWS +// CHECK-AMDGCN-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc" +// +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DEVICE-ONLY +// CHECK-DEVICE-ONLY: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}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 @@ -30,20 +29,20 @@ // CHECK-CUDA-NOT: "-mlink-builtin-bitcode" "{{.*}}.libspirv-{{.*}}.bc" // // The path to the remangled libspirv bitcode file is determined by the installation directory -// RUN: %clang -### -ccc-install-dir %{install_dir} -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ -// RUN: | FileCheck %s -DINSTALL_DIR=%{install_dir} -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DIR -// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[INSTALL_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc" +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ +// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DIR +// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc" // // If libspirv path doesn't exist, error is reported. // DEFINE: %{nonexistent_dir} = %/S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir -// RUN: not %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ -// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-HHH-NONEXISTENT +// RUN: not %clang -### -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ +// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-HHH-NONEXISTENT // CHECK-HHH-NONEXISTENT: error: cannot find 'remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc'; provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv // -// RUN: not %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \ -// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-AMDGCN-HHH-NONEXISTENT +// RUN: not %clang -### -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \ +// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-AMDGCN-HHH-NONEXISTENT // CHECK-AMDGCN-HHH-NONEXISTENT: clang: error: cannot find 'remangled-{{.*}}.libspirv-amdgcn-amd-amdhsa.bc'; provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv // -// RUN: not %clang -fdriver-only -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ -// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-DO-NONEXISTENT +// RUN: not %clang -fdriver-only -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \ +// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-DO-NONEXISTENT // CHECK-DO-NONEXISTENT: error: cannot find 'remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc'; provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv diff --git a/clang/test/Driver/sycl-nvptx-link.cpp b/clang/test/Driver/sycl-nvptx-link.cpp index 9220f7171e5ea..9f3d0bf554d6d 100644 --- a/clang/test/Driver/sycl-nvptx-link.cpp +++ b/clang/test/Driver/sycl-nvptx-link.cpp @@ -10,29 +10,29 @@ // correctly versioned libdevice. We use Inputs/CUDA_80 which has a full set of // libdevice files. -// DEFINE: %{install_dir} = %/S/Inputs/SYCL/bin +// DEFINE: %{resource_dir} = %/S/Inputs/SYCL/lib/clang/resource_dir -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ // RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_30 \ // RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE30 -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ // RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \ // RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE35 -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ // RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_50 \ // RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE50 // CUDA-9+ uses the same libdevice for all GPU variants -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \ // RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \ // RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE10 // Check also that -nocudalib is obeyed -// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib \ +// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib \ // RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \ // RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHECK,NOLIBDEVICE diff --git a/clang/test/Driver/sycl-offload-nvptx.cpp b/clang/test/Driver/sycl-offload-nvptx.cpp index c20273fed071b..d2dcbada56def 100644 --- a/clang/test/Driver/sycl-offload-nvptx.cpp +++ b/clang/test/Driver/sycl-offload-nvptx.cpp @@ -38,7 +38,7 @@ // RUN: %clangxx -ccc-print-phases --sysroot=%S/Inputs/SYCL -std=c++11 \ // RUN: -target x86_64-unknown-linux-gnu -fsycl --no-offloadlib \ // RUN: -fsycl-targets=nvptx64-nvidia-cuda %s 2>&1 \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ // RUN: | FileCheck -check-prefix=CHK-PHASES-NO-CC %s // @@ -71,7 +71,7 @@ // RUN: %clangxx -ccc-print-phases --sysroot=%S/Inputs/SYCL -std=c++11 \ // RUN: -target x86_64-unknown-linux-gnu -fsycl --no-offloadlib \ // RUN: -fsycl-targets=nvptx64-nvidia-cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ // RUN: -Xsycl-target-backend "--cuda-gpu-arch=sm_35" %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES %s diff --git a/clang/test/Driver/sycl-offload-old-model.c b/clang/test/Driver/sycl-offload-old-model.c index c19e909452ddf..c3c980ee6c885 100644 --- a/clang/test/Driver/sycl-offload-old-model.c +++ b/clang/test/Driver/sycl-offload-old-model.c @@ -605,7 +605,7 @@ /// Verify that triple-boundarch pairs are correct with multi-targetting // RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver -fno-sycl-instrument-device-code --no-offloadlib \ // RUN: -fsycl-targets=nvptx64-nvidia-cuda,spir64 -ccc-print-phases --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc %s 2>&1 \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASE-MULTI-TARG-BOUND-ARCH %s // CHK-PHASE-MULTI-TARG-BOUND-ARCH: 0: input, "[[INPUT:.+\.c]]", c++, (host-sycl) // CHK-PHASE-MULTI-TARG-BOUND-ARCH: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) @@ -644,7 +644,7 @@ // RUN: -fno-sycl-instrument-device-code --no-offloadlib \ // RUN: -fsycl-targets=nvptx64-nvidia-cuda,spir64_gen \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: -Xsycl-target-backend=spir64_gen "-device skl" \ // RUN: -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASE-MULTI-TARG-BOUND-ARCH2 %s @@ -686,7 +686,7 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver \ // RUN: -fno-sycl-instrument-device-code --no-offloadlib \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: -fsycl-targets=spir64,nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASE-MULTI-TARG-BOUND-ARCH-FLIPPED %s // CHK-PHASE-MULTI-TARG-BOUND-ARCH-FLIPPED: 0: input, "[[INPUT:.+\.c]]", c++, (host-sycl) @@ -728,7 +728,7 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -fsycl --no-offload-new-driver \ // RUN: -fno-sycl-instrument-device-code --no-offloadlib \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: -fsycl-targets=spir64,nvptx64-nvidia-cuda,amdgcn-amd-amdhsa \ // RUN: -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=sm_75 \ // RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx908 -ccc-print-phases %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-static-lib-2-old-model.cpp b/clang/test/Driver/sycl-offload-static-lib-2-old-model.cpp index 3ba847a3872a5..69c8ffd1d0abc 100644 --- a/clang/test/Driver/sycl-offload-static-lib-2-old-model.cpp +++ b/clang/test/Driver/sycl-offload-static-lib-2-old-model.cpp @@ -88,12 +88,12 @@ // RUN: touch %t_lib.a // RUN: %clangxx -target x86_64-unknown-linux-gnu -fno-sycl-instrument-device-code \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: --no-offloadlib -fsycl --no-offload-new-driver %t_lib.a -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=STATIC_LIB_SRC -DBUNDLE_TRIPLE=sycl-spir64-unknown-unknown // RUN: %clangxx -target x86_64-unknown-linux-gnu -fno-sycl-instrument-device-code --no-offloadlib \ // RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: -fsycl-targets=nvptx64-nvidia-cuda -fsycl --no-offload-new-driver %t_lib.a -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=STATIC_LIB_SRC-CUDA // STATIC_LIB_SRC: 0: input, "[[INPUTA:.+\.a]]", object, (host-sycl) diff --git a/clang/test/Driver/sycl-oneapi-gpu-nvidia.cpp b/clang/test/Driver/sycl-oneapi-gpu-nvidia.cpp index 0925795e00c2b..5c422801cb98b 100644 --- a/clang/test/Driver/sycl-oneapi-gpu-nvidia.cpp +++ b/clang/test/Driver/sycl-oneapi-gpu-nvidia.cpp @@ -84,7 +84,7 @@ /// offload action used for compilation and backend compilation. // RUN: %clangxx -fsycl -fsycl-targets=nvidia_gpu_sm_50 --no-offloadlib \ // RUN: -fno-sycl-instrument-device-code --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \ -// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ +// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc \ // RUN: -target x86_64-unknown-linux-gnu -ccc-print-phases %s 2>&1 | \ // RUN: FileCheck %s --check-prefix=NVIDIA_CHECK_PHASES // NVIDIA_CHECK_PHASES: 0: input, "[[INPUT:.+\.cpp]]", c++, (host-sycl) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 297fbb50de655..e5855e5b982cd 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -84,6 +84,10 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DI set( ${tool}_target ) endforeach() endif() + + # Setup the paths where libclc runtimes should be stored. + set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) + set( LIBCLC_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/clc ) else() # In-tree configuration set( LIBCLC_STANDALONE_BUILD FALSE ) @@ -104,7 +108,17 @@ else() get_host_tool_path( llvm-spirv LLVM_SPIRV llvm-spirv_exe llvm-spirv_target ) get_host_tool_path( opt OPT opt_exe opt_target ) endif() + + # Setup the paths where libclc runtimes should be stored. By default, in an + # in-tree build we place the libraries in clang's resource driectory. + include(GetClangResourceDir) + get_clang_resource_dir( LIBCLC_INSTALL_DIR ) cmake_path( APPEND LIBCLC_INSTALL_DIR "lib" "libclc" ) + + # Note we do not adhere to LLVM_ENABLE_PER_TARGET_RUNTIME_DIR. + cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR ) + cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} ) + file( MAKE_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR} ) endif() if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} ) @@ -351,18 +365,6 @@ set_source_files_properties( enable_testing() -if (LIBCLC_STANDALONE_BUILD) - set(LIBCLC_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) -else(LIBCLC_STANDALONE_BUILD) - set(LIBCLC_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) -endif(LIBCLC_STANDALONE_BUILD) -file( TO_CMAKE_PATH ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/clc LIBCLC_LIBRARY_OUTPUT_INTDIR ) - -# Setup the paths where libclc runtimes should be stored. -# FIXME: Align with upstream -set( LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBRARY_OUTPUT_INTDIR} ) -file( MAKE_DIRECTORY ${LIBCLC_OUTPUT_LIBRARY_DIR} ) - foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) message( STATUS "libclc target '${t}' is enabled" ) string( REPLACE "-" ";" TRIPLE ${t}-- ) @@ -630,16 +632,4 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) endforeach( d ) endforeach( t ) -install(DIRECTORY ${LIBCLC_LIBRARY_OUTPUT_INTDIR} - DESTINATION lib${LLVM_LIBDIR_SUFFIX} - COMPONENT libspirv-builtins - FILES_MATCHING PATTERN "libspirv-*") - -if( LIBCLC_GENERATE_REMANGLED_VARIANTS ) - install(DIRECTORY ${LIBCLC_LIBRARY_OUTPUT_INTDIR} - DESTINATION lib${LLVM_LIBDIR_SUFFIX} - COMPONENT libspirv-builtins - FILES_MATCHING PATTERN "remangled-*libspirv-*") -endif() - add_subdirectory(test) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 91ba847a15a7f..c26b78fea7223 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -448,10 +448,6 @@ function(add_libclc_builtin_set) set( builtins_link_lib $ ) - add_custom_command( OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR} - DEPENDS ${builtins_link_lib} prepare_builtins ) - # For SPIR-V targets we diverage at this point and generate SPIR-V using the # llvm-spirv tool. if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 ) @@ -524,7 +520,6 @@ function(add_libclc_builtin_set) if( ARG_REMANGLE ) set( dummy_in ${LIBCLC_OUTPUT_LIBRARY_DIR}/libclc_dummy_in.cc ) add_custom_command( OUTPUT ${dummy_in} - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR} COMMAND ${CMAKE_COMMAND} -E touch ${dummy_in} ) set(long_widths l32 l64) @@ -540,10 +535,9 @@ function(add_libclc_builtin_set) foreach(long_width ${long_widths}) foreach(signedness ${char_signedness}) # Remangle - set( builtins_remangle_path - "${LIBCLC_OUTPUT_LIBRARY_DIR}/remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}" ) + set( remangled_filename remangled-${long_width}-${signedness}_char.${obj_suffix_mangled} ) + set( builtins_remangle_path "${LIBCLC_OUTPUT_LIBRARY_DIR}/${remangled_filename}" ) add_custom_command( OUTPUT "${builtins_remangle_path}" - COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR} COMMAND ${libclc-remangler_exe} -o "${builtins_remangle_path}" --triple=${ARG_TRIPLE} @@ -552,19 +546,17 @@ function(add_libclc_builtin_set) --input-ir=${libclc_builtins_lib} ${dummy_in} DEPENDS prepare-${obj_suffix} ${libclc_builtins_lib} ${libclc-remangler_target} ${dummy_in}) - add_custom_target( "remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}" ALL - DEPENDS "${builtins_remangle_path}" "${dummy_in}") - set_target_properties("remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}" - PROPERTIES TARGET_FILE "${builtins_remangle_path}") + add_custom_target( ${remangled_filename} ALL + DEPENDS "${builtins_remangle_path}" "${dummy_in}" ) + set_target_properties( ${remangled_filename} + PROPERTIES TARGET_FILE "${builtins_remangle_path}" ) # Add dependency to top-level pseudo target to ease making other # targets dependent on libclc. - add_dependencies(${ARG_PARENT_TARGET} "remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}") + add_dependencies( ${ARG_PARENT_TARGET} ${remangled_filename} ) # Keep remangled variants - install( - FILES ${builtins_remangle_path} - DESTINATION ${CMAKE_INSTALL_DATADIR}/clc ) + libclc_install( FILES ${builtins_remangle_path} ) endforeach() endforeach()