aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/common.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-12-06 10:31:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-12-06 10:31:47 +0200
commit2239b3f57ae4779acd403cb0d0222d3adde1a1ad (patch)
tree545b1826b30b4de473937fd3e504761086ed135c /libbuild2/cc/common.cxx
parenta7085d313a9cfdca578a4fc69dccb20090cc5769 (diff)
Handle bin.whole when specified for interface dependencies
Diffstat (limited to 'libbuild2/cc/common.cxx')
-rw-r--r--libbuild2/cc/common.cxx28
1 files changed, 23 insertions, 5 deletions
diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx
index a250e2a..3eaa523 100644
--- a/libbuild2/cc/common.cxx
+++ b/libbuild2/cc/common.cxx
@@ -408,7 +408,7 @@ namespace build2
if (!li) find_linfo ();
process_libraries_impl (a, bs, *li, *sysd,
- g, *f, la, pt.data,
+ g, *f, la, pt.data /* lflags */,
proc_impl, proc_lib, proc_opt,
true /* self */, proc_opt_group,
cache, chain, nullptr);
@@ -647,13 +647,31 @@ namespace build2
// Process it recursively.
//
- // @@ Where can we get the link flags? Should we try to find
- // them in the library's prerequisites? What about
- // installed stuff?
+ bool u;
+ bool la ((u = t->is_a<libux> ()) || t->is_a<liba> ());
+ lflags lf (0);
+
+ // If this is a static library, see if we need to link it
+ // whole.
//
+ if (la && proc_lib)
+ {
+ // Note: go straight for the public variable pool.
+ //
+ const variable& var (t->ctx.var_pool["bin.whole"]);
+
+ // See the link rule for the lookup semantics.
+ //
+ lookup l (
+ t->lookup_original (var, true /* target_only */).first);
+
+ if (l ? cast<bool> (*l) : u)
+ lf |= lflag_whole;
+ }
+
process_libraries_impl (
a, bs, *li, *sysd,
- g, *t, t->is_a<liba> () || t->is_a<libux> (), 0,
+ g, *t, la, lf,
proc_impl, proc_lib, proc_opt,
true /* self */, proc_opt_group,
cache, chain, dedup);