[clang] [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format (PR #87987)
Phoebe Wang via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 8 06:13:54 PDT 2024
https://github.com/phoebewang created https://github.com/llvm/llvm-project/pull/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.
>From 6d3dbfaa7c5fb6acb5e6cae70455567030c50cf8 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Mon, 8 Apr 2024 11:10:58 +0800
Subject: [PATCH 1/2] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only
for COFF format (#87149)"
This reverts commit cd7517859eef14d8b38cec2d52c0625a58c645a2.
---
clang/lib/Driver/ToolChains/MSVC.h | 5 ++---
clang/test/Misc/win32-elf.c | 5 +++++
2 files changed, 7 insertions(+), 3 deletions(-)
create mode 100644 clang/test/Misc/win32-elf.c
diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h
index 48369e030aade2..3950a8ed38e8b4 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -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
diff --git a/clang/test/Misc/win32-elf.c b/clang/test/Misc/win32-elf.c
new file mode 100644
index 00000000000000..f75281dc418727
--- /dev/null
+++ b/clang/test/Misc/win32-elf.c
@@ -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={{.*}}
>From a716712ee5fd797c47fecbe7a608675889917c77 Mon Sep 17 00:00:00 2001
From: Phoebe Wang <phoebe.wang at intel.com>
Date: Mon, 8 Apr 2024 21:00:33 +0800
Subject: [PATCH 2/2] Linux gcodeview test for a few targets
---
clang/test/Driver/gcodeview-command-line.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/test/Driver/gcodeview-command-line.c b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..83542fc71aece4 100644
--- a/clang/test/Driver/gcodeview-command-line.c
+++ b/clang/test/Driver/gcodeview-command-line.c
@@ -1,5 +1,6 @@
// Note: %s must be preceded by --, otherwise it may be interpreted as a
// command-line option, e.g. on Mac where %s is commonly under /Users.
+// REQUIRES: aarch64-registered-target,arm-registered-target,x86-registered-target
// ON-NOT: "-gno-codview-commandline"
// OFF: "-gno-codeview-command-line"
More information about the cfe-commits
mailing list