Skip to content

Commit

Permalink
wip: arm64 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Feb 6, 2020
1 parent d5ae74c commit d51c6d8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/ci.yml
Expand Up @@ -6,18 +6,23 @@ on:

jobs:
build:
name: ${{ matrix.kind }} ${{ matrix.os }}
name: ${{ matrix.config.os }} ${{ matrix.config.TARGET }}
if: |
github.event_name == 'push' ||
!startsWith(github.event.pull_request.head.label, 'denoland:')
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.config.os }}
timeout-minutes: 120
strategy:
matrix:
os:
- macos-latest
- ubuntu-16.04
- windows-2019
config:
- os: macOS-latest
TARGET: x86_64-apple-darwin
- os: ubuntu-16.04
TARGET: "x86_64-unknown-linux-gnu"
- os: ubuntu-16.04
TARGET: aarch64-unknown-linux-gnu
- os: windows-2019
TARGET: x86_64-pc-windows-msvc

steps:
- name: Configure git
Expand All @@ -39,6 +44,19 @@ jobs:
with:
python-version: "2.7.x"
architecture: x64

- name: Install cross compile deps
if: matrix.config.TARGET == 'aarch64-unknown-linux-gnu'
run: |
rustup target add aarch64-unknown-linux-gnu
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
g++-5-aarch64-linux-gnu gcc-5-aarch64-linux-gnu g++-5-multilib \
libc6-arm64-cross
echo "::set-env name=CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER::/usr/bin/aarch64-linux-gnu-gcc-5"
sudo apt -yq install qemu qemu-user binfmt-support qemu-user-binfmt
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ld-linux-aarch64.so.1
echo "::set-env name=QEMU_LD_PREFIX::/usr/aarch64-linux-gnu"
- name: Install and start sccache
shell: pwsh
Expand All @@ -50,10 +68,10 @@ jobs:
SCCACHE_IDLE_TIMEOUT: 0
run: |
$version = "0.2.12"
$platform =
$platform =
@{ "macOS" = "x86_64-apple-darwin"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
"Linux" = "x86_64-unknown-linux-musl"
"Windows" = "x86_64-pc-windows-msvc"
}.${{ runner.os }}
$basename = "sccache-$version-$platform"
$url = "https://github.com/mozilla/sccache/releases/download/" +
Expand All @@ -67,7 +85,7 @@ jobs:
echo "::set-env name=RUSTC_WRAPPER::sccache"
- name: Test
run: cargo test -vv --locked --all-targets
run: cargo test -vv --locked --all-targets --target ${{ matrix.config.TARGET }}

- name: Clippy
run: |
Expand Down
1 change: 0 additions & 1 deletion .gn
Expand Up @@ -18,7 +18,6 @@ secondary_source = "//v8/"

default_args = {
linux_use_bundled_binutils = false
use_sysroot = false

# TODO(ry) We may want to turn on CFI at some point. Disabling for simplicity
# for now. See http://clang.llvm.org/docs/ControlFlowIntegrity.html
Expand Down
33 changes: 33 additions & 0 deletions build.rs
Expand Up @@ -83,6 +83,24 @@ fn build_v8() {
}
}

dbg!(env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str());

match env::var("CARGO_CFG_TARGET_ARCH").unwrap().as_str() {
"aarch64" => {
gn_args.push("target_cpu=\"arm64\"".to_string());
if need_sysroot_download("arm64") {
install_sysroot("arm64");
}
if need_sysroot_download("amd64") {
install_sysroot("amd64");
}
}
"x86_64" => {
gn_args.push("use_sysroot=false".to_string());
}
_ => unimplemented!(),
};

let gn_root = env::var("CARGO_MANIFEST_DIR").unwrap();

let gn_out = cargo_gn::maybe_gen(&gn_root, gn_args);
Expand All @@ -91,6 +109,21 @@ fn build_v8() {
cargo_gn::build("rusty_v8", None);
}

fn install_sysroot(arch: &str) {
let status = Command::new("python")
.arg("./build/linux/sysroot_scripts/install-sysroot.py")
.arg(format!("--arch={}", arch))
.status()
.expect(&format!("sysroot download failed: {}", arch));
assert!(status.success());
}

fn need_sysroot_download(arch: &str) -> bool {
let sysroot_path =
PathBuf::from(format!("build/linux/debian_sid_{}-sysroot", arch));
!sysroot_path.is_dir()
}

fn platform() -> &'static str {
#[cfg(target_os = "windows")]
{
Expand Down

0 comments on commit d51c6d8

Please sign in to comment.