Skip to content

Commit 68958da

Browse files
committed
fix(hermetic): allow the canonical xpkgs registry for symlink-inherited payloads
mcpp passes symlink-view paths on the command line, but the clang driver reports its own resource dir (clang_rt.crt*) through the canonical path; with payloads symlink-inherited from another MCPP_HOME (the e2e isolation pattern) that canonical registry must be allowed too.
1 parent c744163 commit 68958da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/build/hermetic.cppm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ std::expected<void, std::string> verify_hermetic_link(
116116
if (xpkgsPos == std::string::npos) return {};
117117
std::vector<std::filesystem::path> allowed;
118118
allowed.emplace_back(binStr.substr(0, xpkgsPos + 5)); // the xpkgs root
119+
// Payloads may be symlink-inherited from another MCPP_HOME (the e2e
120+
// isolation pattern): mcpp passes the symlink-view paths on the command
121+
// line, but the driver reports its own resource dir (clang_rt.crt*)
122+
// through the CANONICAL path. Allow that registry too.
123+
{
124+
std::error_code ec;
125+
auto canon = std::filesystem::weakly_canonical(tc.binaryPath, ec).string();
126+
auto pos = ec ? std::string::npos : canon.find("xpkgs");
127+
if (pos != std::string::npos)
128+
allowed.emplace_back(canon.substr(0, pos + 5));
129+
}
119130
if (!tc.sysroot.empty()) allowed.push_back(tc.sysroot);
120131

121132
if (const char* e = std::getenv("MCPP_ALLOW_HOST_LIBS"); e && *e && *e != '0')

0 commit comments

Comments
 (0)