noborus / trdsql

CLI tool that can execute SQL queries on CSV, LTSV, JSON, YAML and TBLN. Can output to various formats.
https://noborus.github.io/trdsql/
MIT License
1.96k stars 73 forks source link

binary is not completely statically compiled #179

Closed akkuman closed 9 months ago

akkuman commented 2 years ago
$ trdsql -ijson "select verbose_name from fudaneducn.json group by verbose_name"
trdsql: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by trdsql)
trdsql: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by trdsql)
trdsql: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by trdsql)

It depends on a particular version of glibc

my glibc info

strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_PRIVATE
GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.
noborus commented 2 years ago

Since trdsql uses go-sqlite3, it is built with cgo enabled. Therefore, it cannot be completely statically linked.

I hope it works with older versions of glibc (I'd love to know if there is a way). The current solution will definitely work if you build it in your own environment.

akkuman commented 2 years ago

cgo can be statically linked, but it need toolchain of special platform. for example, linux need musl. I also used xgo cross-compile initially, but found that adding "-extldflags =-static" would not cross-compile to MacOS, so I switched to zig cc instead https://github.com/akkuman/rotateproxy/blob/master/.github/workflows/release.yml

noborus commented 2 years ago

Thank you for teaching me. I don't think it's right to change the binary right away. I will continue to consider.

noborus commented 10 months ago

I also changed the build environment to put binaries compatible with older libcs built with zig. https://github.com/noborus/trdsql/releases/download/v0.13.0-rc11/trdsql_v0.13.0-rc11_linux_old_amd64.zip A static link version can also be built, but it has not been fully confirmed yet.

noborus commented 9 months ago

I'll close it because it's resolved. If there are any problems, please reopen.