@@ -1356,9 +1356,29 @@ ExecutionHost locate_run_under(const mcpp::build::BuildContext& ctx, std::string
13561356// and the OS run only there. `--no-runner` states that the triple is native
13571357// here, and is believed.
13581358std::optional<std::string> unreachable_execution (const mcpp::build::BuildContext& ctx,
1359- std::string_view tripleKey, bool noRunner) {
1359+ std::string_view tripleKey, bool noRunner,
1360+ bool runnerDeclared = false ) {
13601361 if (noRunner || !ctx.runUnder .empty ()) return std::nullopt ;
13611362 auto t = mcpp::toolchain::triple::parse (tripleKey);
1363+ // AN ARTIFACT OF A SYSTEM A PLATFORM DEFINES runs where its row's
1364+ // `execution` names (mcpp#911 G11): on this machine when that is this
1365+ // machine's system, else through a runner -- a runner package's program,
1366+ // which reaches a VM, a remote host or a device by the run protocol
1367+ // (docs/41) -- or an execution host. With neither it is built, not run.
1368+ if (auto const * d = t ? t->defined () : nullptr ; d && !runnerDeclared) {
1369+ const std::string_view system = d->execution .empty () ? std::string_view (t->os ) : d->execution ;
1370+ const std::string_view here = mcpplibs::os::is_windows ? " windows"
1371+ : mcpplibs::os::is_macos ? " macos" : " linux" ;
1372+ if (system != here)
1373+ return std::format (
1374+ " {} artifacts run on {}, not on this {} host: built, not run.\n "
1375+ " State how they run: [target.{}] runner = [\" <program>\" , \" {{}}\" ], the program a "
1376+ " runner package builds\n "
1377+ " ([target.{}.tools] <program> = {{ ... }}; the run protocol is docs/41), or an "
1378+ " execution host:\n "
1379+ " [target.{}] run_under = [\" remote-run\" , \" <host>\" , \" --\" ]." ,
1380+ tripleKey, system, here, tripleKey, tripleKey, tripleKey);
1381+ }
13621382 // A RUNNER THAT RUNS THE ARTIFACT ON A MACHINE OF ITS ARCHITECTURE
13631383 // (`runner = { ..., host = "same-arch" }`, SPEC-013): an ok image's loader
13641384 // is a program of this machine, and an image of another architecture is
@@ -1534,7 +1554,7 @@ export RunnerOnThisMachine runner_on_this_machine(const BuildContext& ctx) {
15341554 RunnerOnThisMachine out;
15351555 const auto choice = choose_runner (ctx);
15361556 out.arch = std::string (mcpp::toolchain::platform::host_arch);
1537- if (auto why = unreachable_execution (ctx, choice.tripleKey , false )) out.refusal = *why;
1557+ if (auto why = unreachable_execution (ctx, choice.tripleKey , false , !choice. tmpl . empty () )) out.refusal = *why;
15381558 if (!ctx.runUnder .empty ()) {
15391559 auto host = locate_run_under (ctx, choice.tripleKey );
15401560 if (!host.error .empty ()) out.refusal = host.error ;
@@ -3317,7 +3337,7 @@ int run_artifact_via_runner(mcpp::build::BuildContext& ctx,
33173337 return 126 ;
33183338 }
33193339 if (isRunSlot) {
3320- if (auto why = unreachable_execution (ctx, choice.tripleKey , no_runner)) {
3340+ if (auto why = unreachable_execution (ctx, choice.tripleKey , no_runner, !choice. tmpl . empty () )) {
33213341 std::println (libc::stderr (), " error: {}" , *why);
33223342 return 2 ;
33233343 }
@@ -3504,8 +3524,9 @@ std::optional<ChosenLeg> choose_run_leg(std::span<const mcpp::toolchain::target_
35043524 mcpp::ui::error (std::format (" the {} leg: {}" , leg->triple , ctx.error ()));
35053525 return std::nullopt ;
35063526 }
3507- const auto key = choose_runner (*ctx, noRunner).tripleKey ;
3508- if (auto why = unreachable_execution (*ctx, key, noRunner)) {
3527+ const auto chosen = choose_runner (*ctx, noRunner);
3528+ const auto key = chosen.tripleKey ;
3529+ if (auto why = unreachable_execution (*ctx, key, noRunner, !chosen.tmpl .empty ())) {
35093530 passed.push_back (std::format (" {}: {}" , leg->triple , why->substr (0 , why->find (' \n ' ))));
35103531 continue ;
35113532 }
@@ -4463,7 +4484,8 @@ static void test_resolve_runner(TestBuild& tb, const TestOptions& testOpts, bool
44634484 }
44644485 // Not run, with the reason, as a missing runner is: the tests built. Or,
44654486 // where the caller asks, built and not run (a platform package's targets).
4466- if (auto why = unreachable_execution (*ctx, runnerChoice.tripleKey , testOpts.noRunner )) {
4487+ if (auto why = unreachable_execution (*ctx, runnerChoice.tripleKey , testOpts.noRunner ,
4488+ !runnerChoice.tmpl .empty ())) {
44674489 if (testOpts.unreachableIsBuilt ) {
44684490 tb.builtNotRunHere = true ;
44694491 if (!json) mcpp::ui::info (" note" , std::format (" built, not run on this host: {}" , *why));
0 commit comments