diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-21 16:15:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-21 16:15:34 +0200 |
commit | 9d477ab892a720f8920abf397438da1f0d43baf0 (patch) | |
tree | 66feaf18b7e89b8dc71ef6f4c913df1ceaefd860 /libbuild2 | |
parent | f2ff3a70fdbe72939dbe55e3ac51949bd00c297c (diff) |
Work around LLD bug #43744
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/cc/link-rule.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 71d609d..528d67f 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -2717,6 +2717,7 @@ namespace build2 // The same logic as during hashing above. See also a similar loop // inside append_libraries(). // + bool seen_obj (false); for (const prerequisite_target& p: t.prerequisite_targets[a]) { const target* pt (p.target); @@ -2743,7 +2744,10 @@ namespace build2 if (la || ls) append_libraries (sargs, *f, la, p.data, bs, a, li); else + { sargs.push_back (relative (f->path ()).string ()); // string()&& + seen_obj = true; + } } } @@ -2752,6 +2756,25 @@ namespace build2 if (!manifest.empty () && tsys == "mingw32") sargs.push_back (relative (manifest).string ()); + // LLD misses an input file if we are linking only whole archives (LLVM + // bug #43744). Repeating one of the previously-mentioned archives seems + // to work around the issue. + // + if (!seen_obj && + !lt.static_library () && + tsys == "win32-msvc" && + cast<string> (rs["bin.ld.id"]) == "msvc-lld") + { + auto i (find_if (sargs.rbegin (), sargs.rend (), + [] (const string& a) + { + return a.compare (0, 14, "/WHOLEARCHIVE:") == 0; + })); + + if (i != sargs.rend ()) + sargs.push_back (i->c_str () + 14); + } + // Shallow-copy sargs over to args. // append_args (sargs); |