[PATCH] D65430: Add `--write-dependencies` option, which is equivalent to compiler option -MD.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 23:46:24 PDT 2019


ruiu marked an inline comment as done.
ruiu added inline comments.


================
Comment at: lld/ELF/Driver.cpp:1408
+    sys::path::remove_dots(path, /*remove_dot_dot=*/true);
+    os << " \\\n  " << path;
+  }
----------------
pcc wrote:
> Clang has a bunch of complicated logic to handle escaping here: http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/DependencyFile.cpp#299
> 
> Would it be worth extracting it into a function and using it from here? Or maybe there's something simpler that we can do that would be understood by ninja et al.?
I read through the code and honestly my feeling is that we probably wouldn't have to make our code that bullet-proof. That logic is complicated because it tries to handle pathnames containing `#` or a special three-letter sequence `\ #`. If someone actually tried to use a filename that starts with a space followed by '#', that person is intentionally trying to break the build system.

So I made a change to quote a string if it contains a space character, which I believe should be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65430





More information about the llvm-commits mailing list