-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try #88245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ormat" (llvm#87987)", second try This reverts commit 299b636.
@llvm/pr-subscribers-clang Author: Phoebe Wang (phoebewang) ChangesThis is a second try to reland #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 I was thinking Full diff: https://github.com/llvm/llvm-project/pull/88245.diff 7 Files Affected:
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/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
// RTTI-NOT: "-fno-rtti-data"
// RTTI-NOT: "-fno-rtti"
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
// BreproDefault: "-mincremental-linker-compatible"
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
// RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
// FioRACE2: "-E"
// FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// RELATIVE_OBJPATH2: "-object-file-name=foo\\a.obj"
diff --git a/clang/test/Driver/gcodeview-command-line.c b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..f65527a00dc97d 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: coff-supported-target
// ON-NOT: "-gno-codview-commandline"
// OFF: "-gno-codeview-command-line"
@@ -17,3 +18,27 @@
// GCC-style driver
// RUN: %clang -g -gcodeview -gno-codeview-command-line -gcodeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=ON %s
// RUN: %clang -g -gcodeview -gcodeview-command-line -gno-codeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=OFF %s
+
+// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
+// Zi: "-gcodeview"
+// Zi: "-debug-info-kind=constructor"
+
+// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
+// Z7: "-gcodeview"
+// Z7: "-debug-info-kind=constructor"
+
+// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
+// ZGMLT: "-gcodeview"
+// ZGMLT: "-debug-info-kind=line-tables-only"
+
+// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s
+// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
+// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
+// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
+// RELATIVE_OBJPATH2: "-object-file-name=foo\\a.obj"
diff --git a/clang/test/Driver/gcodeview-ghash.c b/clang/test/Driver/gcodeview-ghash.c
index c45c8296604e90..25a6f2d82d7577 100644
--- a/clang/test/Driver/gcodeview-ghash.c
+++ b/clang/test/Driver/gcodeview-ghash.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: coff-supported-target
// GHASH: "-gcodeview-ghash"
// NO_GHASH-NOT: "-gcodeview-ghash"
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={{.*}}
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index e5630a07424c7c..69e3ee592db6d4 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -285,6 +285,8 @@ def is_filesystem_case_insensitive():
if any(config.target_triple.startswith(x) for x in known_arches):
config.available_features.add("clang-target-64-bits")
+if re.match(r"^(aarch64-|arm|x86).*-windows-msvc$", config.target_triple):
+ config.available_features.add("coff-supported-target")
def calculate_arch_features(arch_string):
features = []
|
@llvm/pr-subscribers-clang-driver Author: Phoebe Wang (phoebewang) ChangesThis is a second try to reland #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 I was thinking Full diff: https://github.com/llvm/llvm-project/pull/88245.diff 7 Files Affected:
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/cl-options.c b/clang/test/Driver/cl-options.c
index 5b6dfe308a76ea..202f7a50e618fe 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -545,18 +545,6 @@
// RTTI-NOT: "-fno-rtti-data"
// RTTI-NOT: "-fno-rtti"
-// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
-// Zi: "-gcodeview"
-// Zi: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
-// Z7: "-gcodeview"
-// Z7: "-debug-info-kind=constructor"
-
-// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
-// ZGMLT: "-gcodeview"
-// ZGMLT: "-debug-info-kind=line-tables-only"
-
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
// BreproDefault: "-mincremental-linker-compatible"
diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c
index 4d58f0fb548b57..10bd0c97dcdca8 100644
--- a/clang/test/Driver/cl-outputs.c
+++ b/clang/test/Driver/cl-outputs.c
@@ -294,15 +294,3 @@
// RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
// FioRACE2: "-E"
// FioRACE2: "-o" "foo.x"
-
-// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s
-// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
-// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
-// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
-
-// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
-// RELATIVE_OBJPATH2: "-object-file-name=foo\\a.obj"
diff --git a/clang/test/Driver/gcodeview-command-line.c b/clang/test/Driver/gcodeview-command-line.c
index da8708af322480..f65527a00dc97d 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: coff-supported-target
// ON-NOT: "-gno-codview-commandline"
// OFF: "-gno-codeview-command-line"
@@ -17,3 +18,27 @@
// GCC-style driver
// RUN: %clang -g -gcodeview -gno-codeview-command-line -gcodeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=ON %s
// RUN: %clang -g -gcodeview -gcodeview-command-line -gno-codeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=OFF %s
+
+// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
+// Zi: "-gcodeview"
+// Zi: "-debug-info-kind=constructor"
+
+// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
+// Z7: "-gcodeview"
+// Z7: "-debug-info-kind=constructor"
+
+// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
+// ZGMLT: "-gcodeview"
+// ZGMLT: "-debug-info-kind=line-tables-only"
+
+// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s
+// ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s
+// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
+// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
+
+// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
+// RELATIVE_OBJPATH2: "-object-file-name=foo\\a.obj"
diff --git a/clang/test/Driver/gcodeview-ghash.c b/clang/test/Driver/gcodeview-ghash.c
index c45c8296604e90..25a6f2d82d7577 100644
--- a/clang/test/Driver/gcodeview-ghash.c
+++ b/clang/test/Driver/gcodeview-ghash.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: coff-supported-target
// GHASH: "-gcodeview-ghash"
// NO_GHASH-NOT: "-gcodeview-ghash"
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={{.*}}
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index e5630a07424c7c..69e3ee592db6d4 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -285,6 +285,8 @@ def is_filesystem_case_insensitive():
if any(config.target_triple.startswith(x) for x in known_arches):
config.available_features.add("clang-target-64-bits")
+if re.match(r"^(aarch64-|arm|x86).*-windows-msvc$", config.target_triple):
+ config.available_features.add("coff-supported-target")
def calculate_arch_features(arch_string):
features = []
|
For driver tests we prefer specifying a concrete target triple than making a test dependent on the default target triple (controlled by A concrete target triple (e.g. x86_64-windows) loses coverage for aarch64-windows, but we generally accept the loss. |
d09cd6a
to
bf6c4b8
Compare
Thanks for the suggestion, updated. |
Ping? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, looks good!
@@ -298,15 +298,15 @@ | |||
// FioRACE2: "-E" | |||
// FioRACE2: "-o" "foo.x" | |||
|
|||
// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s | |||
// RUN: %clang_cl -target x86_64-windows /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clang-cl driver generally forces a Windows OS onto the target, but I'm not confident enough to say this isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the key is x86_64
here, but I feel safe to add the windows
together :)
|
||
// GCC-style driver | ||
// RUN: %clang -g -gcodeview -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s | ||
// RUN: %clang -g -gcodeview -gcodeview-ghash -gno-codeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s | ||
// RUN: %clang -target x86_64-windows -g -gcodeview -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the important change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only clang driver, but also clang-cl. The root cause is many target don't set BinFormat to COFF on Windows. This probably because they don't support Windows at all, but we need to exclude them to run this test to avoid the unused-command-line-argument warning.
This is a second try to reland #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
I was thinking
REQUIRES: *-registered-target
could solve the problem, but it didn't. We need to check the actual triple instead of just*-registered-target
.