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

ARM Support #45

Open
disrupted opened this issue Jul 25, 2021 · 7 comments
Open

ARM Support #45

disrupted opened this issue Jul 25, 2021 · 7 comments

Comments

@disrupted
Copy link

disrupted commented Jul 25, 2021

The pre-compiled macOS binary appears to be x86 only. Would it be possible to have a universal build supporting ARM architecture?
When building from source using cargo install ouch rustup first installs an x86-64 toolchain (in addition to the arm64 toolchain) on my computer and later fails during the compilation:

   Compiling ouch v0.1.5
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "~/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/var/folders/_g/nfj48t2948s35nnrcs4p3q_c0000gn/T/cargo-install1namSU/release/deps/ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o" "-o" "/var/folders/_g/nfj48t2948s35nnrcs4p3q_c0000gn/T/cargo-install1namSU/release/deps/ouch-c1fc9f0cbd401a2e" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/var/folders/_g/nfj48t2948s35nnrcs4p3q_c0000gn/T/cargo-install1namSU/release/deps" "-L" "/var/folders/_g/nfj48t2948s35nnrcs4p3q_c0000gn/T/cargo-install1namSU/release/build/bzip2-sys-e23d54bac5dc72d9/out/lib" "-L" "/opt/homebrew/Cellar/xz/5.2.5/lib" "-L" "/Users/salomon/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/var/folders/_g/nfj48t2948s35nnrcs4p3q_c0000gn/T/rustcnCaz4b/libbzip2_sys-ad219373a4b8ba7e.rlib" "/Users/salomon/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-160a7dd17f2dc334.rlib" "-llzma" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv"
  = note: ld: warning: ignoring file /opt/homebrew/Cellar/xz/5.2.5/lib/liblzma.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
          Undefined symbols for architecture x86_64:
            "_lzma_code", referenced from:
                _$LT$xz2..read..XzDecoder$LT$R$GT$$u20$as$u20$std..io..Read$GT$::read::hb1428dcfb9c41431 in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                ouch::compressors::lzma::LzmaCompressor::compress_bytes::h94f82ba83697a63a in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                xz2::write::XzEncoder$LT$W$GT$::try_finish::hcd128a9a358b26ee in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
            "_lzma_easy_encoder", referenced from:
                ouch::compressors::lzma::LzmaCompressor::compress_bytes::h94f82ba83697a63a in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
            "_lzma_auto_decoder", referenced from:
                ouch::decompressors::to_memory::DecompressorToMemory::decompress::hd679a1dec8865489 in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
            "_lzma_end", referenced from:
                ouch::decompressors::to_memory::DecompressorToMemory::decompress::hd679a1dec8865489 in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                core::ptr::drop_in_place$LT$xz2..read..XzDecoder$LT$alloc..boxed..Box$LT$dyn$u20$std..io..Read$u2b$core..marker..Send$GT$$GT$$GT$::hf7ec9572769d8944 in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                core::ptr::drop_in_place$LT$xz2..stream..Stream$GT$::h6048c3516c7203ec in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                ouch::compressors::lzma::LzmaCompressor::compress_bytes::h94f82ba83697a63a in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                core::ptr::drop_in_place$LT$xz2..write..XzEncoder$LT$alloc..vec..Vec$LT$u8$GT$$GT$$GT$::h5164a69ef0e186df in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
                core::ptr::drop_in_place$LT$xz2..stream..Stream$GT$::h92dfb9102f4d6f54 in ouch-c1fc9f0cbd401a2e.ouch.1mb7mks5-cgu.0.rcgu.o
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
@disrupted
Copy link
Author

I investigated a bit more about this as I just got this new ARM-based computer.

It actually works after adding the specific target:

$ rustup target add aarch64-apple-darwin
$ cargo install --target aarch64-apple-darwin ouch

I verified it like this:

$ file -b $(which ouch)
Mach-O 64-bit executable arm64

Perhaps this could be added to the automated release pipeline.

@vrmiguel
Copy link
Member

I'm not sure if GitHub Actions is able to build for aarch64-apple-darwin yet

I gave it a try here but it failed to compile bzip2

Maybe I'm just doing it wrong though, I'll have to retry that later

@disrupted
Copy link
Author

bzip2 might have to be installed through Homebrew, at least that's what I did locally.

@marcospb19
Copy link
Member

@disrupted I'm messing with the CI, trying to make a workflow that provides a binary for your platform.

Now we are stuck in an error while compiling bzip2-sys, as you said, bzip2 might have to be installed through Homebrew for this platform (even tho is not needed for the x86_64 one).

https://github.com/ouch-org/ouch/runs/3715706353#step:4:156

I have never used homebrew, ever, so do you remember what was the command necessary to make it work? Based on it I can try to figure it out how to add as a step in the CI setup.

@marcospb19
Copy link
Member

At the moment of writing, there isn't proper support in the CI for building this regularly, I realized that aarch64-apple-darwin is a tier 2 target, the compiler code is not regularly tested.

We should wait until there is tier 1 support for it.

Also, me and @vrmiguel both use x86_64-linux, and we are the only ones who are actively committed to maintaining ouch.

Here is the tracking issue for support in the official lang repo rust-lang/rust#73908, sadly, there is no planned date for it to be solved, so I'll close this issue for now.


NOTE: if you are from the feature and now GitHub Actions supports running jobs on mac's arm64, feel free to bump this issue.

@NiceGuyIT
Copy link

The future is now.

rust-lang/rust#73908 is still outstanding but it's getting closer because GitHub Actions now support M1 builds. According to the docs, the minute multiplier is 10x for macOS, meaning if it takes 2 minutes to build, your GitHub Actions account will be charged 20 minutes.

Until arm64 binaries are present in the release, is it against the LICENSE to distribute pre-compiled binaries of ouch?

@marcospb19
Copy link
Member

because GitHub Actions now support M1 builds

That's great news for Rust :)

the minute multiplier is 10x for macOS, meaning if it takes 2 minutes to build, your GitHub Actions account will be charged 20 minutes.

Cool piece of info, I believe it is OK for us because Ouch is open-source and GitHub allows us to use too much CI, more than we need here, for sure.

is it against the LICENSE to distribute pre-compiled binaries of ouch?

It is not! Feel free to do so.

(I feel like editing the source code, not updating the LICENSE, AND THEN redistributing this edited version should be illegal, but I'm not sure, I encourage you to update the LICENSE if you do edit the code.)


Reopening while we wait for updates from rust-lang/rust#73908.

@marcospb19 marcospb19 reopened this Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants