Add armhf and i386

This commit is contained in:
Andrea Cavalli 2023-05-12 01:34:32 +02:00
parent cd6c20969e
commit 9ef688a833
8 changed files with 245 additions and 39 deletions

View File

@ -14,14 +14,14 @@ jobs:
matrix:
include:
# todo: re-enable
- { os: ubuntu-20.04, type: "linux-386-ssl1" }
- { os: ubuntu-20.04, type: "linux-386-ssl3" }
- { os: ubuntu-20.04, type: "linux_amd64_ssl1" }
- { os: ubuntu-20.04, type: "linux_arm64_ssl1" }
- { os: ubuntu-20.04, type: "linux-s390x-ssl1" }
- { os: ubuntu-20.04, type: "linux-ppc64le-ssl1" }
- { os: ubuntu-20.04, type: "linux-riscv64-ssl1" }
- { os: ubuntu-22.04, type: "linux_amd64_ssl3" }
- { os: ubuntu-20.04, type: "linux_arm64_ssl1" }
- { os: ubuntu-22.04, type: "linux_arm64_ssl3" }
- { os: ubuntu-20.04, type: "linux-s390x-ssl3" }
- { os: ubuntu-20.04, type: "linux-ppc64le-ssl3" }
- { os: ubuntu-20.04, type: "linux-riscv64-ssl3" }
#- { os: windows-2019, type: "windows_amd64", vcpkgCommitId: "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98", triplet: "x64-windows-static" }
#- { os: macos-12, type: "macos-amd64" }
steps:

View File

@ -0,0 +1,96 @@
#!/bin/bash -ex
# Ubuntu 22.04
REVISION="${REVISION:-1.0.0.0-SNAPSHOT}"
TOOLCHAIN_FILE="$(readlink -e ./.github/workflows/toolchains/toolchain_i386.cmake)"
# Create missing dirs
rm -rf implementations/tdlight/td_tools_build implementations/tdlight/build api/target-legacy api/target api/.ci-friendly-pom.xml implementations/tdlight/td/generate/auto natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
mkdir -p implementations/tdlight/build implementations/tdlight/build/td_bin/bin implementations/tdlight/td_tools_build/java/it/tdlight/jni api/src/main/java-legacy/it/tdlight/jni api/src/main/java-sealed/it/tdlight/jni natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
# machine-specific flags
HOST_CMAKE_C_COMPILER="/usr/bin/clang-14"
HOST_CMAKE_CXX_COMPILER="/usr/bin/clang++-14"
HOST_CMAKE_C_FLAGS="-fuse-ld=lld"
HOST_CMAKE_CXX_FLAGS="${HOST_CMAKE_C_FLAGS} -stdlib=libc++"
HOST_CMAKE_EXE_LINKER_FLAGS="-lc++ -lc++abi -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind"
# ccache
CCACHE=$(which sccache || true)
if [[ -x "$CCACHE" ]]; then
echo "found sccache: $CCACHE"
else
echo "sccache not found"
CCACHE=$(which ccache)
fi
# Build tdlib tools
cd implementations/tdlight/td_tools_build
CXXFLAGS="-stdlib=libc++" CC="$HOST_CMAKE_C_COMPILER" CXX="$HOST_CMAKE_CXX_COMPILER" cmake \
-DCMAKE_C_COMPILER="${HOST_CMAKE_C_COMPILER}" \
-DCMAKE_CXX_COMPILER="${HOST_CMAKE_CXX_COMPILER}" \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER="$CCACHE" \
-DCMAKE_CXX_COMPILER_LAUNCHER="$CCACHE" \
-DCMAKE_C_FLAGS_RELEASE="" \
-DCMAKE_CXX_FLAGS_RELEASE="-O0 -DNDEBUG" \
-DTD_ENABLE_LTO=OFF \
-DTD_ENABLE_JNI=ON \
..
cmake --build . --target prepare_cross_compiling "-j$(nproc)"
cmake --build . --target td_generate_java_api "-j$(nproc)"
cd ../../../
# Generate TdApi.java
./implementations/tdlight/td_tools_build/td/generate/td_generate_java_api TdApi "./implementations/tdlight/td/generate/auto/tlo/td_api.tlo" "./natives/src/main/java" "it/tdlight/jni"
# Optimization flags
export CMAKE_C_FLAGS="${CMAKE_C_FLAGS}"
export CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti"
export CMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL"
export CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -flto=thin -O3"
# Build tdlib
cd implementations/tdlight/build
INSTALL_PREFIX="$(readlink -e ./td_bin/)"
INSTALL_BINDIR="$(readlink -e ./td_bin/bin)"
cmake \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER="$CCACHE" \
-DCMAKE_CXX_COMPILER_LAUNCHER="$CCACHE" \
-DTD_SKIP_BENCHMARK=ON -DTD_SKIP_TEST=ON -DTD_SKIP_TG_CLI=ON \
-DTD_ENABLE_LTO=ON \
-DTD_ENABLE_JNI=ON \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DCMAKE_INSTALL_BINDIR:PATH="$INSTALL_BINDIR" \
-DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
..
cmake --build . --target install --config Release "-j$(nproc)"
cd ../../../
cd natives/build
cmake \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER="$CCACHE" \
-DCMAKE_CXX_COMPILER_LAUNCHER="$CCACHE" \
-DTD_GENERATED_BINARIES_DIR="$(readlink -e ../../implementations/tdlight/td_tools_build/td/generate)" \
-DTD_SRC_DIR="$(readlink -e ../../implementations/tdlight)" \
-DTD_ENABLE_LTO=ON \
-DTDNATIVES_BIN_DIR="$(readlink -e ../tdjni_bin/)" \
-DTDNATIVES_DOCS_BIN_DIR="$(readlink -e ../tdjni_docs/)" \
-DTd_DIR:PATH="$(readlink -e ../../implementations/tdlight/build/td_bin/lib/cmake/Td)" \
-DJAVA_SRC_DIR="$(readlink -e ../src/main/java)" \
-DTDNATIVES_CPP_SRC_DIR="$(readlink -e ../src/main/cpp)" \
-DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
../src/main/cpp
cmake --build . --target install --config Release "-j$(nproc)"
cd ..
mkdir -p src/main/resources/META-INF/tdlightjni/
mv tdjni_bin/libtdjni.so src/main/resources/META-INF/tdlightjni/libtdjni.linux_386_ssl3.so
mvn -B -f pom.xml -Drevision="$REVISION" -Dnative.type.classifier=linux_386_ssl3 package

View File

@ -0,0 +1,26 @@
#!/bin/bash -ex
# Ubuntu 22.04
export DEBIAN_FRONTEND=noninteractive
dpkg --add-architecture i386
sed 's/deb http/deb \[arch=amd64,i386\] http/' -i /etc/apt/sources.list
apt-get --assume-yes update
# Install and bypass a bug in the cross-platform libc++ packages
apt-get --assume-yes autoremove "libc++-14-dev:*" "libc++abi-14-dev:*" "libc++1-14:*" "libc++abi1-14:*" "libunwind-14-dev:*" "libunwind-14:*" || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-14-dev:i386 libc++abi-14-dev:i386 libc++1-14:i386 libc++abi1-14:i386 libunwind-14-dev:i386 libunwind-14:i386
cp --remove-destination \
/usr/lib/llvm-14/lib/{libc++abi.so,libc++abi.so.1.0,libc++.so,libc++.so.1.0,libunwind.so.1.0} \
/usr/lib/aarch64-linux-gnu/ || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install clang-14 libc++-14-dev libc++abi-14-dev libc++1-14 libc++abi1-14 libunwind-14-dev libunwind-14
# End libc++ packages bugfix
# Add i386 common files
apt-get download libclang-common-14-dev:i386
dpkg-deb -xv libclang-common-14-dev_*_i386.deb /
# Install dependencies
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libssl-dev:i386 zlib1g-dev:i386 openjdk-8-jdk-headless:i386 libgcc-12-dev:i386 libc6-dev:i386

View File

@ -13,17 +13,12 @@ echo "deb [arch=arm64,armhf,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ $(ls
apt-get --assume-yes update
# Install and bypass a bug in the cross-platform libc++ packages
apt-get --assume-yes autoremove libc++-10-dev libc++abi-10-dev libc++1-10 libc++abi1-10 || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-10-dev:arm64 libc++abi-10-dev:arm64
rm -r \
/usr/lib/aarch64-linux-gnu/libc++abi.so \
/usr/lib/aarch64-linux-gnu/libc++abi.so.1.0 \
/usr/lib/aarch64-linux-gnu/libc++.so.1.0
mv -t /usr/lib/aarch64-linux-gnu/ \
/usr/lib/llvm-14/lib/libc++abi.so \
/usr/lib/llvm-14/lib/libc++abi.so.1.0 \
/usr/lib/llvm-14/lib/libc++.so.1.0
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-10-dev libc++abi-10-dev
apt-get --assume-yes autoremove "libc++-10-dev:*" "libc++abi-10-dev:*" "libc++1-10:*" "libc++abi1-10:*" || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-10-dev:arm64 libc++abi-10-dev:arm64 libc++1-10:arm64 libc++abi1-10:arm64
cp --remove-destination \
/usr/lib/llvm-10/lib/{libc++abi.so,libc++abi.so.1.0,libc++.so,libc++.so.1.0} \
/usr/lib/aarch64-linux-gnu/ || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install clang-10 libc++-10-dev libc++abi-10-dev libc++1-10 libc++abi1-10
# End libc++ packages bugfix
# Add arm64 common files

View File

@ -13,20 +13,12 @@ echo "deb [arch=arm64,armhf,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ $(ls
apt-get --assume-yes update
# Install and bypass a bug in the cross-platform libc++ packages
apt-get --assume-yes autoremove libc++-14-dev libc++abi-14-dev libc++1-14 libc++abi1-14 libunwind-14-dev libunwind-14 || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install --reinstall libc++-14-dev:arm64 libc++abi-14-dev:arm64 libunwind-14-dev:arm64
rm -r \
/usr/lib/aarch64-linux-gnu/libc++abi.so \
/usr/lib/aarch64-linux-gnu/libc++abi.so.1.0 \
/usr/lib/aarch64-linux-gnu/libc++.so.1.0 \
/usr/lib/aarch64-linux-gnu/libunwind.so.1.0 || true
mv -t /usr/lib/aarch64-linux-gnu/ \
/usr/lib/llvm-14/lib/libc++abi.so \
/usr/lib/llvm-14/lib/libc++abi.so.1.0 \
/usr/lib/llvm-14/lib/libc++.so \
/usr/lib/llvm-14/lib/libc++.so.1.0 \
/usr/lib/llvm-14/lib/libunwind.so.1.0 || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install --reinstall libc++-14-dev libc++abi-14-dev libunwind-14-dev
apt-get --assume-yes autoremove "libc++-14-dev:*" "libc++abi-14-dev:*" "libc++1-14:*" "libc++abi1-14:*" "libunwind-14-dev:*" "libunwind-14:*" || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-14-dev:arm64 libc++abi-14-dev:arm64 libc++1-14:arm64 libc++abi1-14:arm64 libunwind-14-dev:arm64 libunwind-14:arm64
cp --remove-destination \
/usr/lib/llvm-14/lib/{libc++abi.so,libc++abi.so.1.0,libc++.so,libc++.so.1.0,libunwind.so.1.0} \
/usr/lib/aarch64-linux-gnu/ || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install clang-14 libc++-14-dev libc++abi-14-dev libc++1-14 libc++abi1-14 libunwind-14-dev libunwind-14
# End libc++ packages bugfix
# Add arm64 common files

View File

@ -0,0 +1,30 @@
#!/bin/bash -ex
# Ubuntu 22.04
export DEBIAN_FRONTEND=noninteractive
dpkg --add-architecture armhf
sed 's/deb http/deb \[arch=amd64,i386\] http/' -i /etc/apt/sources.list
echo "# tdlight multiarch" > /etc/apt/sources.list.d/tdlight-multiarch.list
echo "deb [arch=arm64,armhf,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ $(lsb_release -cs) main universe restricted multiverse" >> /etc/apt/sources.list.d/tdlight-multiarch.list
echo "deb [arch=arm64,armhf,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ $(lsb_release -cs)-updates main universe restricted multiverse" >> /etc/apt/sources.list.d/tdlight-multiarch.list
echo "deb [arch=arm64,armhf,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ $(lsb_release -cs)-security main universe restricted multiverse" >> /etc/apt/sources.list.d/tdlight-multiarch.list
apt-get --assume-yes update
# Install and bypass a bug in the cross-platform libc++ packages
apt-get --assume-yes autoremove "libc++-14-dev:*" "libc++abi-14-dev:*" "libc++1-14:*" "libc++abi1-14:*" "libunwind-14-dev:*" "libunwind-14:*" || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install libc++-14-dev:armhf libc++abi-14-dev:armhf libc++1-14:armhf libc++abi1-14:armhf libunwind-14-dev:armhf libunwind-14:armhf
cp --remove-destination \
/usr/lib/llvm-14/lib/{libc++abi.so,libc++abi.so.1.0,libc++.so,libc++.so.1.0,libunwind.so.1.0} \
/usr/lib/aarch64-linux-gnu/ || true
apt-get --assume-yes -o Dpkg::Options::="--force-overwrite" install clang-14 libc++-14-dev libc++abi-14-dev libc++1-14 libc++abi1-14 libunwind-14-dev libunwind-14
# End libc++ packages bugfix
# Add armhf common files
apt-get download libclang-common-14-dev:armhf
dpkg-deb -xv libclang-common-14-dev_*_armhf.deb /
# Install dependencies
apt-get --assume-yes install libssl-dev:armhf zlib1g-dev:armhf openjdk-8-jdk-headless:armhf libgcc-12-dev:armhf libc6-dev:armhf

View File

@ -1,7 +1,7 @@
set(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TARGET_TRIPLE arm-linux-gnueabihf
set(TARGET_TRIPLE arm-linux-gnueabihf)
if(EXISTS "/usr/bin/clang-10")
set(CMAKE_C_COMPILER /usr/bin/clang-10)
@ -24,11 +24,11 @@ set(CMAKE_C_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_CXX_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_ASM_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu /usr/include/aarch64-linux-gnu /usr/bin/aarch64-linux-gnu)
set(CMAKE_INCLUDE_PATH /usr/include/aarch64-linux-gnu)
set(CMAKE_LIBRARY_PATH /usr/lib/aarch64-linux-gnu)
set(CMAKE_PROGRAM_PATH /usr/bin/aarch64-linux-gnu)
#set(CMAKE_SYSROOT /usr/lib/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf /usr/include/arm-linux-gnueabihf /usr/bin/arm-linux-gnueabihf)
set(CMAKE_INCLUDE_PATH /usr/include/arm-linux-gnueabihf)
set(CMAKE_LIBRARY_PATH /usr/lib/arm-linux-gnueabihf)
set(CMAKE_PROGRAM_PATH /usr/bin/arm-linux-gnueabihf)
#set(CMAKE_SYSROOT /usr/lib/arm-linux-gnueabihf)
#set(OPENSSL_INCLUDE_DIR /usr/include/openssl)
#include_directories("/usr/include/openssl")
@ -54,13 +54,13 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
#include_directories("${CROSS_OPENJDK_PATH}/include/linux")
SET(JAVA_HOME "/usr/lib/jvm/default-java/")
SET(JAVA_CROSS_HOME "/usr/lib/jvm/java-1.8.0-openjdk-arm64")
SET(JAVA_CROSS_HOME "/usr/lib/jvm/java-1.8.0-openjdk-armhf")
SET(JAVA_INCLUDE_PATH "${JAVA_HOME}/include")
SET(JAVA_AWT_INCLUDE_PATH "${JAVA_HOME}/include")
SET(JAVA_INCLUDE_PATH2 "${JAVA_HOME}/include/linux")
SET(JAVA_JVM_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/aarch64/server/libjvm.so")
SET(JAVA_AWT_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/aarch64/libawt.so")
SET(JAVA_JVM_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/arm/server/libjvm.so")
SET(JAVA_AWT_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/arm/libawt.so")
# Only on aarch64 & armhf architecture

View File

@ -0,0 +1,67 @@
set(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(TARGET_TRIPLE i386-linux-gnu)
if(EXISTS "/usr/bin/clang-10")
set(CMAKE_C_COMPILER /usr/bin/clang-10)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-10)
set(CMAKE_ASM_COMPILER /usr/bin/clang-10)
set(CMAKE_AR "/usr/bin/llvm-ar-10" CACHE FILEPATH "" FORCE)
elseif(EXISTS "/usr/bin/clang-14")
set(CMAKE_C_COMPILER /usr/bin/clang-14)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-14)
set(CMAKE_ASM_COMPILER /usr/bin/clang-14)
set(CMAKE_AR "/usr/bin/llvm-ar-14" CACHE FILEPATH "" FORCE)
else()
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_ASM_COMPILER /usr/bin/clang)
set(CMAKE_AR "/usr/bin/llvm-ar" CACHE FILEPATH "" FORCE)
endif()
set(CMAKE_C_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_CXX_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_ASM_COMPILER_TARGET ${TARGET_TRIPLE})
set(CMAKE_FIND_ROOT_PATH /usr/i386-linux-gnu /usr/lib/i386-linux-gnu /usr/include/i386-linux-gnu /usr/bin/i386-linux-gnu)
set(CMAKE_INCLUDE_PATH /usr/include/i386-linux-gnu)
set(CMAKE_LIBRARY_PATH /usr/lib/i386-linux-gnu)
set(CMAKE_PROGRAM_PATH /usr/bin/i386-linux-gnu)
#set(CMAKE_SYSROOT /usr/lib/i386-linux-gnu)
#set(OPENSSL_INCLUDE_DIR /usr/include/openssl)
#include_directories("/usr/include/openssl")
# Set various compiler flags
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind")
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++")
# Use our definitions for compiler tools
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers in the target directories only
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# This must be set or compiler checks fail when linking
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
#include_directories("${CROSS_OPENJDK_PATH}/include/linux")
SET(JAVA_HOME "/usr/lib/jvm/default-java/")
SET(JAVA_CROSS_HOME "/usr/lib/jvm/java-8-openjdk-i386")
SET(JAVA_INCLUDE_PATH "${JAVA_HOME}/include")
SET(JAVA_AWT_INCLUDE_PATH "${JAVA_HOME}/include")
SET(JAVA_INCLUDE_PATH2 "${JAVA_HOME}/include/linux")
SET(JAVA_JVM_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/i386/server/libjvm.so")
SET(JAVA_AWT_LIBRARY "${JAVA_CROSS_HOME}/jre/lib/i386/libawt.so")
# Use LLD on linux
#add_link_options("-fuse-ld=lld" "-rtlib=compiler-rt" "-unwindlib=libunwind" "-Wl,--as-needed")
#add_link_options("-fuse-ld=lld")