Prior99 / node-libpng

Unofficial bindings for node to libpng.
MIT License
19 stars 11 forks source link

build binary for Apple M1 #47

Closed shff closed 1 year ago

shff commented 2 years ago

I was able to cross-compile for the M1 chip from an Intel machine with these commands:

CFLAGS="-Wno-implicit-function-declaration" CPPFLAGS="-DPNG_ARM_NEON_OPT=0" yarn prebuild --arch=arm64
ARCH="arm64" yarn postbuild

> file node-libpng-darwin-arm64-83.node
node-libpng-darwin-arm64-83.node: Mach-O 64-bit bundle arm64

I airdropped the file to an M1 computer and all tests passed.

Solves #45

shff commented 2 years ago

I'm not 100% sure if this will work in the CI, though! If it does we can apply the same solution to native-image-diff.

tujoworker commented 2 years ago

Amazing news! Thank you so much for the PR 🤩

What do you think @Prior99?

fjaeger commented 2 years ago

@shff But isn't this then always building an arm64 binary, which is likely not working on i386 architectures?! Maybe owe can build both sequentially and use lipo to bundle them to a universal binary?

https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

shff commented 2 years ago

@fjaeger In travis.yml the Intel version is still built in line 58, so they would be built sequentially. Due to how install.js works, it requires different binaries for different architectures. So we need to build and provide two binaries for download anyway.

tobloef commented 2 years ago

Sorry to bump this, but is anything currently stopping us from merging this? It would be great to see this getting released 😃

tujoworker commented 1 year ago

@Prior99 Is it only you who can merge PRs? or also @fjaeger?

fjaeger commented 1 year ago

@tujoworker Unfortunately, I cannot merge PRs here :-(