Skip to content

Commit 388ccf5

Browse files
wenju-heMaetveis
andauthored
[SYCL] remove -### check in findLibspirvPath (#19784)
In our downstream repo, bf21b9d exposed a regression that libspirv path is invalid in -### output. Before bf21b9d, the path was correctly found by `searchAt(D.ResourceDir, "..", "..", "clc")`, which was deleted by the commit. This PR deletes -### check to align behavior with when -### is not present. --------- Co-authored-by: Mészáros Gergely <[email protected]>
1 parent 3241425 commit 388ccf5

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ const char *SYCLInstallationDetector::findLibspirvPath(
6868
SmallString<128> LibraryPath(Path);
6969
llvm::sys::path::append(LibraryPath, a, b, c, Basename);
7070

71-
if (Args.hasArgNoClaim(options::OPT__HASH_HASH_HASH) ||
72-
llvm::sys::fs::exists(LibraryPath))
71+
if (llvm::sys::fs::exists(LibraryPath))
7372
return Args.MakeArgString(LibraryPath);
7473

7574
return nullptr;

clang/test/Driver/sycl-libspirv-toolchain.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@
3434
// RUN: | FileCheck %s -DINSTALL_DIR=%{install_dir} -DRESOURCE_DIR=%{resource_dir} --check-prefixes=CHECK-DIR
3535
// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[INSTALL_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
3636
//
37-
// The `-###` option disables file existence checks
37+
// If libspirv path doesn't exist, error is reported.
3838
// DEFINE: %{nonexistent_dir} = %/S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir
39-
// RUN: %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
39+
// RUN: not %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
4040
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-HHH-NONEXISTENT
41-
// CHECK-HHH-NONEXISTENT: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
41+
// 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
4242
//
43-
// RUN: %clang -### -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \
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 \
4444
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-AMDGCN-HHH-NONEXISTENT
45-
// CHECK-AMDGCN-HHH-NONEXISTENT: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-amdgcn-amd-amdhsa.bc"
45+
// 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
4646
//
47-
// `-fdriver-only` has no such special handling, so it will not find the file
4847
// RUN: not %clang -fdriver-only -ccc-install-dir %{nonexistent_dir} -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
4948
// RUN: | FileCheck %s -DDIR=%{nonexistent_dir} --check-prefixes=CHECK-DO-NONEXISTENT
5049
// 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-native-cpu.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu %s -### 2>&1 | FileCheck %s
2-
// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu --target=aarch64-unknown-linux-gnu %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-AARCH64
1+
// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu -fno-sycl-libspirv %s -### 2>&1 | FileCheck %s
2+
// RUN: %clangxx -fsycl-device-only -fsycl-targets=native_cpu --target=aarch64-unknown-linux-gnu -fno-sycl-libspirv %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-AARCH64
33

44

55
// checks that the host triple is native_cpu, the device triple is set, and that the sycl-native-cpu LLVM option is set
@@ -8,29 +8,29 @@
88
// checks that the target triples are set correctly when the target is set explicitly
99
// CHECK-AARCH64: clang{{.*}}"-triple" "native_cpu"{{.*}}"-aux-triple" "aarch64-unknown-linux-gnu" {{.*}}"-D" "__SYCL_NATIVE_CPU__"
1010

11-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fsycl-targets=native_cpu -g %s 2>&1 | FileCheck -check-prefix=CHECK-LINUX %s
11+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fsycl-targets=native_cpu -g -fno-sycl-libspirv %s 2>&1 | FileCheck -check-prefix=CHECK-LINUX %s
1212
// CHECK-LINUX: {{.*}}"-fsycl-is-device"{{.*}}"-dwarf-version=[[DVERSION:.*]]" "-debugger-tuning=gdb"
1313
// CHECK-LINUX-DAG: {{.*}}"-fsycl-is-host"{{.*}}"-dwarf-version=[[DVERSION]]" "-debugger-tuning=gdb"
1414
// CHECK-LINUX-NOT: codeview
1515

16-
// RUN: %clang -### --target=x86_64-windows-msvc -fsycl -fsycl-targets=native_cpu -g %s 2>&1 | FileCheck -check-prefix=CHECK-WIN %s
16+
// RUN: %clang -### --target=x86_64-windows-msvc -fsycl -fsycl-targets=native_cpu -g -fno-sycl-libspirv %s 2>&1 | FileCheck -check-prefix=CHECK-WIN %s
1717
// CHECK-WIN: {{.*}}"-fsycl-is-device"{{.*}}"-gcodeview"
1818
// CHECK-WIN-DAG: {{.*}}"-fsycl-is-host"{{.*}}"-gcodeview"
1919
// CHECK-WIN-NOT: dwarf
2020

2121
// checks that -sycl-opt is not enabled by default on NativeCPU so that the full llvm optimization is enabled
2222
// Also check that we pass the expected backend options.
23-
// RUN: %clang -fsycl -fsycl-targets=native_cpu --target=aarch64-unknown-linux-gnu -march=armv9.4-a -### %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
23+
// RUN: %clang -fsycl -fsycl-targets=native_cpu --target=aarch64-unknown-linux-gnu -march=armv9.4-a -fno-sycl-libspirv -### %s 2>&1 | FileCheck -check-prefix=CHECK-OPTS %s
2424
// CHECK-OPTS: clang{{.*}}"-triple" "native_cpu"{{.*}}"-aux-triple" "[[TRIPLE:[^"]*]]"
2525
// CHECK-OPTS: clang{{.*}}"-triple" "[[TRIPLE]]"{{.*}}"-fsycl-is-device"
2626
// CHECK-OPTS-NOT: -sycl-opt
2727
// CHECK-OPTS-SAME: "-Wno-override-module" "-mllvm" "-sycl-native-cpu-backend"
2828
// CHECK-OPTS-SAME: "-aux-target-feature" "+v9.4a"
2929

30-
// RUN: %clangxx -fsycl -fsycl-targets=spir64 %s -### 2>&1 | FileCheck -check-prefix=CHECK-NONATIVECPU %s
30+
// RUN: %clangxx -fsycl -fsycl-targets=spir64 -fno-sycl-libspirv %s -### 2>&1 | FileCheck -check-prefix=CHECK-NONATIVECPU %s
3131
// CHECK-NONATIVECPU-NOT: "-D" "__SYCL_NATIVE_CPU__"
3232

3333
// Checking that coverage testing options are accepted by native_cpu, and that device and host compilation invocations receive the same options
34-
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -Werror -fno-profile-instr-generate -fprofile-instr-generate -fno-coverage-mapping -fcoverage-mapping -### %s 2>&1 | FileCheck %s --check-prefix=CHECK_COV_INVO
34+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -Werror -fno-profile-instr-generate -fprofile-instr-generate -fno-coverage-mapping -fcoverage-mapping -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked -### %s 2>&1 | FileCheck %s --check-prefix=CHECK_COV_INVO
3535
// CHECK_COV_INVO:{{.*}}clang{{.*}}"-fsycl-is-device"{{.*}} "-D" "__SYCL_NATIVE_CPU__"{{.*}}"-fprofile-instrument=clang"{{.*}}"-fcoverage-mapping" "-fcoverage-compilation-dir={{.*}}"
3636
// CHECK_COV_INVO:{{.*}}clang{{.*}}"-fsycl-is-host"{{.*}}"-fprofile-instrument=clang"{{.*}}"-fcoverage-mapping" "-fcoverage-compilation-dir={{.*}}"

0 commit comments

Comments
 (0)