Skip to content

Commit de0dc78

Browse files
committed
toolset: the chain's PATH is the tools' own directories, not the engine's whole PATH
The engine's tool_env PATH is the cl.exe directory followed by the PATH of the process that ran mcpp. Under Git Bash that carries Git's msys tools and runtime, and icu's configure, run by vcpkg with that PATH kept, failed with 'invalid variable name: 0'. The toolset's and the SDK's binary directories are what a foreign system needs, as the design's measurement M3c kept.
1 parent 0e7e99d commit de0dc78

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

‎src/toolset.cppm‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ struct resolved_tools {
6969
// `chain` on the MSVC ABI: the environment the tools run with, without
7070
// PATH (INCLUDE, LIB, LIBPATH, ...).
7171
std::vector<std::pair<std::string, std::string>> env;
72-
// `chain`: the directories that go first on PATH, in order, without
73-
// duplicates: the tools' own directories, then the environment's PATH.
72+
// `chain`: the tools' own directories, in order, without duplicates: the
73+
// PATH a foreign system needs for them.
7474
std::vector<std::string> path_dirs;
7575
std::string identity; // toolset_identity(): "msvc 14.44.35207; sdk 10.0.26100.0", "clang 22.1.8"
7676
std::string crt; // msvc_crt_linkage(): "static", "dynamic", or empty off the MSVC ABI
@@ -175,22 +175,16 @@ inline std::expected<resolved_tools, std::string> chain(const choice& c, resolve
175175
c.cc == compiler::abi_native ? "ABI-native" : "row", std::string(mcpp::target())));
176176
if (r.cc.empty()) r.cc = r.cxx;
177177
if (r.msvc_abi) {
178-
auto env = parse_env(mcpp::tool_env());
179-
const std::string path = env_value(env, "PATH");
180-
for (auto const& kv : env) if (!same_key(kv.first, "PATH")) r.env.push_back(kv);
178+
// The environment WITHOUT its PATH. The engine's PATH is the cl.exe
179+
// directory followed by the whole PATH of the process that ran mcpp --
180+
// under Git Bash that holds Git's own msys tools and runtime, and a
181+
// make-based port configured against them failed (`configure: error:
182+
// invalid variable name: '0'`, icu, the plugins' CI). The tools'
183+
// own directories are the PATH a foreign system needs: the toolset's
184+
// bin (cl, link, lib) and the SDK's (rc, mt).
185+
for (auto const& kv : parse_env(mcpp::tool_env()))
186+
if (!same_key(kv.first, "PATH")) r.env.push_back(kv);
181187
for (auto const* t : { &r.cxx, &r.cc, &r.ld, &r.rc, &r.mt }) add_dir(r.path_dirs, *t);
182-
// The environment's PATH carries the SDK's and the toolset's binary
183-
// directories; its entries follow the tools' own, in its order.
184-
std::string_view rest = path;
185-
while (!rest.empty()) {
186-
const auto semi = rest.find(';');
187-
const std::string entry = forward(rest.substr(0, semi));
188-
rest = semi == std::string_view::npos ? std::string_view{} : rest.substr(semi + 1);
189-
if (entry.empty()) continue;
190-
bool seen = false;
191-
for (auto const& d : r.path_dirs) if (same_key(d, entry)) { seen = true; break; }
192-
if (!seen) r.path_dirs.push_back(entry);
193-
}
194188
} else {
195189
for (auto const* t : { &r.cxx, &r.cc }) add_dir(r.path_dirs, *t);
196190
}

0 commit comments

Comments
 (0)