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

add arm64 prebuilds for alpine #714

Merged
merged 2 commits into from
Nov 19, 2021
Merged

add arm64 prebuilds for alpine #714

merged 2 commits into from
Nov 19, 2021

Conversation

Chicken
Copy link
Contributor

@Chicken Chicken commented Oct 26, 2021

Arm64 is getting more and more popular with the oracle servers and raspberry pi's so it would be great to have prebuilds for it.
Could have probably added arm64 support for other builds too but didn't want to start testing if they actually work.

@mceachen
Copy link
Member

I ran this locally and rebuild ignored the --arch flag and produced x64 binaries.

How'd you test this?

@Chicken
Copy link
Contributor Author

Chicken commented Nov 17, 2021

I ran all the commands in a docker environment like the workflow would do:
docker run --rm -it --entrypoint /bin/sh node:16-alpine
and then
apk add build-base git python3 --update-cache
git clone https://github.com/JoshuaWise/better-sqlite3
cd better-sqlite3
npm install --ignore-scripts
npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' --arch aarch64
The --arch flag is for sure the correct one. It's even used in the windows build as --arch ia32
And the output sure looks correct to me:
WindowsTerminal_fz2OKiiB9u

@mceachen
Copy link
Member

mceachen commented Nov 17, 2021

Thanks for providing the commands you used!

And the output sure looks correct to me:

The tarball, at least on my box, is correctly named, but has incorrect binaries:

/better-sqlite3/prebuilds # ls
better-sqlite3-v7.4.4-node-v64-linuxmusl-aarch64.tar.gz
/better-sqlite3/prebuilds # tar xvzf better-sqlite3-v7.4.4-node-v64-linuxmusl-aarch64.tar.gz 
build/Release/better_sqlite3.node
/better-sqlite3/prebuilds # file build/Release/better_sqlite3.node 
build/Release/better_sqlite3.node: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped

To build cross-architecture binaries, I'd expect QEMU (or something like it) to come into play at some point, and I don't see prebuild using that.

TBH, I'm a prebuild n00b: do you know of other projects building cross-architecture prebuilds so we can crib from their work?

@Chicken
Copy link
Contributor Author

Chicken commented Nov 17, 2021

That's certainly interesting...
I sadly don't know any other projects that do this and I'm not sure how hard it would be to find one.
I was basing everything on these four facts:

  • normally builds and runs fine
  • the windows build uses the arch flag
  • prebuild accepts the flag, does something with it, and doesn't complain
  • the tarballs are correctly named

I'll look into this more

@Chicken
Copy link
Contributor Author

Chicken commented Nov 17, 2021

Alright, I no longer have any idea what is happening and why. I'll later try to make a workflow which emulates arm64 with qemu and docker to run the prebuilds. No guarantees if that works though as github workflows are really hard to test.
Honestly kinda annoyed at prebuild. That's some stupid behavior and probably a bug...

@Chicken
Copy link
Contributor Author

Chicken commented Nov 18, 2021

Ran a test with it:
(though the test used a slighty modified version defined here)
https://github.com/Chicken/better-sqlite3/runs/4249357964
image
Now it properly works!

@JoshuaWise
Copy link
Member

LGTM

@JoshuaWise JoshuaWise merged commit ac4d76a into WiseLibs:master Nov 19, 2021
m4heshd added a commit to m4heshd/better-sqlite3-multiple-ciphers that referenced this pull request Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants