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 5, 2020
1 parent d5ae74c commit 1efa31f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build:
name: ${{ matrix.kind }} ${{ matrix.os }}
name: ${{ matrix.arch }} ${{ matrix.os }}
if: |
github.event_name == 'push' ||
!startsWith(github.event.pull_request.head.label, 'denoland:')
Expand All @@ -18,6 +18,15 @@ jobs:
- macos-latest
- ubuntu-16.04
- windows-2019
arch:
- 'x86_64'
- 'arm64'

exclude:
- os: windows-2019
arch: 'arm64'
- os: macOS-latest
arch: 'arm64'

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

- name: Install cross compile deps
if: matrix.arch == 'arm64'
run: |
apt -yq --no-install-suggests --no-install-recommends install \
g++-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-multilib \
libc6-arm64-cross
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="/usr/bin/aarch64-linux-gnu-gcc"
- name: Install and start sccache
shell: pwsh
Expand Down
1 change: 0 additions & 1 deletion .gn
Original file line number Diff line number Diff line change
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
30 changes: 30 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ 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");
}
}
"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 +106,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 1efa31f

Please sign in to comment.