[clang] aa99b60 - [clang][pdb] Don't include -fmessage-length in PDB buildinfo

Tobias Hieta via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 01:06:06 PST 2022


Author: Tobias Hieta
Date: 2022-11-08T10:05:59+01:00
New Revision: aa99b607b5cf8ef1260f5661dcbf077f26ee797c

URL: https://github.com/llvm/llvm-project/commit/aa99b607b5cf8ef1260f5661dcbf077f26ee797c
DIFF: https://github.com/llvm/llvm-project/commit/aa99b607b5cf8ef1260f5661dcbf077f26ee797c.diff

LOG: [clang][pdb] Don't include -fmessage-length in PDB buildinfo

As discussed in https://reviews.llvm.org/D136474 -fmessage-length
creates problems with reproduciability in the PDB files.

This patch just drops that argument when writing the PDB file.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D137322

Added: 
    

Modified: 
    clang/test/CodeGen/debug-info-codeview-buildinfo.c
    llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
index 71c0e7b6f6ac2..e1c6f3655f379 100644
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -8,6 +8,10 @@
 // RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s
 // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE
 
+// -fmessage-length shouldn't be included in the command line since it breaks reproducibility
+// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc -Xclang -fmessage-length=100 /c /Z7 /Fo%t.obj -- %s
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix MESSAGELEN
+
 int main(void) { return 42; }
 
 // CHECK:                       Types (.debug$T)
@@ -36,3 +40,8 @@ int main(void) { return 42; }
 // DISABLE-NEXT:          0x{{.+}}: `{{.*}}`
 // DISABLE-NEXT:          0x{{.+}}: ``
 // DISABLE-NEXT:          <no type>: ``
+
+// MESSAGELEN:                       Types (.debug$T)
+// MESSAGELEN: ============================================================
+// MESSAGELEN: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
+// MESSAGELEN-NOT: -fmessage-length

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index a6f1fbc9d32ae..3bb0df4eeac93 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -908,6 +908,9 @@ static std::string flattenCommandLine(ArrayRef<std::string> Args,
     }
     if (Arg.startswith("-object-file-name") || Arg == MainFilename)
       continue;
+    // Skip fmessage-length for reproduciability.
+    if (Arg.startswith("-fmessage-length"))
+      continue;
     if (PrintedOneArg)
       OS << " ";
     llvm::sys::printArg(OS, Arg, /*Quote=*/true);


        


More information about the cfe-commits mailing list