Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prusa-slicer: 2.8.0 -> 2.8.1 #358215

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

prusa-slicer: 2.8.0 -> 2.8.1 #358215

wants to merge 10 commits into from

Conversation

cbat98
Copy link

@cbat98 cbat98 commented Nov 22, 2024

This PR brings PrusaSlicer in line with the latest public release 2.8.1. Several new features such as UI improvements and a new infill type were added in this version. A full changelog can be found here:

I've also provided a patch file to fix some of the build issues I experienced whilst upgrading this package, however I'm still new to NixOS so any feedback is very welcome.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@cbat98 cbat98 changed the title Prusa prusa-slicer: 2.8.0 -> 2.8.1 Nov 22, 2024
@cbat98
Copy link
Author

cbat98 commented Nov 23, 2024

Result of nixpkgs-review pr 358215 run on x86_64-linux 1

4 packages failed to build:
  • super-slicer
  • super-slicer-beta
  • super-slicer-beta.debug
  • super-slicer.debug
4 packages built:
  • prusa-slicer
  • prusa-slicer.debug
  • super-slicer-latest
  • super-slicer-latest.debug

@cbat98
Copy link
Author

cbat98 commented Nov 23, 2024

The 4 packages that fail to build with nixpkgs-review also seem to fail to build on master using nix-build -A super-slicer. Therefore I believe fixing this falls out of scope of this PR.

@cbat98
Copy link
Author

cbat98 commented Nov 23, 2024

Would I be able to get some advice on this PR please?
@thorstenweber83
@hesiod

This is my first nix PR, be gentle :)

@jmickelin
Copy link

jmickelin commented Nov 23, 2024

Hi, I made a PR upstream to fix all these build issues. I expect it to be merged with the next alpha of 2.9.0, but it might be the case that it's backported to 2.8.*. Note that it replaces the patches used in the current derivation for 2.8.0, and sidesteps some of the more hacky solutions used elsewhere. See the issue for extensive discussions on what the problems were and why this is the right approach.

In any case, here is my overlay that incorporates all the fixes.

final: prev:
(prev.prusa-slicer.override {
    opencascade-occt_7_6 = prev.opencascade-occt_7_6.overrideAttrs {
      version = "7.6.1";
      src = prev.fetchurl {
        name = "occt-V7_6_1.tar.gz";
        url = "https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=V7_6_1;sf=tgz";
        hash = "sha256-PZVrLSbR7nWsArIeg47YtHMdnpFAHK5K80VbVrAA9W0=";
      };
    };
}).overrideAttrs (final: old: rec {
  version = "2.8.1";
  src = prev.fetchFromGitHub {
    owner = "prusa3d";
    repo = "PrusaSlicer";
    hash = "sha256-nMLZvvZLIOChCLn8A9sOph1lqWsHb00eTG8z98/l0C8=";
    rev = "version_${version}";
  };

  buildInputs = old.buildInputs ++ [ prev.webkitgtk_4_0 ];

  prePatch = old.prePatch + ''
    rm cmake/modules/FindEigen3.cmake
    rm cmake/modules/FindDBus.cmake
  '';
  
  patches = [
    (prev.writeText "linker-fixes.patch" ''
       --- a/src/libslic3r/CMakeLists.txt
       +++ b/src/libslic3r/CMakeLists.txt
       @@ -596,6 +596,7 @@ target_link_libraries(libslic3r PUBLIC
            libigl
            agg
            ankerl
       +    boost_headeronly
        )
        
        if (APPLE)
       --- a/CMakeLists.txt
       +++ b/CMakeLists.txt
       @@ -246,7 +246,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
            set(THREADS_PREFER_PTHREAD_FLAG ON)
            find_package(Threads REQUIRED)
       
       -    find_package(DBus REQUIRED)
       +    find_package(DBus1 REQUIRED)
        endif()
         
        if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
       --- a/src/slic3r/CMakeLists.txt
       +++ b/src/slic3r/CMakeLists.txt
       @@ -383,6 +383,7 @@ set(SLIC3R_GUI_SOURCES
        )
            
        find_package(NanoSVG REQUIRED)
       +find_package(OpenSSL REQUIRED)
            
        if (APPLE)
            list(APPEND SLIC3R_GUI_SOURCES
       @@ -438,6 +439,9 @@ target_link_libraries(
            NanoSVG::nanosvgrast
            stb_dxt
            fastfloat
       +    OpenSSL::SSL
       +    OpenSSL::Crypto
       +    boost_headeronly
        )
              
        if (MSVC))
       @@ -443,7 +443,7 @@ target_link_libraries(
        if (MSVC)
            target_link_libraries(libslic3r_gui PUBLIC Setupapi.lib)
        elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
       -    target_link_libraries(libslic3r_gui PUBLIC ''${DBUS_LIBRARIES})
       +    target_link_libraries(libslic3r_gui PUBLIC ''${DBus1_LIBRARIES})
        elseif (APPLE)
            target_link_libraries(libslic3r_gui PUBLIC ''${DISKARBITRATION_LIBRARY} ''${COREWLAN_LIBRARY})
        endif()
       '')
  ];
})

(For reference, the only additional patch needed for 2.9.0-alpha1 is this

(prev.writeText "boost-filesystem.patch" ''
       --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp
       +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp
       @@ -120,7 +120,7 @@ BackgroundSlicingProcess::~BackgroundSlicingProcess()
               std::string prefix = boost::filesystem::path(m_temp_output_path).filename().string();
               prefix = prefix.substr(0, prefix.find('_'));
            for (const auto& entry : boost::filesystem::directory_iterator(temp_dir)) {
       -        if (entry.is_regular_file()) {
       +        if (boost::filesystem::is_regular_file(entry.path())) {
                    const std::string filename = entry.path().filename().string();
                    if (boost::starts_with(filename, prefix) && boost::ends_with(filename, ".gcode"))
                        boost::filesystem::remove(entry);
    '')

)

One nitpick for discussion, should a derivation for opencascade-occt-7_6_1 be created in nixpkgs rather than overriding it inline here? I think it makes sense, since there is precedent for pinned versions already (i.e. opencascade-occt_7_6 which is currently 7.6.2 vs opencascade-occt which is currently 7.8.1).

@jmickelin
Copy link

jmickelin commented Nov 23, 2024

Reading through your patch, it seems you arrived at pretty much the same conclusions, although we solved them differently: Disabling the broken FindEigen3 module, adding the right include directories for dbus-1 and fixing the linking issues with boost, and then linking to OpenSSL as per the patches in the previous version.

For the boost one, note that using BOOST_LOG_DYN_LINK just happens to solve the error by chance (I think because it's deferring the compile-time linking to runtime, where the .so is available), and that the main cause is that CMake just isn't aware that the libraries are needed in some of the files. For the record, Nix has an easier method to define such flags: Rather than patching the CMake files, you can add it to cmakeFlags in the derivation:

  cmakeFlags = ... ++ [ "-DCMAKE_CXX_FLAGS=-DBOOST_LOG_DYN_LINK" ];

I also suggest we turn off building of tests:

  cmakeFlags = ... ++ [ "-DSLIC3R_BUILD_TESTS=0" ];

This is what the derivation for e.g. bambu-studio is doing: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/bambu-studio/default.nix#L156

@cbat98
Copy link
Author

cbat98 commented Nov 23, 2024

@jmickelin Wow, thank you for such an in-depth comment! I'm a fairly new NixOS user, and haven't really worked with C++ build processes before, so attempting to hack together this update really felt like I was biting off more than I could chew. But anyway, lots of frantic Googling later, I seem to stumbled into a combination of things that have sort-of worked.

I appreciate your pick-up of the fact that I've just overridden the OCCT version inline. I've basically just copied over what I had in a local overlay into the nix-pkgs repo, so that's my bad.

I'll work through my patch file and the overlay that you've provided to come up with a bit of a better fix over the next day or so.

Thanks once again :)

@jmickelin
Copy link

Thanks to you too! I was deliberating on creating a PR for nixpkgs, since I've never done it before. Actually I am kind of relieved that you beat me to it :D

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Nov 27, 2024
@ofborg ofborg bot requested review from gebner and amiloradovsky November 27, 2024 13:48
@maxammann
Copy link
Contributor

maxammann commented Nov 27, 2024

Tested it and works!

@jmickelin
Copy link

jmickelin commented Nov 29, 2024

Nitpick:

Note that these lines in the patch don't do anything (whether we use the -DBOOST_LOG_DYN_LINK flag or the upstream patch). This is because the file already contains find_package(Boost [...] ${_boost_components}), which includes log correctly. I did find some Stackoverflow post suggesting including log_setup like you did, but it didn't end up being necessary (or sufficient) to solve it.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31cb4c0ff..42c38102c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -371,10 +373,13 @@ endif()
 # boost::process was introduced first in version 1.64.0,
 # boost::beast::detail::base64 was introduced first in version 1.66.0
 set(MINIMUM_BOOST_VERSION "1.66.0")
-set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams;nowide")
+# set(Boost_USE_STATIC_LIBS ON)
+find_package(Boost REQUIRED COMPONENTS log)
+set(_boost_components "system;filesystem;thread;log;log_setup;locale;regex;chrono;atomic;date_time;iostreams;nowide")
 find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components})
+include_directories(${BOOST_INCLUDE_DIRS})

and

diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt
index 78369233d..1f9c40aaf 100644
--- a/src/slic3r/CMakeLists.txt
+++ b/src/slic3r/CMakeLists.txt
@@ -438,6 +439,7 @@ target_link_libraries(
     NanoSVG::nanosvgrast
     stb_dxt
     fastfloat
+    Boost::log
 )
 
 if (MSVC)

That aside, it might be a good idea to add a comment above the list of patches about removing all of this in the next version, by which point the fix should have been merged. The patches, as written, won't cause any merge conflicts indicating the upstream fix, so it's best to call it out explicitly so people don't keep unnecessary old patches around just in case :)

@VuiMuich
Copy link
Contributor

VuiMuich commented Dec 12, 2024

A couple of days ago, I did test if this PR can be easily updated to build the 2.9.0-alpha1, but it failed with some boost related error. Unfortunately I lost the build-log and haven't had time yet to look into this matter.
My thinking was to possibly add a prusa-slicer-alpha/beta package, as they tend to have pretty long running pre-release phases and usually come with a lot of interesting new features.
That said, if we want to add this package, I would say merge this PR as is, and address the boost patch in the preview package.

@jmickelin
Copy link

Sounds good to me. Better to get it working than to let perfect be the enemy of the good. My nitpick is just a nitpick, and I figure all the patches we add here will be removed once 2.9.0 comes out anyway.

@cbat98: The checks say that this can be merged without waiting for approvals, so should we do that? Otherwise, I believe there is a thread on the NixOS discourse for requesting reviews.

If you want to get 2.9.0-alpha1 working now, you can use this overlay (referencing my fork with the fixes). There was one additional boost dependency that was undeclared, compared to 2.8.1. I've been successfully using it on nixpkgs-24.11:

final: prev: {
  # - Explicit dependency on OCCT 7.6.1, since 7.6.2 and above introduced a bug with chamfers:
  #   https://github.com/prusa3d/PrusaSlicer/commit/c6a02106fd1d3caa9a48a6b7c2bdd04546b24485#diff-54d1bb7ea7d9b83fb3c587bc042046732a50bb843a067cd86c445bafbb6ba1eeR7
  prusa-slicer = (prev.prusa-slicer.override {
    opencascade-occt_7_6 = prev.opencascade-occt_7_6.overrideAttrs {
      version = "7.6.1";
      src = prev.fetchurl {
        name = "occt-V7_6_1.tar.gz";
        url = "https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=V7_6_1;sf=tgz";
        hash = "sha256-PZVrLSbR7nWsArIeg47YtHMdnpFAHK5K80VbVrAA9W0=";
      };
    };
  }).overrideAttrs (old: rec {
    version = "2.9.1-alpha1";
    src = prev.fetchFromGitHub {
      owner = "jmickelin";
      repo = "PrusaSlicer";
      hash = "sha256-LMMsQgtF/qKqbREMpNBtEePEXiF4JBKHRFawIA/8zlo=";
      # Named in reference to 2.8.1, but actually rebased onto
      # 2.9.1-alpha1, awaiting upstream merge.
      rev = "fix-2.8.1-build-errors";
    };

    buildInputs = old.buildInputs ++ [ prev.webkitgtk_4_0 ];

    # Remove old patches, since every change necessary is
    # committed to the branch.
    patches = [ ];

    # Upstream will likely go with the route of deleting the
    # Find-module for Eigen3 rather than using the updated one
    # from my branch. Let's do the same here for 1-1 parity with
    # what upstream is expected to look like in the next alpha.
    prePatch = old.prePatch + ''
      rm cmake/modules/FindEigen3.cmake
    '';

    cmakeFlags = old.cmakeFlags ++ [
      "-DSLIC3R_BUILD_TESTS=0"
    ];
  });
}

@maxammann
Copy link
Contributor

Just as a side note, unfortunately cURL 8 seems to be a bit incompatable with prusa-slicer: #246261

I think ideally this derivation would built all vendored libraries and link them statically. I know this kind of sucks, but prusa-slicer already seems to be kind of a mess, so linking statically might make things easier to handle in the future.

@mogorman
Copy link
Contributor

this is all i needed to get prusa-slicer working with printables curl stuff working on the latest release.

  mog_prusa-slicer = (pkgs.prusa-slicer.overrideAttrs (old: rec {
  version = "2.9.0-beta1";
  src = pkgs.fetchFromGitHub {
    owner = "prusa3d";
    repo = "PrusaSlicer";
#    hash = lib.fakeHash;
    hash = "sha256-2QbSeOHBQDrfsNOq1SjhmhyMSRyhPTMew7MNC1P1cRk=";
    rev = "version_${version}";
  };

  buildInputs = old.buildInputs ++ [ pkgs.webkitgtk_4_0 ];

  patches = [
    (pkgs.writeText "boost-filesystem.patch" ''
       --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp
       +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp
       @@ -120,7 +120,7 @@ BackgroundSlicingProcess::~BackgroundSlicingProcess()
               std::string prefix = boost::filesystem::path(m_temp_output_path).filename().string();
               prefix = prefix.substr(0, prefix.find('_'));
            for (const auto& entry : boost::filesystem::directory_iterator(temp_dir)) {
       -        if (entry.is_regular_file()) {
       +        if (boost::filesystem::is_regular_file(entry.path())) {
                    const std::string filename = entry.path().filename().string();
                    if (boost::starts_with(filename, prefix) && boost::ends_with(filename, ".gcode"))
                        boost::filesystem::remove(entry);
    '')
  ];
})).override{
    boost = pkgs.boost183;
    curl = pkgs.curl.overrideAttrs {
      version = "7.88.1";
      src = pkgs.fetchurl {
        url = "https://curl.se/download/curl-7.88.1.tar.xz";
        hash = "sha256-Ha4xsqfB/iad6ZwMMbtIg0aqs0WbX/ypCdaTgkmuQV8=";
        # lib.fakeHash;
      };
      patches = [];
    };
    opencascade-occt_7_6 = pkgs.opencascade-occt_7_6.overrideAttrs {
      version = "7.6.1";
      src = pkgs.fetchurl {
        name = "occt-V7_6_1.tar.gz";
        url = "https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=V7_6_1;sf=tgz";
        hash = "sha256-PZVrLSbR7nWsArIeg47YtHMdnpFAHK5K80VbVrAA9W0=";
      };
    };
};

@jmickelin
Copy link

jmickelin commented Dec 15, 2024

@mogorman Nice! I believe the patch to change entry.is_regular_file() to boost::filesystem::is_regular_file(entry.path()) is no longer needed since they appear to have bumped up the lower version bound for Boost instead, in this commit: prusa3d/PrusaSlicer@78a0470

It's been a while since I tested this, but could you confirm that it works with just overriding boost to boost183? (I'll try it out myself tonight too.)

@maxammann Good catch about the Curl version! I noticed the downloaded files being truncated to 0 bytes, but was actually not sure if it was caused by the same curl bug that delayed nixpkgs 24.11 a couple of weeks ago or not.

EDIT: Confirmed that it works with just setting the version to boost183, so the additional patch isn't necessary. As of version 2.9.0-beta1, no patches are necessary to build it with Nix. Just the overrides for OCCT-7.6.1, Boost-1.83 and some older version of curl as noted above (though that last one isn't needed for compiling, but rather manifests as a bug at runtime).

@maxammann
Copy link
Contributor

@maxammann Good catch about the Curl version! I noticed the downloaded files being truncated to 0 bytes, but was actually not sure if it was caused by the same curl bug that delayed nixpkgs 24.11 a couple of weeks ago or not.

I don't think it is a bug in curl 8, as it was already broken on 24.05. I believe the curl issue is related to a bug in prusa-slicer actually. Curl 7 tolerated that bug but 8 no longer does. But that is only a guess.

For prusa-slicer I think the best would be to build curl from the cmake files in the prusa-slicer repository. The approach above works but maybe still uses different compilation flags than the cmake build scripts. prusa-slicer seems to be a mess so being as close as possible to the flatpak build is very advantageous in the future.

@cbat98
Copy link
Author

cbat98 commented Dec 16, 2024

Hi again guys, I've been away for a couple of weeks, so I'll take some time to catch up on these messages and see what I can do to update this PR with suggestions.

@mogorman
Copy link
Contributor

@jmickelin yup can confirm it works without. so now even simpler

  mog_prusa-slicer = (pkgs.prusa-slicer.overrideAttrs (old: rec {
  version = "2.9.0-beta1";
  src = pkgs.fetchFromGitHub {
    owner = "prusa3d";
    repo = "PrusaSlicer";
    hash = "sha256-2QbSeOHBQDrfsNOq1SjhmhyMSRyhPTMew7MNC1P1cRk=";
    rev = "version_${version}";
  };

  buildInputs = old.buildInputs ++ [ pkgs.webkitgtk_4_0 ];
 # needed to override the current patches.
  patches = [];
})).override{
    boost = pkgs.boost183;
    curl = pkgs.curl.overrideAttrs {
      version = "7.88.1";
      src = pkgs.fetchurl {
        url = "https://curl.se/download/curl-7.88.1.tar.xz";
        hash = "sha256-Ha4xsqfB/iad6ZwMMbtIg0aqs0WbX/ypCdaTgkmuQV8=";
      };
      patches = [];
    };
    opencascade-occt_7_6 = pkgs.opencascade-occt_7_6.overrideAttrs {
      version = "7.6.1";
      src = pkgs.fetchurl {
        name = "occt-V7_6_1.tar.gz";
        url = "https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=V7_6_1;sf=tgz";
        hash = "sha256-PZVrLSbR7nWsArIeg47YtHMdnpFAHK5K80VbVrAA9W0=";
      };
    };
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants