[PATCH] D46427: [PDB] Quote linker arguments containing spaces (mimic MSVC)
Will Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 7 15:54:27 PDT 2018
lantictac updated this revision to Diff 145577.
lantictac added a comment.
Extracted implementation to a quote() function.
https://reviews.llvm.org/D46427
Files:
COFF/PDB.cpp
test/COFF/pdb-linker-module.test
Index: test/COFF/pdb-linker-module.test
===================================================================
--- test/COFF/pdb-linker-module.test
+++ test/COFF/pdb-linker-module.test
@@ -1,4 +1,4 @@
-RUN: lld-link /debug /pdb:%t.pdb /nodefaultlib /entry:main %S/Inputs/pdb-diff.obj
+RUN: lld-link /debug /pdb:%t.pdb /nodefaultlib /entry:main /manifestuac:"level='asInvoker' uiAccess='false'" %S/Inputs/pdb-diff.obj
RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck --check-prefix=MODS %s
RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck --check-prefix=SYMS %s
@@ -21,4 +21,4 @@
SYMS-NEXT: - pdb
SYMS-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb
SYMS-NEXT: - cmd
-SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib /entry:main {{.*}}pdb-diff.obj
+SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib /entry:main "/manifestuac:level='asInvoker' uiAccess='false'" {{.*}}pdb-diff.obj
Index: COFF/PDB.cpp
===================================================================
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -1029,6 +1029,22 @@
}
}
+static std::string quote(ArrayRef<StringRef> Args) {
+ std::string ArgStr;
+ ArgStr.reserve(256);
+ for (StringRef Arg : Args) {
+ if (!ArgStr.empty())
+ ArgStr.push_back(' ');
+ bool HasWS = Arg.find(' ') != StringRef::npos;
+ if (HasWS)
+ ArgStr.push_back('"');
+ ArgStr.append(Arg);
+ if (HasWS)
+ ArgStr.push_back('"');
+ }
+ return ArgStr;
+}
+
static void addCommonLinkerModuleSymbols(StringRef Path,
pdb::DbiModuleDescriptorBuilder &Mod,
BumpPtrAllocator &Allocator) {
@@ -1064,7 +1080,10 @@
CS.setLanguage(SourceLanguage::Link);
ArrayRef<StringRef> Args = makeArrayRef(Config->Argv).drop_front();
- std::string ArgStr = llvm::join(Args, " ");
+
+ // Mimic MSVC which surrounds arguments containing whitespace with quotes.
+ std::string ArgStr = quote(Args);
+
EBS.Fields.push_back("cwd");
SmallString<64> cwd;
sys::fs::current_path(cwd);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46427.145577.patch
Type: text/x-patch
Size: 2067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180507/19c7b3a2/attachment.bin>
More information about the llvm-commits
mailing list