libasync icon indicating copy to clipboard operation
libasync copied to clipboard

Error when trying to build under Alpine (Musl)

Open cyrusmsk opened this issue 2 years ago • 3 comments

Hi @etcimon. Do you know if the lib should work on Alpine docker container? I faced with this error: /root/.dub/cache/libasync/~master/build/regular-release-RNnj5zspAaZtWLsA4BwBbA/libasync.a(libasync.posix.o): in function _D8libasync5posix13EventLoopImpl6notifyMFNbIiOCQBt6signal11AsyncSignalZb': posix.d:(.text._D8libasync5posix13EventLoopImpl6notifyMFNbIiOCQBt6signal11AsyncSignalZb+0x1d): undefined reference to pthread_sigqueue'

cyrusmsk avatar Jul 18 '23 20:07 cyrusmsk

It seems like a linker issue, I think you need to link to a stub for pthreads to work in this docker.

https://github.com/alpinelinux/docker-alpine/issues/227

Have you tried linking with the supplied libpthread.a?

etcimon avatar Jul 18 '23 22:07 etcimon

I've tried to use it, no luck. But I found the root of the problem (I suppose). Musl still doesn't have pthread_sigqueue. And we don't have it for Musl in core as well. https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/posix/signal.d#L3056

So libasync is not compatible with Musl until someone implement it and upstream into main repo.

cyrusmsk avatar Aug 12 '23 16:08 cyrusmsk

Btw BSD systems also don’t have this function. In the web people are mentioning that it is not very portable (only glibc probably has it).

For example, Microsoft rewrote their implementation with pthread_kill https://github.com/dotnet/runtime/issues/4472

cyrusmsk avatar Aug 14 '23 10:08 cyrusmsk