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

Native dependencies (leveldown): building on (macOS) arm64 for x64 #7586

Closed
rasgo-cc opened this issue May 25, 2023 · 3 comments
Closed

Native dependencies (leveldown): building on (macOS) arm64 for x64 #7586

rasgo-cc opened this issue May 25, 2023 · 3 comments

Comments

@rasgo-cc
Copy link

rasgo-cc commented May 25, 2023

  • Electron-Builder Version: 23.6.0
  • Node Version: 16.20.0
  • Electron Version: 24.3.0
  • Electron Type (current, beta, nightly): current
  • Target: x64

My app has leveldown as a dependency (through pouchdb) and it seems that whenever building it on macOS arm64 and for x64, the binaries picked are still the ones for arm64. When running the app on x64, the app never really starts and I get this error on Sentry (not sure how I could get it any other way as the stdout/stderr doesn't show this):

dlopen(/Applications/BOMIST.app/Contents/Resources/app.asar.unpacked/node_modules/leveldown/build/Release/leveldown.node, 1): no suitable image found.

While building the app this is what I get:

  • writing effective config  file=dist/builder-effective-config.yaml
  • rebuilding native dependencies  [email protected], [email protected] platform=darwin arch=x64
  • rebuilding native dependency  name=leveldown version=5.6.0
  • rebuilding native dependency  name=leveldown version=5.6.0
  • packaging       platform=darwin arch=x64 electron=24.3.0 appOutDir=dist/mac
  • signing         file=dist/mac/BOMIST.app 

From here it looks like it picks the arch correctly but in practice the arm64 binaries are still used?

On arm64 I get a build directory on node_modules/leveldown/build/Release but on x64 that directory is not created, not sure if that helps.

Initially I was trying to build for arch=universal but figured that simply building for x64 from arm64 would yield the same result.

Any idea what's going wrong?

@rasgo-cc
Copy link
Author

Was able to overcome this by building "fat" binaries for leveldown and manually copying them (the build folder) into node_modules/leveldown/build (this, on macOS arm64).

Reference: Level/leveldown#766 (comment)

@rasgo-cc
Copy link
Author

rasgo-cc commented Aug 4, 2023

For reference:
Setting buildDependenciesFromSource=true should also work.

@ufukomer
Copy link

ufukomer commented Dec 2, 2023

@rasgo-cc buildDependenciesFromSource=true does not work when I build on arm64 and run on x64. Can you help me with adding prebuild leveldown into my project? Level/leveldown#766 (comment) I am using PouchDB and leveldown is a dependency of it. I have no idea how to do this.

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

2 participants