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

Homebrew Universal Binary/type - "Bad CPU type in executable" #1011

Open
stacksjb opened this issue Feb 20, 2025 · 2 comments
Open

Homebrew Universal Binary/type - "Bad CPU type in executable" #1011

stacksjb opened this issue Feb 20, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@stacksjb
Copy link
Collaborator

stacksjb commented Feb 20, 2025

Describe the bug
I uninstalled the compiled Cargo (Cargo install tod) version of Tod and installed the Homebroew (brew install tod) version, but it doesn't function on my computer (Intel) as it is not universal (correct CPU type)

To Reproduce
On an i386 (Intel) Mac (as oppposed to m2 - run "arch" from command line), install Tod from homebrew (brew install tod)

It will install sucessfully, but fail to launch.

Expected behaviour
Homebrew entity needs to be a universal binary

Additional context
I will look into this more - most of the documentation around this error happens with code compiled for Intel being unable to run without recompilation (or Rosetta usage) on M1/M2/M3 processors, but I will have to find what is needed to allow it to compile for universal (based on arch).

@stacksjb stacksjb added the bug Something isn't working label Feb 20, 2025
@stacksjb
Copy link
Collaborator Author

Looking into this, there are two ways this could be resolved:

  1. Compile the build as a Universal build by either combining the builds using something like https://gist.github.com/dyfer/6c83905d4593750105897e51e87ec3
  2. Compile separate builds and add logic to the homebrew Formula (https://github.com/alanvardy/homebrew-tod/blob/main/Formula/tod.rb) to check arch with "If" statements (see https://stackoverflow.com/questions/62288259/how-to-detect-a-platform-in-a-homebrew-formula ) with two compiled destinations and fetch the appropriate build depending on architecture

Homebrew is not designed to handle Universal binaries specifically and the 2nd method is preferred (and the method most repositories follow) however it does require maintaining multiple mac builds (an i386 and an arm build).

I will pull/test an updated script (note to self: see Homebrew/brew#1468 for how to run with a local .rb)

@stacksjb
Copy link
Collaborator Author

stacksjb commented Feb 24, 2025

Note to self: This is also a good opportunity to ensure we also support Homebrew on Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant