Skip to content

Commit 37ae194

Browse files
committed
fix(openssl): the xlings sandbox has no os.curdir(), and an unknown call kills install() silently
The diagnostic log added last commit did its job on the first run and contained exactly one line: [mcpp] windows install() start; prefix=D:\a\...\compat-x-openssl\3.5.1 i.e. install() died on the very next statement, os.curdir(), with no message anywhere — not in the job log, not in xlings' error, which stayed a bare E_INTERNAL. The xlings sandbox exposes a SUBSET of xmake's Lua API, and calling outside it terminates the hook silently. That is a nasty failure mode to debug blind, so it is now structural rather than a one-off fix: os.curdir() is gone, and every remaining call that might not be in the sandbox (pkginfo.install_file, os.filedirs, path.absolute, os.files) goes through a `safe` helper that pcalls it and writes 'call failed: <name> -> <error>' into the log with a fallback value.
1 parent fe2a6cf commit 37ae194

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

pkgs/c/compat.openssl.lua

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,22 @@ local function _install_windows_impl()
418418
if fh then fh:write("[mcpp] " .. tostring(msg) .. "\n"); fh:close() end
419419
end
420420
note("windows install() start; prefix=" .. tostring(prefix))
421-
note("cwd=" .. tostring(os.curdir()))
422421

423-
local ifile = pkginfo.install_file()
422+
-- Every call below goes through this. The xlings sandbox exposes a SUBSET
423+
-- of xmake's Lua API, and calling something outside it kills install()
424+
-- silently — the first attempt died on os.curdir() with no message at all,
425+
-- leaving only the line above in the log. `safe` turns that class of
426+
-- failure into a log line naming the call.
427+
local function safe(label, fn, fallback)
428+
local ok, res = pcall(fn)
429+
if not ok then
430+
note("call failed: " .. label .. " -> " .. tostring(res))
431+
return fallback
432+
end
433+
return res
434+
end
435+
436+
local ifile = safe("pkginfo.install_file()", function() return pkginfo.install_file() end)
424437
note("install_file=" .. tostring(ifile))
425438
local srcroot = ifile and tostring(ifile):replace(".tar.gz", "")
426439
or ("openssl-" .. pkginfo.version())
@@ -429,12 +442,13 @@ local function _install_windows_impl()
429442
srcroot = "openssl-" .. pkginfo.version()
430443
end
431444
if not os.isdir(srcroot) then
432-
note("FATAL: no source dir found; entries in cwd:")
433-
for _, f in ipairs(os.filedirs("*")) do note(" " .. tostring(f)) end
445+
note("FATAL: no source dir found. Entries beside it:")
446+
local entries = safe("os.filedirs('*')", function() return os.filedirs("*") end, {})
447+
for _, f in ipairs(entries) do note(" " .. tostring(f)) end
434448
return false
435449
end
436-
srcroot = path.absolute(srcroot)
437-
note("srcroot=" .. srcroot)
450+
srcroot = safe("path.absolute(srcroot)", function() return path.absolute(srcroot) end, srcroot)
451+
note("srcroot=" .. tostring(srcroot))
438452

439453
-- vswhere is installed with every VS 2017+ at a fixed location, and is the
440454
-- supported way to find the toolset; hardcoding a VS path breaks on the
@@ -480,7 +494,8 @@ local function _install_windows_impl()
480494
local libdir = path.join(prefix, "lib")
481495
note("checking " .. libdir)
482496
if os.isdir(libdir) then
483-
for _, f in ipairs(os.files(path.join(libdir, "*"))) do note(" lib/ " .. tostring(f)) end
497+
local produced = safe("os.files(lib/*)", function() return os.files(path.join(libdir, "*")) end, {})
498+
for _, f in ipairs(produced) do note(" lib/ " .. tostring(f)) end
484499
else
485500
note(" (no lib/ directory was produced)")
486501
end

0 commit comments

Comments
 (0)