diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index fb03a289..43e5bfb2 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -1,5 +1,11 @@ name: Build DexKit Native Libraries +env: + LINUX_CODENAME: xenial + LINUX_SYSROOT_PATH: .dexkit-sysroot/ubuntu-16.04-x86_64 + LINUX_GCC10_HEADERS_PATH: .dexkit-sysroot/gcc10-headers + LINUX_SYSROOT_CACHE_KEY_PREFIX: dexkit-linux-amd64-sysroot-v1 + on: push: branches: [ master ] @@ -12,9 +18,9 @@ jobs: strategy: matrix: sys: - - { name: linux-musl, os: ubuntu-latest, shell: 'alpine.sh --root {0}'} - - { name: windows, os: windows-latest, shell: bash} - - { name: macos, os: macos-latest, shell: bash} + - { name: linux, os: ubuntu-latest, shell: bash} + - { name: windows, os: windows-latest, shell: bash} + - { name: macos, os: macos-latest, shell: bash} defaults: run: shell: ${{ matrix.sys.shell }} @@ -24,50 +30,6 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Setup latest Alpine Linux - uses: jirutka/setup-alpine@v1 - if: ${{ matrix.sys.name == 'linux-musl' }} - with: - arch: x86_64 - packages: > - build-base - cmake - ninja - git - musl-dev - libstdc++ - g++ - openjdk17-jdk - wget - unzip - zlib-dev - - - name: Install Android SDK on Alpine - if: ${{ matrix.sys.name == 'linux-musl' }} - env: - JAVA_HOME: /usr/lib/jvm/java-17-openjdk - run: | - export ANDROID_SDK_ROOT=$HOME/android-sdk - - mkdir -p $ANDROID_SDK_ROOT/cmdline-tools - wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O /tmp/tools.zip - unzip -q /tmp/tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools - rm /tmp/tools.zip - - mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest - - export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH - - yes | sdkmanager --licenses || true - sdkmanager --sdk_root=$ANDROID_SDK_ROOT \ - "platform-tools" \ - "build-tools;33.0.2" \ - "cmake;3.22.1" \ - "ndk;26.1.10909125" \ - "platforms;android-34" - - echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties - - name: Setup Java uses: actions/setup-java@v4 with: @@ -79,25 +41,122 @@ jobs: with: version: 3.25.0 - - name: Build musl PIC static libc (musl) - if: ${{ matrix.sys.name == 'linux-musl' }} - env: - JAVA_HOME: /usr/lib/jvm/java-17-openjdk + - name: Install Linux build tools + if: ${{ matrix.sys.name == 'linux' }} run: | - git clone https://git.musl-libc.org/git/musl - cd musl - CFLAGS="-O2 -fPIC" ./configure --prefix=/opt/musl-pic - make - make install - - - name: Run Gradle CMake build (musl) - if: ${{ matrix.sys.name == 'linux-musl' }} - env: - JAVA_HOME: /usr/lib/jvm/java-17-openjdk - MUSL_PATH: /opt/musl-pic + sudo apt-get update + sudo apt-get install -y clang lld ninja-build binutils xz-utils + + - name: Restore target Linux sysroot cache + if: ${{ matrix.sys.name == 'linux' }} + id: cache_linux_sysroot + uses: actions/cache@v4 + with: + path: ${{ env.LINUX_SYSROOT_PATH }}.tar.xz + key: ${{ env.LINUX_SYSROOT_CACHE_KEY_PREFIX }}-${{ env.LINUX_CODENAME }}-${{ hashFiles('build-support/linux-sysroot/**') }} + + - name: Restore GCC 10 headers cache + if: ${{ matrix.sys.name == 'linux' }} + id: cache_linux_gcc10_headers + uses: actions/cache@v4 + with: + path: ${{ env.LINUX_GCC10_HEADERS_PATH }}.tar.xz + key: ${{ env.LINUX_SYSROOT_CACHE_KEY_PREFIX }}-gcc10-headers-${{ hashFiles('build-support/linux-sysroot/**') }} + + - name: Build missing Linux sysroot and GCC 10 headers + if: ${{ matrix.sys.name == 'linux' }} + run: | + build_sysroot() { + local codename="$1" + local path="$2" + + if [ -f "$path.tar.xz" ]; then + return + fi + + rm -rf "$path" + sudo env \ + UBUNTU_CODENAME="$codename" \ + bash build-support/linux-sysroot/build-linux-sysroot.sh "$path" + sudo tar -C "$path" \ + --exclude=./dev \ + --exclude=./proc \ + --exclude=./sys \ + --exclude=./run \ + --exclude=./tmp \ + --exclude=./var/tmp \ + -cJf "$path.tar.xz" . + sudo chown "$USER:$USER" "$path.tar.xz" + sudo rm -rf "$path" + sudo chown -R "$USER:$USER" "$(dirname "$path")" + } + + build_gcc10_headers() { + local path="$1" + + if [ -f "$path.tar.xz" ]; then + return + fi + + rm -rf "$path" + bash build-support/linux-sysroot/fetch-libstdcxx-headers.sh "$path" + tar -C "$path" -cJf "$path.tar.xz" . + rm -rf "$path" + } + + build_sysroot "$LINUX_CODENAME" "$LINUX_SYSROOT_PATH" + build_gcc10_headers "$LINUX_GCC10_HEADERS_PATH" + + - name: Unpack Linux sysroot and GCC 10 headers + if: ${{ matrix.sys.name == 'linux' }} + run: | + unpack_archive() { + local path="$1" + rm -rf "$path" + mkdir -p "$path" + tar -C "$path" -xJf "$path.tar.xz" + } + + unpack_archive "$LINUX_SYSROOT_PATH" + unpack_archive "$LINUX_GCC10_HEADERS_PATH" + + - name: Prepare Linux compatibility headers + if: ${{ matrix.sys.name == 'linux' }} + run: | + compat_dir="$GITHUB_WORKSPACE/.dexkit-sysroot/compat" + target_sysroot="$GITHUB_WORKSPACE/$LINUX_SYSROOT_PATH" + template_dir="$GITHUB_WORKSPACE/build-support/linux-sysroot" + mkdir -p "$compat_dir/gcc5-thread-wrapper" + cp "$template_dir/glibc-libstdcxx10-compat.h" "$compat_dir/glibc-libstdcxx10-compat.h" + + sed "s|@TARGET_SYSROOT@|$target_sysroot|g" \ + "$template_dir/gcc5-thread-wrapper/thread.in" \ + > "$compat_dir/gcc5-thread-wrapper/thread" + sed "s|@TARGET_SYSROOT@|$target_sysroot|g" \ + "$template_dir/gcc5-thread-wrapper/future.in" \ + > "$compat_dir/gcc5-thread-wrapper/future" + + - name: Run Gradle CMake build (linux) + if: ${{ matrix.sys.name == 'linux' }} run: | chmod +x gradlew - ./gradlew :dexkit:cmakeBuild -PlinuxMuslBuild --console=plain + + sysroot="$GITHUB_WORKSPACE/$LINUX_SYSROOT_PATH" + gcc10_headers="$GITHUB_WORKSPACE/$LINUX_GCC10_HEADERS_PATH/usr/include" + compat_dir="$GITHUB_WORKSPACE/.dexkit-sysroot/compat" + compat_header="$compat_dir/glibc-libstdcxx10-compat.h" + cxxflags="-fno-exceptions -nostdinc++ -isystem $compat_dir/gcc5-thread-wrapper -isystem $gcc10_headers/c++/10 -isystem $gcc10_headers/x86_64-linux-gnu/c++/10 -include $compat_header" + + export CC="clang --sysroot=$sysroot --gcc-toolchain=$sysroot/usr" + export CXX="clang++ --sysroot=$sysroot --gcc-toolchain=$sysroot/usr" + export AR=llvm-ar + export RANLIB=llvm-ranlib + export LD=ld.lld + export CFLAGS="" + export CXXFLAGS="$cxxflags" + export LDFLAGS="-Wl,--no-as-needed -lpthread" + + ./gradlew :dexkit:cmakeBuild --console=plain - name: Run Gradle CMake build (windows) if: ${{ matrix.sys.name == 'windows' }} diff --git a/.gitignore b/.gitignore index 98303eb1..dcba87bf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,8 @@ .externalNativeBuild .cxx local.properties +.dexkit-sysroot/ /docs /doc -/apk \ No newline at end of file +/apk diff --git a/build-support/linux-sysroot/README.md b/build-support/linux-sysroot/README.md new file mode 100644 index 00000000..beb9076d --- /dev/null +++ b/build-support/linux-sysroot/README.md @@ -0,0 +1,165 @@ +# Linux sysroot builds + +This directory contains helper files for building DexKit Linux binaries against +older Ubuntu runtime libraries. + +The goal is to keep the generated `libdexkit.so` compatible with the target +distribution's glibc, libstdc++, and libgcc runtime. Do not add +`ppa:ubuntu-toolchain-r/test` to the sysroot: the compatibility target is the +toolchain shipped by the distribution itself. That PPA can upgrade runtime +packages such as `libstdc++6`, so the sysroot would no longer represent the +distribution-provided runtime. + +Run the commands from the repository root. `build-linux-sysroot.sh` must run as +root because `debootstrap` creates device nodes and package metadata inside the +sysroot. If a sysroot or headers directory already exists, remove it first. + +## Pack sysroot backups + +After building a sysroot, it can be packed for backup or reuse. Replace the +path with the target sysroot that was built: + +```bash +sudo tar -C .dexkit-sysroot/ubuntu-16.04-x86_64 \ + --exclude=./dev \ + --exclude=./proc \ + --exclude=./sys \ + --exclude=./run \ + --exclude=./tmp \ + --exclude=./var/tmp \ + -cJf .dexkit-sysroot/ubuntu-16.04-x86_64.tar.xz . +``` + +The GCC 10 headers directory can be packed without special excludes: + +```bash +tar -C .dexkit-sysroot/gcc10-headers \ + -cJf .dexkit-sysroot/gcc10-headers.tar.xz . +``` + +To unpack a backup: + +```bash +rm -rf .dexkit-sysroot/ubuntu-16.04-x86_64 +mkdir -p .dexkit-sysroot/ubuntu-16.04-x86_64 +tar -C .dexkit-sysroot/ubuntu-16.04-x86_64 \ + -xJf .dexkit-sysroot/ubuntu-16.04-x86_64.tar.xz + +rm -rf .dexkit-sysroot/gcc10-headers +mkdir -p .dexkit-sysroot/gcc10-headers +tar -C .dexkit-sysroot/gcc10-headers \ + -xJf .dexkit-sysroot/gcc10-headers.tar.xz +``` + +## Ubuntu 20.04 target + +Ubuntu 20.04 is the baseline C++20 build. Its sysroot includes GCC 10 headers +and libstdc++. + +```bash +sudo env UBUNTU_CODENAME=focal \ + bash build-support/linux-sysroot/build-linux-sysroot.sh \ + .dexkit-sysroot/ubuntu-20.04-x86_64 + +SYSROOT="$PWD/.dexkit-sysroot/ubuntu-20.04-x86_64" + +export CC="clang --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export CXX="clang++ --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export AR=llvm-ar +export RANLIB=llvm-ranlib +export LD=ld.lld + +./gradlew :dexkit:cmakeBuild --console=plain +``` + +## Ubuntu 18.04 target + +Ubuntu 18.04 has an older runtime, but it can use the GCC 10 C++ headers +for C++20 `std::span` and `std::string_view::starts_with` / +`std::string_view::ends_with`. + +```bash +sudo env UBUNTU_CODENAME=bionic \ + bash build-support/linux-sysroot/build-linux-sysroot.sh \ + .dexkit-sysroot/ubuntu-18.04-x86_64 + +bash build-support/linux-sysroot/fetch-libstdcxx-headers.sh \ + .dexkit-sysroot/gcc10-headers + +SYSROOT="$PWD/.dexkit-sysroot/ubuntu-18.04-x86_64" +GCC10_HEADERS="$PWD/.dexkit-sysroot/gcc10-headers/usr/include" +COMPAT_HEADER="$PWD/.dexkit-sysroot/compat/glibc-libstdcxx10-compat.h" + +mkdir -p "$(dirname "$COMPAT_HEADER")" +cp build-support/linux-sysroot/glibc-libstdcxx10-compat.h "$COMPAT_HEADER" + +export CC="clang --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export CXX="clang++ --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export AR=llvm-ar +export RANLIB=llvm-ranlib +export LD=ld.lld +export CFLAGS= +export CXXFLAGS="-nostdinc++ -isystem $GCC10_HEADERS/c++/10 -isystem $GCC10_HEADERS/x86_64-linux-gnu/c++/10 -include $COMPAT_HEADER" +export LDFLAGS="-Wl,--no-as-needed -lpthread" + +./gradlew :dexkit:cmakeBuild --console=plain +``` + +`glibc-libstdcxx10-compat.h` undefines libstdc++ feature macros for pthread +clock APIs that are unavailable in the older glibc target. + +`-lpthread` is needed for pre-2.34 glibc targets such as Ubuntu 18.04 because +pthread is still provided by a separate `libpthread.so.0` there. `--no-as-needed` +keeps `libpthread.so.0` in the dynamic dependencies even if the linker only sees +pthread usage indirectly through libstdc++. + +`fetch-libstdcxx-headers.sh` downloads `libstdc++-10-dev` by parsing Ubuntu +`Packages.xz` indexes. It defaults to the focal repositories because GCC 10 is +the distro compiler there. + +## Ubuntu 16.04 target + +Ubuntu 16.04 is the most constrained target. It uses the xenial GCC 5 runtime, +GCC 10 C++ headers for C++20 library declarations, and wrapper headers for +`` and `` so thread construction uses the GCC 5 `_Impl_base` +ABI. Exceptions are disabled to avoid depending on newer exception ABI symbols. + +```bash +sudo env UBUNTU_CODENAME=xenial \ + bash build-support/linux-sysroot/build-linux-sysroot.sh \ + .dexkit-sysroot/ubuntu-16.04-x86_64 + +bash build-support/linux-sysroot/fetch-libstdcxx-headers.sh \ + .dexkit-sysroot/gcc10-headers + +SYSROOT="$PWD/.dexkit-sysroot/ubuntu-16.04-x86_64" +GCC10_HEADERS="$PWD/.dexkit-sysroot/gcc10-headers/usr/include" +COMPAT_DIR="$PWD/.dexkit-sysroot/compat" +COMPAT_HEADER="$COMPAT_DIR/glibc-libstdcxx10-compat.h" +WRAPPER_DIR="$COMPAT_DIR/gcc5-thread-wrapper" + +mkdir -p "$WRAPPER_DIR" +cp build-support/linux-sysroot/glibc-libstdcxx10-compat.h "$COMPAT_HEADER" +sed "s|@TARGET_SYSROOT@|$SYSROOT|g" \ + build-support/linux-sysroot/gcc5-thread-wrapper/thread.in \ + > "$WRAPPER_DIR/thread" +sed "s|@TARGET_SYSROOT@|$SYSROOT|g" \ + build-support/linux-sysroot/gcc5-thread-wrapper/future.in \ + > "$WRAPPER_DIR/future" + +export CC="clang --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export CXX="clang++ --sysroot=$SYSROOT --gcc-toolchain=$SYSROOT/usr" +export AR=llvm-ar +export RANLIB=llvm-ranlib +export LD=ld.lld +export CFLAGS= +export CXXFLAGS="-fno-exceptions -nostdinc++ -isystem $WRAPPER_DIR -isystem $GCC10_HEADERS/c++/10 -isystem $GCC10_HEADERS/x86_64-linux-gnu/c++/10 -include $COMPAT_HEADER" +export LDFLAGS="-Wl,--no-as-needed -lpthread" + +./gradlew :dexkit:cmakeBuild --console=plain +``` + +Compared with 18.04, the 16.04 target additionally needs the GCC 5 +``/`` wrappers and `-fno-exceptions`. These are only for the +GCC 5 libstdc++ runtime; they can be removed if the minimum target is raised to +18.04 or newer. diff --git a/build-support/linux-sysroot/build-linux-sysroot.sh b/build-support/linux-sysroot/build-linux-sysroot.sh new file mode 100644 index 00000000..d7b34a24 --- /dev/null +++ b/build-support/linux-sysroot/build-linux-sysroot.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +set -e + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 2 +fi + +sysroot_path="$1" +ubuntu_mirror="${UBUNTU_MIRROR:-http://archive.ubuntu.com/ubuntu/}" +ubuntu_codename="${UBUNTU_CODENAME:-focal}" +ubuntu_components="${UBUNTU_COMPONENTS:-main universe}" +if [ "${UBUNTU_EXTRA_PACKAGES+x}" ]; then + extra_packages="$UBUNTU_EXTRA_PACKAGES" +else + extra_packages="" +fi + +if [ -e "$sysroot_path" ]; then + echo "error: sysroot path already exists: $sysroot_path" >&2 + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo "error: this script must be run as root" >&2 + exit 1 +fi + +apt-get update +apt-get install -y debootstrap ubuntu-keyring ca-certificates gnupg xz-utils + +mkdir -p "$(dirname "$sysroot_path")" + +debootstrap \ + --variant=minbase \ + --force-check-gpg \ + --arch amd64 \ + "$ubuntu_codename" \ + "$sysroot_path" \ + "$ubuntu_mirror" + +rm -f "$sysroot_path/etc/apt/sources.list" +rm -rf "$sysroot_path/etc/apt/sources.list.d" +mkdir -p "$sysroot_path/etc/apt/sources.list.d" + +cat < "$sysroot_path/etc/apt/sources.list.d/$ubuntu_codename.list" +deb $ubuntu_mirror $ubuntu_codename $ubuntu_components +deb $ubuntu_mirror $ubuntu_codename-updates $ubuntu_components +deb $ubuntu_mirror $ubuntu_codename-security $ubuntu_components +deb $ubuntu_mirror $ubuntu_codename-backports $ubuntu_components +EOF + +chroot "$sysroot_path" apt-get update +chroot "$sysroot_path" apt-get -f -y install +chroot "$sysroot_path" apt-get -y install \ + build-essential \ + gcc \ + g++ \ + zlib1g-dev \ + symlinks \ + $extra_packages + +chroot "$sysroot_path" symlinks -cr /usr +chroot "$sysroot_path" apt-get clean +rm -rf "$sysroot_path/var/lib/apt/lists"/* "$sysroot_path/tmp"/* "$sysroot_path/var/tmp"/* diff --git a/build-support/linux-sysroot/fetch-libstdcxx-headers.sh b/build-support/linux-sysroot/fetch-libstdcxx-headers.sh new file mode 100644 index 00000000..082dd5b3 --- /dev/null +++ b/build-support/linux-sysroot/fetch-libstdcxx-headers.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 2 +fi + +output_path="$1" +ubuntu_mirror="${UBUNTU_MIRROR:-http://archive.ubuntu.com/ubuntu/}" +ubuntu_codename="${UBUNTU_CODENAME:-focal}" +ubuntu_arch="${UBUNTU_ARCH:-amd64}" +ubuntu_components="${UBUNTU_COMPONENTS:-main universe}" +package_name="${UBUNTU_LIBSTDCXX_DEV_PACKAGE:-libstdc++-10-dev}" + +if [ -e "$output_path" ]; then + echo "error: output path already exists: $output_path" >&2 + exit 1 +fi + +if ! command -v xz >/dev/null 2>&1; then + echo "error: xz is required to read Ubuntu package indexes" >&2 + exit 1 +fi + +download() { + local url="$1" + local output="$2" + + if command -v curl >/dev/null 2>&1; then + curl -fsSL "$url" -o "$output" + elif command -v wget >/dev/null 2>&1; then + wget -qO "$output" "$url" + else + echo "error: curl or wget is required" >&2 + exit 1 + fi +} + +tmpdir="$(mktemp -d)" +trap 'rm -rf "$tmpdir"' EXIT + +find_package_filename() { + local suite="$1" + local component="$2" + local packages_xz="$3" + local url="${ubuntu_mirror%/}/dists/$suite/$component/binary-$ubuntu_arch/Packages.xz" + + if ! download "$url" "$packages_xz" 2>/dev/null; then + return 1 + fi + + xz -dc "$packages_xz" | awk -v package_name="$package_name" ' + BEGIN { RS = ""; FS = "\n" } + { + package = ""; + filename = ""; + for (i = 1; i <= NF; i++) { + if ($i ~ /^Package: /) { + package = substr($i, 10); + } else if ($i ~ /^Filename: /) { + filename = substr($i, 11); + } + } + if (package == package_name && filename != "") { + print filename; + exit; + } + } + ' +} + +package_filename="" +for suite in "$ubuntu_codename-updates" "$ubuntu_codename-security" "$ubuntu_codename"; do + for component in $ubuntu_components; do + candidate="$(find_package_filename "$suite" "$component" "$tmpdir/Packages.xz" || true)" + if [ -n "$candidate" ]; then + package_filename="$candidate" + break 2 + fi + done +done + +if [ -z "$package_filename" ]; then + echo "error: cannot find $package_name in $ubuntu_codename repositories" >&2 + exit 1 +fi + +mkdir -p "$(dirname "$output_path")" +download "${ubuntu_mirror%/}/$package_filename" "$tmpdir/$package_name.deb" +mkdir -p "$output_path" +dpkg-deb -x "$tmpdir/$package_name.deb" "$output_path" + +if [ ! -d "$output_path/usr/include/c++/10" ] || \ + [ ! -d "$output_path/usr/include/x86_64-linux-gnu/c++/10" ]; then + echo "error: $package_name did not provide the expected GCC 10 headers" >&2 + exit 1 +fi diff --git a/build-support/linux-sysroot/gcc5-thread-wrapper/future.in b/build-support/linux-sysroot/gcc5-thread-wrapper/future.in new file mode 100644 index 00000000..7f0dd26a --- /dev/null +++ b/build-support/linux-sysroot/gcc5-thread-wrapper/future.in @@ -0,0 +1,2 @@ +#pragma once +#include "@TARGET_SYSROOT@/usr/include/c++/5/future" diff --git a/build-support/linux-sysroot/gcc5-thread-wrapper/thread.in b/build-support/linux-sysroot/gcc5-thread-wrapper/thread.in new file mode 100644 index 00000000..b38685ee --- /dev/null +++ b/build-support/linux-sysroot/gcc5-thread-wrapper/thread.in @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include +#include + +namespace std { + template + struct __dexkit_bind_simple + { + tuple, decay_t<_Args>...> _M_bound; + + explicit __dexkit_bind_simple(_Callable&& __f, _Args&&... __args) + : _M_bound(std::forward<_Callable>(__f), std::forward<_Args>(__args)...) + { } + + decltype(auto) operator()() + { + return std::apply([](auto& __f, auto&... __args) -> decltype(auto) { + return std::invoke(std::move(__f), std::move(__args)...); + }, _M_bound); + } + }; + + template + auto __bind_simple(_Callable&& __f, _Args&&... __args) + { + return __dexkit_bind_simple<_Callable, _Args...>( + std::forward<_Callable>(__f), std::forward<_Args>(__args)...); + } +} + +#include "@TARGET_SYSROOT@/usr/include/c++/5/thread" diff --git a/build-support/linux-sysroot/glibc-libstdcxx10-compat.h b/build-support/linux-sysroot/glibc-libstdcxx10-compat.h new file mode 100644 index 00000000..10612d7b --- /dev/null +++ b/build-support/linux-sysroot/glibc-libstdcxx10-compat.h @@ -0,0 +1,4 @@ +#include +#undef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT +#undef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK +#undef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK diff --git a/dexkit-dev/build.gradle b/dexkit-dev/build.gradle index e2cb2eaf..99e6bfa0 100644 --- a/dexkit-dev/build.gradle +++ b/dexkit-dev/build.gradle @@ -7,7 +7,6 @@ plugins { } def dexkitSourceProject = project(":dexkit") -def isLinux = System.getProperty('os.name').toLowerCase().contains('linux') base { archivesName = "dexkit-dev" @@ -28,9 +27,6 @@ cmake { cmakeArgs.add("-DCMAKE_C_FLAGS_RELEASE=$configFlags") cmakeArgs.add("-DDEXKIT_ENABLE_INTERNAL_METRICS=ON") cmakeArgs.add("-DDEXKIT_ENABLE_INTERNAL_METRICS_API=ON") - if (project.hasProperty("linuxMuslBuild") && isLinux) { - cmakeArgs.add("-DUSE_MUSL_LIBC=ON") - } } } } diff --git a/dexkit/build.gradle b/dexkit/build.gradle index f2bb149e..bc6411c4 100644 --- a/dexkit/build.gradle +++ b/dexkit/build.gradle @@ -6,7 +6,6 @@ plugins { id("io.github.tomtzook.gradle-cmake") version "1.2.2" } -def isLinux = System.getProperty('os.name').toLowerCase().contains('linux') def enableInternalMetricsApi = providers.gradleProperty("enableInternalMetricsApi") .map { it.toBoolean() } .orElse(false) @@ -30,9 +29,6 @@ cmake { cmakeArgs.add("-DCMAKE_C_FLAGS_RELEASE=$configFlags") cmakeArgs.add("-DDEXKIT_ENABLE_INTERNAL_METRICS=${enableInternalMetricsApi ? 'ON' : 'OFF'}") cmakeArgs.add("-DDEXKIT_ENABLE_INTERNAL_METRICS_API=${enableInternalMetricsApi ? 'ON' : 'OFF'}") - if (project.hasProperty("linuxMuslBuild") && isLinux) { - cmakeArgs.add("-DUSE_MUSL_LIBC=ON") - } } } } diff --git a/dexkit/src/main/cpp/CMakeLists.txt b/dexkit/src/main/cpp/CMakeLists.txt index 44c024c5..cabc4259 100644 --- a/dexkit/src/main/cpp/CMakeLists.txt +++ b/dexkit/src/main/cpp/CMakeLists.txt @@ -39,48 +39,6 @@ if (WIN32) -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive ) endif() -elseif (UNIX AND NOT APPLE) - if(USE_MUSL_LIBC) - if(DEFINED ENV{MUSL_PATH}) - set(MUSL_PATH $ENV{MUSL_PATH}) - else() - set(MUSL_PATH "" CACHE PATH "Path to PIC musl install") - endif() - - if(NOT EXISTS "${MUSL_PATH}/include/stdlib.h" OR NOT EXISTS "${MUSL_PATH}/lib/libc.a") - message(FATAL_ERROR "MUSL_PATH=${MUSL_PATH} is illegal. Please check whether you have made install musl-pic.") - endif() - - set_target_properties(${PROJECT_NAME} PROPERTIES - SKIP_BUILD_RPATH TRUE - ) - target_include_directories(${PROJECT_NAME} - PRIVATE - ${MUSL_PATH}/include - ) - - target_link_directories(${PROJECT_NAME} - PRIVATE - ${MUSL_PATH}/lib - ) - - target_compile_options(${PROJECT_NAME} - PRIVATE - -ffunction-sections - -fdata-sections - -flto - ) - - target_link_options(${PROJECT_NAME} - PRIVATE - -nodefaultlibs - -Wl,--whole-archive -lc -Wl,--no-whole-archive - -Wl,--gc-sections - -Wl,--exclude-libs,ALL - -Wl,--strip-all - -flto - ) - endif() elseif (APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS deployment version" FORCE) endif()