From c3162af18295a9fe77c471e3cd5861f79742a15b Mon Sep 17 00:00:00 2001 From: Eric Kidd Date: Wed, 16 Feb 2022 21:17:03 -0500 Subject: [PATCH] ci: Fix builds for aarch64 Macs This requires passing `--host` when cross-compiling, and making a few small changes to the `libpostal` `configure.ac` and `Makefile.am` files. --- .github/workflows/ci.yml | 8 ++++---- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/libpostal-sys/build.rs | 29 +++++++++++++++++++++++++++++ crates/libpostal-sys/libpostal | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7f7331..e8e325f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,10 +79,10 @@ jobs: host: x86_64-apple-darwin cargo: cargo os: macos-latest - # - target: aarch64-apple-darwin - # host: x86_64-apple-darwin - # cargo: cargo - # os: macos-latest + - target: aarch64-apple-darwin + host: x86_64-apple-darwin + cargo: cargo + os: macos-latest runs-on: ${{ matrix.os }} diff --git a/Cargo.lock b/Cargo.lock index ad6c0c4..3344fa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -582,7 +582,7 @@ dependencies = [ [[package]] name = "geocode-csv" -version = "1.1.0-alpha.2" +version = "1.1.0-ci.6" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 9135095..f9e65af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "geocode-csv" -version = "1.1.0-alpha.2" +version = "1.1.0-ci.6" authors = ["Eric Kidd "] edition = "2018" diff --git a/crates/libpostal-sys/build.rs b/crates/libpostal-sys/build.rs index 0f04da7..79f3b3b 100644 --- a/crates/libpostal-sys/build.rs +++ b/crates/libpostal-sys/build.rs @@ -4,6 +4,8 @@ //! version, because this is a fairly obscure library and it's not availble even //! as an Ubuntu PPE. +use std::env; + /// The main entry point to our build script. fn main() { build_libpostal(); @@ -24,6 +26,33 @@ fn build_libpostal() { // config.reconf("-fi"); // } + // Get our Rust target and host. + let rust_target = env::var("TARGET").expect("cargo should always define TARGET"); + let rust_host = env::var("HOST").expect("cargo should always define HOST"); + + // When cross-compiling for M1 Macs, set `--host` appropriately. Keep in + // mind that: + // + // - Rust `TARGET` is `./configure --host=`. + // - Rust `HOST` is `./configure --build=`. + // - `./configure --target=` is only used when building a compiler on + // `--build` that will run on `--host` and generate code for `--target`. + // But Rust _always_ supports generating code for multiple targets, so it + // doesn't think like this. + // + // I'm not sure why we need to set this manually, but it seems to be + // necessary. We might need to do this for other combinations, but let's add + // them as we discover them. + if rust_target == "aarch64-apple-darwin" && rust_host != "aarch64-apple-darwin" { + config.config_option("host", Some(&rust_target)); + } + + // If we're not on Intel, don't try to use Intel processor extensions. We + // need to disable this manually, apparently. + if !rust_target.starts_with("x86_64-") { + config.disable("sse2", None); + } + let dst = config // You'll need to edit any `-Wall` out of the source tree, // unfortunately. diff --git a/crates/libpostal-sys/libpostal b/crates/libpostal-sys/libpostal index c3b4410..56c4a5d 160000 --- a/crates/libpostal-sys/libpostal +++ b/crates/libpostal-sys/libpostal @@ -1 +1 @@ -Subproject commit c3b44100bdd0fbaa21c3d8d0df04dfacaaff2dd0 +Subproject commit 56c4a5daf747343cd192490d05c35df693f314a3