Skip to content

Commit 9a2ff4b

Browse files
committed
rules: cuda, hip and sycl gain the flag pass-through ascendc already had
`mcpp.tools.island::force_include_flags` returns the flags that make a compiler read the generated boundary header before the island's first line, and three of the four device rules had no way to deliver them. Measured on `examples/09-heterogeneous/cuda`: the island is compiled by nvcc, or by clang in CUDA mode, on a command line the rule assembles -- a driver mcpp did not invoke, which inherits nothing from `mcpp::cflag` or `mcpp::cxxflag`. The project-wide channels are not merely too wide for the job, they are wrong for it. `cxxflag` forces the header into every C++ translation unit, including the seam `src/app.cppm`, and a module interface unit must begin with `export module` -- declarations ahead of that line are ill-formed. `mcpp.rules.ascendc` already had `options::flags`, appended last. The other three now carry the same field with the same position and the same pass-through-unexamined contract, because one rule with it and three without is the shape where a project's build program works for one backend and not the next -- which is what a seam exists to prevent. Verified end to end on this host: the cuda example's island compiles with `-include .../app.kernels.h` on its own command line, and the artifact runs on an RTX 4080.
1 parent bf81b35 commit 9a2ff4b

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎rules/cuda.cppm‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ struct options {
9797
// dependency's directory here, and it knows it only as the absolute path
9898
// `mcpp::dep_dir` answered with.
9999
std::vector<std::string> includes;
100+
// FLAGS FOR THE ISLAND'S COMPILER, PASSED THROUGH UNEXAMINED.
101+
//
102+
// A device compiler is a separate driver with its own command line, and
103+
// `mcpp::cflag`/`mcpp::cxxflag` reach mcpp's compiler rather than this one.
104+
// The case this exists for is `mcpp.tools.island`, whose
105+
// `force_include_flags` makes the island read its generated boundary header
106+
// before its first line -- so the island names no generated file and the
107+
// project has no header of its own. Project-wide flags cannot do that job:
108+
// forcing a header into every C++ translation unit puts declarations ahead
109+
// of `export module`, which no module interface unit accepts.
110+
std::vector<std::string> flags;
100111
std::string out_dir = std::string(mcpp::out_dir());
101112
};
102113

@@ -728,6 +739,7 @@ inline std::vector<edge> plan(std::span<const std::string> sources, options opt
728739
for (auto const& inc : opt.includes)
729740
e.command.push_back("-I" + (std::filesystem::path(inc).is_absolute()
730741
? inc : root + "/" + inc));
742+
for (auto const& f : opt.flags) e.command.push_back(f);
731743
e.command.insert(e.command.end(), { "-c", root + "/" + src, "-o", obj });
732744
e.inputs = { root + "/" + src };
733745
e.outputs = { obj };

‎rules/hip.cppm‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ struct options {
6969
// the form `mcpp::dep_dir` answers with -- a device compiler is a separate
7070
// driver and inherits nothing from the C++ side's include configuration.
7171
std::vector<std::string> includes;
72+
// FLAGS FOR THE ISLAND'S COMPILER, PASSED THROUGH UNEXAMINED.
73+
//
74+
// A device compiler is a separate driver with its own command line, and
75+
// `mcpp::cflag`/`mcpp::cxxflag` reach mcpp's compiler rather than this one.
76+
// The case this exists for is `mcpp.tools.island`, whose
77+
// `force_include_flags` makes the island read its generated boundary header
78+
// before its first line -- so the island names no generated file and the
79+
// project has no header of its own. Project-wide flags cannot do that job:
80+
// forcing a header into every C++ translation unit puts declarations ahead
81+
// of `export module`, which no module interface unit accepts.
82+
std::vector<std::string> flags;
7283
std::string out_dir = std::string(mcpp::out_dir());
7384
};
7485

@@ -420,6 +431,7 @@ inline std::vector<edge> plan(std::span<const std::string> sources, options opt
420431
for (auto const& inc : opt.includes)
421432
e.command.push_back("-I" + (std::filesystem::path(inc).is_absolute()
422433
? inc : root + "/" + inc));
434+
for (auto const& f : opt.flags) e.command.push_back(f);
423435
e.command.insert(e.command.end(), { "-c", root + "/" + src, "-o", obj });
424436
e.inputs = { root + "/" + src };
425437
e.outputs = { obj };

‎rules/sycl.cppm‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ struct options {
9898
// Header search paths for the island. Relative entries resolve against the
9999
// package root; an ABSOLUTE entry is passed through unchanged.
100100
std::vector<std::string> includes;
101+
// FLAGS FOR THE ISLAND'S COMPILER, PASSED THROUGH UNEXAMINED.
102+
//
103+
// A device compiler is a separate driver with its own command line, and
104+
// `mcpp::cflag`/`mcpp::cxxflag` reach mcpp's compiler rather than this one.
105+
// The case this exists for is `mcpp.tools.island`, whose
106+
// `force_include_flags` makes the island read its generated boundary header
107+
// before its first line -- so the island names no generated file and the
108+
// project has no header of its own. Project-wide flags cannot do that job:
109+
// forcing a header into every C++ translation unit puts declarations ahead
110+
// of `export module`, which no module interface unit accepts.
111+
std::vector<std::string> flags;
101112
// An explicit compiler path wins over the payload. Set it when a project
102113
// pins a DPC++ other than the one the workspace installed.
103114
std::string compiler;
@@ -483,6 +494,7 @@ inline std::vector<edge> plan(std::span<const std::string> sources, options opt
483494
for (auto const& inc : opt.includes)
484495
e.command.push_back("-I" + (std::filesystem::path(inc).is_absolute()
485496
? inc : root + "/" + inc));
497+
for (auto const& f : opt.flags) e.command.push_back(f);
486498
// `-x c++` is not optional. `.sycl` is this ecosystem's spelling and
487499
// no compiler knows it; without this the driver classifies the file as
488500
// a LINKER INPUT, warns `'linker' input unused`, exits 0 and produces

0 commit comments

Comments
 (0)