Skip to content

Conversation

@phoebewang
Copy link
Contributor

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.

@phoebewang phoebewang requested review from aeubanks and rnk April 8, 2024 13:13
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 8, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Phoebe Wang (phoebewang)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/87987.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/MSVC.h (+2-3)
  • (modified) clang/test/Driver/gcodeview-command-line.c (+1)
  • (added) clang/test/Misc/win32-elf.c (+5)
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/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"
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={{.*}}

@phoebewang phoebewang changed the title [Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" Apr 8, 2024
@phoebewang phoebewang merged commit 4a93872 into llvm:main Apr 10, 2024
@phoebewang phoebewang deleted the win32-elf branch April 10, 2024 05:58
phoebewang added a commit that referenced this pull request Apr 10, 2024
… COFF format" (#87987)"

This reverts commit 4a93872.

Sorry, there're still buildbot failures.
phoebewang added a commit to phoebewang/llvm-project that referenced this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants