Skip to content

Commit

Permalink
[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (#8…
Browse files Browse the repository at this point in the history
…7149)

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
  • Loading branch information
phoebewang committed Apr 3, 2024
1 parent 468dc32 commit 4b25053
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions clang/lib/Driver/ToolChains/MSVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
/// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
/// override the default.
llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
return getTriple().isOSBinFormatMachO()
? llvm::codegenoptions::DIF_DWARF
: llvm::codegenoptions::DIF_CodeView;
return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView
: llvm::codegenoptions::DIF_DWARF;
}

/// Set the debugger tuning to "default", since we're definitely not tuning
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Misc/win32-elf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Check that basic use of win32-elf targets works.
// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf %s

// RUN: %clang -fsyntax-only -target x86_64-pc-win32-elf -g %s -### 2>&1 | FileCheck %s -check-prefix=DEBUG-INFO
// DEBUG-INFO: -dwarf-version={{.*}}

0 comments on commit 4b25053

Please sign in to comment.