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

Question : How to contribute to repo with prebuilds for Mac M1 #441

Closed
DonJayamanne opened this issue Mar 26, 2021 · 8 comments · Fixed by #522
Closed

Question : How to contribute to repo with prebuilds for Mac M1 #441

DonJayamanne opened this issue Mar 26, 2021 · 8 comments · Fixed by #522
Labels

Comments

@DonJayamanne
Copy link
Contributor

Sorry for not using the right template.
Not sure this is the place to ask this, but I'm trying to find out how we can contribute the prebuilds for Mac m1

@JamesHenry
Copy link

JamesHenry commented Apr 2, 2021

I'm here for the same reason. When installing my repo on a new Mac Mini for the first time, the zeromq piece generated a large output and ultimately exited with a make error.

I'm definitely out of my comfort zone when inspecting these types of logs, but It seems the building piece did actually succeed, but the node-gyp command did not.

In my case zeromq is in my dependencies because of a dependency on sawtooth-sdk which brings it in (and sadly that's v4 of zeromq.js although I don't think that was relevant here).

If I can provide any more information that would be valuable (e.g. the logs I am referring to), please let me know.

@aminya
Copy link
Member

aminya commented Apr 15, 2021

We managed to build Zadeh, one of my native libraries, for macOS by adding the following flags. But there are no CI services or official Node for Arm64 to prebuild and test it. I requested one of my friends who has M1 to build it locally and send me the arm64 prebuild.

https://github.com/atom-community/zadeh/blob/0a5ca9a129fdfd947fa4c697dfdbbdc36dbd721f/binding.gyp#L27-L34

            'OTHER_CFLAGS': [
              '-arch x86_64',
              '-arch arm64'
            ],
            'OTHER_LDFLAGS': [
              '-arch x86_64',
              '-arch arm64'
            ]

@DonJayamanne
Copy link
Contributor Author

@aminya any update on this? Thanks for looking into this.
I could send the executable as well (though, I'm not sure that's the right thing to do, i could easily add any malicious code into that).
I guess we'll wait for the official release.

@aminya aminya added build and removed bug labels May 3, 2021
@aminya
Copy link
Member

aminya commented May 4, 2021

We can add the compiler flags for the source builds, but we cannot provide prebuilds and promise anything about the functionality. We are in a situation where a company has released a new product with a new architecture with no way to test software on it. I don't think we can add official support for that product.

actions/runner-images#2187

@ni-mkrieg
Copy link

ni-mkrieg commented Sep 22, 2021

@aminya, I have similar problems when cross-compiling for arm64 on x64 MacOs using electron-builder; keytar e.g. works great by providing a pre-build for arm64. Even re-compiling externals on x64 does not work, it always ends up just with x64 support even when using your binding.gyp flags proposed above.

I can work around this for separate OS builds by pre-building on arm64 and staging the pre-build into build/Release/zeromq.node but that does not work well in the combined universal build. So it would be great to either have a branch that compiles arm64 on x64 correctly or even better a prebuilt binary for arm64.

@mbui0327
Copy link

We managed to build Zadeh, one of my native libraries, for macOS by adding the following flags. But there are no CI services or official Node for Arm64 to prebuild and test it. I requested one of my friends who has M1 to build it locally and send me the arm64 prebuild.

https://github.com/atom-community/zadeh/blob/0a5ca9a129fdfd947fa4c697dfdbbdc36dbd721f/binding.gyp#L27-L34

            'OTHER_CFLAGS': [
              '-arch x86_64',
              '-arch arm64'
            ],
            'OTHER_LDFLAGS': [
              '-arch x86_64',
              '-arch arm64'
            ]

Interesting, @aminya can you give some introduction on how to make this work with zmq? Thanks.

@mbui0327
Copy link

mbui0327 commented Oct 25, 2021

@aminya, I have similar problems when cross-compiling for arm64 on x64 MacOs using electron-builder; keytar e.g. works great by providing a pre-build for arm64. Even re-compiling externals on x64 does not work, it always ends up just with x64 support even when using your binding.gyp flags proposed above.

I can work around this for separate OS builds by pre-building on arm64 and staging the pre-build into build/Release/zeromq.node but that does not work well in the combined universal build. So it would be great to either have a branch that compiles arm64 on x64 correctly or even better a prebuilt binary for arm64.

@ni-mkrieg can you explain how to do this? Thank you very much.

I did npm run dev:build --build-from-source --Release on a local clone of zeromq.js but I did not get the Release folder.

@ni-mkrieg
Copy link

@mbui0327 indeed you first need to be able to get the Release built on your M1 Mac. Try this and do yarn install:

[package.json]

"scripts": {
"postinstall": "electron-builder install-app-deps"
}

Once you got the release package it up like this:
image

Then add the .tar.gz file to your repository e.g. in ./build/prebuilds.

Now you can cross-compile your app on your x64 Mac:
You need to stage files for the x64 and arm64 builds and also disable the rebuild of app deps during the electron build!

[pakage.json]

"scripts": {
"prebuild-x64": "electron-builder --platform=darwin --arch=x64 install-app-deps",
    "prebuild-arm64": "electron-builder --platform=darwin --arch=arm64 install-app-deps && tar -xvf ./build/prebuilds/zeromq-darwin-arm64.tar.gz -C ./node_modules/zeromq/",
"build": "run-script-os",
"build:darwin": "yarn prebuild-${ARCH} && electron-builder --${ARCH}"
}

"build": {
    "npmRebuild": false
}

That should be all you need so in your Github actions build e.g. just set the ARCH environment variable to "x64" or "arm64" and run yarn build with each once.

Does this make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants