trdsql icon indicating copy to clipboard operation
trdsql copied to clipboard

binary is not completely statically compiled

Open akkuman opened this issue 2 years ago • 3 comments

$ 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.

akkuman avatar Mar 01 '22 08:03 akkuman

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.

noborus avatar Mar 01 '22 10:03 noborus

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

akkuman avatar Mar 01 '22 15:03 akkuman

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

noborus avatar Mar 02 '22 00:03 noborus

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 avatar Nov 10 '23 00:11 noborus

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

noborus avatar Dec 15 '23 00:12 noborus