MSVC records the command line arguments in S_ENVBLOCK, skipping the input file arguments.
This patch adds this filtering on lld-link side.
Differential Revision: https://reviews.llvm.org/D137723
}
// Save the command line after response file expansion so we can write it to
- // the PDB if necessary.
- config->argv = {expandedArgv.begin(), expandedArgv.end()};
+ // the PDB if necessary. Mimic MSVC, which skips input files.
+ config->argv = {argv[0]};
+ for (opt::Arg *arg : args) {
+ if (arg->getOption().getKind() != opt::Option::InputClass) {
+ config->argv.push_back(args.getArgString(arg->getIndex()));
+ }
+ }
// Handle /WX early since it converts missing argument warnings to errors.
errorHandler().fatalWarnings = args.hasFlag(OPT_WX, OPT_WX_no, false);
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
------------------
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'" /force
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:
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