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

Static binary? #174

Closed
jbergstroem opened this issue Nov 16, 2022 · 6 comments
Closed

Static binary? #174

jbergstroem opened this issue Nov 16, 2022 · 6 comments

Comments

@jbergstroem
Copy link

jbergstroem commented Nov 16, 2022

I think distribution and overall usage would benefit from shipping workerd as a static binary.

Refs: #46, #170, cloudflare/workers-sdk#2173

@kentonv
Copy link
Member

kentonv commented Dec 7, 2022

Static binaries on glibc-based systems cannot do DNS lookups, which we need to be able to do, so a purely static binary isn't an option. However, I agree that we should statically link everything other than glibc. (glibc itself has a very stable ABI, so this should be good enough to get all the advantages of a static binary.)

@vlovich
Copy link
Contributor

vlovich commented Feb 16, 2023

FWIW, Matt D is having a problem installing workerd by way of miniflare:

npm ERR! node_modules/workerd/bin/workerd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by node_modules/workerd/bin/workerd)
npm ERR! node_modules/workerd/bin/workerd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by node_modules/workerd/bin/workerd)

He's on Ubuntu 20.04 which admittedly very old. Does it make sense to at least distribute workerd built against a very old glibc to ease compat issues like that.

@jbergstroem
Copy link
Author

jbergstroem commented Feb 16, 2023

Does it make sense to at least distribute workerd built against a very old glibc to ease compat issues like that.

Simple install scripts that does a local check or two could be another way to work around issues like these.

@penalosa
Copy link
Collaborator

I think Ubuntu 20 has other problems (I don't think you can easily install the right libc version). Ubuntu 22 is probably the best bet for now, until there are static (ish) binaries that can be built against an old glibc

@fhanau
Copy link
Collaborator

fhanau commented Jul 6, 2023

As of the latest workerd and wrangler releases, we now statically link libc++ and dynamically link against glibc 2.31. While it is not a fully static build (libc, libm and pthread are dynamically linked), it should fix the issues with library versions on at least Ubuntu 20.04 and Debian Bullseye.

@fhanau fhanau closed this as completed Jul 6, 2023
@kentonv
Copy link
Member

kentonv commented Jul 6, 2023

@fhanau Nice work!

Dynamically linking against glibc (at an older version) is the right thing to do. Statically linking glibc would lead to problems with DNS lookup and other functionality which glibc itself loads dynamically. So it sounds like we're at the right end state now.

(libc, libm, and pthread are all part of glibc.)

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

No branches or pull requests

5 participants