choosenim icon indicating copy to clipboard operation
choosenim copied to clipboard

Using choosenim to install nim on alpine installs binaries dynamically linked to libc.

Open albinvass opened this issue 3 years ago • 1 comments

Instead of building binaries to use with musl choosenim installs the pre-built libc binaries as usual, which does not normally work on alpine.

Installed used the curl>sh command: curl https://nim-lang.org/choosenim/init.sh -sSf | sh

Output from ldd:

~ $ ldd .nimble/bin/nim
        /lib64/ld-linux-x86-64.so.2 (0x7f4afc6da000)
        librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f4afc6da000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f4afc6da000)
Error relocating .nimble/bin/nim: __memcpy_chk: symbol not found
Error relocating .nimble/bin/nim: __longjmp_chk: symbol not found
~ $ ldd .nimble/bin/nimble 
        /lib64/ld-linux-x86-64.so.2 (0x7ff692e6c000)
        librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7ff692e6c000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7ff692e6c000)
Error relocating .nimble/bin/nimble: __memcpy_chk: symbol not found
Error relocating .nimble/bin/nimble: __longjmp_chk: symbol not found

Current workaround is to force choosenim to build from source with: choosenim \#v1.4.0

Edit: However building from source seem to also build binaries linked to libc.

Extracting the tarball and building with the makefile seem to give better results:

~/tar/csources-64e34778fa7e114b4afc753c7845dee250584167 $ ldd bin/nim 
        /lib/ld-musl-x86_64.so.1 (0x7f48d3fd3000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f48d3fd3000)

albinvass avatar Nov 28 '20 11:11 albinvass

choosenim uses a simple method to check whether a binary nim distribution for the chosen version and current system is available. It just builds a filename using the template http://nim-lang.org/download/nim-$1$2_x$3 and fills in $1-3 with the nim version, the OS name and the architecture. It doesn't take things like the libc version into account.

https://github.com/dom96/choosenim/blob/d929b737ef6b042a946c88a5fd2cdee64af6c292/src/choosenimpkg/download.nim#L295

This method fails on Linux systems where libc.so is not glibc or an incompatible glibc version (e.g. this may happen with very old CentOS version).

SpotlightKid avatar Jul 16 '23 07:07 SpotlightKid