cross-rs / cross-toolchains

Additional Dockerfiles and crosstool-ng config files to build additional toolchains.
Apache License 2.0
88 stars 16 forks source link

Problems with building an Apple Silicon version #27

Closed missuo closed 1 year ago

missuo commented 1 year ago

When I cross-build using GitHub Actions, it passes the build with no problem, but when I run it on an M-series Mac, it shows Intel (X86_64) and doesn't seem native.

The Target I use is aarch64-apple-darwin.

jobs:
  lints:
    name: Lints
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: clippy
      - uses: Swatinem/rust-cache@v1
      - name: Clippy
        run: cargo clippy -- -D warnings
      - name: Setup cargo-hack
        run: cargo install cargo-hack
      - name: Check all features
        run: cargo hack check --feature-powerset --no-dev-deps

  build:
    name: Build for ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            exe: rathole
            target: x86_64-unknown-linux-gnu
          - os: windows-latest
            exe: rathole.exe
            target: x86_64-pc-windows-msvc
          - os: macos-latest
            exe: rathole
            target: x86_64-apple-darwin
          - os: macos-latest
            exe: rathole
            target: aarch64-apple-darwin

    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
      - uses: Swatinem/rust-cache@v1
      - name: Build
        run: cargo build
      - name: Run tests
        run: cargo test --verbose
      - uses: actions/upload-artifact@v2
        with:
          name: rathole-${{ matrix.target }}
          path: target/debug/${{ matrix.exe }}

https://missuo.ru/file/66c6fd4a6f090132fd96b.png https://missuo.ru/file/8674db3a25b8bbdd82f5d.png

Emilgardis commented 1 year ago

Hello! I think you've filed this in the wrong place or the example workflow is wrong.

This repo is for the cross project, which you seem to not be using here. I can't see any call to cross.

Do note that we do not provide an image for aarch64-apple-darwin, you'll have to build and publish it yourself as described in this repo. Cross will give an warning like

Warning: cross does not provide a Docker image for target x86_64-apple-darwin, specify a custom image in Cross.toml. Falling back to cargo on the host.

The best course of action for you is probably to compile on an actual mac, you can do this with github actions easily.

Another thing to note is that the mac virtual environment doesn't support linux/* docker images.