Skip to content

Commit b9569b1

Browse files
authored
[SYCL][NATIVECPU] Fix for mismatching debug format between host and device (#11337)
This PR fixes the SYCL toolchain to pass the debug format used for the host compilation to the device compilation. Without this patch mismatching debug formats could lead to corrupt debug information and link errors.
1 parent d7886b6 commit b9569b1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain {
185185
return this->HostTC.isPICDefault();
186186
return false;
187187
}
188+
llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
189+
if (this->IsSYCLNativeCPU)
190+
return this->HostTC.getDefaultDebugFormat();
191+
return ToolChain::getDefaultDebugFormat();
192+
}
188193
bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
189194
return false;
190195
}

clang/test/Driver/sycl-native-cpu.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@
77

88
// checks that the target triples are set correctly when the target is set explicitly
99
// CHECK-AARCH64: clang{{.*}}"-triple" "aarch64-unknown-linux-gnu"{{.*}}"-aux-triple" "aarch64-unknown-linux-gnu"{{.*}}"-fsycl-is-native-cpu"{{.*}}"-D" "__SYCL_NATIVE_CPU__"
10+
11+
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=native_cpu -g %s 2>&1 | FileCheck -check-prefix=CHECK-LINUX %s
12+
// CHECK-LINUX: {{.*}}"-fsycl-is-device"{{.*}}"-dwarf-version=[[DVERSION:.*]]" "-debugger-tuning=gdb"
13+
// CHECK-LINUX-DAG: {{.*}}"-fsycl-is-host"{{.*}}"-dwarf-version=[[DVERSION]]" "-debugger-tuning=gdb"
14+
// CHECK-LINUX-NOT: codeview
15+
16+
// RUN: %clang -### -target x86_64-windows-msvc -fsycl -fsycl-targets=native_cpu -g %s 2>&1 | FileCheck -check-prefix=CHECK-WIN %s
17+
// CHECK-WIN: {{.*}}"-fsycl-is-device"{{.*}}"-gcodeview"
18+
// CHECK-WIN-DAG: {{.*}}"-fsycl-is-host"{{.*}}"-gcodeview"
19+
// CHECK-WIN-NOT: dwarf

0 commit comments

Comments
 (0)