@@ 125,10 125,46 @@ let
stdenv' = pkgs.stdenvAdapters.overrideCC pkgs.stdenv toolchain;
+ patchRelativeLibraries = ''
+ if [ -z "''${noAbsoluteLibraries:-}" ]; then
+ find "''${!outputBin}" "''${!outputLib}" -type f | while read -r elf; do
+ if ! isELF "$elf"; then continue; fi
+ args=
+ for name in $(patchelf --print-needed "$elf"); do
+ if [ "ld.lib.so" == "$name" ]; then
+ continue
+ fi
+ if [ -f "$name" ]; then
+ continue
+ fi
+ argPair=
+ for input in ''${!outputLib} ''${libraryBuildInputs:-}; do
+ local libdir="$input/lib"
+ local libabs=$(realpath "$libdir/$name" 2>/dev/null || true)
+ if [ -f "$libabs" ]; then
+ echo "Replace $name reference with $libabs"
+ argPair="--replace-needed $name $libabs"
+ break
+ fi
+ done
+ if [ -z "$argPair" ]; then
+ echo "Could not find absolute path to $name in buildInputs"
+ exit 1
+ fi
+ args="$args $argPair"
+ done
+ if [ -n "$args" ]; then
+ patchelf $args $elf
+ fi
+ done
+ fi
+ '';
+
buildUpstream =
# Build from the Genode sources
- { name, targets, portInputs ? [ ], nativeBuildInputs ? [ ], patches ? [ ]
- , enableParallelBuilding ? true, meta ? { }, ... }@extraAttrs:
+ { name, targets, portInputs ? [ ], nativeBuildInputs ? [ ]
+ , buildInputs ? [ ], patches ? [ ], enableParallelBuilding ? true
+ , meta ? { }, ... }@extraAttrs:
let havePatches = patches != [ ];
in stdenv'.mkDerivation (extraAttrs // {
@@ 172,6 208,9 @@ let
runHook postInstall
'';
+ libraryBuildInputs = map pkgs.stdenv.lib.getLib buildInputs;
+ postFixup = patchRelativeLibraries;
+
meta = { platforms = lib.platforms.genode; } // meta;
});
@@ 230,6 269,9 @@ let
runHook postInstall
'';
+ libraryBuildInputs = map pkgs.stdenv.lib.getLib buildInputs;
+ postFixup = patchRelativeLibraries;
+
meta = { platforms = lib.platforms.genode; } // meta;
});