[PATCH] D47565: Fix /WholeArchive bug.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 19:43:48 PDT 2018


ruiu added inline comments.


================
Comment at: lld/COFF/Driver.cpp:1248-1249
+      return true;
+    for (auto *Arg : Args.filtered(OPT_wholearchive_file))
+      if (sys::fs::equivalent(Path, Arg->getValue()))
+        return true;
----------------
rnk wrote:
> sys::fs::equivalent internally opens and closes a file handle for the purpose of doing a stat and comparing inodes. This will end up doing `O(inputs * wholearchiveinputs)` equivalency tests, and linkers have many input object files. Is there a way to avoid that?
That's right, but I don't think there's a way to avoid that unless we implement some OS-dependent logic on our side. How operating system normalize pathname components depends on the operating system and the file system, and I believe the only reliable way to do that is to ask about it to the system.

Maybe we could cache stat's results along with filenames to reduce the number of system calls, but I'm not sure if we need it. If it turns out to be too slow, we could optimize, but probably we should do that later when it becomes a real problem.

In reality, what is the largest number of files you can think of you want to pass to the linker? For hundreds of files, this is probably fine. If you pass thousands of files, this is probably slow.


https://reviews.llvm.org/D47565





More information about the llvm-commits mailing list