S3cur3Th1sSh1t/Ruy-Lopez

Final nim stage fails on Ubuntu 23.04. "dangerous relocation: collect2"

docsewell opened this issue · 4 comments

I get an error on the last stage of the instructions when trying to build on Ubuntu 23.04.

nim c -d:release BlockDll.nim # Windows

System Information

dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ cat /etc/issue
Ubuntu 23.04 \n \l

dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ uname -a
Linux ubuntu-23.04 6.2.0-20-generic #20-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  6 07:48:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ nim -v
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2023-02-12
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release
dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.2.0-17ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-Pa930Z/gcc-12-12.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-Pa930Z/gcc-12-12.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Ubuntu 12.2.0-17ubuntu1) 

Error message:

dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ nim c -d:release BlockDll.nim # Windows
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: used config file '/etc/nim/config.nims' [Conf]
.....................................................................................................................................................
/home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(15, 9) Hint: 'lpSize' is declared but not used [XDeclaredButNotUsed]
/home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(51, 8) Hint: duplicate import of 'dynlib'; previous import here: /home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(2, 8) [DuplicateModuleImport]
Hint:  [Link]
/usr/bin/ld: warning: /home/dsewell/.nimble/pkgs/winim-3.9.0/winim/lib/winim64.res: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.40 assertion fail ../../bfd/reloc.c:8632
/home/dsewell/.nimble/pkgs/winim-3.9.0/winim/lib/winim64.res:(.rsrc+0x48): dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
Error: execution of an external program failed: 'gcc   -o /home/dsewell/GitHub/Ruy-Lopez/BlockDll  /home/dsewell/.nimble/pkgs/winim-3.9.0/winim/lib/winim64.res /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@sstd@sprivate@sdigitsutils.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@ssystem@sformatfloat.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@ssystem@sdollars.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@ssystem@swidestrs.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@ssystem@sio.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@ssystem.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s.nimble@spkgs@swinim-3.9.0@swinim@sinc@swinbase.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s.nimble@spkgs@swinim-3.9.0@swinim@sutils.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@spure@sstrutils.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s.nimble@spkgs@swinim-3.9.0@swinim@swinstr.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@m..@s..@s..@s..@susr@slib@snim@slib@spure@sdynlib.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@mHook.nim.c.o /home/dsewell/.cache/nim/BlockDll_r/@mBlockDll.nim.c.o  -lm -lm -lrt   -ldl'

Also add -d:noRes and it should work.

Thanks for the quick response. That got the build to complete. I will let you know if I have any issues running it.

dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ nim c -d:release -d:noRes BlockDll.nim 
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: used config file '/etc/nim/config.nims' [Conf]
.....................................................................................................................................................
/home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(15, 9) Hint: 'lpSize' is declared but not used [XDeclaredButNotUsed]
/home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(51, 8) Hint: duplicate import of 'dynlib'; previous import here: /home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim(2, 8) [DuplicateModuleImport]
Hint:  [Link]
Hint: gc: refc; opt: speed; options: -d:release
1246586 lines; 2.028s; 281.211MiB peakmem; proj: /home/dsewell/GitHub/Ruy-Lopez/BlockDll.nim; out: /home/dsewell/GitHub/Ruy-Lopez/BlockDll [SuccessX]
dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ ls -al *.dll
ls: cannot access '*.dll': No such file or directory
dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ ls -al BlockDll
-rwxrwxr-x 1 dsewell dsewell 126464 May 31 08:21 BlockDll
dsewell@ubuntu-23:~/GitHub/Ruy-Lopez$ file BlockDll
BlockDll: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=153b462ec27a88caa4f44ff5920727d0717128d4, for GNU/Linux 3.2.0, not stripped

From Linux you’ll also need -d=mingw as described in the readme.

Yes, I just realized that I built for Linux. Thanks, it works now.