diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index bed90e4..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,9 +0,0 @@ -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" - -[target.aarch64-unknown-linux-musl] -rustflags = [ - "-C", "target-feature=+crt-static", - "-C", "link-arg=-lgcc" -] - diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c3391cf..db99311 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,7 +4,6 @@ on: [ push, pull_request ] env: CARGO_TERM_COLOR: always - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc jobs: build: @@ -13,44 +12,47 @@ jobs: fail-fast: false matrix: include: + # x86_64 - target: 'x86_64-pc-windows-msvc' os: windows - target: 'x86_64-unknown-linux-gnu' os: ubuntu - target: 'x86_64-unknown-linux-musl' os: ubuntu + # aarch64 (armv8) - target: 'aarch64-unknown-linux-gnu' os: ubuntu - target: 'aarch64-unknown-linux-musl' os: ubuntu + # armv7 + - target: 'armv7-unknown-linux-gnueabihf' + os: ubuntu + - target: 'armv7-unknown-linux-musleabihf' + os: ubuntu + # armv6 + - target: 'arm-unknown-linux-gnueabihf' + os: ubuntu + - target: 'arm-unknown-linux-musleabihf' + os: ubuntu steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Install musl Dependencies - if: contains(matrix.target, 'musl') - run: sudo apt-get update && sudo apt-get install musl-tools - - - name: Install aarch64 Dependencies - if: contains(matrix.target, 'aarch64') - run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu - - - name: Setup aarch64 musl compiler - if: contains(matrix.target, 'aarch64') && contains(matrix.target, 'musl') - run: | - wget https://musl.cc/aarch64-linux-musl-cross.tgz - tar -xvzf aarch64-linux-musl-cross.tgz - echo "CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc" >> "$GITHUB_ENV" - - - name: Install Target - run: rustup target add ${{ matrix.target }} + - name: Install Cross + run: cargo install --git https://github.com/cross-rs/cross cross - name: Setup Cache uses: Swatinem/rust-cache@v2 - - name: Build + # cross doesn't support msvc toolchains out-of-the-box (https://github.com/cross-rs/cross-toolchains) + - name: Build (Windows) + if: matrix.os == 'windows' run: cargo build --release --target=${{ matrix.target }} + - name: Build (Linux) + if: matrix.os == 'ubuntu' + run: cross build --release --target=${{ matrix.target }} + - name: Upload Artifact uses: actions/upload-artifact@v4 with: diff --git a/Dockerfile b/Dockerfile index a52a296..24a07ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,14 @@ #################################################################################################### FROM rust:alpine AS builder -RUN apk add --no-cache musl-dev gcc # GCC needed for aarch64 builds +RUN apk add --no-cache musl-dev WORKDIR /intellectual COPY . . # Figure out what arch we're on -RUN BASE_TARGET=-unknown-linux-musl; \ - case "$(uname -m)" in \ - x86_64) TARGET=x86_64$BASE_TARGET ;; \ - aarch64) TARGET=aarch64$BASE_TARGET ;; \ - *) echo "Unsupported architecture"; exit 1 ;; \ - esac; \ +RUN TARGET=$(uname -m)-unknown-linux-musl; \ # Set environment variables so the build has git info export $(cat .env | xargs); \ # Build the binary