Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a github action to check cross-compilation from Linux #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mitchmindtree
Copy link
Member

This is a port of the old travis-ci cross-compile check, which currently does not seem to be working.

Downloading the SDK works fine, but initially building produces a "missing libclang.so" error.

On NixOS I threw together a small nix shell to get fix the clang error by setting LIBCLANG_PATH and automating the SDK install, however I ran into another error where bindgen seems unable to find the "AudioToolbox/AudioToolbox.h" for some reason. I don't have time to dive deeper into this atm, but thought I'd post my efforts so far in case someone finds them useful.

Nix exprs

Here are my nix expressions in case anyone using nix happens to be digging into this. Using these are not necessary to solve the CI build issues though.

macosx-sdk.nix - Simple package that downloads and "installs" the SDK

{ stdenv, fetchurl, clang }:
stdenv.mkDerivation {
  name = "macosx-sdk";
  src = fetchurl {
    url = https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.13.sdk.tar.xz;
    sha256 = "1az86x4lk6l3kxbxa1ppsahnwgpka1a6vpavazrv91wjms4n92xj";
  };
  dontConfigure = true;
  dontBuild = true;
  installPhase = ''
    mkdir -p $out
    cp -r ./ $out/MacOSX10.13.sdk
  '';
}

coreaudio-dev.nix - Simple shell that includes macosx-sdk, libclang and sets the environment variables

with import <nixpkgs> {};
let
  macosx-sdk = callPackage ./macosx-sdk.nix {};
in
  stdenv.mkDerivation {
    name = "coreaudio-dev";
    buildInputs = [
      llvmPackages.libclang
      macosx-sdk
    ];
    COREAUDIO_SDK_PATH = "${macosx-sdk}/MacOSX10.13.sdk";
    LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
  }

Copy link
Member

@simlay simlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good aside from CI not passing.

- name: Add apple target
run: rustup target add x86_64-apple-darwin
- name: Download SDK
run: curl -sL https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.13.sdk.tar.xz | tar -Jxf -; export COREAUDIO_SDK_PATH="$PWD/MacOSX10.13.sdk"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we feel about maxing this a jobs.<job_id>.strategy.matrix option and having a couple versions of the SDK being tested? One nice thing about linux -> macos cross compilation is that it's easy to get a bunch of SDKs and test against.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

I guess one important thing to note is that if we want to make sure documentation builds successfully, we'll need to be able to recreate the same cross compilation approach (with same version targets etc) that docs.rs use, otherwise there's a chance the docs build will fail despite our CI passing. See rust-lang/docs.rs#853.

@mitchmindtree
Copy link
Member Author

Hi folks, just thought I'd mention that I don't have plans to finish this off in the near future, but would be more happy for someone to take over / finish this small PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants