godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.13k stars 19.94k forks source link

Make Linux binaries load all their dependencies via libdl #64550

Closed sylware closed 2 years ago

sylware commented 2 years ago

Godot version

master/main

System information

elf/linux distro

Issue description

The following is to avoid GNU symbol/module version issues on the medium/long run (it is probably OS agnostic).

Expected: distributed binaries should be pure and simple elf64, namely fetch everything they need from the system with libdl (dlopen/dlsym/dlclose). It means that for all distributed binaries, system dependencies should be limited to libdl, that in their elf static loading module list, and no other undefined symbols other than the ones from the distributed binaries should be in the elf dynamic symbol section.

problem: the static libstdc++ and static libgcc do not support libdl and seems to pull glibc internal symbols into the dynamic symbol section.

Steps to reproduce

get some godot game binaries compiled and link with a recent glibc, and try to run it on an old glibc (~2years should be enough) (or with another c/elf runtime which has a libdl)

Minimal reproduction project

No response

Calinou commented 2 years ago

problem: the static libstdc++ and static libgcc do not support libdl and seems to pull glibc internal symbols into the dynamic symbol section.

How can this be resolved?

This would be interesting to do, as it'd allow you to use a recent Linux distribution to build binaries that could run on old Linux distributions (without having to use a container running an old Linux distribution to build binaries).

However, is this a viable approach for graphical applications that need to use OpenGL/Vulkan? In particular, won't this cause issues with the proprietary NVIDIA driver?

sylware commented 2 years ago

In this current state, c++ is not meant for binary-only distribution.

The userland container trick is shaby at best, since some games rely on direct /dev /sysfs interface (for instance feral interactive game loader), which is linux version specific in spite of "ABI stability", namely those containers would have to package the right linux version too. In other words, a really-working/fully tested full vm plus 3D driver "pass-thru", that for each game...

2 major ways:

1 - eat the bullet and get in control: move godot towards conservative C (not gcc/clang only) and assembly.

2 - fix libgcc/libstdc++: either outmatch microsoft money (irony) to make gcc devs fix them, or fork them and fix them yourself (at the part required). Namely adding a libdl mode and removing any dependency on glibc internal symbols.

Calinou commented 2 years ago

Closing, as this is not a problem we can address in any way. Neither 1. nor 2. are viable approaches for us, and any efforts of this kind should be tackled upstream.