feat(translation,ide): add native C driver, Ninja custom commands, CMake CXX_MODULES, and vbs ide integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
This commit is contained in:
1 parent
5e1916dc5c
commit
6c225c2dff
27 files changed
+3443
-331
No files matched your search
+255
-110
@@ -110,6 +110,10 @@ bool is_module_source_extension(const std::filesystem::path &p) {
|
||||
return ext == ".cppm" || ext == ".ixx" || ext == ".ccm";
|
||||
}
|
||||
|
||||
bool is_c_source_extension(const std::filesystem::path &p) {
|
||||
return p.extension().string() == ".c";
|
||||
}
|
||||
|
||||
bool is_cpp_source_extension(const std::filesystem::path &p) {
|
||||
const auto ext = p.extension().string();
|
||||
return ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".c" ||
|
||||
@@ -221,6 +225,7 @@ ProjectDescription::from_json(std::string_view json_text) {
|
||||
desc.profile.compile_options = get_str_array(*prof, "compile_options");
|
||||
desc.profile.link_options = get_str_array(*prof, "link_options");
|
||||
desc.profile.defines = get_str_array(*prof, "defines");
|
||||
desc.profile.c_standard = parse_c_standard(get_str(*prof, "c_standard", "default"));
|
||||
desc.profile.cxx_standard = parse_cxx_standard(get_str(*prof, "cxx_standard", "default"));
|
||||
desc.profile.lto = parse_lto_mode(get_str(*prof, "lto", "none"));
|
||||
for (const auto &s : get_str_array(*prof, "sanitizers")) {
|
||||
@@ -292,6 +297,7 @@ ProjectDescription::from_json(std::string_view json_text) {
|
||||
}
|
||||
}
|
||||
t.prerequisites = get_str_array(*to, "prerequisites");
|
||||
t.c_standard = parse_c_standard(get_str(*to, "c_standard", "default"));
|
||||
t.cxx_standard = parse_cxx_standard(get_str(*to, "cxx_standard", "default"));
|
||||
t.precompiled_header = get_str(*to, "precompiled_header");
|
||||
t.unity_enabled = get_bool(*to, "unity_enabled", false);
|
||||
@@ -661,6 +667,8 @@ lower_project_graph(const ProjectDescription &description,
|
||||
std::vector<std::filesystem::path> exported_objects;
|
||||
std::vector<std::string> exported_link_options;
|
||||
std::vector<std::string> exported_prerequisite_actions;
|
||||
std::map<std::string, std::filesystem::path, std::less<>> exported_module_bmis;
|
||||
std::map<std::string, std::string, std::less<>> exported_module_action_ids;
|
||||
};
|
||||
std::map<std::string, TargetComputed, std::less<>> computed;
|
||||
|
||||
@@ -731,6 +739,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
}
|
||||
for (const auto &aid : computed.at(pre_name).exported_prerequisite_actions) {
|
||||
add_unique_str(target_prereq_actions, aid);
|
||||
add_unique_str(tc.exported_prerequisite_actions, aid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,7 +792,13 @@ lower_project_graph(const ProjectDescription &description,
|
||||
|
||||
for (const auto &in : t.action_inputs) {
|
||||
const auto p = std::filesystem::path{in};
|
||||
act.declared_inputs.push_back(p.is_absolute() ? p : (canonical_root / p));
|
||||
const auto resolved_in =
|
||||
(p.is_absolute() ? p : (canonical_root / p)).lexically_normal();
|
||||
if (const auto prod_it = output_owner.find(resolved_in);
|
||||
prod_it != output_owner.end()) {
|
||||
add_unique_str(act.dependencies, prod_it->second);
|
||||
}
|
||||
act.declared_inputs.push_back(resolved_in);
|
||||
}
|
||||
for (const auto &out : t.action_outputs) {
|
||||
const auto p = std::filesystem::path{out};
|
||||
@@ -813,6 +828,8 @@ lower_project_graph(const ProjectDescription &description,
|
||||
std::vector<std::string> effective_link_opts = description.profile.link_options;
|
||||
|
||||
// Ordered transitive link inputs (preserve exact order; never sort!).
|
||||
std::map<std::string, std::filesystem::path, std::less<>> external_module_bmis;
|
||||
std::map<std::string, std::string, std::less<>> external_module_action_ids;
|
||||
std::vector<std::filesystem::path> link_objects;
|
||||
std::vector<std::filesystem::path> link_static_libs;
|
||||
std::vector<std::filesystem::path> link_shared_libs;
|
||||
@@ -894,6 +911,12 @@ lower_project_graph(const ProjectDescription &description,
|
||||
effective_compile_opts.insert(effective_compile_opts.end(),
|
||||
dep.exported_compile_options.begin(),
|
||||
dep.exported_compile_options.end());
|
||||
for (const auto &[mname, bmi_p] : dep.exported_module_bmis) {
|
||||
external_module_bmis.try_emplace(mname, bmi_p);
|
||||
}
|
||||
for (const auto &[mname, aid] : dep.exported_module_action_ids) {
|
||||
external_module_action_ids.try_emplace(mname, aid);
|
||||
}
|
||||
}
|
||||
if (link.visibility != Visibility::Private) {
|
||||
tc.exported_includes.insert(tc.exported_includes.end(),
|
||||
@@ -905,6 +928,12 @@ lower_project_graph(const ProjectDescription &description,
|
||||
tc.exported_compile_options.insert(tc.exported_compile_options.end(),
|
||||
dep.exported_compile_options.begin(),
|
||||
dep.exported_compile_options.end());
|
||||
for (const auto &[mname, bmi_p] : dep.exported_module_bmis) {
|
||||
tc.exported_module_bmis.try_emplace(mname, bmi_p);
|
||||
}
|
||||
for (const auto &[mname, aid] : dep.exported_module_action_ids) {
|
||||
tc.exported_module_action_ids.try_emplace(mname, aid);
|
||||
}
|
||||
}
|
||||
|
||||
// Link usage: static private dependencies STILL propagate to final linkers!
|
||||
@@ -979,6 +1008,9 @@ lower_project_graph(const ProjectDescription &description,
|
||||
effective_compile_opts.insert(effective_compile_opts.end(),
|
||||
imp.compile_options.begin(),
|
||||
imp.compile_options.end());
|
||||
for (const auto &[mname, bmi_p] : imp.module_bmis) {
|
||||
external_module_bmis.try_emplace(mname, bmi_p);
|
||||
}
|
||||
}
|
||||
if (link.visibility != Visibility::Private) {
|
||||
tc.exported_includes.insert(tc.exported_includes.end(),
|
||||
@@ -988,6 +1020,9 @@ lower_project_graph(const ProjectDescription &description,
|
||||
tc.exported_compile_options.insert(tc.exported_compile_options.end(),
|
||||
imp.compile_options.begin(),
|
||||
imp.compile_options.end());
|
||||
for (const auto &[mname, bmi_p] : imp.module_bmis) {
|
||||
tc.exported_module_bmis.try_emplace(mname, bmi_p);
|
||||
}
|
||||
}
|
||||
const bool propagate_to_consumers = (link.visibility != Visibility::Private) ||
|
||||
(t.kind == TargetKind::StaticLibrary) ||
|
||||
@@ -1081,12 +1116,15 @@ lower_project_graph(const ProjectDescription &description,
|
||||
summary.expanded_sources = expanded_sources;
|
||||
|
||||
if (t.kind == TargetKind::HeaderOnly) {
|
||||
summary.exported_module_bmis = tc.exported_module_bmis;
|
||||
computed[t.name] = std::move(tc);
|
||||
graph.targets.push_back(std::move(summary));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Effective C++ standard, LTO, sanitizers (target overrides/extends profile).
|
||||
// Effective C & C++ standards, LTO, sanitizers (target overrides/extends profile).
|
||||
const CStandard eff_c_std =
|
||||
t.c_standard != CStandard::Default ? t.c_standard : description.profile.c_standard;
|
||||
const CxxStandard eff_std = t.cxx_standard != CxxStandard::Default
|
||||
? t.cxx_standard
|
||||
: description.profile.cxx_standard;
|
||||
@@ -1251,6 +1289,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
std::filesystem::path logical_src;
|
||||
std::filesystem::path physical_src;
|
||||
std::vector<std::string> tu_opts;
|
||||
bool is_c{false};
|
||||
bool is_explicit_module{false};
|
||||
bool has_per_file_override{false};
|
||||
};
|
||||
@@ -1265,6 +1304,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
cu.tu_opts = effective_compile_opts;
|
||||
cu.is_explicit_module =
|
||||
explicit_module_sources.contains(src_path) || is_module_source_extension(src_path);
|
||||
cu.is_c = !cu.is_explicit_module && is_c_source_extension(src_path);
|
||||
for (const auto &pfo : t.per_file_options) {
|
||||
if (pfo.source_path == src_path.generic_string() ||
|
||||
pfo.source_path == cu.logical_src.generic_string()) {
|
||||
@@ -1284,7 +1324,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
const auto norm_phys = cu.physical_src.lexically_normal();
|
||||
all_phys.push_back(norm_phys);
|
||||
raw_by_phys[norm_phys] = &cu;
|
||||
if (cu.is_explicit_module || cu.has_per_file_override) {
|
||||
if (cu.is_c || cu.is_explicit_module || cu.has_per_file_override) {
|
||||
excluded_phys.push_back(norm_phys);
|
||||
}
|
||||
}
|
||||
@@ -1310,14 +1350,18 @@ lower_project_graph(const ProjectDescription &description,
|
||||
compile_units = std::move(raw_units);
|
||||
}
|
||||
|
||||
// 6. Compile actions (C++20/23/26 P1689 named modules & partitions OR regular TUs).
|
||||
// 6. Compile actions (C++20/23/26 P1689 named modules & partitions OR regular C/C++ TUs).
|
||||
std::vector<std::string> compile_action_ids;
|
||||
const bool has_module_sources = std::ranges::any_of(
|
||||
compile_units, [](const CompileUnitSpec &u) { return u.is_explicit_module; });
|
||||
const bool has_cpp_sources =
|
||||
std::ranges::any_of(compile_units, [](const CompileUnitSpec &u) { return !u.is_c; });
|
||||
const bool run_module_pipeline =
|
||||
has_module_sources || (has_cpp_sources && !external_module_bmis.empty());
|
||||
|
||||
std::optional<std::filesystem::path> shared_hu_mapper;
|
||||
if (!gcc_header_unit_mapper_lines.empty() && toolchain.family == CompilerFamily::Gcc &&
|
||||
!has_module_sources) {
|
||||
!run_module_pipeline) {
|
||||
shared_hu_mapper = target_bmi_root / "header_units.modmap";
|
||||
if (auto w = Platform::atomic_write_file(*shared_hu_mapper,
|
||||
gcc_header_unit_mapper_lines, false);
|
||||
@@ -1326,9 +1370,121 @@ lower_project_graph(const ProjectDescription &description,
|
||||
}
|
||||
}
|
||||
|
||||
if (has_module_sources) {
|
||||
auto emit_regular_compile_action =
|
||||
[&](const CompileUnitSpec &cu) -> Void::Result::Result<void, Void::Result::Error> {
|
||||
const std::string src_hash = Util::sha256_hex(cu.logical_src.string()).substr(0, 12);
|
||||
const auto obj_path =
|
||||
objects_root / sanitize_id_component(t.name) /
|
||||
(sanitize_id_component(cu.logical_src.filename().string()) + "_" + src_hash + ".o");
|
||||
const auto dep_path = std::filesystem::path{obj_path.string() + ".d"};
|
||||
|
||||
Toolchain::CompileRequest req;
|
||||
req.source_file = cu.physical_src;
|
||||
req.output_object = obj_path;
|
||||
req.depfile = dep_path;
|
||||
req.response_file_dir = rsp_root;
|
||||
req.include_dirs = physical_includes;
|
||||
req.defines = effective_defines;
|
||||
req.compile_options = cu.tu_opts;
|
||||
req.is_c_source = cu.is_c;
|
||||
req.c_standard = cu.is_c ? eff_c_std : CStandard::Default;
|
||||
req.cxx_standard =
|
||||
cu.is_c ? CxxStandard::Default
|
||||
: ((!header_unit_bmi_paths.empty() && eff_std == CxxStandard::Default)
|
||||
? CxxStandard::Cxx20
|
||||
: eff_std);
|
||||
req.lto = eff_lto;
|
||||
req.sanitizers = eff_sans;
|
||||
req.position_independent = pic;
|
||||
req.precompiled_header = cu.is_c ? std::nullopt : pch_include_prefix;
|
||||
req.prefix_maps = prefix_maps;
|
||||
req.reproducibility_epoch = description.profile.reproducibility_epoch;
|
||||
req.nondeterministic = t.nondeterministic || description.profile.nondeterministic;
|
||||
req.response_file_threshold = options.response_file_threshold;
|
||||
if (!cu.is_c) {
|
||||
if (shared_hu_mapper) {
|
||||
req.module_mapper_file = shared_hu_mapper;
|
||||
} else if (!header_unit_bmi_paths.empty() &&
|
||||
toolchain.family == CompilerFamily::Clang) {
|
||||
for (const auto &hb : header_unit_bmi_paths) {
|
||||
req.module_bmi_imports.emplace_back(std::string{}, hb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto lowered = Toolchain::lower_compile_command(toolchain, req);
|
||||
if (!lowered) {
|
||||
return std::unexpected{lowered.error()};
|
||||
}
|
||||
|
||||
ActionNode act;
|
||||
act.id = "compile:" + sanitize_id_component(t.name) + ":" + src_hash;
|
||||
act.kind = ActionKind::Compile;
|
||||
act.target_name = t.name;
|
||||
act.executable = lowered->executable;
|
||||
act.arguments = std::move(lowered->arguments);
|
||||
act.environment = std::move(lowered->environment);
|
||||
act.working_directory = canonical_root;
|
||||
act.response_file = lowered->response_file;
|
||||
act.response_file_content = std::move(lowered->response_file_content);
|
||||
act.declared_inputs = {cu.physical_src};
|
||||
if (!cu.is_c) {
|
||||
for (const auto &hb : header_unit_bmi_paths) {
|
||||
act.declared_inputs.push_back(hb);
|
||||
}
|
||||
if (shared_hu_mapper) {
|
||||
act.declared_inputs.push_back(*shared_hu_mapper);
|
||||
}
|
||||
}
|
||||
act.declared_outputs = {obj_path};
|
||||
act.depfile = dep_path;
|
||||
act.logical_source_file = cu.logical_src;
|
||||
act.physical_source_file = cu.physical_src;
|
||||
act.logical_output_file = obj_path;
|
||||
act.physical_output_file = obj_path;
|
||||
act.logical_include_dirs = effective_includes;
|
||||
act.physical_include_dirs = physical_includes;
|
||||
act.defines = effective_defines;
|
||||
act.compile_options = cu.tu_opts;
|
||||
act.is_c_source = req.is_c_source;
|
||||
act.c_standard = req.c_standard;
|
||||
act.cxx_standard = req.cxx_standard;
|
||||
act.lto = eff_lto;
|
||||
act.sanitizers = eff_sans;
|
||||
act.position_independent = pic;
|
||||
act.precompiled_header = req.precompiled_header;
|
||||
act.dependencies = target_prereq_actions;
|
||||
if (!cu.is_c) {
|
||||
if (pch_action_id) {
|
||||
add_unique_str(act.dependencies, *pch_action_id);
|
||||
}
|
||||
for (const auto &huid : header_unit_action_ids) {
|
||||
add_unique_str(act.dependencies, huid);
|
||||
}
|
||||
}
|
||||
if (const auto prod_it = output_owner.find(cu.logical_src);
|
||||
prod_it != output_owner.end()) {
|
||||
add_unique_str(act.dependencies, prod_it->second);
|
||||
}
|
||||
act.nondeterministic = req.nondeterministic;
|
||||
act.cacheable = !act.nondeterministic;
|
||||
if (auto reg = register_output(obj_path, act.id); !reg) {
|
||||
return std::unexpected{reg.error()};
|
||||
}
|
||||
act.action_key = compute_action_key(act, graph);
|
||||
compile_action_ids.push_back(act.id);
|
||||
tc.object_files.push_back(obj_path);
|
||||
summary.action_ids.push_back(act.id);
|
||||
graph.action_index_by_id[act.id] = graph.actions.size();
|
||||
graph.actions.push_back(std::move(act));
|
||||
return {};
|
||||
};
|
||||
|
||||
if (run_module_pipeline) {
|
||||
const CxxStandard mod_std =
|
||||
(eff_std == CxxStandard::Default) ? CxxStandard::Cxx20 : eff_std;
|
||||
(eff_std == CxxStandard::Default || eff_std == CxxStandard::Cxx17)
|
||||
? CxxStandard::Cxx20
|
||||
: eff_std;
|
||||
const auto scan_dir =
|
||||
graph.profile_build_dir / "modscan" / sanitize_id_component(t.name);
|
||||
|
||||
@@ -1336,6 +1492,12 @@ lower_project_graph(const ProjectDescription &description,
|
||||
scanned.reserve(compile_units.size());
|
||||
std::map<std::filesystem::path, const CompileUnitSpec *> cu_by_phys;
|
||||
for (const auto &cu : compile_units) {
|
||||
if (cu.is_c) {
|
||||
if (auto r = emit_regular_compile_action(cu); !r) {
|
||||
return std::unexpected{r.error()};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const auto norm_phys = cu.physical_src.lexically_normal();
|
||||
cu_by_phys[norm_phys] = &cu;
|
||||
auto scan = Modules::scan_translation_unit(toolchain, norm_phys, scan_dir,
|
||||
@@ -1347,8 +1509,9 @@ lower_project_graph(const ProjectDescription &description,
|
||||
scanned.push_back(std::move(*scan));
|
||||
}
|
||||
|
||||
auto collated = Modules::collate_modules(
|
||||
scanned, target_bmi_root, graph.profile_identity + ":" + t.name, bmi_ext);
|
||||
auto collated = Modules::collate_modules(scanned, target_bmi_root,
|
||||
graph.profile_identity + ":" + t.name, bmi_ext,
|
||||
external_module_bmis);
|
||||
if (!collated) {
|
||||
return std::unexpected{collated.error()};
|
||||
}
|
||||
@@ -1365,10 +1528,14 @@ lower_project_graph(const ProjectDescription &description,
|
||||
std::vector<std::pair<std::string, std::filesystem::path>> bmis;
|
||||
std::set<std::string> seen;
|
||||
std::queue<std::string> q;
|
||||
bool uses_external = false;
|
||||
for (const auto &r : direct_reqs) {
|
||||
if (seen.insert(r).second) {
|
||||
q.push(r);
|
||||
}
|
||||
if (external_module_bmis.contains(r)) {
|
||||
uses_external = true;
|
||||
}
|
||||
}
|
||||
while (!q.empty()) {
|
||||
const auto cur = q.front();
|
||||
@@ -1376,6 +1543,10 @@ lower_project_graph(const ProjectDescription &description,
|
||||
if (const auto bit = collated->module_to_bmi.find(cur);
|
||||
bit != collated->module_to_bmi.end()) {
|
||||
bmis.emplace_back(cur, bit->second);
|
||||
} else if (const auto ebit = external_module_bmis.find(cur);
|
||||
ebit != external_module_bmis.end()) {
|
||||
bmis.emplace_back(cur, ebit->second);
|
||||
uses_external = true;
|
||||
}
|
||||
if (const auto dit = module_deps_by_name.find(cur);
|
||||
dit != module_deps_by_name.end()) {
|
||||
@@ -1386,6 +1557,13 @@ lower_project_graph(const ProjectDescription &description,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uses_external) {
|
||||
for (const auto &[mname, bmi_p] : external_module_bmis) {
|
||||
if (seen.insert(mname).second) {
|
||||
bmis.emplace_back(mname, bmi_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bmis;
|
||||
};
|
||||
for (const auto &node : collated->ordered_units) {
|
||||
@@ -1397,6 +1575,10 @@ lower_project_graph(const ProjectDescription &description,
|
||||
"_" + src_hash + ".o");
|
||||
const auto dep_path = std::filesystem::path{obj_path.string() + ".d"};
|
||||
|
||||
const bool tu_uses_modules =
|
||||
!node.provides.empty() || !node.required_modules.empty();
|
||||
const CxxStandard tu_std = tu_uses_modules ? mod_std : eff_std;
|
||||
|
||||
std::vector<std::string> unit_deps = target_prereq_actions;
|
||||
if (pch_action_id) {
|
||||
add_unique_str(unit_deps, *pch_action_id);
|
||||
@@ -1408,8 +1590,25 @@ lower_project_graph(const ProjectDescription &description,
|
||||
prod_it != output_owner.end()) {
|
||||
add_unique_str(unit_deps, prod_it->second);
|
||||
}
|
||||
bool tu_uses_external_mod = false;
|
||||
for (const auto &req_mod : node.required_modules) {
|
||||
add_unique_str(unit_deps, provider_action_by_module.at(req_mod));
|
||||
if (const auto pit = provider_action_by_module.find(req_mod);
|
||||
pit != provider_action_by_module.end()) {
|
||||
add_unique_str(unit_deps, pit->second);
|
||||
} else {
|
||||
tu_uses_external_mod = true;
|
||||
if (const auto epit = external_module_action_ids.find(req_mod);
|
||||
epit != external_module_action_ids.end()) {
|
||||
add_unique_str(unit_deps, epit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tu_uses_external_mod ||
|
||||
(!node.provides.empty() && !external_module_action_ids.empty())) {
|
||||
for (const auto &[mname, aid] : external_module_action_ids) {
|
||||
(void)mname;
|
||||
add_unique_str(unit_deps, aid);
|
||||
}
|
||||
}
|
||||
|
||||
if (toolchain.family == CompilerFamily::Gcc) {
|
||||
@@ -1447,7 +1646,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
req.include_dirs = physical_includes;
|
||||
req.defines = effective_defines;
|
||||
req.compile_options = tu_opts;
|
||||
req.cxx_standard = mod_std;
|
||||
req.cxx_standard = tu_std;
|
||||
req.lto = eff_lto;
|
||||
req.sanitizers = eff_sans;
|
||||
req.position_independent = pic;
|
||||
@@ -1480,6 +1679,14 @@ lower_project_graph(const ProjectDescription &description,
|
||||
(void)mname;
|
||||
act.declared_inputs.push_back(bmi_p);
|
||||
}
|
||||
if (tu_uses_external_mod || !node.provides.empty()) {
|
||||
for (const auto &[mname, bmi_p] : external_module_bmis) {
|
||||
(void)mname;
|
||||
if (!std::ranges::contains(act.declared_inputs, bmi_p)) {
|
||||
act.declared_inputs.push_back(bmi_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto &hb : header_unit_bmi_paths) {
|
||||
act.declared_inputs.push_back(hb);
|
||||
}
|
||||
@@ -1502,7 +1709,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
act.physical_include_dirs = physical_includes;
|
||||
act.defines = effective_defines;
|
||||
act.compile_options = tu_opts;
|
||||
act.cxx_standard = mod_std;
|
||||
act.cxx_standard = tu_std;
|
||||
act.lto = eff_lto;
|
||||
act.sanitizers = eff_sans;
|
||||
act.position_independent = pic;
|
||||
@@ -1516,6 +1723,20 @@ lower_project_graph(const ProjectDescription &description,
|
||||
act.action_key = compute_action_key(act, graph);
|
||||
for (const auto &prov : node.provides) {
|
||||
provider_action_by_module[prov] = act.id;
|
||||
tc.exported_module_bmis[prov] = node.bmi_output_path;
|
||||
tc.exported_module_action_ids[prov] = act.id;
|
||||
}
|
||||
if (!node.provides.empty()) {
|
||||
for (const auto &[imp_m, imp_bmi] : node.imported_bmis) {
|
||||
tc.exported_module_bmis.try_emplace(imp_m, imp_bmi);
|
||||
if (const auto pit = provider_action_by_module.find(imp_m);
|
||||
pit != provider_action_by_module.end()) {
|
||||
tc.exported_module_action_ids.try_emplace(imp_m, pit->second);
|
||||
} else if (const auto epit = external_module_action_ids.find(imp_m);
|
||||
epit != external_module_action_ids.end()) {
|
||||
tc.exported_module_action_ids.try_emplace(imp_m, epit->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
compile_action_ids.push_back(act.id);
|
||||
tc.object_files.push_back(obj_path);
|
||||
@@ -1545,7 +1766,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
breq.include_dirs = physical_includes;
|
||||
breq.defines = effective_defines;
|
||||
breq.compile_options = bmi_opts;
|
||||
breq.cxx_standard = mod_std;
|
||||
breq.cxx_standard = tu_std;
|
||||
breq.lto = eff_lto;
|
||||
breq.sanitizers = eff_sans;
|
||||
breq.position_independent = pic;
|
||||
@@ -1596,6 +1817,21 @@ lower_project_graph(const ProjectDescription &description,
|
||||
const std::string bmi_act_id = bmi_act.id;
|
||||
for (const auto &prov : node.provides) {
|
||||
provider_action_by_module[prov] = bmi_act_id;
|
||||
tc.exported_module_bmis[prov] = node.bmi_output_path;
|
||||
tc.exported_module_action_ids[prov] = bmi_act_id;
|
||||
}
|
||||
for (const auto &[imp_m, imp_bmi] : clang_imports) {
|
||||
if (imp_m.empty()) {
|
||||
continue;
|
||||
}
|
||||
tc.exported_module_bmis.try_emplace(imp_m, imp_bmi);
|
||||
if (const auto pit = provider_action_by_module.find(imp_m);
|
||||
pit != provider_action_by_module.end()) {
|
||||
tc.exported_module_action_ids.try_emplace(imp_m, pit->second);
|
||||
} else if (const auto epit = external_module_action_ids.find(imp_m);
|
||||
epit != external_module_action_ids.end()) {
|
||||
tc.exported_module_action_ids.try_emplace(imp_m, epit->second);
|
||||
}
|
||||
}
|
||||
summary.action_ids.push_back(bmi_act_id);
|
||||
graph.action_index_by_id[bmi_act_id] = graph.actions.size();
|
||||
@@ -1606,7 +1842,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
oreq.source_file = node.bmi_output_path;
|
||||
oreq.output_object = obj_path;
|
||||
oreq.response_file_dir = rsp_root;
|
||||
oreq.cxx_standard = mod_std;
|
||||
oreq.cxx_standard = tu_std;
|
||||
oreq.lto = eff_lto;
|
||||
oreq.sanitizers = eff_sans;
|
||||
oreq.position_independent = pic;
|
||||
@@ -1661,7 +1897,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
req.include_dirs = physical_includes;
|
||||
req.defines = effective_defines;
|
||||
req.compile_options = cu.tu_opts;
|
||||
req.cxx_standard = mod_std;
|
||||
req.cxx_standard = tu_std;
|
||||
req.lto = eff_lto;
|
||||
req.sanitizers = eff_sans;
|
||||
req.position_independent = pic;
|
||||
@@ -1703,7 +1939,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
act.physical_include_dirs = physical_includes;
|
||||
act.defines = effective_defines;
|
||||
act.compile_options = cu.tu_opts;
|
||||
act.cxx_standard = mod_std;
|
||||
act.cxx_standard = tu_std;
|
||||
act.lto = eff_lto;
|
||||
act.sanitizers = eff_sans;
|
||||
act.position_independent = pic;
|
||||
@@ -1725,101 +1961,9 @@ lower_project_graph(const ProjectDescription &description,
|
||||
}
|
||||
} else {
|
||||
for (const auto &cu : compile_units) {
|
||||
const std::string src_hash =
|
||||
Util::sha256_hex(cu.logical_src.string()).substr(0, 12);
|
||||
const auto obj_path = objects_root / sanitize_id_component(t.name) /
|
||||
(sanitize_id_component(cu.logical_src.filename().string()) +
|
||||
"_" + src_hash + ".o");
|
||||
const auto dep_path = std::filesystem::path{obj_path.string() + ".d"};
|
||||
|
||||
Toolchain::CompileRequest req;
|
||||
req.source_file = cu.physical_src;
|
||||
req.output_object = obj_path;
|
||||
req.depfile = dep_path;
|
||||
req.response_file_dir = rsp_root;
|
||||
req.include_dirs = physical_includes;
|
||||
req.defines = effective_defines;
|
||||
req.compile_options = cu.tu_opts;
|
||||
req.cxx_standard =
|
||||
(!header_unit_bmi_paths.empty() && eff_std == CxxStandard::Default)
|
||||
? CxxStandard::Cxx20
|
||||
: eff_std;
|
||||
req.lto = eff_lto;
|
||||
req.sanitizers = eff_sans;
|
||||
req.position_independent = pic;
|
||||
req.precompiled_header = pch_include_prefix;
|
||||
req.prefix_maps = prefix_maps;
|
||||
req.reproducibility_epoch = description.profile.reproducibility_epoch;
|
||||
req.nondeterministic = t.nondeterministic || description.profile.nondeterministic;
|
||||
req.response_file_threshold = options.response_file_threshold;
|
||||
if (shared_hu_mapper) {
|
||||
req.module_mapper_file = shared_hu_mapper;
|
||||
} else if (!header_unit_bmi_paths.empty() &&
|
||||
toolchain.family == CompilerFamily::Clang) {
|
||||
for (const auto &hb : header_unit_bmi_paths) {
|
||||
req.module_bmi_imports.emplace_back(std::string{}, hb);
|
||||
}
|
||||
if (auto r = emit_regular_compile_action(cu); !r) {
|
||||
return std::unexpected{r.error()};
|
||||
}
|
||||
|
||||
auto lowered = Toolchain::lower_compile_command(toolchain, req);
|
||||
if (!lowered) {
|
||||
return std::unexpected{lowered.error()};
|
||||
}
|
||||
|
||||
ActionNode act;
|
||||
act.id = "compile:" + sanitize_id_component(t.name) + ":" + src_hash;
|
||||
act.kind = ActionKind::Compile;
|
||||
act.target_name = t.name;
|
||||
act.executable = lowered->executable;
|
||||
act.arguments = std::move(lowered->arguments);
|
||||
act.environment = std::move(lowered->environment);
|
||||
act.working_directory = canonical_root;
|
||||
act.response_file = lowered->response_file;
|
||||
act.response_file_content = std::move(lowered->response_file_content);
|
||||
act.declared_inputs = {cu.physical_src};
|
||||
for (const auto &hb : header_unit_bmi_paths) {
|
||||
act.declared_inputs.push_back(hb);
|
||||
}
|
||||
if (shared_hu_mapper) {
|
||||
act.declared_inputs.push_back(*shared_hu_mapper);
|
||||
}
|
||||
act.declared_outputs = {obj_path};
|
||||
act.depfile = dep_path;
|
||||
act.logical_source_file = cu.logical_src;
|
||||
act.physical_source_file = cu.physical_src;
|
||||
act.logical_output_file = obj_path;
|
||||
act.physical_output_file = obj_path;
|
||||
act.logical_include_dirs = effective_includes;
|
||||
act.physical_include_dirs = physical_includes;
|
||||
act.defines = effective_defines;
|
||||
act.compile_options = cu.tu_opts;
|
||||
act.cxx_standard = req.cxx_standard;
|
||||
act.lto = eff_lto;
|
||||
act.sanitizers = eff_sans;
|
||||
act.position_independent = pic;
|
||||
act.precompiled_header = pch_include_prefix;
|
||||
act.dependencies = target_prereq_actions;
|
||||
if (pch_action_id) {
|
||||
add_unique_str(act.dependencies, *pch_action_id);
|
||||
}
|
||||
for (const auto &huid : header_unit_action_ids) {
|
||||
add_unique_str(act.dependencies, huid);
|
||||
}
|
||||
if (const auto prod_it = output_owner.find(cu.logical_src);
|
||||
prod_it != output_owner.end()) {
|
||||
add_unique_str(act.dependencies, prod_it->second);
|
||||
}
|
||||
act.nondeterministic = req.nondeterministic;
|
||||
act.cacheable = !act.nondeterministic;
|
||||
if (auto reg = register_output(obj_path, act.id); !reg) {
|
||||
return std::unexpected{reg.error()};
|
||||
}
|
||||
act.action_key = compute_action_key(act, graph);
|
||||
compile_action_ids.push_back(act.id);
|
||||
tc.object_files.push_back(obj_path);
|
||||
summary.action_ids.push_back(act.id);
|
||||
graph.action_index_by_id[act.id] = graph.actions.size();
|
||||
graph.actions.push_back(std::move(act));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1938,6 +2082,7 @@ lower_project_graph(const ProjectDescription &description,
|
||||
graph.actions.push_back(std::move(act));
|
||||
}
|
||||
|
||||
summary.exported_module_bmis = tc.exported_module_bmis;
|
||||
computed[t.name] = std::move(tc);
|
||||
graph.targets.push_back(std::move(summary));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user