From bdbb7e2535009b2a142567a2235ac0a71352c749 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 29 Nov 2019 13:59:20 +0200 Subject: Reorder {cc,c/cxx}.{poptions,loptions} Now it is c/cxx first followed by cc which is the reverse order of coptions since the header/library search paths are examined in the order specified (in contrast to the "last value wins" semantics that we assume for coptions). --- libbuild2/cc/common.cxx | 9 +++++---- libbuild2/cc/compile-rule.cxx | 15 ++++++++++----- libbuild2/cc/gcc.cxx | 2 +- libbuild2/cc/link-rule.cxx | 7 ++++++- libbuild2/cc/pkgconfig.cxx | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index d24eb02..2ac8c0b 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -38,7 +38,7 @@ namespace build2 // // Note that the order of processing is: // - // 1. options + // 1. options (x.* then cc.* to be consistent with poptions/loptions) // 2. lib itself (if self is true) // 3. dependency libs (prerequisite_targets, left to right, depth-first) // 4. dependency libs (*.libs variables). @@ -141,24 +141,25 @@ namespace build2 // perhaps we can assume non-common values will be set on // libs{}/liba{}. // - proc_opt (l, *t, true, true); proc_opt (l, *t, false, true); + proc_opt (l, *t, true, true); + } else { // For default export we use the same options as were used to // build the library. // - proc_opt (l, *t, true, false); proc_opt (l, *t, false, false); + proc_opt (l, *t, true, false); } } else { // Interface: only add *.export.* (interface dependencies). // - proc_opt (l, *t, true, true); proc_opt (l, *t, false, true); + proc_opt (l, *t, true, true); } } } diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index da958f4..328b65e 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -860,8 +860,8 @@ namespace build2 if (md.pp != preprocessed::all) { - append_options (cs, t, c_poptions); append_options (cs, t, x_poptions); + append_options (cs, t, c_poptions); // Hash *.export.poptions from prerequisite libraries. // @@ -1416,8 +1416,8 @@ namespace build2 // First process our own. // - append_prefixes (m, t, c_poptions); append_prefixes (m, t, x_poptions); + append_prefixes (m, t, c_poptions); // Then process the include directories from prerequisite libraries. // @@ -2807,8 +2807,8 @@ namespace build2 if (reprocess) args.push_back ("-D__build2_preprocess"); - append_options (args, t, c_poptions); append_options (args, t, x_poptions); + append_options (args, t, c_poptions); // Add *.export.poptions from prerequisite libraries. // @@ -4075,8 +4075,8 @@ namespace build2 if (reprocess) args.push_back ("-D__build2_preprocess"); - append_options (args, t, c_poptions); append_options (args, t, x_poptions); + append_options (args, t, c_poptions); append_lib_options (t.base_scope (), args, a, t, li); @@ -5681,8 +5681,13 @@ namespace build2 // if (md.pp != preprocessed::all) { - append_options (args, t, c_poptions); + // Note that these come in the reverse order of coptions since the + // header search paths are examined in the order specified (in + // contrast to the "last value wins" semantics that we assume for + // coptions). + // append_options (args, t, x_poptions); + append_options (args, t, c_poptions); // Add *.export.poptions from prerequisite libraries. // diff --git a/libbuild2/cc/gcc.cxx b/libbuild2/cc/gcc.cxx index cf0ccdc..5857709 100644 --- a/libbuild2/cc/gcc.cxx +++ b/libbuild2/cc/gcc.cxx @@ -184,8 +184,8 @@ namespace build2 append_options (args, rs, c_coptions); append_options (args, rs, x_coptions); append_options (args, tstd); - append_options (args, rs, c_loptions); append_options (args, rs, x_loptions); + append_options (args, rs, c_loptions); append_options (args, rs, x_mode); args.push_back ("-print-search-dirs"); args.push_back (nullptr); diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 4fbdeda..8da9619 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -2312,8 +2312,13 @@ namespace build2 append_options (args, tstd); } - append_options (args, t, c_loptions); + // Note that these come in the reverse order of coptions since the + // library search paths are examined in the order specified (in + // contrast to the "last value wins" semantics that we assume for + // coptions). + // append_options (args, t, x_loptions); + append_options (args, t, c_loptions); // Extra system library dirs (last). // diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx index 56acafc..6fcf711 100644 --- a/libbuild2/cc/pkgconfig.cxx +++ b/libbuild2/cc/pkgconfig.cxx @@ -1358,8 +1358,8 @@ namespace build2 // os << "Cflags:"; os << " -I" << escape (idir.string ()); - save_poptions (c_export_poptions); save_poptions (x_export_poptions); + save_poptions (c_export_poptions); os << endl; // Libs. -- cgit v1.1