[PATCH] D137723: [PDB] Don't include input files in the 'cmd' entry of S_ENVBLOCK

Sylvain Audi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 09:05:11 PST 2022


saudi updated this revision to Diff 474292.
saudi added a comment.
Herald added a reviewer: MaskRay.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Added release note


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137723/new/

https://reviews.llvm.org/D137723

Files:
  lld/COFF/PDB.cpp
  lld/docs/ReleaseNotes.rst
  lld/test/COFF/pdb-linker-module.test
  lld/test/COFF/pdb-relative-source-lines.test


Index: lld/test/COFF/pdb-relative-source-lines.test
===================================================================
--- lld/test/COFF/pdb-relative-source-lines.test
+++ lld/test/COFF/pdb-relative-source-lines.test
@@ -77,7 +77,7 @@
 CHECK-NEXT:         - pdb 
 CHECK-NEXT:         - 'c:\src\out.pdb'
 CHECK-NEXT:         - cmd
-CHECK-NEXT:         - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
+CHECK-NEXT:         - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb'
 
 CHECK-LABEL: IpiStream:
 
@@ -125,7 +125,7 @@
 POSIX-NEXT:         - pdb 
 POSIX-NEXT:         - '/usr/src/out.pdb'
 POSIX-NEXT:         - cmd
-POSIX-NEXT:         - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
+POSIX-NEXT:         - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb'
 
 ABSOLUTE-LABEL: StringTable:
 ABSOLUTE-NOT: {{/|\\}}.{{/|\\}}pdb_lines_1.c
Index: lld/test/COFF/pdb-linker-module.test
===================================================================
--- lld/test/COFF/pdb-linker-module.test
+++ lld/test/COFF/pdb-linker-module.test
@@ -22,4 +22,4 @@
 SYMS-NEXT: - pdb
 SYMS-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb
 SYMS-NEXT: - cmd
-SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib "/entry:1 ""hello"" 2" "/manifestuac:level='asInvoker' uiAccess='false'" {{.*}}pdb-diff.obj
+SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib "/entry:1 ""hello"" 2" "/manifestuac:level='asInvoker' uiAccess='false'"
Index: lld/docs/ReleaseNotes.rst
===================================================================
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -43,7 +43,9 @@
 COFF Improvements
 -----------------
 
-* ...
+* The linker command line entry in ``S_ENVBLOCK`` of the PDB is now stripped
+  from input files, to align with MSVC behavior.
+  (`D137723 <https://reviews.llvm.org/D137723>`_)
 
 MinGW Improvements
 ------------------
Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -1348,10 +1348,14 @@
 // Mimic MSVC which surrounds arguments containing whitespace with quotes.
 // Double double-quotes are handled, so that the resulting string can be
 // executed again on the cmd-line.
-static std::string quote(ArrayRef<StringRef> args) {
+// Also, MSVC discards input file arguments (not prefixed with "/" or "-").
+// It avoids reaching the size limit for S_ENVBLOCK in most scenarios.
+static std::string makeArgString(ArrayRef<StringRef> args) {
   std::string r;
   r.reserve(256);
   for (StringRef a : args) {
+    if (!a.startswith("/") && !a.startswith("-"))
+      continue;
     if (!r.empty())
       r.push_back(' ');
     bool hasWS = a.contains(' ');
@@ -1408,7 +1412,7 @@
   ons.Signature = 0;
 
   ArrayRef<StringRef> args = makeArrayRef(config->argv).drop_front();
-  std::string argStr = quote(args);
+  std::string argStr = makeArgString(args);
   ebs.Fields.push_back("cwd");
   SmallString<64> cwd;
   if (config->pdbSourcePath.empty())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137723.474292.patch
Type: text/x-patch
Size: 3254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221109/2b081695/attachment.bin>


More information about the llvm-commits mailing list