Closed hippke closed 3 years ago
Some progress. I change line 320 of the makefile to:
LDFLAGS += $(EXTRALDFLAGS) -static-libstdc++
The segfault is gone. However, it does not statically link glibc
and thus complains that GLIBC_2.16
and GLIBC_2.17
are missing on the old system (Debian Squeeze). I have spent hours trying to install glibc manually, so far without success. Any ideas how to statically link glibc?
The glibc statically linking seems to be discouraged, see https://stackoverflow.com/questions/57476533/why-is-statically-linking-glibc-discouraged
We build cutechess-cli
(with static Qt5) on an old Linux distribution to raise the compatibility with different linux distributions / versions, see https://github.com/glinscott/fishtest/wiki/Build-cutechess-with-Qt5-static#linux
You can install a modern gcc on old Ubuntu versions, perhaps this works also on Debian:
# install the default building tools
sudo apt update
sudo apt install -y git build-essential software-properties-common
# add the repository "ubuntu-toolchain-r/test"
sudo apt update
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
# install other GCC versions
sudo apt install -y gcc-9 g++-9
# configure the alternatives for gcc and g++, setting a higher priority to a newer version (ymmv)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50 --slave /usr/bin/g++ g++ /usr/bin/g++-9
# check or change the alternatives configuration
update-alternatives --config gcc
Thank you for your assistance! Debian Squeeze on my architecture (i486) is too old for pre-built packages such as those from Ubuntu, which are all i686. I also tried installing glibc and gcc from source, but many problems occur, including segfaults.
I am actually trying to run SF-NNUE on a physical 486 PC from the early 1990s - a fun experiment. I like to play a match at a few kN/s on the old machine, against an old software running on a new machine (e.g. Fritz 5 which runs on my i7).
However, with standard Linux that's surprisingly difficult. I have two more ideas: Gentoo Linux which apparently still runs on 486, or moving to Windows 95 or 98. But I guess compiling to these old Windowses will be even more difficult...
Other info from your "Gento on 486" link: https://yeokhengmeng.com/2018/01/make-the-486-great-again/ https://retrocomputing.stackexchange.com/questions/1811/which-linux-or-bsd-distributions-do-still-support-i386-i486-or-i586-cpus
I'm suggesting to change the title in something like this "RetroFish: statically linking" :)
Solved using CFish. To reproduce:
sudo apt update
sudo apt install build-essentials
sudo apt install gcc-11 g++-11
numa = no
bits = 32
embed = yes
CFLAGS += -pedantic -Wextra -Wshadow -static
CFLAGS += -m$(bits) -static
LDFLAGS += -m$(bits) -static
CFLAGS += -Wno-pedantic-ms-format -static
make CXX="g++-11 -static" build ARCH=x86-32
. This creates:
cfish: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=d0de69062a5a4490e26e71dac8fe080b78918c97, with debug_info, not stripped
./cfish bench
Note:
embed=yes
is required. Otherwise, it fails by not finding the NNUE file, despite it being therestatic
flags are required. Otherwise, a segfault occurs if the C library version mismatches. Installing the right C libraries can be very difficult on old systems.
I compiled SF14 on Linux (Ubuntu 18.04) with statically linked libraries. This is because I want to run SF on PCs where the latest versions of glibc are not available, and are not easily installable. Without various glibc dependencies, SF does not run.
To achieve a static compile, I modified line 320 in the makefile:
I compile with gcc11:
The file is indeed statically linked:
However, when I run SF I get an error:
Any advice appreciated!