525ffc2bb1
Currently, we configure glibc to not add compatibility support for kernels older than the one used for the headers. This is on the expectation that the system will never run on a kernel that is older than the one used for the headers or, when Buildroot builds the kernel, on another, older kernel. However, in some situations, it is possible to build for a generic system, where the kernel may be a different version. This can be the case, for example, when Building an image that is to be used in a container that can run on a range of machines each with different kernel versions. In such a case, it is interesting to build glibc in a way as to take better advantage of the newer kernels, and thus using newer kernel headers, while still allowing running on older kernels, and thus carrying more compatibility code. We add an option to glibc to allow the user to enable compatibility shims. To simplify the case, when that option is enabled, we just let glibc enable as old compatibility shims as supported by the current architecture. The code size increase is very small. For an ARM Cortex-A7, with gcc-10.3.0, the delta is as follows (other files installed by glibc had no size delta; sizes in bytes): file | no compat | compat | delta ----------------------+-----------+-----------+------- ld-linux-armhf.so.3 | 200216 | 200284 | + 68 libc.so.6 | 1814496 | 1823120 | +8624 ------+------- Total | +8692 No runtime overhead has been measured; the overhead is most probably in the measurement noise. Indeed, the compatibility shims are very lightweight. For example, there are 9 arch-generic shims: renameat2(), execveat(), mlock2(), statx(), faccessat2(), close_range(), time64-related syscall shenanigans, a waitid() feature, and a futex operation (LOCK_PI2) and then each arch may define a few others. i386 has less than 20 (mostly related to socket options, and one for the ordering of the clone() arguments), while ARM seems to have only two (mlock2() and a configurable futex feature). Note: however, as Arnout pointed out, some programs may still actually fail to run even with such compatibility shim, if they really expect the shimed syscalls to really exist and have no fallback (and/or no proper error-handling). Still, in the vast majority of cases, those compatibility shims are enough to have a system running. Signed-off-by: Yann E. MORIN <yann.morin@orange.com> Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com> Cc: Arnout Vandecappelle <arnout@mind.be> Tested-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
32 lines
888 B
Plaintext
32 lines
888 B
Plaintext
if BR2_TOOLCHAIN_BUILDROOT_GLIBC
|
|
|
|
comment "Glibc Options"
|
|
|
|
config BR2_PACKAGE_GLIBC
|
|
bool
|
|
default y
|
|
select BR2_PACKAGE_LINUX_HEADERS
|
|
select BR2_TOOLCHAIN_HAS_SSP if BR2_PACKAGE_HOST_BINUTILS_SUPPORTS_CFI
|
|
help
|
|
https://www.gnu.org/software/libc/
|
|
|
|
config BR2_PACKAGE_GLIBC_KERNEL_COMPAT
|
|
bool "Enable compatibiltiy shims to run on older kernels"
|
|
help
|
|
Say 'y' here if you plan on running your system on a kernel
|
|
older than the version used for the toolchain headers.
|
|
|
|
Enabling those compatibility shims may generate a slightly
|
|
bigger and slightly slower glibc library.
|
|
|
|
The oldest supported kernel version depends on the
|
|
architecture.
|
|
|
|
config BR2_PACKAGE_GLIBC_UTILS
|
|
bool "Install glibc utilities"
|
|
help
|
|
Enabling this option will compile and install the getconf,
|
|
ldconfig, ldd and locale glibc utilities for the target.
|
|
|
|
endif # BR2_TOOLCHAIN_BUILDROOT_GLIBC
|