diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0001-Fix-mapping-of-library-paths-for-jetson-mounts.patch b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0001-Fix-mapping-of-library-paths-for-jetson-mounts.patch deleted file mode 100644 index ca33406a..00000000 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0001-Fix-mapping-of-library-paths-for-jetson-mounts.patch +++ /dev/null @@ -1,180 +0,0 @@ -From 695d38e6fb2b4e0b3e2cbf4e86aaab63d12a8935 Mon Sep 17 00:00:00 2001 -From: Ilies CHERGUI -Date: Sun, 8 Aug 2021 21:40:36 +0100 -Subject: [PATCH 1/3] Fix mapping of library paths for jetson mounts - -Signed-off-by: Matt Madison -Signed-off-by: Ilies CHERGUI ---- - src/jetson_mount.c | 70 ++++++++++++++++++++++++++++++++++++++++------ - src/jetson_mount.h | 2 +- - src/nvc_mount.c | 4 +-- - 3 files changed, 64 insertions(+), 12 deletions(-) - -diff --git a/src/jetson_mount.c b/src/jetson_mount.c -index 1c5d9de9..5cf94c81 100644 ---- a/src/jetson_mount.c -+++ b/src/jetson_mount.c -@@ -18,6 +18,9 @@ - #include "utils.h" - #include "xfuncs.h" - #include "jetson_mount.h" -+#define stringify(s__) stringify__(s__) -+#define stringify__(s__) #s__ -+static const char *hostlibdir = stringify(HOST_LIBDIR) "/"; - - static int - resolve_symlink(struct error *err, const char *src, char *dst) -@@ -34,30 +37,69 @@ resolve_symlink(struct error *err, const char *src, char *dst) - } - - char ** --mount_jetson_files(struct error *err, const char *root, const struct nvc_container *cnt, char *paths[], size_t size) -+mount_jetson_files(struct error *err, const char *root, const struct nvc_container *cnt, const char *dir, char *paths[], size_t size) - { - char src[PATH_MAX]; - char dst[PATH_MAX]; - mode_t mode; - char **mnt, **ptr; -+ char *file; - - mnt = ptr = array_new(err, size + 1); /* NULL terminated. */ - if (mnt == NULL) - return (NULL); - - for (size_t i = 0; i < size; ++i) { -+ int samepath = 0; - if (!match_jetson_library_flags(paths[i], cnt->flags) && - !match_jetson_directory_flags(paths[i], cnt->flags)) - continue; - - if (path_new(err, src, root) < 0) - goto fail; -- if (path_new(err, dst, cnt->cfg.rootfs) < 0) -- goto fail; - -+ if (dir != NULL) { -+ size_t hostlibdirlen = strlen(hostlibdir); -+ /* -+ * Special hackery to handle the case where the host does -+ * *not* use debian multiarch by default but has files located -+ * under the /usr/lib/aarch64-linux-gnu directory to satisfy -+ * some compiled-in hard-coded paths in NVIDIA binaries that -+ * assume debian multiarch. -+ * -+ * Also don't move to the container's libdir if the path of -+ * the file we're mounting is *not* under the host libdir. -+ */ -+ if (!str_has_prefix(paths[i], hostlibdir) || -+ (strcmp(hostlibdir, dir) != 0 && str_has_prefix(paths[i], dir))) { -+ samepath = 1; -+ if (path_new(err, dst, cnt->cfg.rootfs) < 0) -+ goto fail; -+ } else if (str_has_prefix(paths[i], hostlibdir) && -+ strchr(paths[i]+hostlibdirlen, '/') != NULL) { -+ char tmp[PATH_MAX], sub[PATH_MAX], *cp; -+ strcpy(sub, paths[i]+hostlibdirlen); -+ for (cp = sub + strlen(sub); cp > sub && *cp != '/'; cp--); -+ *cp = '\0'; -+ log_infof("%s: %s subpath: %s", __func__, paths[i], sub); -+ if (path_join(err, tmp, dir, sub) < 0) -+ goto fail; -+ if (path_resolve_full(err, dst, cnt->cfg.rootfs, tmp) < 0) -+ goto fail; -+ } else { -+ if (path_resolve_full(err, dst, cnt->cfg.rootfs, dir) < 0) -+ goto fail; -+ } -+ } else { -+ samepath = 1; -+ if (path_new(err, dst, cnt->cfg.rootfs) < 0) -+ goto fail; -+ } -+ -+ file = basename(paths[i]); - if (path_append(err, src, paths[i]) < 0) - goto fail; -- if (path_append(err, dst, paths[i]) < 0) -+ if (path_append(err, dst, (samepath ? paths[i] : file)) < 0) - goto fail; - - if (file_mode(err, src, &mode) < 0) -@@ -89,25 +131,35 @@ create_jetson_symlinks(struct error *err, const char *root, const struct nvc_con - char src[PATH_MAX]; - char src_lnk[PATH_MAX]; - char dst[PATH_MAX]; -+ char *file; - - for (size_t i = 0; i < size; ++i) { -+ file = basename(paths[i]); - if (!match_jetson_symlink_flags(paths[i], cnt->flags)) - continue; - - if (path_new(err, src, root) < 0) - return (-1); -- if (path_new(err, dst, cnt->cfg.rootfs) < 0) -- return (-1); - - if (path_append(err, src, paths[i]) < 0) - return (-1); -- if (path_append(err, dst, paths[i]) < 0) -- return (-1); - - if (resolve_symlink(err, src, src_lnk) < 0) - return (-1); - -- printf("src: %s, src_lnk: %s, dst: %s, dst_lnk: %s\n", src, src_lnk, dst); -+ if (str_has_prefix(file, "lib")) { -+ if (path_resolve_full(err, dst, cnt->cfg.rootfs, cnt->cfg.libs_dir) < 0) -+ return (-1); -+ if (path_append(err, dst, file) < 0) -+ return (-1); -+ } else { -+ if (path_new(err, dst, cnt->cfg.rootfs) < 0) -+ return (-1); -+ if (path_append(err, dst, paths[i]) < 0) -+ return (-1); -+ } -+ -+ printf("src: %s, src_lnk: %s, dst: %s\n", src, src_lnk, dst); - if (remove(dst) < 0 && errno != ENOENT) - return (-1); - -diff --git a/src/jetson_mount.h b/src/jetson_mount.h -index c11e6d36..b1af8358 100644 ---- a/src/jetson_mount.h -+++ b/src/jetson_mount.h -@@ -8,7 +8,7 @@ - #include "nvc_internal.h" - #include "error.h" - --char **mount_jetson_files(struct error *, const char *, const struct nvc_container *, char * [], size_t); -+char **mount_jetson_files(struct error *, const char *, const struct nvc_container *, const char *, char * [], size_t); - int create_jetson_symlinks(struct error *, const char *, const struct nvc_container *, char * [], size_t); - - #endif /* HEADER_JETSON_MOUNT_H */ -diff --git a/src/nvc_mount.c b/src/nvc_mount.c -index fc2d0ec9..8971e286 100644 ---- a/src/nvc_mount.c -+++ b/src/nvc_mount.c -@@ -477,7 +477,7 @@ nvc_driver_mount(struct nvc_context *ctx, const struct nvc_container *cnt, const - - log_info("mount jetson libraries"); - if (info->jetson->libs != NULL && info->jetson->nlibs > 0) { -- if ((tmp = (const char **)mount_jetson_files(&ctx->err, ctx->cfg.root, cnt, info->jetson->libs, info->jetson->nlibs)) == NULL) -+ if ((tmp = (const char **)mount_jetson_files(&ctx->err, ctx->cfg.root, cnt, cnt->cfg.libs_dir, info->jetson->libs, info->jetson->nlibs)) == NULL) - goto fail; - ptr = array_append(ptr, tmp, array_size(tmp)); - free(tmp); -@@ -485,7 +485,7 @@ nvc_driver_mount(struct nvc_context *ctx, const struct nvc_container *cnt, const - - log_info("mount jetson dirs"); - if (info->jetson->dirs != NULL && info->jetson->ndirs > 0) { -- if ((tmp = (const char **)mount_jetson_files(&ctx->err, ctx->cfg.root, cnt, info->jetson->dirs, info->jetson->ndirs)) == NULL) -+ if ((tmp = (const char **)mount_jetson_files(&ctx->err, ctx->cfg.root, cnt, NULL, info->jetson->dirs, info->jetson->ndirs)) == NULL) - goto fail; - ptr = array_append(ptr, tmp, array_size(tmp)); - free(tmp); --- -2.34.1 - diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0002-OE-cross-build-fixups.patch b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0002-OE-cross-build-fixups.patch deleted file mode 100644 index e29f6469..00000000 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0002-OE-cross-build-fixups.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 2206062fca84109db3456b8730a09ffaf197ca27 Mon Sep 17 00:00:00 2001 -From: Ilies CHERGUI -Date: Sun, 8 Aug 2021 21:18:48 +0100 -Subject: [PATCH 2/3] OE cross-build fixups - -Signed-off-by: Pablo Rodriguez Quesada -Signed-off-by: Ilies CHERGUI -Signed-off-by: Matt Madison ---- - Makefile | 40 ++++++++++++++++++++++------------------ - mk/common.mk | 4 ++-- - 2 files changed, 24 insertions(+), 20 deletions(-) - -diff --git a/Makefile b/Makefile -index 709102b7..da836fae 100644 ---- a/Makefile -+++ b/Makefile -@@ -23,17 +23,17 @@ WITH_SECCOMP ?= yes - - ##### Global definitions ##### - --export prefix = /usr/local --export exec_prefix = $(prefix) --export libdir = $(exec_prefix)/lib --export docdir = $(prefix)/share/doc --export libdbgdir = $(prefix)/lib/debug$(libdir) --export includedir = $(prefix)/include --export pkgconfdir = $(libdir)/pkgconfig -+export prefix ?= /usr/local -+export exec_prefix ?= $(prefix) -+export libdir ?= $(exec_prefix)/lib -+export docdir ?= $(prefix)/share/doc -+export libdbgdir ?= $(prefix)/lib/debug$(libdir) -+export includedir ?= $(prefix)/include -+export pkgconfdir ?= $(libdir)/pkgconfig - - export PKG_DIR ?= $(CURDIR)/pkg - export TESTS_DIR ?= $(CURDIR)/test --export SRCS_DIR ?= $(CURDIR)/src -+export SRCS_DIR ?= src - export DEPS_DIR ?= $(CURDIR)/deps - export DIST_DIR ?= $(CURDIR)/dist - export MAKE_DIR ?= $(CURDIR)/mk -@@ -119,21 +119,23 @@ LIB_PKGCFG := $(LIB_NAME).pc - ##### Flags definitions ##### - - # Common flags --CPPFLAGS := -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -g3 -D JETSON=$(JETSON) $(CPPFLAGS) -+CPPFLAGS := -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -g3 -D JETSON=$(JETSON) -DHOST_LIBDIR=$(libdir) $(CPPFLAGS) -+CCNAME := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) - CFLAGS := -std=gnu11 -O0 -g3 -fdata-sections -ffunction-sections -fstack-protector -fno-strict-aliasing -fvisibility=hidden \ - -Wall -Wextra -Wcast-align -Wpointer-arith -Wmissing-prototypes -Wnonnull \ - -Wwrite-strings -Wlogical-op -Wformat=2 -Wmissing-format-attribute -Winit-self -Wshadow \ - -Wstrict-prototypes -Wunreachable-code -Wconversion -Wsign-conversion \ -- -Wno-unknown-warning-option -Wno-format-extra-args -Wno-gnu-alignof-expression $(CFLAGS) -+ -Wno-format-extra-args $(if $(filter clang,$(CCNAME)),-Wno-unknown-warning-option -Wno-gnu-alignof-expression,) \ -+ -I=/usr/include/tirpc $(CFLAGS) - LDFLAGS := -Wl,-zrelro -Wl,-znow -Wl,-zdefs -Wl,--gc-sections $(LDFLAGS) - LDLIBS := $(LDLIBS) - - # Library flags (recursively expanded to handle target-specific flags) - LIB_CPPFLAGS = -DNV_LINUX -isystem $(DEPS_DIR)$(includedir) -include $(BUILD_DEFS) - LIB_CFLAGS = -fPIC --LIB_LDFLAGS = -L$(DEPS_DIR)$(libdir) -shared -Wl,-soname=$(LIB_SONAME) --LIB_LDLIBS_STATIC = -l:libnvidia-modprobe-utils.a --LIB_LDLIBS_SHARED = -ldl -lcap -+LIB_LDFLAGS = -shared -Wl,-soname=$(LIB_SONAME) -+LIB_LDLIBS_STATIC = -L$(DEPS_DIR)$(libdir) -l:libnvidia-modprobe-utils.a -+LIB_LDLIBS_SHARED = -ltirpc -ldl -lcap -lpthread - ifeq ($(WITH_LIBELF), yes) - LIB_CPPFLAGS += -DWITH_LIBELF - LIB_LDLIBS_SHARED += -lelf -@@ -170,13 +172,17 @@ DEPENDENCIES := $(LIB_OBJS:%.lo=%.d) - $(BUILD_DEFS): - @printf '#define BUILD_DATE "%s"\n' '$(strip $(DATE))' >$(BUILD_DEFS) - @printf '#define BUILD_COMPILER "%s " __VERSION__\n' '$(notdir $(COMPILER))' >>$(BUILD_DEFS) -+ifeq ($(EXCLUDE_BUILD_FLAGS),) - @printf '#define BUILD_FLAGS "%s"\n' '$(strip $(CPPFLAGS) $(CFLAGS) $(LDFLAGS))' >>$(BUILD_DEFS) -+else -+ @printf '#define BUILD_FLAGS ""\n' >>$(BUILD_DEFS) -+endif - @printf '#define BUILD_REVISION "%s"\n' '$(strip $(REVISION))' >>$(BUILD_DEFS) - @printf '#define BUILD_PLATFORM "%s"\n' '$(strip $(PLATFORM))' >>$(BUILD_DEFS) - - $(LIB_RPC_SRCS): $(LIB_RPC_SPEC) - $(RM) $@ -- cd $(dir $@) && $(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $(notdir $@) $(LIB_RPC_SPEC) -+ cd $(dir $@) && $(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $(notdir $@) $(notdir $(LIB_RPC_SPEC)) - - $(LIB_OBJS): %.lo: %.c | deps - $(CC) $(LIB_CFLAGS) $(LIB_CPPFLAGS) -MMD -MF $*.d -c $(OUTPUT_OPTION) $< -@@ -189,24 +195,22 @@ $(LIB_SHARED): $(LIB_OBJS) - $(OBJCPY) --only-keep-debug $@ $(LIB_SONAME) - $(OBJCPY) --add-gnu-debuglink=$(LIB_SONAME) $@ - $(MV) $(LIB_SONAME) $(DEBUG_DIR) -- $(STRIP) --strip-unneeded -R .comment $@ - - $(LIB_STATIC_OBJ): $(LIB_OBJS) - # FIXME Handle user-defined LDFLAGS and LDLIBS - $(LD) -d -r --exclude-libs ALL -L$(DEPS_DIR)$(libdir) $(OUTPUT_OPTION) $^ $(LIB_LDLIBS_STATIC) - $(OBJCPY) --localize-hidden $@ -- $(STRIP) --strip-unneeded -R .comment $@ - - ##### Public rules ##### - - all: CPPFLAGS += -DNDEBUG --all: STRIP := @echo skipping: strip -+all: - all: shared static - - # Run with ASAN_OPTIONS="protect_shadow_gap=0" to avoid CUDA OOM errors - debug: CFLAGS += -pedantic -fsanitize=undefined -fno-omit-frame-pointer -fno-common -fsanitize=address - debug: LDLIBS += -lubsan --debug: STRIP := @echo skipping: strip -+debug: - debug: shared static - - shared: $(LIB_SHARED) -diff --git a/mk/common.mk b/mk/common.mk -index d6ef499d..f8170de8 100644 ---- a/mk/common.mk -+++ b/mk/common.mk -@@ -22,9 +22,9 @@ UID := $(shell id -u) - GID := $(shell id -g) - DATE := $(shell date -u --iso-8601=minutes) - REVISION := $(shell git rev-parse HEAD) --COMPILER := $(realpath $(shell which $(CC))) -+COMPILER := $(realpath $(shell which $(firstword $(CC)))) - PLATFORM ?= $(shell uname -m) --JETSON := TRUE -+JETSON ?= TRUE - - ifeq ($(DATE),) - $(error Invalid date format) --- -2.34.1 - diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0003-Add-support-for-separate-pass-through-tree.patch b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0003-Add-support-for-separate-pass-through-tree.patch deleted file mode 100644 index 80755e8c..00000000 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson/0003-Add-support-for-separate-pass-through-tree.patch +++ /dev/null @@ -1,257 +0,0 @@ -From 74fac9f0aa34cceddba9dc963ebe2b30cd6f9fa4 Mon Sep 17 00:00:00 2001 -From: Matt Madison -Date: Sun, 5 Mar 2023 08:47:33 -0800 -Subject: [PATCH 3/3] Add support for separate pass-through tree - -So we can export stock L4T pre-built userland binaries to -containers, instead of the versions we build from sources, -to avoid glibc and other shared library mismatches inside -NVIDIA's containers. - -Signed-off-by: Matt Madison ---- - Makefile | 3 +++ - src/jetson_mount.c | 57 +++++++++++++++++++++++++++++++++++++--------- - src/nvc_info.c | 31 +++++++++++++++++++++---- - src/utils.c | 12 ++++++++++ - src/utils.h | 1 + - 5 files changed, 88 insertions(+), 16 deletions(-) - -diff --git a/Makefile b/Makefile -index da836fae..045e4707 100644 ---- a/Makefile -+++ b/Makefile -@@ -142,6 +142,9 @@ LIB_LDLIBS_SHARED += -lelf - else - LIB_LDLIBS_STATIC += -l:libelf.a - endif -+ifneq ($(PASSTHRU_ROOT),) -+LIB_CPPFLAGS += -DPASSTHRU_ROOT="$(PASSTHRU_ROOT)" -+endif - ifeq ($(WITH_TIRPC), yes) - LIB_CPPFLAGS += -isystem $(DEPS_DIR)$(includedir)/tirpc -DWITH_TIRPC - LIB_LDLIBS_STATIC += -l:libtirpc.a -diff --git a/src/jetson_mount.c b/src/jetson_mount.c -index 5cf94c81..d5b6844d 100644 ---- a/src/jetson_mount.c -+++ b/src/jetson_mount.c -@@ -21,13 +21,25 @@ - #define stringify(s__) stringify__(s__) - #define stringify__(s__) #s__ - static const char *hostlibdir = stringify(HOST_LIBDIR) "/"; -+#ifdef PASSTHRU_ROOT -+static const char *passthrudir = stringify(PASSTHRU_ROOT) "/"; -+#else -+static const char *passthrudir = NULL; -+#endif - - static int - resolve_symlink(struct error *err, const char *src, char *dst) - { -- ssize_t n; -+ ssize_t n = -1; -+ char passthrusrc[PATH_MAX]; - -- n = readlink(src, dst, PATH_MAX); -+ if (passthrudir != NULL) { -+ if (path_join(err, passthrusrc, passthrudir, src) < 0) -+ return -1; -+ n = readlink(passthrusrc, dst, PATH_MAX); -+ } -+ if (n < 0) -+ n = readlink(src, dst, PATH_MAX); - if (n < 0 || n >= PATH_MAX) - return -1; - -@@ -58,6 +70,13 @@ mount_jetson_files(struct error *err, const char *root, const struct nvc_contain - if (path_new(err, src, root) < 0) - goto fail; - -+ if (passthrudir != NULL && str_has_prefix(paths[i], passthrudir)) { -+ if (path_join(err, dst, cnt->cfg.rootfs, paths[i] + (strlen(passthrudir)-1)) < 0) -+ goto fail; -+ if (path_append(err, src, paths[i]) < 0) -+ goto fail; -+ goto mount_prep; -+ } - if (dir != NULL) { - size_t hostlibdirlen = strlen(hostlibdir); - /* -@@ -102,6 +121,7 @@ mount_jetson_files(struct error *err, const char *root, const struct nvc_contain - if (path_append(err, dst, (samepath ? paths[i] : file)) < 0) - goto fail; - -+ mount_prep: - if (file_mode(err, src, &mode) < 0) - goto fail; - if (file_create(err, dst, NULL, cnt->uid, cnt->gid, mode) < 0) -@@ -131,35 +151,50 @@ create_jetson_symlinks(struct error *err, const char *root, const struct nvc_con - char src[PATH_MAX]; - char src_lnk[PATH_MAX]; - char dst[PATH_MAX]; -- char *file; -+ size_t hostlibdirlen = strlen(hostlibdir); - - for (size_t i = 0; i < size; ++i) { -- file = basename(paths[i]); - if (!match_jetson_symlink_flags(paths[i], cnt->flags)) - continue; - - if (path_new(err, src, root) < 0) - return (-1); -+ if (path_new(err, dst, cnt->cfg.rootfs) < 0) -+ return (-1); - - if (path_append(err, src, paths[i]) < 0) - return (-1); -+ if (path_append(err, dst, paths[i]) < 0) -+ return (-1); - - if (resolve_symlink(err, src, src_lnk) < 0) - return (-1); - -- if (str_has_prefix(file, "lib")) { -- if (path_resolve_full(err, dst, cnt->cfg.rootfs, cnt->cfg.libs_dir) < 0) -+ /* Move symlinks residing directly in /usr/lib (not in subdirs) on host to /usr/lib/aarch64-linux-gnu in container */ -+ if (str_has_prefix(src, hostlibdir) && strchr(src+hostlibdirlen, '/') == NULL && -+ (strcmp(hostlibdir, cnt->cfg.libs_dir) != 0 && !str_has_prefix(src, cnt->cfg.libs_dir))) { -+ char tmp[PATH_MAX]; -+ if (path_join(err, tmp, cnt->cfg.rootfs, cnt->cfg.libs_dir) < 0) - return (-1); -- if (path_append(err, dst, file) < 0) -+ if (path_append(err, tmp, basename(src)) < 0) - return (-1); -- } else { -- if (path_new(err, dst, cnt->cfg.rootfs) < 0) -+ log_infof("%s: moving symlink at %s to %s", __func__, dst, tmp); -+ strcpy(dst, tmp); -+ } -+ if (str_has_prefix(src_lnk, hostlibdir) && -+ (strcmp(hostlibdir, cnt->cfg.libs_dir) != 0 && str_has_prefix(src_lnk, cnt->cfg.libs_dir) && strchr(src_lnk+hostlibdirlen, '/') != NULL)) { -+ char tmp[PATH_MAX], sub[PATH_MAX], *cp; -+ strcpy(sub, src_lnk+hostlibdirlen); -+ for (cp = sub + strlen(sub); cp > sub && *cp != '/'; cp--); -+ *cp = '\0'; -+ if (path_join(err, tmp, cnt->cfg.libs_dir, sub) < 0) - return (-1); -- if (path_append(err, dst, paths[i]) < 0) -+ if (path_append(err, tmp, basename(src_lnk)) < 0) - return (-1); -+ log_infof("%s: %s rewritten to %s", __func__, src_lnk, tmp); -+ strcpy(src_lnk, tmp); - } - -- printf("src: %s, src_lnk: %s, dst: %s\n", src, src_lnk, dst); - if (remove(dst) < 0 && errno != ENOENT) - return (-1); - -diff --git a/src/nvc_info.c b/src/nvc_info.c -index fd0e60f1..e0c03da9 100644 ---- a/src/nvc_info.c -+++ b/src/nvc_info.c -@@ -23,7 +23,15 @@ - #include "jetson_info.h" - #include "xfuncs.h" - --#define MAX_BINS (nitems(utility_bins) + \ -+#define stringify(s__) stringify__(s__) -+#define stringify__(s__) #s__ -+#ifdef PASSTHRU_ROOT -+static const char *passthrudir = stringify(PASSTHRU_ROOT) "/"; -+#else -+static const char *passthrudir = NULL; -+#endif -+ -+#define MAX_BINS (nitems(utility_bins) + \ - nitems(compute_bins)) - #define MAX_LIBS (nitems(utility_libs) + \ - nitems(compute_libs) + \ -@@ -402,10 +410,20 @@ static int - lookup_jetson_libs(struct error *err, struct nvc_jetson_info *info, const char *root) - { - char path[PATH_MAX]; -+ char passthrulib[PATH_MAX], passthrupath[PATH_MAX]; - - for (size_t i = 0; i < info->nlibs; ++i) { -- if (path_resolve(err, path, root, info->libs[i]) < 0) -- return (-1); -+ int ok = 0; -+ if (passthrudir != NULL && path_join(err, passthrulib, passthrudir, info->libs[i]) >= 0) { -+ if (path_join(err, passthrupath, root, passthrulib) >= 0 && file_or_symlink_exists(err, passthrupath)) { -+ strcpy(path, passthrupath); -+ ok = 1; -+ } -+ } -+ if (!ok && path_resolve(err, path, root, info->libs[i]) < 0) { -+ log_infof("%s: could not find path for %s", __func__, info->libs[i]); -+ continue; -+ } - - free(info->libs[i]); - info->libs[i] = NULL; -@@ -418,6 +436,7 @@ lookup_jetson_libs(struct error *err, struct nvc_jetson_info *info, const char * - info->libs[i] = xstrdup(err, path); - if (info->libs[i] == NULL) - return (-1); -+ log_infof("%s: found library %s", __func__, path); - } - - array_pack(info->libs, &info->nlibs); -@@ -458,15 +477,17 @@ lookup_jetson_symlinks(struct error *err, struct nvc_jetson_info *info, const ch - { - (void) root; - -- char path[PATH_MAX]; -+ char path[PATH_MAX], passthrupath[PATH_MAX]; - struct stat s; - - for (size_t i = 0; i < info->nsyms; ++i) { - strcpy(path, info->syms[i]); -+ if (passthrudir != NULL && path_join(err, passthrupath, passthrudir, info->syms[i]) < 0) -+ return (-1); - free(info->syms[i]); - info->syms[i] = NULL; - -- if (lstat(path, &s) < 0) { -+ if (lstat(passthrupath, &s) < 0 && lstat(path, &s) < 0) { - log_warnf("missing symlink %s", path); - continue; - } -diff --git a/src/utils.c b/src/utils.c -index 1baab823..81a456e4 100644 ---- a/src/utils.c -+++ b/src/utils.c -@@ -658,6 +658,18 @@ file_exists(struct error *err, const char *path) - return (rv == 0); - } - -+int -+file_or_symlink_exists(struct error *err, const char *path) -+{ -+ int rv; -+ -+ if ((rv = faccessat(AT_FDCWD, path, F_OK, AT_SYMLINK_NOFOLLOW)) < 0 && errno != ENOENT) { -+ error_set(err, "file/symlink lookup failed: %s", path); -+ return (-1); -+ } -+ return (rv == 0); -+} -+ - int - file_exists_at(struct error *err, const char *dir, const char *path) - { -diff --git a/src/utils.h b/src/utils.h -index 4beb86da..95d0834c 100644 ---- a/src/utils.h -+++ b/src/utils.h -@@ -73,6 +73,7 @@ int file_unmap(struct error *, const char *, void *, size_t); - int file_create(struct error *, const char *, const char *, uid_t, gid_t, mode_t); - int file_remove(struct error *, const char *); - int file_exists(struct error *, const char *); -+int file_or_symlink_exists(struct error *, const char *); - int file_exists_at(struct error *, const char *, const char *); - int file_mode(struct error *, const char *, mode_t *); - int file_read_line(struct error *, const char *, char *, size_t); --- -2.34.1 - diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson_0.11.bb b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson_0.11.bb deleted file mode 100644 index 8bd47b65..00000000 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container-jetson_0.11.bb +++ /dev/null @@ -1,98 +0,0 @@ -SUMMARY = "NVIDIA container runtime library for Jetson platforms" - -DESCRIPTION = "NVIDIA container runtime library \ -The nvidia-container library provides an interface to configure GNU/Linux \ -containers leveraging NVIDIA hardware. The implementation relies on several \ -kernel subsystems and is designed to be agnostic of the container runtime. \ -This recipe builds a Jetson-specific version of the library. \ -" -HOMEPAGE = "https://github.com/NVIDIA/libnvidia-container" - -COMPATIBLE_MACHINE = "(tegra)" - -DEPENDS = " \ - coreutils-native \ - pkgconfig-native \ - libcap \ - elfutils \ - libtirpc \ - ldconfig-native \ -" -LICENSE = "BSD-3-Clause & MIT & Proprietary" - -# Both source repositories include GPL COPYING (and for -# libnvidia-container, COPYING.LESSER) files. However: -# * For libnvidia-container, those files might only apply if elfutils -# sources were included (the makefile has commands to download and -# build libelf from elfutils sources). We configure the build to -# use libelf provided externally. -# * For nvidia-modprobe, only the nvidia-modprobe-utils library is -# built and used. All sources for that library are MIT-licensed. - -LIC_FILES_CHKSUM = "\ - file://LICENSE;md5=06cff45c51018e430083a716510821b7 \ - file://deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION}/modprobe-utils/nvidia-modprobe-utils.c;endline=22;md5=8f11a22ea12c5aecde3340212f7fc9a1 \ - file://deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION}/modprobe-utils/pci-enum.h;endline=29;md5=b2c0e63b1fa594dcb4f4093247d74a29 \ - file://deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION}/modprobe-utils/pci-sysfs.c;endline=25;md5=a5eee0d4ba40238ac5823a33ead29b6d \ - file://src/cuda.h;endline=48;md5=d212e7eced2562852ccf8267e4811e6f \ -" - -NVIDIA_MODPROBE_VERSION = "396.51" - -SRC_URI = "git://github.com/NVIDIA/libnvidia-container.git;protocol=https;name=libnvidia;branch=jetson \ - git://github.com/NVIDIA/nvidia-modprobe.git;protocol=https;branch=main;name=modprobe;destsuffix=git/deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION} \ - file://0001-Fix-mapping-of-library-paths-for-jetson-mounts.patch \ - file://0002-OE-cross-build-fixups.patch \ - file://0003-Add-support-for-separate-pass-through-tree.patch \ - " - -# tag: v0.11.0+jetpack -SRCREV_libnvidia = "1b60893021cd00c87f201d11eb207215afa3ab11" -# Nvidia modprobe version 396.51 -SRCREV_modprobe = "d97c08af5061f1516fb2e3a26508936f69d6d71d" -SRCREV_FORMAT = "libnvidia_modprobe" - -S = "${WORKDIR}/git" - -PACKAGECONFIG ??= "" -PACKAGECONFIG[seccomp] = "WITH_SECCOMP=yes,WITH_SECCOMP=no,libseccomp" - -def build_date(d): - import datetime - epoch = d.getVar('SOURCE_DATE_EPOCH') - if epoch: - dt = datetime.datetime.fromtimestamp(int(epoch), tz=datetime.timezone.utc) - return 'DATE=' + dt.isoformat(timespec='minutes') - return '' - -# This must match the setting in tegra-container-passthrough recipe -PASSTHRU_ROOT = "${datadir}/nvidia-container-passthrough" - -EXTRA_OEMAKE = "EXCLUDE_BUILD_FLAGS=1 PASSTHRU_ROOT=${PASSTHRU_ROOT} PLATFORM=${HOST_ARCH} JETSON=TRUE WITH_LIBELF=yes COMPILER=${@d.getVar('CC').split()[0]} REVISION=${SRCREV_libnvidia} ${@build_date(d)} ${PACKAGECONFIG_CONFARGS}" - -export OBJCPY="${OBJCOPY}" - -# Fix me: Create an independent recipe for nvidia-modprobe -do_configure:append() { - # Mark Nvidia modprobe as downloaded - touch ${S}/deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION}/.download_stamp -} - -do_install () { - oe_runmake install DESTDIR=${D} - # Remove the development files, as this library is only used as - # an adjunct for Jetson-specific handling, dlopened at runtime. - rm -f ${D}${libdir}/libnvidia-container.so ${D}${libdir}/libnvidia-container.a - rm -rf ${D}${libdir}/pkgconfig ${D}${includedir} - # See note about licensing above - find ${D}${datadir}/doc -type f -name 'COPYING*' -delete -} - -# These package names would conflict with the ones -# generated by the normal libnvidia-container recipe, -# so make sure they don't get renamed based on the -# library stem name. -DEBIAN_NOAUTONAME:${PN}-dbg = "1" -DEBIAN_NOAUTONAME:${PN}-dev = "1" -DEBIAN_NOAUTONAME:${PN}-doc = "1" -DEBIAN_NOAUTONAME:${PN}-src = "1" diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container/0001-OE-cross-build-fixups.patch b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container/0001-OE-cross-build-fixups.patch index d932465d..31e45f62 100644 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container/0001-OE-cross-build-fixups.patch +++ b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container/0001-OE-cross-build-fixups.patch @@ -1,21 +1,21 @@ -From 56ef33321c4ac6c8b09d34710a85efd9f5fb4087 Mon Sep 17 00:00:00 2001 -From: Ilies CHERGUI -Date: Sun, 8 Aug 2021 21:18:48 +0100 +From b7345be7dfdcf3c4d0c46daf86264d362bff6681 Mon Sep 17 00:00:00 2001 +From: Ilies CHERGUI +Date: Tue, 5 Mar 2024 11:52:33 +0000 Subject: [PATCH] OE cross-build fixups Signed-off-by: Pablo Rodriguez Quesada -Signed-off-by: Ilies CHERGUI Signed-off-by: Matt Madison +Signed-off-by: Ilies CHERGUI --- Makefile | 38 ++++++++++++++++++++------------------ mk/common.mk | 2 +- mk/nvidia-modprobe.mk | 3 ++- 3 files changed, 23 insertions(+), 20 deletions(-) -Index: git/Makefile -=================================================================== ---- git.orig/Makefile -+++ git/Makefile +diff --git a/Makefile b/Makefile +index a374cc09..1d1b566d 100644 +--- a/Makefile ++++ b/Makefile @@ -24,17 +24,17 @@ WITH_SECCOMP ?= yes ##### Global definitions ##### @@ -43,7 +43,7 @@ Index: git/Makefile export DEPS_DIR ?= $(CURDIR)/deps export DIST_DIR ?= $(CURDIR)/dist export MAKE_DIR ?= $(CURDIR)/mk -@@ -140,20 +140,22 @@ LIBGO_SYMLINK := $(LIBGO_NAME).so +@@ -137,20 +137,22 @@ LIBGO_SYMLINK := $(LIBGO_NAME).so # Common flags CPPFLAGS := -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 $(CPPFLAGS) @@ -54,7 +54,7 @@ Index: git/Makefile -Wstrict-prototypes -Wunreachable-code -Wconversion -Wsign-conversion \ - -Wno-unknown-warning-option -Wno-format-extra-args -Wno-gnu-alignof-expression $(CFLAGS) + -Wno-format-extra-args $(if $(filter clang,$(CCNAME)),-Wno-unknown-warning-option -Wno-gnu-alignof-expression,) \ -+ -I=/usr/include/tirpc $(CFLAGS) ++ -I=/usr/include/tirpc $(CFLAGS) LDFLAGS := -Wl,-zrelro -Wl,-znow -Wl,-zdefs -Wl,--gc-sections $(LDFLAGS) LDLIBS := $(LDLIBS) @@ -70,7 +70,7 @@ Index: git/Makefile ifeq ($(WITH_NVCGO), yes) LIB_CPPFLAGS += -DWITH_NVCGO LIB_LDLIBS_SHARED += -lpthread -@@ -205,13 +207,17 @@ DEPENDENCIES := $(BIN_OBJS:%.o=%.d) $( +@@ -202,13 +204,17 @@ DEPENDENCIES := $(BIN_OBJS:%.o=%.d) $(LIB_OBJS:%.lo=%.d) $(BUILD_DEFS): @printf '#define BUILD_DATE "%s"\n' '$(strip $(DATE))' >$(BUILD_DEFS) @printf '#define BUILD_COMPILER "%s " __VERSION__\n' '$(notdir $(COMPILER))' >>$(BUILD_DEFS) @@ -87,9 +87,9 @@ Index: git/Makefile - cd $(dir $@) && $(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $(notdir $@) $(LIB_RPC_SPEC) + cd $(dir $@) && $(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $(notdir $@) $(notdir $(LIB_RPC_SPEC)) - $(LIB_OBJS): %.lo: %.c | deps + $(LIB_OBJS): %.lo: %.c | deps $(SRCS_DIR)/nvc.h $(CC) $(LIB_CFLAGS) $(LIB_CPPFLAGS) -MMD -MF $*.d -c $(OUTPUT_OPTION) $< -@@ -227,17 +233,14 @@ $(LIB_SHARED): $(LIB_OBJS) +@@ -224,17 +230,14 @@ $(LIB_SHARED): $(LIB_OBJS) $(OBJCPY) --only-keep-debug $@ $(LIB_SONAME) $(OBJCPY) --add-gnu-debuglink=$(LIB_SONAME) $@ $(MV) $(LIB_SONAME) $(DEBUG_DIR) @@ -107,7 +107,7 @@ Index: git/Makefile ##### Public rules ##### -@@ -247,7 +250,6 @@ all: shared static tools +@@ -244,7 +247,6 @@ all: shared static tools # Run with ASAN_OPTIONS="protect_shadow_gap=0" to avoid CUDA OOM errors debug: CFLAGS += -pedantic -fsanitize=undefined -fno-omit-frame-pointer -fno-common -fsanitize=address debug: LDLIBS += -lubsan @@ -158,16 +158,3 @@ Index: git/mk/nvidia-modprobe.mk ##### Public rules ##### -Index: git/src/nvcgo/Makefile -=================================================================== ---- git.orig/src/nvcgo/Makefile -+++ git/src/nvcgo/Makefile -@@ -39,7 +39,7 @@ build: $(OBJ_NAME) - $(OBJ_NAME): $(wildcard $(CURDIR)/*.go) $(wildcard */*.go) - export CGO_CFLAGS="$(CGO_CFLAGS)"; \ - export CGO_LDFLAGS="$(CGO_LDFLAGS)"; \ -- $(GO) build -o $(@) -ldflags "-s -w" -buildmode=c-shared . -+ $(GO) build -o $(@) -ldflags "-s -w" -trimpath -buildmode=c-shared . - - install: $(OBJ_NAME) - $(INSTALL) -d -m 755 $(addprefix $(DESTDIR),$(libdir) $(includedir)/$(PKG_NAME)) diff --git a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.10.0.bb b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.14.2.bb similarity index 94% rename from external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.10.0.bb rename to external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.14.2.bb index e11695e0..e6d16761 100644 --- a/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.10.0.bb +++ b/external/virtualization-layer/recipes-containers/libnvidia-container/libnvidia-container_1.14.2.bb @@ -47,8 +47,8 @@ SRC_URI = "git://github.com/NVIDIA/libnvidia-container.git;protocol=https;name=l file://0002-Expose-device-file-attrs.patch \ " -# tag: v1.10.0 -SRCREV_libnvidia = "395fd41701117121f1fd04ada01e1d7e006a37ae" +# tag: v1.14.2 +SRCREV_libnvidia = "1eb5a30a6ad0415550a9df632ac8832bf7e2bbba" # Nvidia modprobe version 495.44 SRCREV_modprobe = "292409904a5d18163fc7d1fbc11f98627324b82a" SRCREV_FORMAT = "libnvidia_modprobe" @@ -100,5 +100,5 @@ FILES:${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \ ${libdir}/cmake ${datadir}/cmake" FILES:${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" # - XXX -RDEPENDS:${PN}:append:tegra = " ldconfig tegra-libraries-cuda tegra-container-passthrough nv-tegra-release libnvidia-container-jetson" INSANE_SKIP:${PN} = "already-stripped ldflags" +RDEPENDS:${PN}:append:tegra = " ldconfig tegra-libraries-cuda"