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 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 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 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()) 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/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