diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d532109ec8..6b935fb1f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,25 +12,70 @@ jobs: strategy: fail-fast: false matrix: - compiler: [gcc, clang] - image: [ubuntu-20.04, ubuntu-22.04] + arch: + [ + amd64, + arm64, + armel, + armhf, + i386, + mips, + mips64, + mips64el, + mips64r6, + mips64r6el, + mipsel, + mipsr6, + mipsr6el, + powerpc, + ppc64el, + s390x, + riscv64, + ] include: - - compiler: gcc - image: ubuntu-20.04 - configure_flag: '' - - compiler: gcc - image: ubuntu-22.04 - configure_flag: --enable-static --enable-all-static - - compiler: clang - image: ubuntu-20.04 - configure_flag: '' - - compiler: clang - image: ubuntu-22.04 - configure_flag: --enable-static --enable-all-static - runs-on: ${{ matrix.image }} + - arch: amd64 + CC: "x86_64-linux-gnu" + - arch: arm64 + CC: "aarch64-linux-gnu" + - arch: armel + CC: "arm-linux-gnueabi" + - arch: armhf + CC: "arm-linux-gnueabihf" + - arch: i386 + CC: "i686-linux-gnu" + - arch: mips + CC: "mips-linux-gnu" + - arch: mips64 + CC: "mips64-linux-gnuabi64" + - arch: mips64el + CC: "mips64el-linux-gnuabi64" + - arch: mips64r6 + CC: "mipsisa64r6-linux-gnuabi64" + - arch: mips64r6el + CC: "mipsisa64r6el-linux-gnuabi64" + - arch: mipsel + CC: "mipsel-linux-gnu" + - arch: mipsr6 + CC: "mipsisa32r6-linux-gnu" + - arch: mipsr6el + CC: "mipsisa32r6el-linux-gnu" + - arch: powerpc + CC: "powerpc-linux-gnu" + - arch: ppc64el + CC: "powerpc64le-linux-gnu" + - arch: s390x + CC: "s390x-linux-gnu" + - arch: riscv64 + CC: "riscv64-linux-gnu" + runs-on: ubuntu-22.04 env: - CC: ${{ matrix.compiler }} - SUFFIX: linux-${{ matrix.image }}-${{ matrix.compiler }} + AR: ${{ matrix.CC }}-ar + CHOST: ${{ matrix.cc }} + CC: ${{ matrix.cc }}-gcc + CPP: ${{ matrix.cc }}-cpp + CXX: ${{ matrix.cc }}-g++ + LDFLAGS: -s + SUFFIX: linux-${{ matrix.arch }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -38,20 +83,26 @@ jobs: submodules: true - name: Install packages run: | - sudo apt-get update -qq - sudo apt-get install -y automake autoconf + sudo apt-get update + sudo apt-get upgrade + sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }} - name: Build run: | autoreconf -i ./configure \ + --host=${{ matrix.CC }} \ --disable-docs \ --disable-maintainer-mode \ --disable-valgrind \ --with-oniguruma=builtin \ - ${{ matrix.configure_flag }} - make - strip jq + --enable-static \ + --enable-all-static + make -j$(nproc) + file ./jq + cp ./jq jq-${{ env.SUFFIX }} - name: Test + # Only run tests for amd64 matching the CI machine arch + if: ${{ matrix.arch == 'amd64' }} run: | make check git diff --exit-code @@ -68,20 +119,28 @@ jobs: uses: actions/upload-artifact@v3 with: name: jq-${{ env.SUFFIX }} + path: jq-${{ env.SUFFIX }} if-no-files-found: error retention-days: 7 - path: jq macos: strategy: fail-fast: false matrix: - compiler: [gcc, clang] - image: [macos-11, macos-12, macos-13] - runs-on: ${{ matrix.image }} + arch: + [ + amd64, + arm64, + ] + include: + - arch: amd64 + target: "x86_64-apple-darwin" + - arch: arm64 + target: "arm64-apple-darwin" + runs-on: macos-13 env: - CC: ${{ matrix.compiler }} - SUFFIX: macos-${{ matrix.image }}-${{ matrix.compiler }} + LDFLAGS: -s + SUFFIX: macos-${{ matrix.arch }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -92,19 +151,26 @@ jobs: # brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!" brew update || brew update-reset brew install autoconf automake libtool + - name: "Set CC" + run: | + echo "CC=clang -target ${{ matrix.target }}$(uname -r)" >> $GITHUB_ENV - name: Build run: | autoreconf -i ./configure \ + --host=${{ matrix.target }}$(uname -r) \ --disable-docs \ --disable-maintainer-mode \ --disable-valgrind \ --with-oniguruma=builtin \ --enable-static \ --enable-all-static - make - strip jq + make -j$(nproc) + file ./jq + cp ./jq jq-${{ env.SUFFIX }} - name: Test + # Only run tests for amd64 matching the CI machine arch + if: ${{ matrix.arch == 'amd64' }} run: | make check git diff --exit-code @@ -121,20 +187,34 @@ jobs: uses: actions/upload-artifact@v3 with: name: jq-${{ env.SUFFIX }} + path: jq-${{ env.SUFFIX }} if-no-files-found: error retention-days: 7 - path: jq windows: strategy: fail-fast: false matrix: - compiler: [gcc] - image: [windows-2019, windows-2022] - runs-on: ${{ matrix.image }} + arch: + [ + amd64, + i386, + ] + include: + - arch: amd64 + CC: "x86_64-pc-msys" + toolchain: "gcc" + msystem: msys + - arch: i386 + CC: "i686-w64-mingw32" + toolchain: "mingw-w64-i686-toolchain" + msystem: mingw32 + runs-on: windows-2022 env: - CC: ${{ matrix.compiler }} - SUFFIX: windows-${{ matrix.image }}-${{ matrix.compiler }} + CHOST: ${{ matrix.CC }} + CC: ${{ matrix.CC }}-gcc + LDFLAGS: -s + SUFFIX: windows-${{ matrix.arch }} steps: - name: Clone repository uses: actions/checkout@v3 @@ -143,18 +223,20 @@ jobs: - uses: msys2/setup-msys2@v2 with: update: true + msystem: ${{ matrix.msystem }} install: >- base-devel git - clang autoconf automake libtool + ${{ matrix.toolchain }} - name: Build shell: msys2 {0} run: | autoreconf -i ./configure \ + --host=${{ matrix.CC }} \ --disable-docs \ --disable-maintainer-mode \ --disable-valgrind \ @@ -162,9 +244,12 @@ jobs: --disable-shared \ --enable-static \ --enable-all-static - make - strip jq.exe + make -j$(nproc) + file ./jq.exe + cp ./jq.exe jq-${{ env.SUFFIX }}.exe - name: Test + # Only run tests for amd64 matching the CI machine arch + if: ${{ matrix.arch == 'amd64' }} shell: msys2 {0} run: | make check @@ -182,9 +267,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: jq-${{ env.SUFFIX }} + path: jq-${{ env.SUFFIX }}.exe if-no-files-found: error retention-days: 7 - path: jq.exe dist: runs-on: ubuntu-latest @@ -265,17 +350,15 @@ jobs: uses: actions/checkout@v3 - name: Merge built artifacts uses: actions/download-artifact@v3 - with: - path: artifacts - name: Upload release env: TAG_NAME: ${{ github.ref_name }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - mkdir release - cp artifacts/jq-linux-ubuntu-22.04-gcc/jq release/jq-linux-amd64 - cp artifacts/jq-macos-macos-13-gcc/jq release/jq-macos-amd64 - cp artifacts/jq-windows-windows-2022-gcc/jq.exe release/jq-windows-amd64.exe - cp artifacts/jq-dist/jq-* release/ + mkdir -p "release" + for files in jq-*; do + cp -rf "${files}/"* "release/" + done + gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes gh release upload "$TAG_NAME" --clobber release/jq-* diff --git a/src/jv.c b/src/jv.c index 6de4150727..facc59609a 100644 --- a/src/jv.c +++ b/src/jv.c @@ -222,6 +222,7 @@ enum { #include "jv_thread.h" #ifdef WIN32 +#ifndef __MINGW32__ /* Copied from Heimdal: thread-specific keys; see lib/base/dll.c in Heimdal */ /* @@ -486,6 +487,9 @@ pthread_getspecific(pthread_key_t key) #else #include #endif +#else +#include +#endif static pthread_key_t dec_ctx_key; static pthread_key_t dec_ctx_dbl_key; diff --git a/src/jv_thread.h b/src/jv_thread.h index a34cd08746..c6718aba17 100644 --- a/src/jv_thread.h +++ b/src/jv_thread.h @@ -2,6 +2,7 @@ #define JV_THREAD_H #ifdef WIN32 +#ifndef __MINGW32__ #include #include #include @@ -69,4 +70,7 @@ void *pthread_getspecific(pthread_key_t); #else #include #endif +#else +#include +#endif #endif /* JV_THREAD_H */