Skip to content

Commit 4b25053

Browse files
authored
[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (#87149)
We have many problems to use CodeView for a win32-elf target, e.g., #87140 and `error: .seh_* directives are not supported on this target`. Fixes: #87140
1 parent 468dc32 commit 4b25053

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang/lib/Driver/ToolChains/MSVC.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
6161
/// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
6262
/// override the default.
6363
llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
64-
return getTriple().isOSBinFormatMachO()
65-
? llvm::codegenoptions::DIF_DWARF
66-
: llvm::codegenoptions::DIF_CodeView;
64+
return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
65+
: llvm::codegenoptions::DIF_DWARF;
6766
}
6867

6968
/// Set the debugger tuning to "default", since we're definitely not tuning

clang/test/Misc/win32-elf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Check that basic use of win32-elf targets works.
2+
// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s
3+
4+
// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | FileCheck %s -check-prefix=DEBUG-INFO
5+
// DEBUG-INFO: -dwarf-version={{.*}}

0 commit comments

Comments
 (0)