Skip to content

Commit

Permalink
libnvidia-container: fix cross-compilation for aarch64-linux
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <avn@avnik.info>
  • Loading branch information
avnik committed Jan 10, 2025
1 parent 5634f52 commit a5fef0d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkgs/by-name/li/libnvidia-container/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ stdenv.mkDerivation rec {
# libtirpc (for now)
# 4. prevent installation of static libraries because of step 3
# 5. prevent installation of libnvidia-container-go.so twice
# 6. Replace pkg-config and objcopy with target platform's one
# 7. Stub ldconfig
#
sed -i Makefile \
-e 's#DESTDIR=\$(DEPS_DIR)#DESTDIR=""#g' \
-e 's#\$(DEPS_DIR)\$#\$#g' \
-e 's#all: shared static tools#all: shared tools#g' \
-e '/$(INSTALL) -m 644 $(LIB_STATIC) $(DESTDIR)$(libdir)/d' \
-e '/$(INSTALL) -m 755 $(libdir)\/$(LIBGO_SHARED) $(DESTDIR)$(libdir)/d'
-e '/$(INSTALL) -m 755 $(libdir)\/$(LIBGO_SHARED) $(DESTDIR)$(libdir)/d' \
-e "s,pkg-config,$PKG_CONFIG,g"
substituteInPlace mk/common.mk \
--replace-fail objcopy '$(OBJCOPY)' \
--replace-fail ldconfig true
'';

enableParallelBuilding = true;
Expand All @@ -98,7 +105,12 @@ stdenv.mkDerivation rec {
HOME="$(mktemp -d)"
'';

env.NIX_CFLAGS_COMPILE = toString [ "-I${lib.getInclude libtirpc}/include/tirpc" ];
env = {
NIX_CFLAGS_COMPILE = toString [ "-I${lib.getInclude libtirpc}/include/tirpc" ];
CGO_ENABLED = "1"; # Needed for cross-compilation
GOFLAGS = "-trimpath"; # Don't include paths to Go stdlib to resulting binary
inherit (go) GOARCH GOOS;
};
NIX_LDFLAGS = [
"-L${lib.getLib libtirpc}/lib"
"-ltirpc"
Expand Down

0 comments on commit a5fef0d

Please sign in to comment.