v
v copied to clipboard
`-skip-unused` causes undefined references to V functions
V version: V 0.2.4 0ac4509.717b4db OS: linux, "EndeavourOS Linux"
What did you do?
I tried to compile my project using the -skip-unused
flag, first in an Alpine linux container, then on the host system. Both times, I got this error:
> v -o pvieter -prod -skip-unused src
==================
/usr/bin/ld: <artificial>:(.text+0xb11b): undefined reference to `main__App_put_package'
collect2: error: ld returned 1 exit status
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error. This should never happen.
This is a compiler bug, please report it using `v bug file.v`.
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
The attached tarball contains the code that caused this issue. It also contains a Dockerfile.builder
file, which you can use to reproduce the builder image that I used to test the compilation on Alpine. You can compile the code using make prod
, but I did use the linker flags LDFLAGS=-lz -lbz2 -llzma -lexpat -lzstd -llz4 -static
inside the Alpine container in order to create a statically compiled binary.
What did you expect to see? Succesful compilation with possibly a smaller binary.
What did you see instead?
Errors stating undefined references.
Still exists in V 0.3.2 4747e70.bb512f7
One thing - V changed a lot from the moment your code was implemented. Can you review it @ChewingBever and reimplement it for a new V version? Just for test purposes I fixed errors very quickly but not sure if program still works as expected, so wouldn't push any code updates
Latest V is V 0.3.3 4c33a92
, and yes, the code has lots of errors so it won't compile at all with the latest.
@ChewingBever please test again to see if there is still a problem, or if what you saw before has been fixed.