summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-02-15 09:11:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-02-15 09:11:34 +0200
commit9c74a58db7cdb86d6d5a4600accd8ba9df3e1bbe (patch)
tree105dc6708a80bfa4cd97e6fb5f947bef78be4d87
parentf11213933bc79c8115974f5f7971b97413481654 (diff)
downloadbuild2-9c74a58db7cdb86d6d5a4600accd8ba9df3e1bbe.zip
build2-9c74a58db7cdb86d6d5a4600accd8ba9df3e1bbe.tar.gz
build2-9c74a58db7cdb86d6d5a4600accd8ba9df3e1bbe.tar.xz
Don't try to pass utility's loptions/libs when linking static library
-rw-r--r--build2/cc/common.cxx4
-rw-r--r--build2/cc/link-rule.cxx45
2 files changed, 36 insertions, 13 deletions
diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx
index 318a7f1..5ccb198 100644
--- a/build2/cc/common.cxx
+++ b/build2/cc/common.cxx
@@ -305,8 +305,8 @@ namespace build2
{
// This is something like -lpthread or shell32.lib so should be
// a valid path. But it can also be an absolute library path
- // (e.g., something that in the future will come from our
- // -static/-shared .pc files.
+ // (e.g., something that may come from our .static/shared.pc
+ // files).
//
if (proc_lib)
proc_lib (nullptr, n.value, 0, sys_simple (n.value));
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index a899ab2..30f1df8 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -1193,7 +1193,10 @@ namespace build2
linfo li;
} d {args, l, a, li};
- auto imp = [] (const file&, bool la) {return la;};
+ auto imp = [] (const file&, bool la)
+ {
+ return la;
+ };
auto lib = [&d, this] (const file* const* lc,
const string& p,
@@ -1204,7 +1207,11 @@ namespace build2
if (l == nullptr)
{
- d.args.push_back (p);
+ // Don't try to link a library (whether -lfoo or foo.lib) to a
+ // static library.
+ //
+ if (d.li.type != otype::a)
+ d.args.push_back (p);
}
else
{
@@ -1313,9 +1320,16 @@ namespace build2
}
};
- auto opt = [&args, this] (
- const file& l, const string& t, bool com, bool exp)
+ auto opt = [&d, this] (const file& l,
+ const string& t,
+ bool com,
+ bool exp)
{
+ // Don't try to pass any loptions when linking a static library.
+ //
+ if (d.li.type == otype::a)
+ return;
+
// If we need an interface value, then use the group (lib{}).
//
if (const target* g = exp && l.is_a<libs> () ? l.group : &l)
@@ -1327,7 +1341,7 @@ namespace build2
? (exp ? x_export_loptions : x_loptions)
: var_pool[t + (exp ? ".export.loptions" : ".loptions")]));
- append_options (args, *g, var);
+ append_options (d.args, *g, var);
}
};
@@ -1341,8 +1355,6 @@ namespace build2
const file& l, bool la, lflags lf,
const scope& bs, action a, linfo li) const
{
- auto imp = [] (const file&, bool la) {return la;};
-
struct data
{
sha256& cs;
@@ -1352,6 +1364,11 @@ namespace build2
linfo li;
} d {cs, bs.root_scope ()->out_path (), update, mt, li};
+ auto imp = [] (const file&, bool la)
+ {
+ return la;
+ };
+
auto lib = [&d, this] (const file* const* lc,
const string& p,
lflags f,
@@ -1361,7 +1378,8 @@ namespace build2
if (l == nullptr)
{
- d.cs.append (p);
+ if (d.li.type != otype::a)
+ d.cs.append (p);
}
else
{
@@ -1407,9 +1425,14 @@ namespace build2
}
};
- auto opt = [&cs, this] (
- const file& l, const string& t, bool com, bool exp)
+ auto opt = [&d, this] (const file& l,
+ const string& t,
+ bool com,
+ bool exp)
{
+ if (d.li.type == otype::a)
+ return;
+
if (const target* g = exp && l.is_a<libs> () ? l.group : &l)
{
const variable& var (
@@ -1419,7 +1442,7 @@ namespace build2
? (exp ? x_export_loptions : x_loptions)
: var_pool[t + (exp ? ".export.loptions" : ".loptions")]));
- hash_options (cs, *g, var);
+ hash_options (d.cs, *g, var);
}
};