aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/link-rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-04-10 11:18:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-04-10 11:18:10 +0200
commit74d42005e25e4a3c8356d44010b82a206b8aa7e6 (patch)
tree14a6de5c761d66502aaffb38b18c2fd1a939db26 /libbuild2/cc/link-rule.cxx
parent2905180c48e4b8974d4dee1949a00fc8e7bcafc6 (diff)
Fix inconsistent /usr/local/{include,lib} search
In particular, we were adding -L/usr/local/lib which means it is considered before built-in directories (/usr/lib, etc) but in our own library search code we were considering it after (because we were storing it at the end of sys_lib_dirs). Now in both sys_{hdr,lib}_dirs we store /usr/local/{include,lib} after mode and before built-in directories. Note that as part of this fix we now pass -isystem /usr/local/include instead of -idirafter (which is consistent with the -L behavior and also the customarily expected semantics).
Diffstat (limited to 'libbuild2/cc/link-rule.cxx')
-rw-r--r--libbuild2/cc/link-rule.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 490e0b4..76fd3c5 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -3365,25 +3365,24 @@ namespace build2
// Extra system library dirs (last).
//
- assert (sys_lib_dirs_extra <= sys_lib_dirs.size ());
+ assert (sys_lib_dirs_mode + sys_lib_dirs_extra <= sys_lib_dirs.size ());
+
+ // Note that the mode options are added as part of cmode.
+ //
+ auto b (sys_lib_dirs.begin () + sys_lib_dirs_mode);
+ auto x (b + sys_lib_dirs_extra);
if (tsys == "win32-msvc")
{
// If we have no LIB environment variable set, then we add all of
// them. But we want extras to come first.
//
- // Note that the mode options are added as part of cmode.
- //
- auto b (sys_lib_dirs.begin () + sys_lib_dirs_mode);
- auto m (sys_lib_dirs.begin () + sys_lib_dirs_extra);
- auto e (sys_lib_dirs.end ());
-
- for (auto i (m); i != e; ++i)
+ for (auto i (b); i != x; ++i)
sargs1.push_back ("/LIBPATH:" + i->string ());
if (!getenv ("LIB"))
{
- for (auto i (b); i != m; ++i)
+ for (auto i (x), e (sys_lib_dirs.end ()); i != e; ++i)
sargs1.push_back ("/LIBPATH:" + i->string ());
}
@@ -3394,7 +3393,7 @@ namespace build2
append_option_values (
args,
"-L",
- sys_lib_dirs.begin () + sys_lib_dirs_extra, sys_lib_dirs.end (),
+ b, x,
[] (const dir_path& d) {return d.string ().c_str ();});
}
}