Skip to content

Commit 692be93

Browse files
committed
fix(opencv): wire glibc + linux-headers include dirs via CPATH (host-free headers)
With LIBRARY_PATH fixed, the build advances to compiling 3rdparty (libjpeg-turbo, zlib) then fails: 'stdlib.h / limits.h: No such file'. Same gap as the LINK env but for HEADERS — gcc's specs don't add xim:glibc's include (nor xim:linux-headers uapi) to the search path; mcpp's build supplies it via CPATH, not inherited by install(). Export CPATH=<glibc>/include:<linux-headers>/include for the cmake steps and declare xim:linux-headers@5.11.1 so pkginfo can resolve it. Fully host-free.
1 parent cdb6eb1 commit 692be93

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

pkgs/c/compat.opencv.lua

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ package = {
5050
-- xim:glibc is declared explicitly (though transitively pulled by
5151
-- cmake/gcc) so install() can resolve its lib dir via pkginfo for the
5252
-- LINK-time LIBRARY_PATH (crt1.o/crti.o/libm) — see install() below.
53-
deps = { "xim:cmake@4.0.2", "xim:make@latest", "xim:gcc@16.1.0", "xim:glibc@2.39" },
53+
deps = { "xim:cmake@4.0.2", "xim:make@latest", "xim:gcc@16.1.0",
54+
"xim:glibc@2.39", "xim:linux-headers@5.11.1" },
5455
["4.13.0"] = {
5556
-- Plain-string GLOBAL url (no CN mirror table): this session lacks
5657
-- mcpp-res write access. Per the add-package skill, CN users fall
@@ -182,17 +183,29 @@ local function _install_impl()
182183
-- Point gcc at xim:glibc/lib (+ xim:gcc/lib64 for libgcc_s) via LIBRARY_PATH so
183184
-- the build resolves the ecosystem glibc and stays host-free. (openblas never
184185
-- hit this: it only compiles + archives a .a, it never LINKS an executable.)
186+
-- Same gap on the HEADER side: gcc's own limits.h does `#include_next
187+
-- <limits.h>` and the C sources pull <stdlib.h> etc., all from xim:glibc's
188+
-- include dir (+ the kernel uapi headers from xim:linux-headers). gcc's specs
189+
-- do NOT add these to the header search path; mcpp's build supplies them via
190+
-- CPATH, which an install() subprocess doesn't inherit -> "stdlib.h / limits.h:
191+
-- No such file". Point CPATH at both so the build is host-free.
185192
local glibc_dir = pkginfo.install_dir("xim:glibc", "2.39")
186193
or pkginfo.install_dir("glibc", "2.39")
187194
local gcc_dir = pkginfo.install_dir("xim:gcc", "16.1.0")
188195
or pkginfo.install_dir("gcc", "16.1.0")
189-
local libpaths = {}
190-
if glibc_dir then table.insert(libpaths, path.join(glibc_dir, "lib")) end
196+
local kern_dir = pkginfo.install_dir("xim:linux-headers", "5.11.1")
197+
or pkginfo.install_dir("scode:linux-headers", "5.11.1")
198+
or pkginfo.install_dir("linux-headers", "5.11.1")
199+
local libpaths, incpaths = {}, {}
200+
if glibc_dir then table.insert(libpaths, path.join(glibc_dir, "lib"))
201+
table.insert(incpaths, path.join(glibc_dir, "include")) end
191202
if gcc_dir then table.insert(libpaths, path.join(gcc_dir, "lib64")) end
192-
if #libpaths == 0 then
193-
error("compat.opencv: cannot resolve xim:glibc / xim:gcc lib dirs for the LINK env")
203+
if kern_dir then table.insert(incpaths, path.join(kern_dir, "include")) end
204+
if #libpaths == 0 or #incpaths == 0 then
205+
error("compat.opencv: cannot resolve xim:glibc / xim:gcc / xim:linux-headers dirs for the build env")
194206
end
195-
local libenv = "export LIBRARY_PATH=" .. sh_quote(table.concat(libpaths, ":")) .. " && "
207+
local libenv = "export LIBRARY_PATH=" .. sh_quote(table.concat(libpaths, ":"))
208+
.. " CPATH=" .. sh_quote(table.concat(incpaths, ":")) .. " && "
196209

197210
-- Move the extracted tree INTO the install dir (this CREATES prefix — xim's
198211
-- restricted Lua has no os.mkdir; os.cd is the only dir primitive, same as

0 commit comments

Comments
 (0)