Feature/flatpak clang llvm21 (#12727)

* Fix GIT_COMMIT_HASH not set in Flatpak builds

The env var check was gated inside the .git directory check, so
Flatpak builds (which exclude .git from the sandbox) always fell
back to "0000000". Lift the env var check to top level and inject
the commit hash into the Flatpak manifest via build-options.env.

* Switch Flatpak build to Clang/LLD via LLVM 21 SDK extension

- Add org.freedesktop.Sdk.Extension.llvm21
- Bump runtime to GNOME 49 (SDK 25.08) for llvm21 availability

* fix build errors and improving build speed for flatpak

* fxi more build errors

* Update error messages for GNOME Platform and SDK versions
This commit is contained in:
SoftFever
2026-03-11 14:59:29 +08:00
committed by GitHub
parent 2ebc0aa6c1
commit 322b44d84a
8 changed files with 57 additions and 27 deletions

View File

@@ -134,7 +134,7 @@ jobs:
flatpak:
name: "Flatpak"
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-48
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-49
options: --privileged
volumes:
- /usr/local/lib/android:/usr/local/lib/android
@@ -194,7 +194,12 @@ jobs:
restore-keys: flatpak-builder-${{ matrix.variant.arch }}-
- name: Disable debug info for faster CI builds
run: |
sed -i '0,/^finish-args:/s//build-options:\n no-debuginfo: true\n strip: true\nfinish-args:/' \
sed -i '/^build-options:/a\ no-debuginfo: true\n strip: true' \
scripts/flatpak/io.github.orcaslicer.OrcaSlicer.yml
shell: bash
- name: Inject git commit hash into Flatpak manifest
run: |
sed -i "/name: OrcaSlicer/{n;s|buildsystem: simple|buildsystem: simple\n build-options:\n env:\n git_commit_hash: \"$git_commit_hash\"|}" \
scripts/flatpak/io.github.orcaslicer.OrcaSlicer.yml
shell: bash
- name: Inject git commit hash into Flatpak manifest

View File

@@ -173,10 +173,7 @@ option(BUILD_TESTS "Build unit tests" OFF)
option(ORCA_TOOLS "Build Orca tools" OFF)
if (FLATPAK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++20")
set(SLIC3R_PCH OFF CACHE BOOL "" FORCE)
set(SLIC3R_FHS ON CACHE BOOL "" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SLIC3R_DESKTOP_INTEGRATION OFF CACHE BOOL "" FORCE)
endif ()
@@ -457,9 +454,12 @@ if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMP
add_compile_options(-Wno-unknown-pragmas)
endif()
# Bit of a hack for flatpak building: compress the debug info with zstd to save space in CI
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0)
add_compile_options(-gz=zstd)
# Compress the debug info with zstd to save space in Flatpak CI builds
if(FLATPAK)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0) OR
("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0))
add_compile_options(-gz=zstd)
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)

View File

@@ -198,22 +198,22 @@ echo -e "${GREEN}All required dependencies found${NC}"
# Install runtime and SDK if requested
if [[ "$INSTALL_RUNTIME" == true ]]; then
echo -e "${YELLOW}Installing GNOME runtime and SDK...${NC}"
flatpak install --user -y flathub org.gnome.Platform//48
flatpak install --user -y flathub org.gnome.Sdk//48
flatpak install --user -y flathub org.gnome.Platform//49
flatpak install --user -y flathub org.gnome.Sdk//49
fi
# Check if required runtime is available
if ! flatpak info --user org.gnome.Platform//48 &> /dev/null; then
echo -e "${RED}Error: GNOME Platform 48 runtime is not installed.${NC}"
if ! flatpak info --user org.gnome.Platform//49 &> /dev/null; then
echo -e "${RED}Error: GNOME Platform 49 runtime is not installed.${NC}"
echo "Run with -i flag to install it automatically, or install manually:"
echo "flatpak install --user flathub org.gnome.Platform//48"
echo "flatpak install --user flathub org.gnome.Platform//49"
exit 1
fi
if ! flatpak info --user org.gnome.Sdk//48 &> /dev/null; then
echo -e "${RED}Error: GNOME SDK 48 is not installed.${NC}"
if ! flatpak info --user org.gnome.Sdk//49 &> /dev/null; then
echo -e "${RED}Error: GNOME SDK 49 is not installed.${NC}"
echo "Run with -i flag to install it automatically, or install manually:"
echo "flatpak install --user flathub org.gnome.Sdk//48"
echo "flatpak install --user flathub org.gnome.Sdk//49"
exit 1
fi
@@ -318,7 +318,7 @@ fi
MANIFEST="scripts/flatpak/io.github.orcaslicer.OrcaSlicer.yml"
if [[ "$NO_DEBUGINFO" == true ]]; then
MANIFEST="scripts/flatpak/io.github.orcaslicer.OrcaSlicer.no-debug.yml"
sed '0,/^finish-args:/s//build-options:\n no-debuginfo: true\n strip: true\nfinish-args:/' \
sed '/^build-options:/a\ no-debuginfo: true\n strip: true' \
scripts/flatpak/io.github.orcaslicer.OrcaSlicer.yml > "$MANIFEST"
echo -e "${YELLOW}Debug info disabled (using temp manifest)${NC}"
fi

3
deps/CMakeLists.txt vendored
View File

@@ -189,6 +189,9 @@ if (NOT IS_CROSS_COMPILE OR NOT APPLE)
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}
-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}
-DBUILD_SHARED_LIBS:BOOL=OFF
${_cmake_osx_arch}
"${_configs_line}"

2
deps/TBB/TBB.cmake vendored
View File

@@ -1,4 +1,4 @@
if (FLATPAK)
if (FLATPAK AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(_patch_command ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/GNU.cmake ./cmake/compilers/GNU.cmake)
else()
set(_patch_command "")

View File

@@ -1,10 +1,19 @@
app-id: io.github.orcaslicer.OrcaSlicer
runtime: org.gnome.Platform
runtime-version: "48"
runtime-version: "49"
sdk: org.gnome.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.llvm21
command: entrypoint
separate-locales: true
rename-icon: OrcaSlicer
build-options:
append-path: /usr/lib/sdk/llvm21/bin
prepend-ld-library-path: /usr/lib/sdk/llvm21/lib
env:
CC: clang
CXX: clang++
LDFLAGS: "-fuse-ld=lld"
finish-args:
- --share=ipc
- --socket=x11
@@ -38,6 +47,8 @@ modules:
sha256: e305b9f07f52743ca481da0a4e0c76c35efd60adaf1b0694eb3bb021e2137e39
- name: glu
build-options:
cxxflags: -Wno-register
config-opts:
- --disable-static
sources:
@@ -70,6 +81,9 @@ modules:
# Config-opts mirror deps/wxWidgets/wxWidgets.cmake with FLATPAK=ON, DEP_WX_GTK3=ON
- name: wxWidgets
buildsystem: cmake-ninja
build-options:
env:
CMAKE_POLICY_VERSION_MINIMUM: "3.5"
config-opts:
- -DCMAKE_BUILD_TYPE=Release
- -DwxBUILD_PRECOMP=ON
@@ -99,6 +113,9 @@ modules:
- -DwxUSE_LIBJPEG=sys
- -DwxUSE_LIBTIFF=OFF
- -DwxUSE_EXPAT=sys
- -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld
- -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld
- -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld
sources:
- type: git
url: https://github.com/SoftFever/Orca-deps-wxWidgets
@@ -118,7 +135,10 @@ modules:
-DDEP_DOWNLOAD_DIR=/run/build/orca_deps/external-packages \
-DCMAKE_PREFIX_PATH=/app \
-DDESTDIR=/app \
-DCMAKE_INSTALL_PREFIX=/app
-DCMAKE_INSTALL_PREFIX=/app \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld"
- cmake --build $BUILD_DIR --parallel
- rm -rf /run/build/orca_deps/external-packages
@@ -290,7 +310,10 @@ modules:
-DFLATPAK=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/app \
-DCMAKE_INSTALL_PREFIX=/app
-DCMAKE_INSTALL_PREFIX=/app \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld"
- cmake --build build_flatpak --target OrcaSlicer -j$FLATPAK_BUILDER_N_JOBS
- ./scripts/run_gettext.sh
- cmake --build build_flatpak --target install -j$FLATPAK_BUILDER_N_JOBS

View File

@@ -791,9 +791,8 @@ if (UNIX AND NOT APPLE)
# I don't know why this is needed, but for whatever reason slic3r isn't
# linking to X11 and webkit2gtk. force it.
find_package(X11 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(webkit2gtk REQUIRED webkit2gtk-4.1)
target_link_libraries (libslic3r_gui ${X11_LIBRARIES} ${webkit2gtk_LIBRARIES})
target_link_libraries(libslic3r_gui ${X11_LIBRARIES} ${webkit2gtk_LIBRARIES})
endif()
target_include_directories(libslic3r_gui SYSTEM PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS} ${LIBSECRET_INCLUDE_DIRS})
target_link_libraries(libslic3r_gui ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig ${LIBSECRET_LIBRARIES})

View File

@@ -67,10 +67,10 @@ private:
static bool get_stream_url(std::string *url = nullptr);
private:
static const wxMediaState MEDIASTATE_IDLE = (wxMediaState) 3;
static const wxMediaState MEDIASTATE_INITIALIZING = (wxMediaState) 4;
static const wxMediaState MEDIASTATE_LOADING = (wxMediaState) 5;
static const wxMediaState MEDIASTATE_BUFFERING = (wxMediaState) 6;
static inline const wxMediaState MEDIASTATE_IDLE = static_cast<wxMediaState>(3);
static inline const wxMediaState MEDIASTATE_INITIALIZING = static_cast<wxMediaState>(4);
static inline const wxMediaState MEDIASTATE_LOADING = static_cast<wxMediaState>(5);
static inline const wxMediaState MEDIASTATE_BUFFERING = static_cast<wxMediaState>(6);
// token
std::shared_ptr<int> m_token = std::make_shared<int>(0);