fix(build): make BuildLinux.sh work on clean Debian, Fedora and Arch systems - #11732
fix(build): make BuildLinux.sh work on clean Debian, Fedora and Arch systems#11732YeeP79 wants to merge 4 commits into
Conversation
libslic3r_gui linked OSMesa unconditionally on Linux, with no find_library
guard and no build option. That assumes every distribution still ships the
classic Mesa off-screen renderer, which is no longer true:
- Arch has no non-conflicting provider at all. libOSMesa comes only from
mesa-amber, which Conflicts With mesa, so pulling it in would remove the
regular Mesa stack from the machine doing the build.
- Fedora 42 obsoletes mesa-libOSMesa-devel and moved the library into
mesa-compat-libOSMesa-devel.
Where the library is absent the build failed at link time with
"cannot find -lOSMesa". Probe for it and link it only when it is present, so
distributions that still ship it are unaffected and the others fall back to
the EGL context path already configured below.
Fedora 42 obsoletes mesa-libOSMesa-devel (obsoletes: < 25.1.0~rc2-1), so dnf
reports the transaction as complete while installing nothing at all.
BuildLinux.sh -u therefore exits 0 and looks healthy, and the build only
fails much later when libslic3r_gui is linked:
/usr/sbin/ld: cannot find -lOSMesa: No such file or directory
The library now ships in mesa-compat-libOSMesa-devel, which provides
/usr/lib64/libOSMesa.so.
BuildLinux.sh runs with set -e, and linux.d/debian opens by assigning the result of a pipeline that ends in grep. On a system that does not have GTK3 installed yet that grep matches nothing and returns 1, so the script exits before installing anything -- meaning -u, whose only job is to install the build dependencies, requires those dependencies to already be present. Tolerate the empty match the way linux.d/fedora already does.
linux.d only covered debian and fedora. Arch reports ID=arch and sets no ID_LIKE at all, so the candidate loop in BuildLinux.sh matched nothing and the script exited with "Your distribution does not appear to be currently supported by these build scripts". Arch ships headers alongside the runtime package, so there is no -dev/-devel split to mirror, and pacman --needed makes the per-package pre-filtering the dpkg and rpm paths perform unnecessary. libOSMesa is deliberately absent from the list: its only provider conflicts with mesa, and the build now treats it as optional.
|
Some additional context on the Mesa retired the classic OSMesa build in 25.1 (Fedora's obsoletes marker is Reports that trace back to this:
Worth noting that PrusaSlicer, which this project is based on, has no reference to OSMesa anywhere in its CMake files or sources — the link was added downstream. Making it conditional brings the Linux build back in line with upstream while leaving distributions that still ship the library completely unaffected (verified above: the Debian link line is byte-for-byte equivalent). One scope caveat so this isn't over-read: the change fixes builds from source. Users on the official AppImage or on distro packages built from the release tarball only benefit once a release is produced with it. |
Summary
BuildLinux.shcurrently cannot bootstrap a build on a clean system for any of the three distributions it nominally targets. This PR fixes the dependency handling for Debian and Fedora, adds the missing Arch definition, and stops the GUI link step from requiring a Mesa component that several distributions no longer ship.Each change is a separate commit and each is independently useful.
BuildLinux.sh -uexits 1 immediatelyset -eplus agrepthat matches nothing on a machine without GTK3-uexits 0, build fails much later at linkmesa-libOSMesa-develis obsoleted on F42 and installs nothingBuildLinux.shexits 1, "distribution does not appear to be currently supported"linux.d/archThe libOSMesa problem
src/slic3r/CMakeLists.txtlinksOSMesaunconditionally on Linux, with nofind_libraryprobe and no build option. That was safe when every distribution shipped the classic Mesa off-screen renderer. It no longer holds.Fedora 42 obsoletes the package that
linux.d/fedoraasks for:Because it is obsoleted with no replacement pulled in,
dnf install -y mesa-libOSMesa-develprintsComplete!and installs nothing.BuildLinux.sh -uexits 0, so the problem is invisible until the link step:The library moved to
mesa-compat-libOSMesa-devel, which provides/usr/lib64/libOSMesa.so. Installing that makes-lOSMesaresolve again.Arch has no usable provider at all. Current
mesa(26.1.5) ships no OSMesa files, and the only package that does ismesa-amber, a legacy 21.3.9 compatibility build which declaresConflicts With: mesa. Installing it would remove the regular Mesa stack from the machine doing the build, so it is not something a dependency list can reasonably ask for.Prior art
The AUR package
bambu-studiohit exactly this and has carried a local patch since 2026-04-19,0001-src-slic3r-CMakeLists.txt-avoid-linking-to-the-depre.patch, which dropsOSMesafrom the link line entirely and depends on plainmesa. That package builds and runs, which is useful evidence that the off-screen renderer is not required for a working build.Removing the link outright would regress distributions that still ship the library, so this PR probes for it instead and links it only when present. Debian still finds and links it exactly as before; Arch and any other distribution without it fall back to the EGL context path already configured immediately below.
Changes
fix(cmake)— probe forlibOSMesawithFIND_LIBRARYand link it only when found.fix(build)— Fedora:mesa-libOSMesa-devel→mesa-compat-libOSMesa-devel.fix(build)— Debian: tolerate the emptygrepmatch, matching whatlinux.d/fedoraalready does with|| true. Without this,-u(whose only job is installing the dependencies) requires the dependencies to already be installed.feat(build)— addlinux.d/arch. Arch reportsID=archand sets noID_LIKE, so the candidate loop matched nothing. Arch ships headers with the runtime package, so there is no-dev/-develsplit to mirror, andpacman --neededmakes the per-package pre-filtering the dpkg and rpm paths perform unnecessary.Testing
All testing was done in the same container images the release workflow uses, starting from a clean image each time.
Arch (
archlinux:latest, GCC 16.1.1) — full build from scratch:CMake took the fallback path (
OSMESA_LIBRARIES-NOTFOUND), producedbuild/src/bambu-studio, and the resulting binary runs:lddconfirms nolibOSMesadependency. No extra toolchain workarounds were needed — in particular FFMPEG built cleanly, so no LTO or C-standard overrides.Debian (
debian:trixie) —-unow exits 0 and installslibgtk-3-devandlibOSMesa.so;-dand-sboth exit 0. To confirm the guard changes nothing where the library does exist, the generated link line forsrc/bambu-studiowas compared against an unpatched reconfigure of the same tree with the same prebuilt dependencies:Same library, same two positions, same total:
find_libraryresolves to exactly the file the-lflag would have found. Neither build records aNEEDEDentry for it, because GLFW loads the off-screen renderer withdlopenrather than linking against it directly.Fedora (
fedora:42) — verified before and after: linking-lOSMesafails with the currently-listed package and succeeds withmesa-compat-libOSMesa-devel.Note on #11321 / #11323
This overlaps with the native-packaging work in #11323 — the Arch and Fedora jobs there cannot currently get past the dependency and link steps for the reasons above. This PR is deliberately scoped to
BuildLinux.shand the GUI link only, and stands on its own for anyone building from source; it does not touch packaging or CI.