Skip to content

Commit 745b2ac

Browse files
committed
[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format
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 070d7af commit 745b2ac

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

clang/lib/Driver/ToolChains/MSVC.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ 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()
65+
? llvm::codegenoptions::DIF_CodeView
66+
: llvm::codegenoptions::DIF_DWARF;
6767
}
6868

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

clang/test/Misc/win32-elf.c

+5
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)