prebuild / prebuildify

Create and package prebuilds for native modules
MIT License
198 stars 37 forks source link

Distributing N-API modules for different linux distributions #40

Closed alcuadrado closed 4 years ago

alcuadrado commented 4 years ago

Hi,

I'm using an npm package that is built using this project, and run into this issue which I'm trying to fix.

The problem is that the package is built and linked with glibc, and some users are trying to run it on Alpine, which uses the musl libc. I understand that this combination is not meant to work, and wonder what's your recommended way for dealing with this.

I have a few options in mind:

  1. Link the libc statically for Linux distributions.
  2. Have separate prebuilds for glibc- and musllibc-based systems.
  3. Fallback to a js implementation in musllibc-based systems.

I'd say that my personal preference would be (1), but I'd love to know your opinions. I'm not exactly sure how any option would be implemented.

Can you please help me with this?

Thanks!

vweevers commented 4 years ago

A fourth option would be to pass --tag-libc to prebuildify. This way the prebuild name will include .glibc and be skipped on alpine. An npm install will then fall back to compiling from source. This can also be done manually with npm i --build-from-source.

As for option 2, see prebuildify-cross which can compile a prebuild in an alpine docker image. For an example see leveldown.

alcuadrado commented 4 years ago

Oh, that's great, @vweevers! I guess we should use both --tag-libc and prebuildify-cross.

Thanks for the quick answer and for linking an example!

fanatid commented 4 years ago

~prebuildify-cross should be installed from github? On npm latest version is 3.1.2 https://www.npmjs.com/package/prebuildify-cross~ nvm, I see that leveldown use github as source =\

vweevers commented 4 years ago

@fanatid https://github.com/prebuild/prebuildify-cross/issues/8