|
1 | 1 | { stdenv
|
2 | 2 | , stdenvNoCC
|
| 3 | +, buildPackages |
3 | 4 | , addOpenGLRunpath
|
4 | 5 | , lib
|
5 | 6 | , fetchurl
|
|
22 | 23 | , l4tVersion
|
23 | 24 | }:
|
24 | 25 | let
|
| 26 | + # The version currently in nixpkgs 23.11 and master 0.15 is pretty old and |
| 27 | + # doesn't have the --rename-dynamic-symbols feature we need |
| 28 | + patchelf_new = buildPackages.patchelf.overrideAttrs (_: rec { |
| 29 | + version = "0.18.0"; |
| 30 | + src = fetchurl { |
| 31 | + url = "https://github.com/NixOS/patchelf/releases/download/${version}/patchelf-${version}.tar.bz2"; |
| 32 | + sha256 = "sha256-GVKyp4K6V2J5whHulC40F0j9tEmX9wTdU970bNBVRws="; |
| 33 | + }; |
| 34 | + }); |
| 35 | + |
25 | 36 | # Wrapper around mkDerivation that has some sensible defaults to extract a .deb file from the L4T BSP pacckage
|
26 | 37 | buildFromDeb =
|
27 | 38 | # Nicely, the t194 and t234 packages are currently identical, so we just
|
@@ -114,16 +125,26 @@ let
|
114 | 125 | ln -sf libnvidia-ptxjitcompiler.so.${l4tVersion} lib/libnvidia-ptxjitcompiler.so.1
|
115 | 126 | ln -sf libnvidia-ptxjitcompiler.so.${l4tVersion} lib/libnvidia-ptxjitcompiler.so
|
116 | 127 |
|
117 |
| - # Some libraries, like libEGL_nvidia.so.0 from l3t-3d-core use a dlopen |
118 |
| - # wrapper called NvOsLibraryLoad, which originates in libnvos.so in this |
| 128 | + # Some libraries, like libEGL_nvidia.so.0 from l4t-3d-core use a dlopen |
| 129 | + # wrapper called NvOsLibraryLoad, which originates in libnvos.so in |
119 | 130 | # l4t-core. Unfortunately, calling dlopen from libnvos.so instead of the
|
120 | 131 | # original library/executable means that dlopen will use the DT_RUNPATH
|
121 | 132 | # from libnvos.so instead of the binary/library which called it. In ordo
|
122 |
| - # to handle this, we Make a copy of libnvos specifically for this package |
123 |
| - # so we can set the RUNPATH differently here. |
124 |
| - patchelf --replace-needed libnvos.so libnvos_3d.so lib/*.so |
| 133 | + # to handle this, we make a copy of libnvos specifically for this package |
| 134 | + # so we can set the RUNPATH differently here. Additionally to avoid |
| 135 | + # linking conflicts we rename the library and NvOsLibraryLoad symbol. |
125 | 136 | cp --no-preserve=ownership,mode ${l4t-core}/lib/libnvos.so lib/libnvos_3d.so
|
126 | 137 | patchelf --set-soname libnvos_3d.so lib/libnvos_3d.so
|
| 138 | +
|
| 139 | + remapFile=$(mktemp) |
| 140 | + echo NvOsLibraryLoad NvOsLibraryLoad_3d > $remapFile |
| 141 | + for lib in $(find ./lib -name "*.so*"); do |
| 142 | + if isELF $lib; then |
| 143 | + ${patchelf_new}/bin/patchelf "$lib" \ |
| 144 | + --rename-dynamic-symbols "$remapFile" \ |
| 145 | + --replace-needed libnvos.so libnvos_3d.so |
| 146 | + fi |
| 147 | + done |
127 | 148 | '';
|
128 | 149 |
|
129 | 150 | # We append a postFixupHook since we need to have this happen after
|
|
262 | 283 |
|
263 | 284 | # Make a copy of libnvos specifically for this package so we can set the RUNPATH differently here.
|
264 | 285 | # See note above for NvOsLibraryLoad
|
265 |
| - patchelf --replace-needed libnvos.so libnvos_multimedia.so lib/*.so |
266 | 286 | cp --no-preserve=ownership,mode ${l4t-core}/lib/libnvos.so lib/libnvos_multimedia.so
|
267 | 287 | patchelf --set-soname libnvos_multimedia.so lib/libnvos_multimedia.so
|
| 288 | +
|
| 289 | + remapFile=$(mktemp) |
| 290 | + echo NvOsLibraryLoad NvOsLibraryLoad_multimedia > $remapFile |
| 291 | + for lib in $(find ./lib -name "*.so*"); do |
| 292 | + if isELF $lib; then |
| 293 | + ${patchelf_new}/bin/patchelf "$lib" \ |
| 294 | + --rename-dynamic-symbols "$remapFile" \ |
| 295 | + --replace-needed libnvos.so libnvos_multimedia.so |
| 296 | + fi |
| 297 | + done |
268 | 298 | '';
|
269 | 299 |
|
270 | 300 | # We append a postFixupHook since we need to have this happen after
|
|
0 commit comments