-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unclear how to compile a static binary #21760
Comments
Results in
|
Cool! It does work on Ubuntu. On NixOS, you need to have $ nix-shell -p glibc.static vlang
$ v -cflags -static hello.v
$ file ./hello
./hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.10.0, not stripped
$ ./hello
hello world I still think that either this should be made the default, or the necessary flags clearly documented, or the claims about producing static binaries adjusted. On another note, |
I doubt it will be made the default, as it increases the file size by quite a bit...
... over twice as large output. However, agreed that it could be made more obvious how to achieve statically linked binaries, and that it will also be necessary for a switch that works with the native backend... once that's actually working. :-) |
Describe the bug
The V website claims that "You get a single statically linked binary". However, by default the compiler produces a dynamic binary, and there seems to be no way to produce a working static binary.
Reproduction Steps
Compile any code with V. Result is a dynamically linked binary.
Expected Behavior
Expected V to produce a statically linked binary.
Current Behavior
Compiling without any additional flags produces a dynamic binary:
Compiling with musl-gcc as suggested in #19792 (comment) does not work because pthreads fail to link:
Compiling with
-freestanding
as suggested by a Stack Overflow answer does produce a static binary, but it also makes V not link the C standard library at all (statically or dynamically). Since basic functionality of V depends on libc, this means that even basic code does not work out of the box in this mode:Possible Solution
V should either:
v -static
. V shouldn't lose basic functionality when the code is compiled this way.Additional Information/Context
No response
V version
V 0.4.6 4a7c70c
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: