GitHub Action to build for AWS ARM64 VM

I created a GitHub workflow that successfully deploys to AWS - this was (I thought) the hard part (it's pretty complex).

What I can't seem to get to work is the Rust build part.

Using rust-build.action, like this

      - name: Compile and release
        uses: rust-build/rust-build.action@v1.4.5
        with:
          RUSTTARGET: ${{ matrix.target }}
          EXTRA_FILES: "README.md"

the build errors with

error: manifest path `/github/workspace/Cargo.toml` is a virtual manifest, but this command requires running against an actual package in this workspace

I do have a Workspace-based project and indeed there is no [package] at the top level, making it a virtual manifest, but I think this error is nonsensical, because from the command line cargo build (along with run, test, etc.) works just fine.

I'm using the latest release of Rust.

I think there may be another problem anyway: The list of supported targets


    x86_64-pc-windows-gnu
    x86_64-unknown-linux-musl
    wasm32-wasi
    x86_64-apple-darwin

doesn't include ARM64 Linux.

I think looked at the GitHub Rust Actions docs, but there is no way to set build target that I can see here.

Although... I guess that could be set directly in the cargo build command.

Appreciate any input on either path.

I switched to running cargo directly:

now failing with

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

So the build environment has to install openssl.

What a tough nut this has been.

Using ubuntu for the worker, it's unable to find OpenSSL artifacts even though it installs them. Error:

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

I run this before cargo build:

      - name: Install Build Dependencies
        run: sudo apt-get update && sudo apt-get install pkg-config libssl-dev gcc && openssl version -d && ls /usr/include/openssl && ls /usr/lib/ssl

The install output even shows the SSL dir set properly:

0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.
OPENSSLDIR: "/usr/lib/ssl"

Which is what the build's env sets:

env:
  AWS_REGION: "us-east-2"
  OPENSSL_DIR: "/usr/lib/ssl"
  OPENSSL_INCLUDE_DIR: "/usr/include/openssl"

My entire build:

  build-and-deploy:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        BUILD_TARGET: [release]
    outputs:
      release_built: ${{ steps.set-output.outputs.release_built }}

    steps:
      - uses: actions/checkout@v4

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: aarch64-unknown-linux-gnu

      - name: Install Build Dependencies
        run: sudo apt-get update && sudo apt-get install pkg-config libssl-dev gcc && openssl version -d && sudo find libssl.a / | grep libssl.a

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --release --target=aarch64-unknown-linux-gnu

this only installed the library for the host, you need them for the target archtecture. you can enable the vendored feature of the openssl crate, which should build libssl from source.

1 Like

Can you explain a bit more? Installing for the build host is what I was trying to do - the build needs the lib. Yes, the target needs it to for running - and it's there (on the EC2 VMs).

I can build & run the app on the EC2 VM now and it works fine.

So I don't see why vendored is necessary or would even help. The build needs the header files.

I'll give it a try, though.

you not only need it for running, ut also need the library for linking.

building from the vendored source code is the simplest way to make it work.

if you don't want that, you can try to install the package for the correct archtecture, I believe the ubuntu distro does provide arm64 packages, but you'll have to check the manual to learn how to install them on an x86-64 host, I only know very basic apt commands.

1 Like

I get it now. I thought, for some reason, the linking was dynamic.

It worked.