This is an archive of the discontinued LLVM Phabricator instance.

[PDB] Quote linker arguments containing spaces (mimic MSVC)
ClosedPublic

Authored by aganea on Nov 29 2018, 1:17 PM.

Details

Summary

Expand cmd-line in * Linker * module by double-quoting arguments with spaces when needed.
Double double-quotes are correctly escaped as suggested by @ruiu.

Tested on Windows and WSL Ubuntu. The cmd-line in the S_ENVBLOCK can now be extracted and executed as-it on Windows; however on Linux that would require some extra parsing as single/double-quotes are treated differently.

This is a replacement for D46427. After discussing with @lantictac offline, we agreed that I will finish his patch.

============================================================
  Mod 0001 | `* Linker *`:
...      64 | S_ENVBLOCK [size = 404]
           - cwd
           - /mnt/f/svn/buildWSL/tools/lld/test/COFF
           - exe
           - /mnt/f/svn/buildWSL/bin/lld-link
           - pdb
           - /mnt/f/svn/buildWSL/tools/lld/test/COFF/Output/pdb-linker-module.test.tmp.pdb
           - cmd
           - /debug /pdb:/mnt/f/svn/buildWSL/tools/lld/test/COFF/Output/pdb-linker-module.test.tmp.pdb /nodefaultlib "/entry:1 ""hello"" 2" "/manifestuac:level='asInvoker' uiAccess='false'" /mnt/f/svn/lld/test/COFF/Inputs/pdb-diff.obj /force

Diff Detail

Event Timeline

aganea created this revision.Nov 29 2018, 1:17 PM
aganea set the repository for this revision to rLLD LLVM Linker.
aganea added a subscriber: llvm-commits.
ruiu added a comment.Nov 29 2018, 2:00 PM

Looks good, but I just want to make sure that you have already run the exact same test with MSVC to get the same result.

Yes I did - I've also tried piggybacking the result from the PDB on the command-line and it generates the same PDB.

aganea@PC MINGW64 /f/svn/lld
$ py /f/svn/build/bin/llvm-lit.py -vv test/COFF/pdb-linker-module.test
-- Testing: 1 tests, 1 threads --
PASS: lld :: COFF/pdb-linker-module.test (1 of 1)
Testing Time: 0.33s
  Expected Passes    : 1

$ "F:\svn\build\bin\llvm-pdbutil.EXE" "dump" -modi=1 -symbols "F:\svn\build\tools\lld\test\COFF\Output\pdb-linker-module.test.tmp.pdb"

                          Symbols
============================================================
  Mod 0001 | `* Linker *`:
       4 | S_OBJNAME [size = 20] sig=0, `* Linker *`
      24 | S_COMPILE3 [size = 40]
           machine = intel 80386, Ver = LLVM Linker, language = link
           frontend = 0.0.0.0, backend = 14.10.25019.0
           flags = none
      64 | S_ENVBLOCK [size = 376]
           - cwd
           - F:\svn\build\tools\lld\test\COFF
           - exe
           - F:\svn\build\bin\lld-link.exe
           - pdb
           - F:\svn\build\tools\lld\test\COFF\Output\pdb-linker-module.test.tmp.pdb
           - cmd
           - /debug /pdb:F:\svn\build\tools\lld\test\COFF\Output\pdb-linker-module.test.tmp.pdb /nodefaultlib "/entry:1 ""hello"" 2" "/manifestuac:level='asInvoker' uiAccess='false'" F:\svn\lld\test\COFF/Inputs/pdb-diff.obj /force
     440 | S_SECTION [size = 28] `.text`
           length = 10, alignment = 12, rva = 4096, section # = 1
           characteristics =
             code
             execute permissions
             read permissions
     468 | S_SECTION [size = 28] `.rdata`
           length = 123, alignment = 12, rva = 8192, section # = 2
           characteristics =
             initialized data
             read permissions
     496 | S_SECTION [size = 28] `.data`
           length = 4, alignment = 12, rva = 12288, section # = 3
           characteristics =
             initialized data
             read permissions
             write permissions
ruiu accepted this revision.Nov 29 2018, 2:15 PM

LGTM

This revision is now accepted and ready to land.Nov 29 2018, 2:15 PM
This revision was automatically updated to reflect the committed changes.