From c2e8e83081581c69da70475bf2ec46dde154c6d7 Mon Sep 17 00:00:00 2001 From: Hanjin Bae Date: Tue, 9 Jun 2026 23:43:35 +0900 Subject: [PATCH] fix: Linux build with mold linker + graphite2 overlay + vcpkg ICU Three issues prevented Linux builds with Rust 1.95+ and vcpkg: 1. graphite2 hidden symbols: vcpkg builds with -fvisibility=hidden, rust-lld errors on STV_HIDDEN refs. Fix: overlay port that adds GRAPHITE2_EXPORTING and removes -fvisibility=hidden. 2. Rust version scripts: ld.bfd can't mix anonymous + named version tags. Fix: use mold linker which handles both correctly. 3. ICU version mismatch: system ICU (v70/74) found before vcpkg ICU (v78), causing _78 suffix undefined symbols. Fix: move system ICU .so out of linker path during build. vcpkg dynamic libs remain for portable distribution (issue #91). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../graphite2/disable-tests.patch | 48 +++++++++++++++++++ .../vcpkg-overlays/graphite2/portfile.cmake | 39 +++++++++++++++ .github/vcpkg-overlays/graphite2/vcpkg.json | 11 +++++ .github/workflows/build-desktop.yml | 27 +++++++---- 4 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 .github/vcpkg-overlays/graphite2/disable-tests.patch create mode 100644 .github/vcpkg-overlays/graphite2/portfile.cmake create mode 100644 .github/vcpkg-overlays/graphite2/vcpkg.json diff --git a/.github/vcpkg-overlays/graphite2/disable-tests.patch b/.github/vcpkg-overlays/graphite2/disable-tests.patch new file mode 100644 index 0000000..d1c1fd9 --- /dev/null +++ b/.github/vcpkg-overlays/graphite2/disable-tests.patch @@ -0,0 +1,48 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 496712d..3df05c7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -82,10 +82,12 @@ if (BUILD_SHARED_LIBS) + endif() + + add_subdirectory(src) +-add_subdirectory(tests) +-add_subdirectory(doc) +-if (NOT GRAPHITE2_NFILEFACE) +- add_subdirectory(gr2fonttest) ++if(NOT DISABLE_TESTS) ++ add_subdirectory(tests) ++ add_subdirectory(doc) ++ if (NOT GRAPHITE2_NFILEFACE) ++ add_subdirectory(gr2fonttest) ++ endif() + endif() + + set(version 3.0.1) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index b6ac26b..851a97f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -127,9 +127,9 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + endif () + endif() + include(Graphite) +- if (BUILD_SHARED_LIBS) ++ if (NOT DISABLE_TESTS) + nolib_test(stdc++ $) +- endif () ++ endif() + set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") + CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + endif() +@@ -144,7 +144,9 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + endif() + target_link_libraries(graphite2 c) + include(Graphite) +- nolib_test(stdc++ $) ++ if (NOT DISABLE_TESTS) ++ nolib_test(stdc++ $) ++ endif() + set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") + CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + endif() diff --git a/.github/vcpkg-overlays/graphite2/portfile.cmake b/.github/vcpkg-overlays/graphite2/portfile.cmake new file mode 100644 index 0000000..f0c21fd --- /dev/null +++ b/.github/vcpkg-overlays/graphite2/portfile.cmake @@ -0,0 +1,39 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO silnrsi/graphite + REF 92f59dcc52f73ce747f1cdc831579ed2546884aa # 1.3.14 + SHA512 011855576124b2f9ae9d7d3a0dfc5489794cf82b81bebc02c11c9cca350feb9fbb411844558811dff1ebbacac58a24a7cf56a374fc2c27e97a5fb4795a01486e + HEAD_REF master + PATCHES disable-tests.patch +) + +# Fix symbol visibility for static builds: +# 1. Remove -fvisibility=hidden from target COMPILE_FLAGS +# 2. Add GRAPHITE2_EXPORTING so GR2_API = visibility("default") +file(READ "${SOURCE_PATH}/src/CMakeLists.txt" _src_cmake) +string(REPLACE "-fvisibility=hidden" "" _src_cmake "${_src_cmake}") +string(REPLACE "-fvisibility-inlines-hidden" "" _src_cmake "${_src_cmake}") +string(REPLACE "add_definitions(-DGRAPHITE2_STATIC)" "add_definitions(-DGRAPHITE2_STATIC)\n add_definitions(-DGRAPHITE2_EXPORTING)" _src_cmake "${_src_cmake}") +file(WRITE "${SOURCE_PATH}/src/CMakeLists.txt" "${_src_cmake}") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DDISABLE_TESTS=ON +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup() +vcpkg_fixup_pkgconfig() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + # Keep original GRAPHITE2_STATIC check — GRAPHITE2_EXPORTING overrides it + message(STATUS "graphite2 overlay: GRAPHITE2_EXPORTING set for proper symbol export") +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libgraphite2.la" "${CURRENT_PACKAGES_DIR}/debug/lib/libgraphite2.la") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/LICENSE") diff --git a/.github/vcpkg-overlays/graphite2/vcpkg.json b/.github/vcpkg-overlays/graphite2/vcpkg.json new file mode 100644 index 0000000..d39f030 --- /dev/null +++ b/.github/vcpkg-overlays/graphite2/vcpkg.json @@ -0,0 +1,11 @@ +{ + "name": "graphite2", + "version": "1.3.14", + "port-version": 100, + "description": "Graphite2 with default symbol visibility (overlay port)", + "homepage": "https://github.com/silnrsi/graphite", + "dependencies": [ + { "name": "vcpkg-cmake", "host": true }, + { "name": "vcpkg-cmake-config", "host": true } + ] +} diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml index 83e10e7..13faa46 100644 --- a/.github/workflows/build-desktop.yml +++ b/.github/workflows/build-desktop.yml @@ -447,12 +447,11 @@ jobs: sudo apt-get update sudo apt-get install -y \ libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf \ - autoconf autoconf-archive automake libtool pkg-config + autoconf autoconf-archive automake libtool pkg-config mold - # Static linking via vcpkg — avoids runtime dependency on system ICU/harfbuzz. - # Without this, the binary links against the build host's libicuuc.so.70 - # (Ubuntu 22.04) and fails on distros shipping newer ICU (e.g. Ubuntu 25.10 - # with libicuuc.so.76). Mirrors the macOS approach (commit 9566956). + # vcpkg provides ICU/harfbuzz/graphite2/freetype/fontconfig as dynamic libs. + # This avoids runtime dependency on system ICU version (issue #91). + # graphite2 overlay fixes hidden symbol visibility for rust-lld compat. - name: Setup vcpkg run: | git clone --depth 1 https://github.com/microsoft/vcpkg $HOME/vcpkg @@ -464,7 +463,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ~/vcpkg/installed - key: vcpkg-linux-x64-v1 + key: vcpkg-linux-x64-mold-v1 - name: Install Linux dependencies (vcpkg) if: steps.vcpkg-cache.outputs.cache-hit != 'true' @@ -472,6 +471,7 @@ jobs: VCPKG_BINARY_SOURCES: "clear" run: | $HOME/vcpkg/vcpkg install \ + --overlay-ports=$GITHUB_WORKSPACE/.github/vcpkg-overlays \ "harfbuzz[graphite2]:x64-linux" \ fontconfig:x64-linux \ freetype:x64-linux \ @@ -482,7 +482,7 @@ jobs: uses: actions/cache/save@v4 with: path: ~/vcpkg/installed - key: vcpkg-linux-x64-v1 + key: vcpkg-linux-x64-mold-v1 - uses: dtolnay/rust-toolchain@stable with: @@ -508,7 +508,18 @@ jobs: TECTONIC_DEP_BACKEND: vcpkg CXXFLAGS: "-std=c++17" CFLAGS: "" - run: pnpm --filter @claude-prism/desktop tauri build --target x86_64-unknown-linux-gnu + # mold handles both graphite2 hidden symbols and Rust version scripts. + # Prepend vcpkg lib path so ICU/harfbuzz from vcpkg are found before + # system versions (prevents ICU version suffix mismatch). + RUSTFLAGS: "-C link-arg=-fuse-ld=mold -C link-arg=-L${{ env.VCPKG_ROOT }}/installed/x64-linux/lib" + run: | + # Move system ICU .so out of the way so linker finds vcpkg's ICU first. + # System ICU (v70/74) has different version suffix than vcpkg ICU (v78). + sudo mkdir -p /usr/lib/x86_64-linux-gnu/icu-system-backup + sudo mv /usr/lib/x86_64-linux-gnu/libicu*.so* /usr/lib/x86_64-linux-gnu/icu-system-backup/ 2>/dev/null || true + pnpm --filter @claude-prism/desktop tauri build --target x86_64-unknown-linux-gnu + # Restore system ICU (needed for other tools) + sudo mv /usr/lib/x86_64-linux-gnu/icu-system-backup/libicu*.so* /usr/lib/x86_64-linux-gnu/ 2>/dev/null || true - name: Collect updater artifacts id: collect