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

build fat binaries on macosx #294

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

elcritch
Copy link
Contributor

It looks like choosenim is still using rosetta x86 builds for M1 based Macs. This change should get the macosx build to generate "fat binaries" that support both x86_64 and arm64 variants.

I'm testing it on my M1, but don't have access to an x86 Mac to verify the binaries work there as well.

@heinthanth
Copy link

Yes ... it's good!

@dom96
Copy link
Owner

dom96 commented Jan 30, 2022

Epic. I've got a x86 mac so I should be able to test this :)

Remind me if I forget, got lots of other stuff to do this weekend.

@elcritch
Copy link
Contributor Author

Great! I tried getting Nim itself to compile a fat binary too. But, there's too many levels of bootstrap builds. It did produce arm64 native builds. Any thoughts on which stage I'd need to modify to get the Nim compiler to build a fat binary?

@heinthanth
Copy link

Hello, will u merge this? We have to manual compile and install nim from source till now.

@dom96
Copy link
Owner

dom96 commented Jul 6, 2022

I suppose unsurprisingly I cannot build with these flags on a x86 Mac. So I cannot test it. But I will merge and we can see if @marcomq's build script succeeds in building binaries for this.

@dom96 dom96 merged commit aa690a4 into dom96:master Jul 6, 2022
@dom96
Copy link
Owner

dom96 commented Jul 6, 2022

Sadly not:

image

@dom96
Copy link
Owner

dom96 commented Jul 6, 2022

Reverted in e9ed20d but would appreciate a fix :)

@heinthanth
Copy link

I think it's due to Zippy dependency which use asm on amd64. I'm figuring out.

@elcritch
Copy link
Contributor Author

elcritch commented Jul 7, 2022

Thanks! Though making choosenim a fat binary doesn't fix the compiler itself. That might require setting up choosenim to download a different Nim binary when it's run on MacOS/ARM.

@heinthanth
Copy link

heinthanth commented Jul 7, 2022

Yeah ...

  1. when cross-compiling arm64 from amd64 with nim c --passC:'-arch arm64' --passL:'-arch arm64',
  2. amd64 is defined and this lines are activated: https://github.com/guzba/zippy/blob/8e472c468c1c67b3221a71ad7224cd058492b752/src/zippy/internal.nim#L323-L336
  3. To fix that we can set --cpu flag.

Choosenim also use proxy binaries. So, we can't build universal bin. Instead, we have to use separate choosenim arm64 and amd64. What do u think?

@dom96
Copy link
Owner

dom96 commented Jul 7, 2022

Personally I think that implementing arm support for choosenim is far more important than making choosenim itself a fat binary. As long as macOS will support Rosetta it should be fine.

What this ideally means is also arm Linux support. But this is trickier. If we can get choosenim to build an arm macOS Nim that would be a great first step.

@heinthanth
Copy link

Yeah ... I see. Let me attempt to create a PR.

@heinthanth
Copy link

Hello ... I've created an initial patch that works: #301. I think I need to M1 user to test this 🤔 .

@elcritch
Copy link
Contributor Author

elcritch commented Jul 8, 2022

@heinthanth awesome! I'll test it out here and see if it works.

@dryajov dryajov mentioned this pull request Sep 9, 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

Successfully merging this pull request may close these issues.

3 participants