From f08ae94e379af149c74e889f45b619284175cb8a Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:05:36 +0800 Subject: [PATCH] feature test compile --- .gitea/workflows/build.yaml | 75 +++++++++++++++++++ toolchains/himix200.toolchain.cmake | 33 ++++++++ toolchains/hisiv500.toolchain.cmake | 29 +++++++ toolchains/hisiv510.toolchain.cmake | 29 +++++++ toolchains/host-afl.toolchain.cmake | 9 +++ toolchains/host.toolchain.cmake | 0 .../mips64el-linux-gnuabi64.toolchain.cmake | 27 +++++++ .../mipsel-openwrt-linux-musl.toolchain.cmake | 27 +++++++ .../mipsel-openwrt-linux.toolchain.cmake | 27 +++++++ 9 files changed, 256 insertions(+) create mode 100644 .gitea/workflows/build.yaml create mode 100644 toolchains/himix200.toolchain.cmake create mode 100644 toolchains/hisiv500.toolchain.cmake create mode 100644 toolchains/hisiv510.toolchain.cmake create mode 100644 toolchains/host-afl.toolchain.cmake create mode 100644 toolchains/host.toolchain.cmake create mode 100644 toolchains/mips64el-linux-gnuabi64.toolchain.cmake create mode 100644 toolchains/mipsel-openwrt-linux-musl.toolchain.cmake create mode 100644 toolchains/mipsel-openwrt-linux.toolchain.cmake diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..009cca8 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,75 @@ +name: rpcrypto-build +on: + - push + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + build: + strategy: + matrix: + build_type: + - Debug + - Release + toolchain: + - host.toolchain.cmake + - host-afl.toolchain.cmake + - hisiv500.toolchain.cmake + - hisiv510.toolchain.cmake + - himix200.toolchain.cmake + - mips64el-linux-gnuabi64.toolchain.cmake + - mipsel-openwrt-linux-musl.toolchain.cmake + - mipsel-openwrt-linux.toolchain.cmake + runs-on: ubuntu-20.04 + env: + build_command: | + cd ${{ github.workspace }} + pwd + ls -alh + # /bin/bash scripts/install-flatc.sh + cmake . -Bbuild \ + -DCMAKE_TOOLCHAIN_FILE=toolchains/${{ matrix.toolchain }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_INSTALL_PREFIX=./install \ + -DCMAKE_VERBOSE_MAKEFILE=ON + cmake --build build --config ${{ matrix.build_type }} --target all -- -j `nproc` + cmake --build build --config ${{ matrix.build_type }} --target install + steps: + # - name: Install Dependencies + # run: | + # apt-get update -y + # apt-get install -y \ + # cmake make g++ libssl-dev pkg-config autoconf libtool + - uses: actions/checkout@v4 + # - name: configure + # run: cmake . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + # - name: build + # run: cmake --build build --config ${{ matrix.build_type }} --target all -- -j `nproc` + - name: build + if: matrix.toolchain == 'host.toolchain.cmake' + run: | + apt-get update -y + apt-get install -y libarchive-dev libssl-dev autoconf libtool pkg-config cmake make gcc g++ + ${{ env.build_command }} + + - name: build-afl + if: matrix.toolchain == 'host-afl.toolchain.cmake' + run: | + apt-get update -y + apt-get install -y libarchive-dev libssl-dev autoconf libtool pkg-config afl++ cmake make gcc g++ + export AFL_LLVM_LAF_ALL=1 + export CC=/usr/bin/afl-clang-fast + export CXX=/usr/bin/afl-clang-fast++ + ${{ env.build_command }} + + - name: build-in-centos + uses: addnab/docker-run-action@v3 + if: matrix.toolchain != 'host.toolchain.cmake' && matrix.toolchain != 'host-afl.toolchain.cmake' + with: + image: tqcq/hisi:centos + options: --rm --volumes-from ${{ env.JOB_CONTAINER_NAME }} + run: | + yum clean all + yum install -y libarchive cmake make gcc gcc-c++ openssl-devel autoconf libtool pkg-config + ${{ env.build_command }} \ No newline at end of file diff --git a/toolchains/himix200.toolchain.cmake b/toolchains/himix200.toolchain.cmake new file mode 100644 index 0000000..5c3152a --- /dev/null +++ b/toolchains/himix200.toolchain.cmake @@ -0,0 +1,33 @@ +# set cross-compiled system type, it's better not use the type which cmake cannot recognized. +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +# when hislicon SDK was installed, toolchain was installed in the path as below: +set(CMAKE_C_COMPILER "/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gcc") +set(CMAKE_CXX_COMPILER "/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/hisi-linux/x86-arm/arm-himix200-linux") + +# set searching rules for cross-compiler +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +# set ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS}flag for cross-compiled process +set(CROSS_COMPILATION_ARM himix200) +set(CROSS_COMPILATION_ARCHITECTURE armv7-a) + +# set g++ param +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file diff --git a/toolchains/hisiv500.toolchain.cmake b/toolchains/hisiv500.toolchain.cmake new file mode 100644 index 0000000..277c3d3 --- /dev/null +++ b/toolchains/hisiv500.toolchain.cmake @@ -0,0 +1,29 @@ +# set cross-compiled system type, it's better not use the type which cmake cannot recognized. +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +# when hislicon SDK was installed, toolchain was installed in the path as below: +set(CMAKE_C_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/arm-hisiv500-linux-gcc") +set(CMAKE_CXX_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/arm-hisiv500-linux-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/hisi-linux/x86-arm/arm-hisiv500-linux") + +# set searching rules for cross-compiler +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +# set ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS}flag for cross-compiled process +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file diff --git a/toolchains/hisiv510.toolchain.cmake b/toolchains/hisiv510.toolchain.cmake new file mode 100644 index 0000000..190334f --- /dev/null +++ b/toolchains/hisiv510.toolchain.cmake @@ -0,0 +1,29 @@ +# set cross-compiled system type, it's better not use the type which cmake cannot recognized. +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +# when hislicon SDK was installed, toolchain was installed in the path as below: +set(CMAKE_C_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv510-linux/target/bin/arm-hisiv510-linux-gcc") +set(CMAKE_CXX_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv510-linux/target/bin/arm-hisiv510-linux-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/hisi-linux/x86-arm/arm-hisiv510-linux") + +# set searching rules for cross-compiler +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +# set ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS}flag for cross-compiled process +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file diff --git a/toolchains/host-afl.toolchain.cmake b/toolchains/host-afl.toolchain.cmake new file mode 100644 index 0000000..a56722c --- /dev/null +++ b/toolchains/host-afl.toolchain.cmake @@ -0,0 +1,9 @@ +#set(CMAKE_SYSTEM_NAME Linux) +#set(CMAKE_SYSTEM_PROCESSOR x86_64) +#set(CMAKE_HOST_SYSTEM x86_64) +#set(CMAKE_C_COMPILER_LAUNCHER "/usr/bin/afl-clang-fast") +#set(CMAKE_CXX_COMPILER_LAUNCHER "/usr/bin/afl-clang-fast++") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fsanitize=address,undefined -fno-sanitize-recover=all -g") +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fsanitize=address,undefined -fno-sanitize-recover=all -g") +#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-rtti -fsanitize=address,undefined -fno-sanitize-recover=all") +#set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fno-rtti -fsanitize=address,undefined -fno-sanitize-recover=all") diff --git a/toolchains/host.toolchain.cmake b/toolchains/host.toolchain.cmake new file mode 100644 index 0000000..e69de29 diff --git a/toolchains/mips64el-linux-gnuabi64.toolchain.cmake b/toolchains/mips64el-linux-gnuabi64.toolchain.cmake new file mode 100644 index 0000000..bb32fed --- /dev/null +++ b/toolchains/mips64el-linux-gnuabi64.toolchain.cmake @@ -0,0 +1,27 @@ +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR mips64el) + +set(CMAKE_C_COMPILER "/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-gcc") +set(CMAKE_CXX_COMPILER "/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/gcc-4.9.3-64-gnu/") + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +set(CMAKE_C_FLAGS "-march=mips64") +set(CMAKE_CXX_FLAGS "-march=mips64") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file diff --git a/toolchains/mipsel-openwrt-linux-musl.toolchain.cmake b/toolchains/mipsel-openwrt-linux-musl.toolchain.cmake new file mode 100644 index 0000000..e1f248b --- /dev/null +++ b/toolchains/mipsel-openwrt-linux-musl.toolchain.cmake @@ -0,0 +1,27 @@ +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR mipsel) + +set(CMAKE_C_COMPILER "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-musl-gcc") +set(CMAKE_CXX_COMPILER "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-musl-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl") + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +set(CMAKE_C_FLAGS "-march=mips32") +set(CMAKE_CXX_FLAGS "-march=mips32") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file diff --git a/toolchains/mipsel-openwrt-linux.toolchain.cmake b/toolchains/mipsel-openwrt-linux.toolchain.cmake new file mode 100644 index 0000000..1f57b0f --- /dev/null +++ b/toolchains/mipsel-openwrt-linux.toolchain.cmake @@ -0,0 +1,27 @@ +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR mipsel) + +set(CMAKE_C_COMPILER "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-gcc") +set(CMAKE_CXX_COMPILER "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-g++") +set(CMAKE_FIND_ROOT_PATH "/opt/openwrt-toolchain/toolchain-mipsel_24kc_gcc-7.3.0_musl") + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +set(CMAKE_C_FLAGS "-march=mips32") +set(CMAKE_CXX_FLAGS "-march=mips32") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") \ No newline at end of file