Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statically link to libstdc++ helps many users on various linux distributions. #5596

Closed
ruffianeo opened this issue Sep 14, 2024 · 8 comments
Closed
Labels

Comments

@ruffianeo
Copy link

Describe the issue

After downloading stockfish 17 avx2 on my debian bullseye system, it won't run, because:

./stockfish-17-ubuntu-x86-64-avx2: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./stockfish-17-ubuntu-x86-64-avx2)
./stockfish-17-ubuntu-x86-64-avx2: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by ./stockfish-17-ubuntu-x86-64-avx2)

Expected behavior

If you opt for statically linked standard libraries (on linux), this would not happen and the program would be usable out of the box on many more systems.

Steps to reproduce

./stockfish-17-ubuntu-x86-64-avx2: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./stockfish-17-ubuntu-x86-64-avx2)
./stockfish-17-ubuntu-x86-64-avx2: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by ./stockfish-17-ubuntu-x86-64-avx2)

Anything else?

The compiler option you might want to use to fix this is: -static-libstdc++.

Operating system

All

Stockfish version

Stockfish 17 as of the time of this issue post.

@Disservin
Copy link
Member

see #4026 for some previous talk about this, there are also some other aspects of why static linking on linux is not recommended.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
Apparently gcc 10 is the default for debian 11.. quite old tbh given that it just became LTS.
GCC 11.1.0: GLIBCXX_3.4.29, CXXABI_1.3.13 are you able to easily install gcc 11.1?

@R-Goc
Copy link
Contributor

R-Goc commented Sep 15, 2024

Out of curiosity what is stockfish currently linking to on linux? On windows ldd output is:

        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffcf4510000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffcf3180000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffcf1890000)

@Disservin
Copy link
Member

linux-vdso.so.1 (0x00007fff4af3d000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f033e704000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f033e61d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f033e5fd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f033e3d4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f03435b0000

windows has static linking, due to the nature of libraries generally missing there

@vondele
Copy link
Member

vondele commented Sep 16, 2024

On linux package maintainers do a fairly good job at tracking the most recent releases.

https://packages.debian.org/search?keywords=stockfish
https://packages.fedoraproject.org/pkgs/stockfish/stockfish/ (already at 17)
https://launchpad.net/ubuntu/+source/stockfish
...

@quanvm0501ghcodespacehdfoipgcoi
Copy link

quanvm0501ghcodespacehdfoipgcoi commented Dec 31, 2024

(Just FOUND) How to solve: https://askubuntu.com/questions/1393285/how-to-install-glibcxx-3-4-29-on-ubuntu-20-04
Please add this to the Stockfish manual.
From the best solution:
Translated into practical steps:

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt install -y g++-11

Then check if the version appears in the list:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
Resource: https://lindevs.com/install-g-on-ubuntu
Video (on github codespace): (music link)
https://drive.google.com/file/d/18FChsM9JO_0uZ3MMAnBHNuNy4qIIJNBQ/view?usp=sharing

@Disservin
Copy link
Member

This is basic knowledge, also credit you because you took someone elses answer lol?
We currently have the gcc version fixed at gcc-11 for our release builds.
Debia Bullseye is went EOL 4 months ago and Bookworm comes with gcc-12, Ubuntu 20 goes EOL Apr 2025, and Ubuntu 22 will have gcc-11 by default, so not much of an issue soon anymore.
Installing a new GCC version is usually also relatively easy and I don't think we'll statically link for linux in the foreseeable future.

@Disservin Disservin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2024
@R-Goc
Copy link
Contributor

R-Goc commented Dec 31, 2024

Annoying part about these old libc versions is they keep the compiler version old. And that potentially makes the final binary slower, and on clang makes the build slower. GCC didn't have big build speed improvements if I remember correctly.

@Disservin
Copy link
Member

iirc from testing different compilers older versions were actually better at optimizations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants