aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/c/init.cxx14
-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
-rw-r--r--libbuild2/cxx/init.cxx33
8 files changed, 35 insertions, 55 deletions
diff --git a/libbuild2/c/init.cxx b/libbuild2/c/init.cxx
index 7760808..38ee3d2 100644
--- a/libbuild2/c/init.cxx
+++ b/libbuild2/c/init.cxx
@@ -36,23 +36,23 @@ namespace build2
explicit
config_module (config_data&& d): cc::config_module (move (d)) {}
- virtual strings
+ virtual void
translate_std (const compiler_info&,
const target_triplet&,
scope&,
+ strings&,
const string*) const override;
};
using cc::module;
- strings config_module::
+ void config_module::
translate_std (const compiler_info& ci,
const target_triplet&,
scope& rs,
+ strings& mode,
const string* v) const
{
- strings r;
-
switch (ci.class_)
{
case compiler_class::msvc:
@@ -116,13 +116,11 @@ namespace build2
else if (*v == "90") o += "c90";
else o += *v; // In case the user specifies `gnuNN` or some such.
- r.push_back (move (o));
+ mode.insert (mode.begin (), move (o));
}
break;
}
}
-
- return r;
}
static const char* const hinters[] = {"cxx", nullptr};
@@ -340,8 +338,6 @@ namespace build2
cast<strings> (rs[cm.x_mode]),
cast<target_triplet> (rs[cm.x_target]),
- cm.tstd,
-
false, // No C modules yet.
false, // No __symexport support since no modules.
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_*.
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index bb6653d..a43dcb2 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -37,23 +37,23 @@ namespace build2
explicit
config_module (config_data&& d): cc::config_module (move (d)) {}
- virtual strings
+ virtual void
translate_std (const compiler_info&,
const target_triplet&,
scope&,
+ strings&,
const string*) const override;
};
using cc::module;
- strings config_module::
+ void config_module::
translate_std (const compiler_info& ci,
const target_triplet& tt,
scope& rs,
+ strings& mode,
const string* v) const
{
- strings r;
-
compiler_type ct (ci.id.type);
compiler_class cl (ci.class_);
uint64_t mj (ci.version.major);
@@ -104,6 +104,11 @@ namespace build2
string o;
+ auto prepend = [&mode, i = mode.begin ()] (string o) mutable
+ {
+ i = mode.insert (i, move (o)) + 1;
+ };
+
switch (cl)
{
case compiler_class::msvc:
@@ -182,7 +187,7 @@ namespace build2
}
if (!o.empty ())
- r.push_back (move (o));
+ prepend (move (o));
break;
}
@@ -257,7 +262,7 @@ namespace build2
}
if (!o.empty ())
- r.push_back (move (o));
+ prepend (move (o));
break;
}
@@ -275,7 +280,7 @@ namespace build2
// the experimenters to enjoy.
//
if (mj > 19 || (mj == 19 && mi >= 12))
- r.push_back ("/permissive-");
+ prepend ("/permissive-");
break;
}
@@ -301,14 +306,14 @@ namespace build2
//
if (mj > 19 || (mj == 19 && mi >= (l ? 10 : 12)))
{
- r.push_back (
+ prepend (
mj > 19 || mi >= 24 ?
"/D__cpp_modules=201810" : // p1103 (merged modules)
mj == 19 || mi >= 12 ?
"/D__cpp_modules=201704" : // p0629r0 (export module M;)
"/D__cpp_modules=201703"); // n4647 ( module M;)
- r.push_back ("/experimental:module");
+ prepend ("/experimental:module");
modules = true;
}
break;
@@ -328,7 +333,7 @@ namespace build2
// Currently defines __cpp_modules=201810 which is said to
// correspond to p1103 (merged modules).
//
- r.push_back ("-fmodules-ts");
+ prepend ("-fmodules-ts");
modules = true;
}
break;
@@ -350,8 +355,8 @@ namespace build2
//
if (l)
{
- r.push_back ("-D__cpp_modules=201704"); // p0629r0
- r.push_back ("-fmodules-ts");
+ prepend ("-D__cpp_modules=201704"); // p0629r0
+ mode.push_back ("-fmodules-ts"); // For the hack to work.
modules = true;
}
break;
@@ -364,8 +369,6 @@ namespace build2
rs.assign (v_m) = modules;
//rs.assign (v_c) = concepts;
-
- return r;
}
static const char* const hinters[] = {"c", nullptr};
@@ -627,8 +630,6 @@ namespace build2
cast<strings> (rs[cm.x_mode]),
cast<target_triplet> (rs[cm.x_target]),
- cm.tstd,
-
modules,
symexport,