1

Attempting to compile a rust program for usage on Mac. Configured Github Action as follows:

  build_macos:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Install required tools
      run: sudo apt install libdbus-1-dev pkg-config libudev-dev libglfw3-dev libglew-dev
    - name: Install required target
      run: rustup target add aarch64-apple-darwin
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose
    - name: Build Release
      run: cargo build --verbose --release --target=aarch64-apple-darwin
    - name: Artifact MacOS
      uses: actions/upload-artifact@v3
      with:
        name: Build MacOS
        path: ./target/aarch64-apple-darwin/release/control_harts
        retention-days: 5

which fails on Build Release Image Investigating the log further points me to the following (full log):

  = note: cc: error: unrecognized command-line option '-arch'
          cc: error: unrecognized command-line option '-framework'
          cc: error: unrecognized command-line option '-framework'

What would be the best way to solve this? If any further information is required, please let me know.

P.S. the program uses quite some libraries, but it does not appear to fail when compiling those, but only on the project itself. This makes me believe it maybe a configuration error on my end, but I cannot seem to figure that out.

P.P.S. the windows and linux tasks pass and produce a functioning executable, with all tests passing.

P.P.P.S. If it is preferable that I make a minimal piece of code or a repo that runs into this issue I could, but I am hoping the issue is just a simple oversight.

I was expecting a MacOS executable to pop out like the files for windows and linux do, but unfortunately the task runs into this error.

I tried looking for existing solutions for this problem, and I found: (1, 2, 3 found after searching for the first line (-arch), 4 and 5 for the second line (-framework))

  • 1. -> I cannot seem to configure these flags myself, as (from my very limited understanding) they are either part of the packages' build scripts or generated by rustc.
  • 2. -> Unsolved github issue
  • 3. -> Potentially solved github issue but it seems this is just part of the build script of that lib
  • 4. -> Requires access to the MakeFile, which I may have but I cannot seem to figure out where it is.
  • 5. -> for GoLang, and also without solution.

1 Answers1

0

I was building with runs-on: ubuntu-latest as Azeem pointed out. After changing this to runs-on: macos-latest and removing the Install required tools task, it ran smoothly and created the distr as I wanted.

I cannot test this because I do not have a Mac, but the test cases pass so it seems ok.

  • If it's a command line app, you can test it in the runner as well. I see in your workflow that you're already running tests. You can run the x86_64 executable there. AFAIK, M1 GHA runner has not been added yet so you need your own machine (locally or an AWS EC2 M1 instance) to test it. – Azeem Feb 17 '23 at 15:04
  • Maybe you can use something like https://github.com/TimeToogo/tunshell to borrow a CLI from a GHA run. – nelsonjchen Feb 17 '23 at 16:05