From bcca922de57099a275284616e63b975fb0e6dce8 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 18 Sep 2022 19:53:14 +0200 Subject: [PATCH] prusa-slicer: Fix STEP format support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We move the OCCTWrapper dynamic library /bin to /lib and patch the loading code to find its location dynamically. Previously the library load would fail on STEP imports like this: > /nix/store/4j1rm3sqjvfii68kb51ccvynzvll0jna-prusa-slicer-2.5.0/bin/OCCTWrapper.so: cannot dynamically load executable because when wrapped it is not a library any more. > OCCTWrapper.so: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/bzd91shky9j9d43girrrj6vmqlw7x9m8-glibc-2.35-163/lib/ld-linux-x86-64.so.2, BuildID\[sha1\]=28396fb28c32d0ec7bb75ea5c550760186b86c20, for GNU/Linux 2.6.32, not stripped Co-authored-by: André-Patrick Bubel --- .../applications/misc/prusa-slicer/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/applications/misc/prusa-slicer/default.nix b/pkgs/applications/misc/prusa-slicer/default.nix index 286abfb3fdb1..1592ef546155 100644 --- a/pkgs/applications/misc/prusa-slicer/default.nix +++ b/pkgs/applications/misc/prusa-slicer/default.nix @@ -130,6 +130,15 @@ stdenv.mkDerivation rec { # likely due to commit e682dd84cff5d2420fcc0a40508557477f6cc9d3 # See issue #185808 for details. sed -i 's|test_voronoi.cpp||g' tests/libslic3r/CMakeLists.txt + + # prusa-slicer expects the OCCTWrapper shared library in the same folder as + # the executable when loading STEP files. We force the loader to find it in + # the usual locations (i.e. LD_LIBRARY_PATH) instead. See the manpage + # dlopen(3) for context. + if [ -f "src/libslic3r/Format/STEP.cpp" ]; then + substituteInPlace src/libslic3r/Format/STEP.cpp \ + --replace 'libpath /= "OCCTWrapper.so";' 'libpath = "OCCTWrapper.so";' + fi ''; src = fetchFromGitHub { @@ -147,11 +156,20 @@ stdenv.mkDerivation rec { postInstall = '' ln -s "$out/bin/prusa-slicer" "$out/bin/prusa-gcodeviewer" + mkdir -p "$out/lib" + mv -v $out/bin/*.so $out/lib/ + mkdir -p "$out/share/pixmaps/" ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer.png" "$out/share/pixmaps/PrusaSlicer.png" ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer-gcodeviewer_192px.png" "$out/share/pixmaps/PrusaSlicer-gcodeviewer.png" ''; + preFixup = '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "$out/lib" + ) + ''; + meta = with lib; { description = "G-code generator for 3D printer"; homepage = "https://github.com/prusa3d/PrusaSlicer";