Skip to content

Commit 81d32f5

Browse files
wenju-heMaetveis
andauthored
[libclc][Cmake] Change libclc library output library to clang resource dir (#20701)
Restore pulldown omissions: * Restore output layout from df74736: build/lib/clc -> build/lib/clang/<LLVM_VERSION>/lib/libclc * Restore standalone build LIBCLC_INSTALL_DIR from b9e2f7a. Additional changes: * Remove repeated directory creation for LIBCLC_OUTPUT_LIBRARY_DIR. * Install libspirv remangled-* bitcodes into LIBCLC_INSTALL_DIR. * SYCLInstallationDetector findLibspirvPath is now simplifed. * Updated libspirv path in sycl-jit/jit-compiler. --------- Co-authored-by: Mészáros Gergely <[email protected]>
1 parent 8ae03ed commit 81d32f5

19 files changed

+83
-115
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,10 @@ const char *SYCLInstallationDetector::findLibspirvPath(
6464

6565
const SmallString<64> Basename =
6666
getLibSpirvBasename(DeviceTriple, HostTriple);
67-
auto searchAt = [&](StringRef Path, const Twine &a = "", const Twine &b = "",
68-
const Twine &c = "") -> const char * {
69-
SmallString<128> LibraryPath(Path);
70-
llvm::sys::path::append(LibraryPath, a, b, c, Basename);
71-
72-
if (D.getVFS().exists(LibraryPath))
73-
return Args.MakeArgString(LibraryPath);
74-
75-
return nullptr;
76-
};
77-
78-
for (const auto &IC : InstallationCandidates) {
79-
// Expected path w/out install.
80-
if (const char *R = searchAt(IC, "lib", "clc"))
81-
return R;
82-
83-
// Expected path w/ install.
84-
if (const char *R = searchAt(IC, "share", "clc"))
85-
return R;
86-
}
67+
SmallString<256> LibclcPath(D.ResourceDir);
68+
llvm::sys::path::append(LibclcPath, "lib", "libclc", Basename);
69+
if (D.getVFS().exists(LibclcPath))
70+
return Args.MakeArgString(LibclcPath);
8771

8872
return nullptr;
8973
}

clang/test/Driver/Inputs/SYCL/bin/.gitkeep

Whitespace-only changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc renamed to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc

File renamed without changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc renamed to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc

File renamed without changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc renamed to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc

File renamed without changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc renamed to clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/libclc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc

File renamed without changes.

clang/test/Driver/sycl-cuda-rdc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
// UNSUPPORTED: system-windows
66

7-
// 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 \
7+
// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_61 -fgpu-rdc -nocudalib \
8+
// 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 \
89
// RUN: | FileCheck %s -check-prefix=CHECK-SYCL_RDC_NVPTX
910

1011
// Verify that ptxas does not pass "-c"

clang/test/Driver/sycl-device-obj-asm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
/// -fsycl-device-obj=asm should always be accompanied by -fsycl-device-only
3232
/// and -S, check that the compiler issues a correct warning message:
33-
// 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
33+
// 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
3434
// 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]
3535

3636
/// -fsycl-device-obj=asm will finish at generating assembly stage, hence
3737
/// inform users that generating library will not be possible (ignore -c)
38-
// 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
38+
// 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
3939
// CHECK-DASH-C-IGNORE: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
// Test the search logic for the libspirv bitcode library in the offloading toolchains that need it.
22

3-
// DEFINE: %{install_dir} = %/S/Inputs/SYCL/bin
43
// DEFINE: %{resource_dir} = %/S/Inputs/SYCL/lib/clang/resource_dir
54

6-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2>&1 \
5+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2>&1 \
76
// RUN: | FileCheck %s --check-prefixes=CHECK-WINDOWS
8-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-gnu %s 2>&1 \
7+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-gnu %s 2>&1 \
98
// RUN: | FileCheck %s --check-prefixes=CHECK-WINDOWS
109
// CHECK-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc"
1110
//
12-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2>&1 \
11+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2>&1 \
1312
// RUN: | FileCheck %s --check-prefixes=CHECK-LINUX
14-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-cygnus %s 2>&1 \
13+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-cygnus %s 2>&1 \
1514
// RUN: | FileCheck %s --check-prefixes=CHECK-LINUX
1615
// CHECK-LINUX: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc"
1716
//
18-
// 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 \
17+
// 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 \
1918
// RUN: | FileCheck %s --check-prefixes=CHECK-AMDGCN-WINDOWS
2019
// CHECK-AMDGCN-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l32-signed_char.libspirv-amdgcn-amd-amdhsa.bc"
2120
//
22-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
21+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
2322
// RUN: | FileCheck %s --check-prefixes=CHECK-DEVICE-ONLY
2423
// CHECK-DEVICE-ONLY: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
2524
//
@@ -29,21 +28,21 @@
2928
// CHECK-CUDA: "-cc1"{{.*}} "-fcuda-is-device"
3029
// CHECK-CUDA-NOT: "-mlink-builtin-bitcode" "{{.*}}.libspirv-{{.*}}.bc"
3130
//
32-
// The path to the remangled libspirv bitcode file is determined by the installation directory
33-
// RUN: %clang -### -ccc-install-dir %{install_dir} -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
34-
// RUN: | FileCheck %s -DINSTALL_DIR=%{install_dir} -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DIR
35-
// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[INSTALL_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
31+
// The path to the remangled libspirv bitcode file is determined by the resource directory
32+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
33+
// RUN: | FileCheck %s -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DIR
34+
// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
3635
//
3736
// If libspirv path doesn't exist, error is reported.
3837
// DEFINE: %{nonexistent_dir} = %/S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir
39-
// RUN: not %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
40-
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-HHH-NONEXISTENT
38+
// RUN: not %clang -### -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
39+
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-HHH-NONEXISTENT
4140
// 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
4241
//
43-
// RUN: not %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \
44-
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-AMDGCN-HHH-NONEXISTENT
42+
// RUN: not %clang -### -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \
43+
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-AMDGCN-HHH-NONEXISTENT
4544
// 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
4645
//
47-
// RUN: not %clang -fdriver-only -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
48-
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-DO-NONEXISTENT
46+
// RUN: not %clang -fdriver-only -resource-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
47+
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-DO-NONEXISTENT
4948
// 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

clang/test/Driver/sycl-nvptx-link.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
// correctly versioned libdevice. We use Inputs/CUDA_80 which has a full set of
1111
// libdevice files.
1212

13-
// DEFINE: %{install_dir} = %/S/Inputs/SYCL/bin
13+
// DEFINE: %{resource_dir} = %/S/Inputs/SYCL/lib/clang/resource_dir
1414

15-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
15+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
1616
// RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_30 \
1717
// RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
1818
// RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE30
19-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
19+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
2020
// RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \
2121
// RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
2222
// RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE35
23-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
23+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
2424
// RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_50 \
2525
// RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
2626
// RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE50
2727

2828
// CUDA-9+ uses the same libdevice for all GPU variants
29-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
29+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
3030
// RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \
3131
// RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \
3232
// RUN: | FileCheck %s --check-prefixes=CHECK,LIBDEVICE10
3333

3434
// Check also that -nocudalib is obeyed
35-
// RUN: %clang -### -ccc-install-dir %{install_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib \
35+
// RUN: %clang -### -resource-dir %{resource_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib \
3636
// RUN: -Xsycl-target-backend --cuda-gpu-arch=sm_35 \
3737
// RUN: --sysroot=%S/Inputs/SYCL --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \
3838
// RUN: | FileCheck %s --check-prefixes=CHECK,NOLIBDEVICE

0 commit comments

Comments
 (0)