Remove obsolete debug checks.
Now that stamp files are replaced by phony Ninja targets, it is
perfectly possible for a target to not generate any Ninja rule,
so remove a DCHECK() call that caused a debug version of GN to
assert at runtime when processing a Chromium build graph.
Also remove a NOTREACHED() statement when expanding C++ specific
substitution expressions (e.g. {{cflags}} or {{include_dirs}})
that are used in action() targets, such as those expanded by
the nocompile_source_set() Chromium template. This also caused
the debug version of GN to assert at runtime.
Comparison of the generated Ninja build plan after/before this
CL shows no difference for a regular Chromium Linux/x64
configuration.
Fixed: 388100196
Change-Id: Iebc465517ea866cb35b724080058f995f885597b
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/18280
Commit-Queue: David Turner <digit@google.com>
Reviewed-by: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/command_gen.cc b/src/gn/command_gen.cc
index ac94487..f997086 100644
--- a/src/gn/command_gen.cc
+++ b/src/gn/command_gen.cc
@@ -109,12 +109,12 @@
std::string rule =
NinjaTargetWriter::RunAndWriteFile(target, resolved, ninja_outputs);
- DCHECK(!rule.empty());
-
{
std::lock_guard<std::mutex> lock(write_info->lock);
- write_info->rules[target->toolchain()].emplace_back(target,
- std::move(rule));
+ if (!rule.empty()) {
+ write_info->rules[target->toolchain()].emplace_back(target,
+ std::move(rule));
+ }
if (write_info->want_ninja_outputs) {
write_info->ninja_outputs_map.emplace(target,
diff --git a/src/gn/substitution_writer.cc b/src/gn/substitution_writer.cc
index c9624d7..a1f0254 100644
--- a/src/gn/substitution_writer.cc
+++ b/src/gn/substitution_writer.cc
@@ -384,8 +384,10 @@
} else if (IsValidRustSubstitution(type)) {
to_rebase = source.value();
} else {
- NOTREACHED() << "Unsupported substitution for this function: "
- << type->name;
+ // Do not add NOTREACHED() statement here, as Chromium
+ // nobuild_source_set() templates rely on passing {{cflags}}
+ // substitution expressions (and other C++ specific ones)
+ // to action_foreach(). See https://gn.issues.chromium.org/388100196.
return std::string();
}