Linux-musl.so: How do I link musl properly / statically?

I made a post yesterday, but it had issues and then I got busy so I deleted it. Unfortunately even in the case of musl, linking libc isn’t as simple as just linking a static library. Libc has a global internal state that needs to be initialized by it’s corresponding C runtime. I believe that using a shared object that is simply statically linked with libc.a can run into UB issues with unitialized state depending on what parts of libc the shared object makes use of.

I was able to get some very simple experiments to work by manually linking libc.a into a shared object, but as stated above this is not an intended use case and it’s not supported for a good reason.

1 Like