denoland / rusty_v8

Rust bindings for the V8 JavaScript engine
https://crates.io/crates/v8
MIT License
3.25k stars 305 forks source link

ci: x86_64 build failed on macos-latest image #1472

Open Chiichen opened 5 months ago

Chiichen commented 5 months ago
          > LGTM, waiting on a build pass.

@Chiichen It appears that 4e30365 seems to have caused the apple builds to fail.

Thanks for your reply. It reports in workflow's log at line 135

135 error[E0463]: can't find crate for `core`

This looks like a classic error that can occur when we cross-compile without the corresponding tool chain installed. and I found it at line 7

6 Runner Image
7   Image: macos-14-arm64
8   Version: 20240415.6
9   Included Software: https://github.com/actions/runner-images/blob/macos-14-arm64/20240415.6/images/macos/macos-14-arm64-Readme.md
10  Image Release: https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240415.6

It seems that we are trying to build a x86_64 target on aarch64 platform. I think this may be caused by us not properly installing the Rust toolchain for x86_64-macos on the aarch64-macos device

Actually, I found that the existing workflow does not handle cross-compilation on macos devices. One method is to force it to use x86_64 machines by specifying an older macos version(macos11 or macos12), and the other method is to amend the workflow to support cross-compilation on the macos platform.

_Originally posted by @Chiichen in https://github.com/denoland/rusty_v8/issues/1458#issuecomment-2072854434_

Chiichen commented 5 months ago

here defines the image to be used in ci workflow

      matrix:
        config:
          - os: macOS-latest
            target: x86_64-apple-darwin
            variant: debug
            cargo: cargo

          - os: macOS-latest
            target: x86_64-apple-darwin
            variant: release
            cargo: cargo

However, Macos-latest was added as a mirror in the PR 4 years ago #266. At that time, all github actions used the x86_64 architecture macos as the build mirror. However, today, 4 years later, the macos-latest mirror (that is, macos14) has It may be arm64. The specific image information is given here runner images

Chiichen commented 5 months ago

It's time to rewrite the workflow for both x86_64 and arm64 macos, since we can not specify the arch of the macos iamge we use in github action. We must assume that every build on the macos image is a possible cross-compile