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

M1 or universal releases for Darwin #1015

Open
sax opened this issue Aug 25, 2022 · 8 comments
Open

M1 or universal releases for Darwin #1015

sax opened this issue Aug 25, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@sax
Copy link

sax commented Aug 25, 2022

I currently install git-mit via cargo, which means that every time I update my installed Rust version I need to look up the install directions again. This is not a huge problem, but it would be nice to be able to install via your homebrew tap.

It's possible to build a aarch64-apple-darwin target. At least on a Mac, one can use lipo to combine two arch-specific binaries into a universal package.

rustup target install aarch64-apple-darwin
cargo build --target aarch64-apple-darwin -r

mkdir -p <release_dir>/universal-apple-darwin/release
cd <release_dir>/universal-apple-darwin/release
lipo ../../aarch64-apple-darwin/release/git-mit ../../x86_64-apple-darwin/release/git-mit -create -output git-mit

It looks to me like this repo ports lipo to Linux.

I'm not sure yet what the level of effort of getting this into your workflow would be, so I thought I'd start with an issue.

Describe the solution you'd like

A binary install of git-mit on M1 Macs.

Describe alternatives you've considered

I can keep installing via cargo.

@sax sax added the enhancement New feature or request label Aug 25, 2022
@sax
Copy link
Author

sax commented Aug 25, 2022

By the way, I'm happy to try out a pull request to do this, but wanted to check to make sure this wasn't already in the works, and whether you'd prefer an aarch64 release vs universal. I have not yet succeeded in my own homebrew taps to install a different tarball depending on architecture.

@PurpleBooth
Copy link
Owner

It is not in the works and I would love a pull request for it! I have an M1 myself and just been suffering through.

@sax
Copy link
Author

sax commented Aug 25, 2022

How about I start with the M1 build on its own? That shouldn't be too difficult, and if it's something you can drop into your homebrew bottle then fine, otherwise my next iteration would be a universal binary.

@PurpleBooth
Copy link
Owner

Sounds great!

@sax
Copy link
Author

sax commented Aug 25, 2022

That shouldn't be too difficult... 🤦‍♂️

Current status, trying to build for M1 on an Intel Mac:

error: failed to run custom build command for `openssl-sys v0.9.75`

Caused by:
  process didn't exit successfully: `/Users/sax/workspace/github/PurpleBooth/git-mit/target/release/build/openssl-sys-65e95f4dff79b933/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "pkg-config has not been configured to support cross-compilation.\n\nInstall a sysroot for the target platform and configure it via\nPKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\ncross-compiling wrapper for pkg-config and set it via\nPKG_CONFIG environment variable."

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-apple-darwin
  $TARGET = aarch64-apple-darwin
  openssl-sys = 0.9.75

  ', /Users/sax/.asdf/installs/rust/1.63.0/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.75/build/find_normal.rs:191:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

@PurpleBooth
Copy link
Owner

PurpleBooth commented Aug 26, 2022

Jinxed it! I have dropped a message over on the homebrew forums on how to do this, last time I dug into this it was prohibatively hard, but I would love to make it happen

Edit: I am an idiot and didn't read that you had installed this via cargo. It is already possible for you to install this via my homebrew tap it will just build it for you

@PurpleBooth
Copy link
Owner

PurpleBooth commented Aug 26, 2022

I've also added m1 builds to the binaries we build on release in the releases page, however homebrew does not use these, and are built by the tap repo.

@sax
Copy link
Author

sax commented Aug 29, 2022

I think this is stuck on 1) having an M1 host for GitHub actions, or 2) successfully cross-compiling rust's openssl package with an aarch64 target from a x86_64 host.

Point 1 might be solved with a self-hosted runner until it's officially supported. The GitHub action self-hosted runner agent requires Rosetta 2, which I've been stubbornly refusing to install on any of my computers. I played around with running virtualized M1 MacOS from an M1 Mac mini, to see if maybe that would be a way to keep a clean host. It seems possible, but would take a bit of work.

I played around with cross-compilation without success. I don't see anyone else successfully solving the problem described in the error I posted above, but maybe with a deeper dive into the openssl / openssl-sys crate it might be possible?

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

No branches or pull requests

2 participants