marler8997 / zigup

Download and manage zig compilers.
MIT No Attribution
793 stars 61 forks source link

ability to specify arch #60

Closed jhigdon closed 2 years ago

jhigdon commented 2 years ago

Hello,

Is there a way to specify arch ?

Current issue: $ zigup master retrieves zig-macos-x86_64 but I would like zig-macos-aarch64

Thanks!

marler8997 commented 2 years ago

It should pull the arch from your current host architecture i.e. https://github.com/marler8997/zigup/blob/9f8c5f98cd2052370ad676ebf287eb25106f2be8/zigup.zig#L17

Are you on arm machine and it's pulling down x86, or were you trying to pull down the arm build on an x86 machine?

jhigdon commented 2 years ago

I am on a m1 mac that is pulling down x86, the terminal reports arm64 when running "arch" command. but the zigup is zigup: Mach-O 64-bit executable x86_64. In this scenario I would actually like it to pull down aarch64 version. I don't think "builtin.cpu.arch" pulls in the native cpu arch in this case or it's being confused because the x86 zigup is running in rosetta maybe?

marler8997 commented 2 years ago

It works on my m1 Mac:

% zigup master
install directory '/Users/marler8997/zig'
mkdir '/Users/marler8997/zig'
rm -rf '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing'
mkdir '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing'
downloading 'https://ziglang.org/builds/zig-macos-aarch64-0.10.0-dev.3027+0e26c6149.tar.xz' to '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing/zig-macos-aarch64-0.10.0-dev.3027+0e26c6149.tar.xz'
[RUN] tar xf /Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing/zig-macos-aarch64-0.10.0-dev.3027+0e26c6149.tar.xz -C /Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing
rm -rf '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing/zig-macos-aarch64-0.10.0-dev.3027+0e26c6149.tar.xz'
mv '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing/zig-macos-aarch64-0.10.0-dev.3027+0e26c6149' '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing/files'
mv '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149.installing' '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149'
ln -s '0.10.0-dev.3027+0e26c6149' '/Users/marler8997/zig/master'
symlink '/Users/marler8997/bin/zig' already points to '/Users/marler8997/zig/0.10.0-dev.3027+0e26c6149/files/zig'

marler8997@Jonathans-Air zigup % zig version
0.10.0-dev.3027+0e26c6149

Did you build zigup yourself or did you download it? This is running from an instance of zigup that I built on my M1. If you downloaded the one from the releases section, that one uses x86_64. I've heard Mac has a way to emulate x86_64, so maybe that's the issue. If so, I could probably update the archives to differentiate between x86 and arm so people don't run into this issue.

jhigdon commented 2 years ago

I downloaded one from releases; yep 'builtin.cpu.arch' is reporting x86_64 because the program is running in rosetta etc, a update to the archives would be awesome!

zenspider commented 2 years ago
  1. download the zigup binary for x86, fails to install zig 0.10 because of some download issue
  2. download zig 0.10 binary, try to build zigup... fails on:
/Users/ryan/Work/git/marler8997/zigup/dep/ziget/ziget.zig:8:6: error: empty test name must be omitted
test "" {
     ^~

there's a real bootstrapping issue here. Either arch needs to be an option or #10 needs to be worked out. SOME way to start from scratch or from latest stable release. The current code doesn't work with 0.9 OR 0.10 and that's more friction than I know how to deal with.

xEgoist commented 2 years ago

I can confirm that this is related to downloading the x86_64 binaries from the release page. Rosetta would still be able to run zigup. However, because the architecture of the CPU is reported as x86 from rosetta. zigup will download the x86_64.

One way to solve this issue is by tweaking the CI and creating the cross-compiled binaries for aarch64 for people to download. I attempted to do so in my fork: Here are some sample artifacts

changes are also found here

The only caveat of doing it completely from CI is that it requires building without testing for anything other than x86_64 due to what github action provides.

I am unsure whether this change is plausible, but I can tidy the CI a bit and make a pull request if needed.

marler8997 commented 2 years ago

@xEgoist your change looks plausible. PR welcome.

marler8997 commented 2 years ago

The latest release includes aarch64 binaries for macos: https://github.com/marler8997/zigup/releases/tag/v2022_08_25