Steps to reproduce:
Minimal example as a Dockerized gist
To run:
$ docker build --no-cache .
Expected results:
Simple eval:
WORKS
Static build, no MT:
WORKS
Dynamic build, no MT:
WORKS
Dynamic build, MT:
WORKS
Static build, MT:
WORKS
Actual results:
Simple eval:
WORKS
Static build, no MT:
WORKS
Dynamic build, no MT:
WORKS
Dynamic build, MT:
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: G-C-.o: in function `set_stackbottom':
/usr/share/crystal/src/gc/boehm.cr:245: undefined reference to `GC_set_stackbottom'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: G-C-.o: in function `current_thread_stack_bottom':
/usr/share/crystal/src/gc/boehm.cr:236: undefined reference to `GC_get_my_stackbottom'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/usr/src/application/app' -rdynamic -lpcre -lm /usr/lib/libgc.a -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent_pthreads -levent -lrt -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib`
Static build, MT:
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: G-C-.o: in function `set_stackbottom':
/usr/share/crystal/src/gc/boehm.cr:245: undefined reference to `GC_set_stackbottom'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: G-C-.o: in function `current_thread_stack_bottom':
/usr/share/crystal/src/gc/boehm.cr:236: undefined reference to `GC_get_my_stackbottom'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/usr/src/application/app' -rdynamic -static /usr/lib/libpcre.a /usr/lib/libm.a /usr/lib/libgc.a /usr/lib/libpthread.a /usr/share/crystal/src/ext/libcrystal.a /usr/lib/libevent_pthreads.a /usr/lib/libevent.a /usr/lib/librt.a -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib`
Occurs when run against the following Docker images:
0.33.0-alpine-build0.33.0-alpine0.32.1-alpine-build0.32.1-alpineThis is a known issue as we're waiting for an upstream release for the GC that includes a patch to support MT.
@straight-shoota would know more.
Ah, I see. I did look for an official note to that effect but obviously I looked in the wrong places :upside_down_face:
@straight-shoota What is it about musl that causes the problem?
It's got nothing to do with musl. Multithreading just needs some newer API in bdwgc which were implemented based on a custom patch for Crystal. There hasn't been a bdwgc release yet which includes this. It was my understanding that a new release 8.2.0 should have been expected in February. Still waiting for it.
In expectance of the new bdwgc release I didn't go the extra mile to build a custom libgc from master like in the ubuntu Dockerfile because it would soon be obsoleted.
This is really easy to fix: If you want MT support, just build bdwgc from master and use that.
PRs to crystal-lang/distribution-scripts are welcome, too.
Most helpful comment
It's got nothing to do with musl. Multithreading just needs some newer API in bdwgc which were implemented based on a custom patch for Crystal. There hasn't been a bdwgc release yet which includes this. It was my understanding that a new release 8.2.0 should have been expected in February. Still waiting for it.
In expectance of the new bdwgc release I didn't go the extra mile to build a custom libgc from master like in the ubuntu Dockerfile because it would soon be obsoleted.
This is really easy to fix: If you want MT support, just build bdwgc from master and use that.
PRs to crystal-lang/distribution-scripts are welcome, too.