diff options
| author | Stefan Boberg <[email protected]> | 2026-03-16 10:28:28 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-16 10:28:28 +0100 |
| commit | 252b98eaf76cc3e702b8e9fc0e3a835af5d7b33e (patch) | |
| tree | 71e60a1a5b2a50c8cb305b2e259b4fb83dcd57d9 | |
| parent | URI decoding, process env, compiler info, httpasio strands, regex route remov... (diff) | |
| download | zen-252b98eaf76cc3e702b8e9fc0e3a835af5d7b33e.tar.xz zen-252b98eaf76cc3e702b8e9fc0e3a835af5d7b33e.zip | |
Linux build improvements (#843)
- **Sentry crashpad patch**: Make static libc++ linking conditional on `-stdlib=libc++` being active, so the patch doesn't break gcc or system clang builds that use libstdc++
- **GCC warning fix**: Suppress `-Wunused-but-set-variable` for gcc (false positive with `constinit` static locals passed by reference)
- **ASIO typo fix**: `ASIO_STANDLONE` → `ASIO_STANDALONE`
- **Toolchain verification script**: `scripts/ue_build_linux/verify_linux_toolchains.sh` for testing builds across gcc, ue-clang, clang-19 and clang-20
| -rw-r--r-- | repo/packages/s/sentry-native/patches/0.12.1/crashpad_static_libcxx.patch | 31 | ||||
| -rw-r--r-- | repo/packages/s/sentry-native/xmake.lua | 2 | ||||
| -rwxr-xr-x | scripts/ue_build_linux/verify_linux_toolchains.sh | 121 | ||||
| -rw-r--r-- | thirdparty/asio/asio/include/asio/detail/io_uring_service.hpp | 2 | ||||
| -rw-r--r-- | thirdparty/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake.lua | 2 |
6 files changed, 146 insertions, 18 deletions
diff --git a/repo/packages/s/sentry-native/patches/0.12.1/crashpad_static_libcxx.patch b/repo/packages/s/sentry-native/patches/0.12.1/crashpad_static_libcxx.patch index 2005ad4ec..8d0a8f11e 100644 --- a/repo/packages/s/sentry-native/patches/0.12.1/crashpad_static_libcxx.patch +++ b/repo/packages/s/sentry-native/patches/0.12.1/crashpad_static_libcxx.patch @@ -1,24 +1,25 @@ --- a/external/crashpad/handler/CMakeLists.txt 2026-03-09 14:47:42.109197582 +0000 +++ b/external/crashpad/handler/CMakeLists.txt 2026-03-09 14:51:45.343538268 +0000 -@@ -120,6 +120,21 @@ +@@ -120,6 +120,22 @@ endif() endif() - + ++ # Statically link libc++ and libc++abi into crashpad_handler so it has ++ # no runtime dependency on libc++.so.1. This is needed when building with ++ # a toolchain that uses libc++ (e.g. UE clang) but deploys to systems ++ # where libc++.so.1 is not available. ++ # Only applied when -stdlib=libc++ is active (i.e. not GCC or system clang ++ # using libstdc++). + if(LINUX) -+ # Statically link libc++ and libc++abi into crashpad_handler so it has -+ # no runtime dependency on libc++.so.1. This is needed when building with -+ # a toolchain that uses libc++ (e.g. UE clang) but deploys to systems -+ # where libc++.so.1 is not available. -+ # -nostdlib++ suppresses clang's automatic -lc++ addition (a linker flag, -+ # added at the end). The explicit -Bstatic libs are added via -+ # target_link_libraries so they appear after crashpad's static archives in -+ # the link order, letting the single-pass linker resolve all libc++ symbols. -+ target_link_options(crashpad_handler PRIVATE -nostdlib++) -+ target_link_libraries(crashpad_handler PRIVATE -+ -Wl,-Bstatic,-lc++,-lc++abi,-Bdynamic -+ ) ++ string(FIND "${CMAKE_CXX_FLAGS}" "-stdlib=libc++" _libcxx_pos) ++ if(NOT _libcxx_pos EQUAL -1) ++ target_link_options(crashpad_handler PRIVATE -nostdlib++) ++ target_link_libraries(crashpad_handler PRIVATE ++ -Wl,-Bstatic,-lc++,-lc++abi,-Bdynamic ++ ) ++ endif() + endif() + set_property(TARGET crashpad_handler PROPERTY EXPORT_NAME crashpad_handler) add_executable(crashpad::handler ALIAS crashpad_handler) - + diff --git a/repo/packages/s/sentry-native/xmake.lua b/repo/packages/s/sentry-native/xmake.lua index 43672b9de..0da513ead 100644 --- a/repo/packages/s/sentry-native/xmake.lua +++ b/repo/packages/s/sentry-native/xmake.lua @@ -37,7 +37,7 @@ package("sentry-native") add_versions("0.4.4", "fe6c711d42861e66e53bfd7ee0b2b226027c64446857f0d1bbb239ca824a3d8d") add_patches("0.4.4", path.join(os.scriptdir(), "patches", "0.4.4", "zlib_fix.patch"), "1a6ac711b7824112a9062ec1716a316facce5055498d1f87090d2cad031b865b") add_patches("0.7.6", path.join(os.scriptdir(), "patches", "0.7.6", "breakpad_exceptions.patch"), "7781bad0404a92252cbad39e865d17ac663eedade03cbd29c899636c7bfab1b5") - add_patches("0.12.1", path.join(os.scriptdir(), "patches", "0.12.1", "crashpad_static_libcxx.patch"), "3c2115b90179808fa639865f6eb23090e2cb6025d816ffb66c2d75c26473ec72") + add_patches("0.12.1", path.join(os.scriptdir(), "patches", "0.12.1", "crashpad_static_libcxx.patch"), "e297c1b9dc58f446edfec5566a73c9e3e6b53c207f7247d45b93c640af2bff1a") add_patches("0.12.1", path.join(os.scriptdir(), "patches", "0.12.1", "breakpad_exceptions.patch"), "9e0cd152192f87b9ce182c8ddff22c0471acb99bd61a872ca48afbbacdf27575") add_deps("cmake") diff --git a/scripts/ue_build_linux/verify_linux_toolchains.sh b/scripts/ue_build_linux/verify_linux_toolchains.sh new file mode 100755 index 000000000..10fad8a82 --- /dev/null +++ b/scripts/ue_build_linux/verify_linux_toolchains.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# +# Verify that the project builds on Linux with gcc, ue-clang, clang-19 and clang-20. +# Each toolchain gets a clean slate (build dirs + xmake caches wiped). +# +# Usage: +# ./scripts/verify_linux_toolchains.sh # build all four +# ./scripts/verify_linux_toolchains.sh gcc clang-19 # build only specific ones +# ./scripts/verify_linux_toolchains.sh --clean # also wipe ~/.xmake package cache +# +# Installing toolchains (Ubuntu 24.04): +# - gcc: sudo apt install build-essential +# - ue-clang: use scripts/ue_build_linux/get_ue_toolchain.sh +# - clang-19: sudo apt install clang-19 +# - clang-20: sudo apt install clang-20 + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +PASSED=() +FAILED=() +declare -A TIMINGS +CLEAN_XMAKE_HOME=false + +clean_build_state() { + echo -e "${YELLOW}Cleaning build state...${NC}" + rm -rf "$PROJECT_DIR/.xmake" "$PROJECT_DIR/build" + if [ "$CLEAN_XMAKE_HOME" = true ]; then + rm -rf ~/.xmake + fi +} + +build_toolchain() { + local NAME="$1" + shift + local CONFIG_ARGS=("$@") + + echo "" + echo "============================================================" + echo -e "${YELLOW}Building with: ${NAME}${NC}" + echo " xmake config args: ${CONFIG_ARGS[*]}" + echo "============================================================" + + clean_build_state + + local START_TIME=$SECONDS + + if ! (cd "$PROJECT_DIR" && xmake config -y -m debug "${CONFIG_ARGS[@]}"); then + TIMINGS[$NAME]=$(( SECONDS - START_TIME )) + echo -e "${RED}FAILED: ${NAME} (config, ${TIMINGS[$NAME]}s)${NC}" + FAILED+=("$NAME") + return 1 + fi + + if ! (cd "$PROJECT_DIR" && xmake -y -j"$(nproc)"); then + TIMINGS[$NAME]=$(( SECONDS - START_TIME )) + echo -e "${RED}FAILED: ${NAME} (build, ${TIMINGS[$NAME]}s)${NC}" + FAILED+=("$NAME") + return 1 + fi + + TIMINGS[$NAME]=$(( SECONDS - START_TIME )) + echo -e "${GREEN}PASSED: ${NAME} (${TIMINGS[$NAME]}s)${NC}" + PASSED+=("$NAME") +} + +# Available toolchain configurations +declare -A TOOLCHAINS +TOOLCHAINS[gcc]="--toolchain=gcc" +TOOLCHAINS[ue-clang]="--toolchain=ue-clang" +TOOLCHAINS[clang-19]="--toolchain=clang-19" +TOOLCHAINS[clang-20]="--toolchain=clang-20" + +# Parse arguments +SELECTED=() +for ARG in "$@"; do + if [ "$ARG" = "--clean" ]; then + CLEAN_XMAKE_HOME=true + else + SELECTED+=("$ARG") + fi +done + +if [ ${#SELECTED[@]} -eq 0 ]; then + SELECTED=(gcc ue-clang clang-19 clang-20) +fi + +TOTAL_START=$SECONDS + +for TC in "${SELECTED[@]}"; do + if [ -z "${TOOLCHAINS[$TC]+x}" ]; then + echo -e "${RED}Unknown toolchain: ${TC}${NC}" + echo "Available: ${!TOOLCHAINS[*]}" + exit 1 + fi + + # shellcheck disable=SC2086 + build_toolchain "$TC" ${TOOLCHAINS[$TC]} || true +done + +TOTAL_ELAPSED=$(( SECONDS - TOTAL_START )) + +echo "" +echo "============================================================" +echo "Results (${TOTAL_ELAPSED}s total):" +echo "============================================================" +for TC in "${PASSED[@]}"; do + echo -e " ${GREEN}PASS${NC} ${TC} (${TIMINGS[$TC]}s)" +done +for TC in "${FAILED[@]}"; do + echo -e " ${RED}FAIL${NC} ${TC} (${TIMINGS[$TC]}s)" +done + +[ ${#FAILED[@]} -eq 0 ] diff --git a/thirdparty/asio/asio/include/asio/detail/io_uring_service.hpp b/thirdparty/asio/asio/include/asio/detail/io_uring_service.hpp index 7cc6cc51b..f76ac953a 100644 --- a/thirdparty/asio/asio/include/asio/detail/io_uring_service.hpp +++ b/thirdparty/asio/asio/include/asio/detail/io_uring_service.hpp @@ -50,7 +50,7 @@ private: public: enum op_types { read_op = 0, write_op = 1, except_op = 2, max_ops = 3 }; - class io_object; + struct io_object; // An I/O queue stores operations that must run serially. class io_queue : operation diff --git a/thirdparty/xmake.lua b/thirdparty/xmake.lua index 59233649a..f06eb6fff 100644 --- a/thirdparty/xmake.lua +++ b/thirdparty/xmake.lua @@ -67,7 +67,11 @@ target('cpr') target('asio') set_kind('headeronly') set_group('thirdparty') - add_defines("ASIO_STANDLONE", "ASIO_HEADER_ONLY", {public=true}) + add_defines("ASIO_STANDALONE", "ASIO_HEADER_ONLY", {public=true}) + if is_plat("linux") and not (get_config("toolchain") == "ue-clang") then + add_defines("ASIO_HAS_IO_URING", {public=true}) + add_packages("liburing", {public=true}) + end add_headerfiles("asio/asio/include/**.hpp") add_includedirs("asio/asio/include", {public=true}) @@ -202,6 +202,8 @@ if is_os("linux") or is_os("macosx") then add_cxxflags("-Wno-unused-value") add_cxxflags("-Wno-unused-variable") add_cxxflags("-Wno-vla-cxx-extension") + -- GCC false positive: constinit static locals used by reference are reported as unused-but-set + add_cxxflags("-Wno-unused-but-set-variable", {tools="gcc"}) end if get_config("toolchain") == "clang-cl" then |