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

Fix build with musl 1.2.4 #3755

Merged
merged 1 commit into from
Aug 7, 2023
Merged

Conversation

kleisauke
Copy link
Contributor

@kleisauke kleisauke commented Aug 7, 2023

musl 1.2.4 has removed the legacy LFS64 glibc-ABI-compat symbols, which would cause an error during npm install sharp when compiled from source (either with the --build-from-source flag or when a globally installed libvips is detected).

On the API level, the legacy "LFS64" ("large file support") interfaces, which were provided by macros remapping them to their standard names (#define stat64 stat and similar) have been deprecated and are no longer provided under the _GNU_SOURCE feature profile, only under explicit _LARGEFILE64_SOURCE. The latter will also be removed in a future version. Builds broken by this change can be fixed short-term by adding -D_LARGEFILE64_SOURCE to CFLAGS, but should be fixed to use the standard interfaces.
https://musl.libc.org/releases.html

The fix is to replace the OS-specific #ifdef's with a single one that checks whether _LARGEFILE64_SOURCE is defined. Other libc implementations that provide nondegenerate LFS64 interfaces are expected to define this macro as well.

Reproducer
$ mkdir sharp-musl && cd sharp-musl
$ docker run -v $(pwd):/app -w /app -it alpine:edge sh -c "\
    apk add build-base git npm python3 vips-cpp vips-dev && \
    npm install --build-from-source sharp"
...
npm ERR! ../src/pipeline.cc: In member function 'virtual void PipelineWorker::OnOK()':
npm ERR! ../src/pipeline.cc:1267:30: error: aggregate 'PipelineWorker::OnOK()::stat64 st' has incomplete type and cannot be defined
npm ERR!  1267 |         struct STAT64_STRUCT st;
npm ERR!       |                              ^~
npm ERR! ../src/pipeline.cc:1268:55: error: invalid use of incomplete type 'struct PipelineWorker::OnOK()::stat64'
npm ERR!  1268 |         if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) {
npm ERR!       |                                                       ^
npm ERR! ../src/pipeline.cc:33:23: note: forward declaration of 'struct PipelineWorker::OnOK()::stat64'
npm ERR!    33 | #define STAT64_STRUCT stat64
npm ERR!       |                       ^~~~~~
npm ERR! ../src/pipeline.cc:1267:16: note: in expansion of macro 'STAT64_STRUCT'
npm ERR!  1267 |         struct STAT64_STRUCT st;
npm ERR!       |                ^~~~~~~~~~~~~
npm ERR! make: *** [sharp-linuxmusl-x64.target.mk:169: Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o] Error 1
...

@lovell lovell merged commit 2829e17 into lovell:main Aug 7, 2023
17 checks passed
@lovell
Copy link
Owner

lovell commented Aug 7, 2023

Dankjewel Kleis!

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

Successfully merging this pull request may close these issues.

2 participants