mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
Unable to compile static Go binary -- undefined reference to _kBrotli constants
#515
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dmartindms on GitHub (Aug 15, 2024).
When attempting to compile a static Go binary with brotli static libs, it fails to find symbols defined in the libbrotlicommon.
Example Alpine Dockerfile:
Another Dockerfile example with Debian (in case of any musl weirdness):
Has the following error:
The static libs (.a suffix) appear to be present in the Alpine build:
The same error happens with the Debian Dockerfile, so I'm at a loss as to why the linker or gcc can't find
_kdefined constants in brotlicommon when using-static.I was able to compile a dynamic executable successfully with the normal
go build.@eustas commented on GitHub (May 28, 2025):
Will investigate soon. Looks like some symbols have been dropped by linker.
@eustas commented on GitHub (May 28, 2025):
FWIW:
@eustas commented on GitHub (Oct 1, 2025):
Inspected contents of common / dec libraries: not only dictionary symbol missing, contents are missing as well.
@eustas commented on GitHub (Oct 1, 2025):
It seems that LTO nukes dictionary in static build.
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/brotli/APKBUILD
@dimitre commented on GitHub (Oct 6, 2025):
I'm having a similar issue here, only in linux64 now.
building with this formula here, commit
f1c8022https://github.com/dimitre/ofLibs/blob/main/brotli/chalet.yaml
@eustas commented on GitHub (Oct 6, 2025):
Hello @dimitre. Your case seems to be different. I could guess that wrong (old, installed in system) static library is used. Need more logs to see if the guess is true.