Unresolved symbols using "nim"

I’m trying to get setup to use the “nim” compiler (https://nim-lang.org/).
I’ve got a nix-shell setup with niv to use nixpkgs-unstable get the latest nim compiler (1.4.2).

I’ve got a test nim script from their site that I’m trying to compile.
When I run nim compile test.nim, I get unresolved errors:

$ nim compile test.nim 
Hint: used config file '/nix/store/92r6yp0i2n3wb5mv1fr6wfpv57dm5h8q-x86_64-unknown-linux-gnu-nim-wrapper-1.4.2/etc/nim/nim.cfg' [Conf]
....CC: stdlib_io.nim
CC: stdlib_system.nim
/bin/sh: symbol lookup error: /nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libc.so.6: undefined symbol: _dl_fatal_printf, version GLIBC_PRIVATE
CC: test.nim
/bin/sh: symbol lookup error: /nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libc.so.6: undefined symbol: _dl_fatal_printf, version GLIBC_PRIVATE

Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3   -I/nix/store/impyg4875ygammahsaa73s7w6h91wpmz-nim-unwrapped-1.4.2/nim/lib -I/home/adam/Workspace/nim-test -o /home/adam/.cache/nim/test_d/stdlib_io.nim.c.o /home/adam/.cache/nim/test_d/stdlib_io.nim.c' failed with exit code: 127

/bin/sh: symbol lookup error: /nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libc.so.6: undefined symbol: _dl_fatal_printf, version GLIBC_PRIVATE

If I run the GCC command manually, it appears to succeed.

$ gcc -c  -w -fmax-errors=3   -I/nix/store/impyg4875ygammahsaa73s7w6h91wpmz-nim-unwrapped-1.4.2/nim/lib -I/home/adam/Workspace/nim-test -o /home/adam/.cache/nim/test_d/stdlib_io.nim.c.o /home/adam/.cache/nim/test_d/stdlib_io.nim.c

$ ls ~/.cache/nim/test_d/stdlib_io.nim.c

This makes me suspect that nim isn’t running an environment aware gcc.
I’ve tried adding gcc and glibc to the buildInputs.
I’ve also tried exporting the NIX_* compiler variables that I’m aware of.


# shell.nix
    sources = import ./nix/sources.nix;
    pkgs = import sources.nixpkgs {};
pkgs.mkShell {
    nativeBuildInputs = [
    buildInputs = [

    NIMBLE_DIR = toString ./.nimble;

    shellHooks = ''
        export LDFLAGS=$NIX_LDFLAGS


$ cat test.nim 
echo "What's your name? "
var name: string = readLine(stdin)
echo "Hi, ", name, "!"

If I revert shell.nix back to using the system nixpkgs, I can compile packages using nim.
However I need the nim version from unstable and wasn’t wanting to jump through the hoops to figure out how to do an overlay.

It seems the issue is a glibc mismatch between stable/unstable?
Any ideas?

It sounds to me like Nim is compiling using glibc headers that define and use the procedure _dl_fatal_printf, but the linker is using a glibc binary from a version where _dl_fatal_printf was removed or something.

In other words, shitty interface from forty years ago is shitty.

I ended up finding a work-around. If I install “nim-unwrapped” I get a working nim, and then I use the “nim” package to get nimble

It’s still a work around though and indicates that something is still NQR.

I was able to reproduce this error by running nix run nimble#about on a NixOS host built from release-20.09, whereas the same builds correctly on a NixOS host built from master.

Glad you could reproduce.
I just noticed that you’re the nim maintainer, thanks for looking into this!
I’ve created an issue on GH: nim: unresolved symbols with host 20.09 and nim from unstable · Issue #116368 · NixOS/nixpkgs · GitHub