aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/compile-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/compile-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/compile-rule.cxx')
-rw-r--r--libbuild2/cc/compile-rule.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 7a357d9..b63b3cf 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -295,24 +295,25 @@ namespace build2
void compile_rule::
append_sys_hdr_options (T& args) const
{
- assert (sys_hdr_dirs_extra <= sys_hdr_dirs.size ());
+ assert (sys_hdr_dirs_mode + sys_hdr_dirs_extra <= sys_hdr_dirs.size ());
// Note that the mode options are added as part of cmode.
//
auto b (sys_hdr_dirs.begin () + sys_hdr_dirs_mode);
- auto m (sys_hdr_dirs.begin () + sys_hdr_dirs_extra);
- auto e (sys_hdr_dirs.end ());
+ auto x (b + sys_hdr_dirs_extra);
+ // Add extras.
+ //
// Note: starting from 16.10, MSVC gained /external:I option though it
// doesn't seem to affect the order, only "system-ness".
//
append_option_values (
args,
- cclass == compiler_class::gcc ? "-idirafter" :
+ cclass == compiler_class::gcc ? "-isystem" :
cclass == compiler_class::msvc ? (isystem (*this)
? "/external:I"
: "/I") : "-I",
- m, e,
+ b, x,
[] (const dir_path& d) {return d.string ().c_str ();});
// For MSVC if we have no INCLUDE environment variable set, then we
@@ -328,7 +329,7 @@ namespace build2
{
append_option_values (
args, "/I",
- b, m,
+ x, sys_hdr_dirs.end (),
[] (const dir_path& d) {return d.string ().c_str ();});
}
}