From 25fa5be7e197249f602b96bccc5a883d13d60c24 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 2 Jun 2025 23:38:28 +1200 Subject: [PATCH] 'Generic Commit' --- ipdemo/CMakeLists.txt | 20 +++++- src/dropshell-build | 3 +- src/dropshell-build-install-requirements | 86 +++++++++++++++++++++++- test.sh | 2 + 4 files changed, 107 insertions(+), 4 deletions(-) diff --git a/ipdemo/CMakeLists.txt b/ipdemo/CMakeLists.txt index 4dc6da5..a7ac8a9 100644 --- a/ipdemo/CMakeLists.txt +++ b/ipdemo/CMakeLists.txt @@ -79,8 +79,24 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git GIT_TAG v0.8.3 ) -FetchContent_MakeAvailable(cpptrace) +# Explicitly configure cpptrace to use libunwind +set(CPPTRACE_UNWIND_WITH_LIBUNWIND ON CACHE BOOL "Use libunwind for unwinding" FORCE) +set(CPPTRACE_UNWIND_WITH_UNWIND OFF CACHE BOOL "Disable libgcc unwind" FORCE) +set(CPPTRACE_UNWIND_WITH_EXECINFO OFF CACHE BOOL "Disable execinfo" FORCE) +set(CPPTRACE_UNWIND_WITH_WINAPI OFF CACHE BOOL "Disable winapi" FORCE) +set(CPPTRACE_UNWIND_WITH_DBGHELP OFF CACHE BOOL "Disable dbghelp" FORCE) +set(CPPTRACE_UNWIND_WITH_NOTHING OFF CACHE BOOL "Disable nothing backend" FORCE) + +# Disable cpptrace auto-configuration +set(CPPTRACE_NO_AUTO_CONFIG ON CACHE BOOL "Disable cpptrace auto-configuration" FORCE) + +# Explicitly set libunwind paths +set(LibUnwind_INCLUDE_DIR "${CMAKE_SYSROOT}/usr/include" CACHE PATH "libunwind include directory" FORCE) +set(LibUnwind_LIBRARY "${CMAKE_SYSROOT}/usr/lib/libunwind.a" CACHE FILEPATH "libunwind library" FORCE) +set(LibUnwind_FOUND TRUE CACHE BOOL "libunwind found" FORCE) + +FetchContent_MakeAvailable(cpptrace) # Add nlohmann/json FetchContent_Declare( nlohmann_json @@ -92,8 +108,8 @@ FetchContent_MakeAvailable(nlohmann_json) # Link libraries target_link_libraries(${PROJECT_EXE_NAME} PRIVATE libassert::assert - "${CMAKE_SYSROOT}/usr/lib/libunwind.a" cpptrace::cpptrace + "${CMAKE_SYSROOT}/usr/lib/libunwind.a" nlohmann_json::nlohmann_json ) diff --git a/src/dropshell-build b/src/dropshell-build index 7dbeaf6..148b023 100755 --- a/src/dropshell-build +++ b/src/dropshell-build @@ -184,7 +184,8 @@ function build_arch() { -DCMAKE_PREFIX_PATH="${ARCH_SYSROOT}/usr" \ -DCMAKE_LIBRARY_PATH="${ARCH_SYSROOT}/usr/lib" \ -DCMAKE_LIBRARY_PATH="${ARCH_SYSROOT}/usr/lib64" \ - -DCMAKE_INCLUDE_PATH="${ARCH_SYSROOT}/usr/include" + -DCMAKE_INCLUDE_PATH="${ARCH_SYSROOT}/usr/include" \ + -DCPPTRACE_STATIC_DEFINE="true" cd "${ARCH_BUILD_DIR}" || exit 1 ninja -k0 -j"${JOBS}" diff --git a/src/dropshell-build-install-requirements b/src/dropshell-build-install-requirements index 3b5bcbc..6906c7a 100755 --- a/src/dropshell-build-install-requirements +++ b/src/dropshell-build-install-requirements @@ -129,7 +129,7 @@ function check_packages() { # } #---------------------------------------------------------------------------------------------------------- -# unwind for musl cross toolchains +# set_current_arch #---------------------------------------------------------------------------------------------------------- function set_current_arch() { @@ -188,6 +188,10 @@ function set_current_arch() { export MAKEFLAGS="-j${JOBS}" } +#---------------------------------------------------------------------------------------------------------- +# unwind for musl cross toolchains +#---------------------------------------------------------------------------------------------------------- + function install_unwind_musl() { set_current_arch "$1" @@ -219,6 +223,84 @@ function install_unwind_musl() { rm -rf "$BUILD_DIR" } +#---------------------------------------------------------------------------------------------------------- +# libassert for musl cross toolchains +#---------------------------------------------------------------------------------------------------------- + + +function install_libassert_musl() { + local TOOLCHAIN="$1" + set_current_arch "$TOOLCHAIN" + + echo "Installing libassert for ${ARCH}" + + local BUILD_DIR="/tmp/libassert-build-${ARCH}" + rm -rf "${BUILD_DIR}" + mkdir -p "${BUILD_DIR}" + pushd "${BUILD_DIR}" + + git clone --depth 1 --branch v2.1.5 https://github.com/jeremy-rifkin/libassert.git . + mkdir build && cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSROOT="${ARCH_SYSROOT}" \ + -DCMAKE_C_COMPILER="${CC}" \ + -DCMAKE_CXX_COMPILER="${CXX}" \ + -DCMAKE_INSTALL_PREFIX="${ARCH_SYSROOT}/usr" \ + -DBUILD_SHARED_LIBS=OFF + + make + make install + + popd + rm -rf "${BUILD_DIR}" +} + +#---------------------------------------------------------------------------------------------------------- +# cpptrace for musl cross toolchains +#---------------------------------------------------------------------------------------------------------- + +function install_cpptrace_musl() { + local TOOLCHAIN="$1" + set_current_arch "$TOOLCHAIN" + + echo "Installing cpptrace for ${ARCH}" + + local BUILD_DIR="/tmp/cpptrace-build-${ARCH}" + rm -rf "${BUILD_DIR}" + mkdir -p "${BUILD_DIR}" + pushd "${BUILD_DIR}" + + git clone --depth 1 --branch v0.8.3 https://github.com/jeremy-rifkin/cpptrace.git . + mkdir build && cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSROOT="${ARCH_SYSROOT}" \ + -DCMAKE_C_COMPILER="${CC}" \ + -DCMAKE_CXX_COMPILER="${CXX}" \ + -DCMAKE_INSTALL_PREFIX="${ARCH_SYSROOT}/usr" \ + -DCPPTRACE_UNWIND_WITH_LIBUNWIND=ON \ + -DCPPTRACE_UNWIND_WITH_UNWIND=OFF \ + -DCPPTRACE_UNWIND_WITH_EXECINFO=OFF \ + -DCPPTRACE_UNWIND_WITH_WINAPI=OFF \ + -DCPPTRACE_UNWIND_WITH_DBGHELP=OFF \ + -DCPPTRACE_UNWIND_WITH_NOTHING=OFF \ + -DCPPTRACE_NO_AUTO_CONFIG=ON \ + -DLibUnwind_INCLUDE_DIR="${ARCH_SYSROOT}/usr/include" \ + -DLibUnwind_LIBRARY="${ARCH_SYSROOT}/usr/lib/libunwind.a" \ + -DLibUnwind_FOUND=TRUE \ + -DBUILD_SHARED_LIBS=OFF \ + -DCPPTRACE_STATIC_DEFINE=ON + + make -j$(nproc) + make install + + popd + rm -rf "${BUILD_DIR}" +} + #---------------------------------------------------------------------------------------------------------- # OpenSSL for musl cross toolchains #---------------------------------------------------------------------------------------------------------- @@ -330,6 +412,8 @@ function install_musl() { install_openssl_musl "$TOOLCHAIN" install_unwind_musl "$TOOLCHAIN" + install_libassert_musl "$TOOLCHAIN" + install_cpptrace_musl "$TOOLCHAIN" done # Clean up diff --git a/test.sh b/test.sh index e71fec0..89b38a5 100755 --- a/test.sh +++ b/test.sh @@ -6,6 +6,8 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" echo "Testing dropshell-build" +rm -rf "${SCRIPT_DIR}/ipdemo/build" + DROPSHELL_BUILD_TAG="test" "${SCRIPT_DIR}/src/dropshell-build" -r -m "${SCRIPT_DIR}/ipdemo" "${SCRIPT_DIR}/ipdemo/output/ipdemo.x86_64"