Skip to content

Commit 4a93872

Browse files
authored
Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (#87987)
This relands #87149. The previous commit exposed failures on some targets. The reason is only a few targets support COFF ObjectFormatType on Windows: https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842 With #87149, the targets don't support COFF will report "warning: argument unused during compilation: '-gcodeview-command-line' [-Wunused-command-line-argument]" in the test gcodeview-command-line.c This patch limits gcodeview-command-line.c only run on targets support COFF.
1 parent c174d8f commit 4a93872

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-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/Driver/gcodeview-command-line.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Note: %s must be preceded by --, otherwise it may be interpreted as a
22
// command-line option, e.g. on Mac where %s is commonly under /Users.
3+
// REQUIRES: aarch64-registered-target,arm-registered-target,x86-registered-target
34

45
// ON-NOT: "-gno-codview-commandline"
56
// OFF: "-gno-codeview-command-line"

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)