aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-13 08:05:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-13 08:05:41 +0200
commitdb73844a1e11787025a8642f69a52b5f9c87aea2 (patch)
tree439ab3e274c130759dd75bb5bd886f9bc37aa404 /libbuild2/cc
parent70b4532ae118accdbe11f1983a81a26927fc9065 (diff)
Fold translated *.std options into compiler mode options
This way they are accessible in ad hoc recipes.
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/common.hxx4
-rw-r--r--libbuild2/cc/compile-rule.cxx12
-rw-r--r--libbuild2/cc/gcc.cxx2
-rw-r--r--libbuild2/cc/link-rule.cxx1
-rw-r--r--libbuild2/cc/module.cxx14
-rw-r--r--libbuild2/cc/module.hxx10
6 files changed, 13 insertions, 30 deletions
diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx
index 6df1ab0..781fcf5 100644
--- a/libbuild2/cc/common.hxx
+++ b/libbuild2/cc/common.hxx
@@ -155,8 +155,6 @@ namespace build2
const string& tsys; // x.target.system
const string& tclass; // x.target.class
- const strings& tstd; // Translated x_std value (options).
-
bool modules; // x.features.modules
bool symexport; // x.features.symexport
@@ -218,7 +216,6 @@ namespace build2
const process_path& path,
const strings& mode,
const target_triplet& tgt,
- const strings& std,
bool fm,
bool fs,
const dir_paths& sld,
@@ -239,7 +236,6 @@ namespace build2
cmaj (mj), cmin (mi),
cpath (path), cmode (mode),
ctgt (tgt), tsys (ctgt.system), tclass (ctgt.class_),
- tstd (std),
modules (fm),
symexport (fs),
xlate_hdr (nullptr),
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 29d79d0..29312a8 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -893,7 +893,6 @@ namespace build2
append_options (cs, t, c_coptions);
append_options (cs, t, x_coptions);
- append_options (cs, tstd);
if (ot == otype::s)
{
@@ -3057,8 +3056,6 @@ namespace build2
append_options (args, t, c_coptions, werror);
append_options (args, t, x_coptions, werror);
- append_options (args, tstd,
- tstd.size () - (modules && clang ? 1 : 0));
switch (cclass)
{
@@ -3127,7 +3124,8 @@ namespace build2
}
}
- append_options (args, cmode);
+ append_options (args, cmode,
+ cmode.size () - (modules && clang ? 1 : 0));
append_sys_inc_options (args); // Extra system header dirs (last).
// Setup the dynamic module mapper if needed.
@@ -4312,8 +4310,6 @@ namespace build2
append_options (args, t, c_coptions, werror);
append_options (args, t, x_coptions, werror);
- append_options (args, tstd,
- tstd.size () - (modules && clang ? 1 : 0));
append_header_options (env, args, header_args, a, t, md, dd);
@@ -4359,7 +4355,8 @@ namespace build2
}
}
- append_options (args, cmode);
+ append_options (args, cmode,
+ cmode.size () - (modules && clang ? 1 : 0));
append_sys_inc_options (args);
args.push_back ("-E");
@@ -5916,7 +5913,6 @@ namespace build2
append_options (args, t, c_coptions);
append_options (args, t, x_coptions);
- append_options (args, tstd);
string out, out1; // Output options storage.
small_vector<string, 2> header_args; // Header unit options storage.
diff --git a/libbuild2/cc/gcc.cxx b/libbuild2/cc/gcc.cxx
index 29bf824..30f2092 100644
--- a/libbuild2/cc/gcc.cxx
+++ b/libbuild2/cc/gcc.cxx
@@ -77,7 +77,6 @@ namespace build2
// line are factored into the output.
//
cstrings args {xc.recall_string ()};
- append_options (args, tstd);
append_options (args, rs, x_mode);
// Compile as.
@@ -253,7 +252,6 @@ namespace build2
size_t rn (r.size ());
cstrings args {xc.recall_string ()};
- append_options (args, tstd);
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 9b526ee..e94f538 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -2346,7 +2346,6 @@ namespace build2
{
append_options (args, t, c_coptions);
append_options (args, t, x_coptions);
- append_options (args, tstd);
}
// Note that these come in the reverse order of coptions since the
diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx
index a80d770..eed2510 100644
--- a/libbuild2/cc/module.cxx
+++ b/libbuild2/cc/module.cxx
@@ -389,6 +389,7 @@ namespace build2
// config.x.std overrides x.std
//
+ strings& mode (cast<strings> (rs.assign (x_mode))); // Set by guess.
{
lookup l (lookup_config (rs, config_x_std));
@@ -401,9 +402,10 @@ namespace build2
else
v = cast_null<string> (rs[x_std]);
- // Translate x_std value (if any) to the compiler option(s) (if any).
+ // Translate x_std value (if any) to the compiler option(s) (if any)
+ // and fold them into the compiler mode.
//
- tstd = translate_std (xi, tt, rs, v);
+ translate_std (xi, tt, rs, mode, v);
}
// config.x.translatable_header
@@ -546,8 +548,6 @@ namespace build2
//
if (verb >= (new_config ? 2 : 3))
{
- const strings& mode (cast<strings> (rs[x_mode]));
-
diag_record dr (text);
{
@@ -609,12 +609,6 @@ namespace build2
dr << "\n c stdlib " << xi.c_stdlib;
}
- if (!tstd.empty ())
- {
- dr << "\n std "; // One less space.
- for (const string& o: tstd) dr << ' ' << o;
- }
-
if (!xi.pattern.empty ()) // Note: bin_pattern printed by bin
{
dr << "\n pattern " << xi.pattern;
diff --git a/libbuild2/cc/module.hxx b/libbuild2/cc/module.hxx
index 28e8d51..81456b3 100644
--- a/libbuild2/cc/module.hxx
+++ b/libbuild2/cc/module.hxx
@@ -44,17 +44,17 @@ namespace build2
init (scope&, const location&, const variable_map&);
// Translate the x.std value (if any) to the standard-selecting
- // option(s) (if any). May also check/set x.features.* variables on the
- // root scope.
+ // option(s) (if any) and fold them (normally by pre-pending) into the
+ // compiler mode options. This function may also check/set x.features.*
+ // variables on the root scope.
//
- virtual strings
+ virtual void
translate_std (const compiler_info&,
const target_triplet&,
scope&,
+ strings&,
const string*) const = 0;
- strings tstd;
-
const compiler_info* x_info;
// Temporary storage for data::sys_*_dirs_*.