switch into gcc #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- .github/workflows/main.yml | |
workflow_dispatch: | |
env: | |
GMP_CONFIGURE_OPTIONS: --enable-shared --disable-static --enable-fat --enable-cxx | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- os: linux | |
arch: x64 | |
gmp_so: libgmp.so.10.5.0 | |
gmp_cpp_so: libgmpxx.so.4.7.0 | |
- os: linux | |
arch: x86 | |
gmp_so: libgmp.so.10.5.0 | |
gmp_cpp_so: libgmpxx.so.4.7.0 | |
- os: linux | |
arch: arm64 | |
gmp_so: libgmp.so.10.5.0 | |
gmp_cpp_so: libgmpxx.so.4.7.0 | |
- os: linux | |
arch: arm | |
gmp_so: libgmp.so.10.5.0 | |
gmp_cpp_so: libgmpxx.so.4.7.0 | |
- os: win | |
arch: x64 | |
gmp_so: libgmp-10.dll | |
gmp_cpp_so: libgmpxx-4.dll | |
env: | |
GMP_VERSION: 6.3 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Install Toolchain (arch-specific) | |
run: | | |
sudo apt-get update | |
if [ "${{ matrix.arch }}" = "x86" ]; then | |
sudo apt-get install -y gcc-multilib g++-multilib | |
elif [ "${{ matrix.arch }}" = "arm64" ]; then | |
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
sudo apt-get install -y qemu-user | |
elif [ "${{ matrix.arch }}" = "arm" ]; then | |
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | |
sudo apt-get install -y qemu-user | |
elif [ "${{ matrix.os }}" = "win" ]; then | |
sudo apt-get install -y mingw-w64 | |
sudo apt-get install -y wine | |
fi | |
- name: Download GMP Source | |
run: | | |
git clone --depth 1 https://github.com/gmp-mirror/gmp-${GMP_VERSION}.git | |
- name: Autoreconf | |
run: | | |
cd gmp-${GMP_VERSION} | |
autoreconf -ivf | |
- name: Configure GMP | |
run: | | |
cd gmp-${GMP_VERSION} | |
if [ "${{ matrix.arch }}" = "x86" ]; then | |
./configure --host=i686-pc-linux-gnu ${{ env.GMP_CONFIGURE_OPTIONS }} | |
elif [ "${{ matrix.arch }}" = "arm64" ]; then | |
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ \ | |
./configure --host=aarch64-linux-gnu ${{ env.GMP_CONFIGURE_OPTIONS }} | |
elif [ "${{ matrix.arch }}" = "arm" ]; then | |
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \ | |
./configure --host=arm-linux-gnueabihf ${{ env.GMP_CONFIGURE_OPTIONS }} | |
elif [ "${{ matrix.os }}" = "win" ]; then | |
CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ \ | |
./configure --host=x86_64-w64-mingw32 ${{ env.GMP_CONFIGURE_OPTIONS }} | |
else | |
./configure ${{ env.GMP_CONFIGURE_OPTIONS }} | |
fi | |
- name: Build GMP | |
run: | | |
cd gmp-${GMP_VERSION} | |
make MAKEINFO=true | |
- name: Check .libs | |
run: | | |
cd gmp-${GMP_VERSION}/.libs | |
ls -l | |
file ${{ matrix.gmp_so }} | |
- name: Strip GMP Library | |
run: | | |
cd gmp-${GMP_VERSION}/.libs | |
if [ "${{ matrix.arch }}" = "arm64" ]; then | |
aarch64-linux-gnu-strip --strip-unneeded ${{ matrix.gmp_so }} | |
aarch64-linux-gnu-strip --strip-unneeded ${{ matrix.gmp_cpp_so }} | |
elif [ "${{ matrix.arch }}" = "arm" ]; then | |
arm-linux-gnueabihf-strip --strip-unneeded ${{ matrix.gmp_so }} | |
arm-linux-gnueabihf-strip --strip-unneeded ${{ matrix.gmp_cpp_so }} | |
elif [ "${{ matrix.os }}" = "win" ]; then | |
x86_64-w64-mingw32-strip --strip-unneeded ${{ matrix.gmp_so }} | |
x86_64-w64-mingw32-strip --strip-unneeded ${{ matrix.gmp_cpp_so }} | |
else | |
strip --strip-unneeded ${{ matrix.gmp_so }} | |
strip --strip-unneeded ${{ matrix.gmp_cpp_so }} | |
fi | |
- name: Compile C Program | |
run: | | |
if [ "${{ matrix.arch }}" = "x86" ]; then | |
gcc -m32 -o factorial_gmp .github/workflows/factorial_gmp.c \ | |
-I${{ github.workspace }}/gmp-${GMP_VERSION} \ | |
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \ | |
-lgmp | |
elif [ "${{ matrix.arch }}" = "arm64" ]; then | |
aarch64-linux-gnu-gcc -o factorial_gmp .github/workflows/factorial_gmp.c \ | |
-I${{ github.workspace }}/gmp-${GMP_VERSION} \ | |
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \ | |
-lgmp | |
elif [ "${{ matrix.arch }}" = "arm" ]; then | |
arm-linux-gnueabihf-gcc -o factorial_gmp .github/workflows/factorial_gmp.c \ | |
-I${{ github.workspace }}/gmp-${GMP_VERSION} \ | |
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \ | |
-lgmp | |
elif [ "${{ matrix.os }}" = "win" ]; then | |
x86_64-w64-mingw32-gcc -o factorial_gmp.exe .github/workflows/factorial_gmp.c \ | |
-I${{ github.workspace }}/gmp-${GMP_VERSION} \ | |
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \ | |
-lgmp | |
else | |
gcc -o factorial_gmp .github/workflows/factorial_gmp.c \ | |
-I${{ github.workspace }}/gmp-${GMP_VERSION} \ | |
-L${{ github.workspace }}/gmp-${GMP_VERSION}/.libs \ | |
-lgmp | |
fi | |
- name: Run C Program | |
run: | | |
if [ "${{ matrix.arch }}" = "arm64" ]; then | |
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs qemu-aarch64 -L /usr/aarch64-linux-gnu/ ${GITHUB_WORKSPACE}/factorial_gmp | |
elif [ "${{ matrix.arch }}" = "arm" ]; then | |
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs qemu-arm -L /usr/arm-linux-gnueabihf/ ${GITHUB_WORKSPACE}/factorial_gmp | |
elif [ "${{ matrix.os }}" = "win" ]; then | |
cp ${{ github.workspace }}/gmp-${GMP_VERSION}/.libs/${{ matrix.gmp_so }} . | |
wine ${GITHUB_WORKSPACE}/factorial_gmp.exe | |
else | |
LD_LIBRARY_PATH=${{ github.workspace }}/gmp-${GMP_VERSION}/.libs ./factorial_gmp | |
fi | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.arch }} | |
path: | | |
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/gmp.h | |
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/gmpxx.h | |
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/.libs/${{ matrix.gmp_so }} | |
${{ github.workspace }}/gmp-${{ env.GMP_VERSION }}/.libs/${{ matrix.gmp_cpp_so }} |