2013-06-30 21:29:11 +02:00
|
|
|
################################################################################
|
|
|
|
#
|
2016-06-08 23:40:56 +02:00
|
|
|
# glibc
|
2013-06-30 21:29:11 +02:00
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2017-10-29 10:52:48 +01:00
|
|
|
# Generate version string using:
|
2019-03-12 23:35:25 +01:00
|
|
|
# git describe --match 'glibc-*' --abbrev=40 origin/release/MAJOR.MINOR/master | cut -d '-' -f 2-
|
2020-01-26 00:49:18 +01:00
|
|
|
# When updating the version, please also update localedef
|
2022-06-15 04:23:48 +02:00
|
|
|
GLIBC_VERSION = 2.35-134-gb6aade18a7e5719c942aa2da6cf3157aca993fa4
|
2017-10-29 10:52:48 +01:00
|
|
|
# Upstream doesn't officially provide an https download link.
|
|
|
|
# There is one (https://sourceware.org/git/glibc.git) but it's not reliable,
|
|
|
|
# sometimes the connection times out. So use an unofficial github mirror.
|
|
|
|
# When updating the version, check it on the official repository;
|
|
|
|
# *NEVER* decide on a version string by looking at the mirror.
|
|
|
|
# Then check that the mirror has been synced already (happens once a day.)
|
package/glibc: switch to downloading a tarball
Currently, we do a full git clone of the repository, which takes quite
some time, especially on slow networks.
This was done like that because the initial patch was using the official
repository as the source of the download, and that repository did not
offer remotely-generated tarballs.
But now we've switched to using a mirror on github, which does provide
such a tarball, which provides faster downloads.
Use that.
However, the tarball from github differs from the one we were generating
locally, because the paths inside are different. WE used to create a
archive with paths starting with glibc-glibc-2.26-73-g4b692dfb95[...],
while github does away with the git-describe prefix, and generates paths
that start with just glibc-4b692dffb95[...]. The content are exactly
identicall (checked with a diff), though.
Update the hash accordingly.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Waldemar Brodkorb <wbx@openadk.org>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2017-11-13 22:30:17 +01:00
|
|
|
GLIBC_SITE = $(call github,bminor,glibc,$(GLIBC_VERSION))
|
2017-10-10 15:31:50 +02:00
|
|
|
|
2017-03-30 15:43:38 +02:00
|
|
|
GLIBC_LICENSE = GPL-2.0+ (programs), LGPL-2.1+, BSD-3-Clause, MIT (library)
|
2018-02-05 21:57:15 +01:00
|
|
|
GLIBC_LICENSE_FILES = COPYING COPYING.LIB LICENSES
|
2020-12-04 16:46:01 +01:00
|
|
|
GLIBC_CPE_ID_VENDOR = gnu
|
2013-06-30 21:29:11 +02:00
|
|
|
|
2014-02-14 10:55:04 +01:00
|
|
|
# glibc is part of the toolchain so disable the toolchain dependency
|
|
|
|
GLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO
|
|
|
|
|
2016-06-08 23:40:54 +02:00
|
|
|
# Before glibc is configured, we must have the first stage
|
2013-06-30 21:29:11 +02:00
|
|
|
# cross-compiler and the kernel headers
|
2018-09-03 21:19:33 +02:00
|
|
|
GLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-bison host-gawk \
|
2019-03-12 23:35:25 +01:00
|
|
|
$(BR2_MAKE_HOST_DEPENDENCY) $(BR2_PYTHON3_HOST_DEPENDENCY)
|
2018-09-03 21:19:33 +02:00
|
|
|
|
2013-09-02 18:06:33 +02:00
|
|
|
GLIBC_SUBDIR = build
|
2013-06-30 21:29:11 +02:00
|
|
|
|
2013-09-02 18:06:33 +02:00
|
|
|
GLIBC_INSTALL_STAGING = YES
|
2013-06-30 21:29:11 +02:00
|
|
|
|
2014-09-27 21:32:41 +02:00
|
|
|
GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
|
2013-06-30 21:29:11 +02:00
|
|
|
|
2013-07-19 15:06:32 +02:00
|
|
|
# Thumb build is broken, build in ARM mode
|
|
|
|
ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
|
2013-09-02 18:06:33 +02:00
|
|
|
GLIBC_EXTRA_CFLAGS += -marm
|
2013-07-19 15:06:32 +02:00
|
|
|
endif
|
|
|
|
|
2013-09-25 17:00:57 +02:00
|
|
|
# MIPS64 defaults to n32 so pass the correct -mabi if
|
|
|
|
# we are using a different ABI. OABI32 is also used
|
|
|
|
# in MIPS so we pass -mabi=32 in this case as well
|
|
|
|
# even though it's not strictly necessary.
|
|
|
|
ifeq ($(BR2_MIPS_NABI64),y)
|
|
|
|
GLIBC_EXTRA_CFLAGS += -mabi=64
|
|
|
|
else ifeq ($(BR2_MIPS_OABI32),y)
|
|
|
|
GLIBC_EXTRA_CFLAGS += -mabi=32
|
|
|
|
endif
|
|
|
|
|
2015-01-01 11:16:43 +01:00
|
|
|
ifeq ($(BR2_ENABLE_DEBUG),y)
|
|
|
|
GLIBC_EXTRA_CFLAGS += -g
|
|
|
|
endif
|
|
|
|
|
2020-10-18 00:17:43 +02:00
|
|
|
# glibc explicitly requires compile barriers between files
|
|
|
|
ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
|
|
|
|
GLIBC_EXTRA_CFLAGS += -fno-lto
|
|
|
|
endif
|
|
|
|
|
2013-10-08 20:16:59 +02:00
|
|
|
# The stubs.h header is not installed by install-headers, but is
|
|
|
|
# needed for the gcc build. An empty stubs.h will work, as explained
|
|
|
|
# in http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html. The same trick
|
|
|
|
# is used by Crosstool-NG.
|
|
|
|
ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GLIBC),y)
|
|
|
|
define GLIBC_ADD_MISSING_STUB_H
|
|
|
|
mkdir -p $(STAGING_DIR)/usr/include/gnu
|
|
|
|
touch $(STAGING_DIR)/usr/include/gnu/stubs.h
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2018-09-23 22:54:57 +02:00
|
|
|
GLIBC_CONF_ENV = \
|
2019-12-03 01:14:05 +01:00
|
|
|
ac_cv_path_BASH_SHELL=/bin/$(if $(BR2_PACKAGE_BASH),bash,sh) \
|
2018-09-23 22:54:57 +02:00
|
|
|
libc_cv_forced_unwind=yes \
|
|
|
|
libc_cv_ssp=no
|
|
|
|
|
2019-12-03 01:14:05 +01:00
|
|
|
# POSIX shell does not support localization, so remove the corresponding
|
|
|
|
# syntax from ldd if bash is not selected.
|
|
|
|
ifeq ($(BR2_PACKAGE_BASH),)
|
|
|
|
define GLIBC_LDD_NO_BASH
|
|
|
|
$(SED) 's/$$"/"/g' $(@D)/elf/ldd.bash.in
|
|
|
|
endef
|
|
|
|
GLIBC_POST_PATCH_HOOKS += GLIBC_LDD_NO_BASH
|
|
|
|
endif
|
|
|
|
|
2018-09-12 12:22:54 +02:00
|
|
|
# Override the default library locations of /lib64/<abi> and
|
|
|
|
# /usr/lib64/<abi>/ for RISC-V.
|
|
|
|
ifeq ($(BR2_riscv),y)
|
2018-10-21 21:12:01 +02:00
|
|
|
ifeq ($(BR2_RISCV_64),y)
|
2018-09-12 12:22:54 +02:00
|
|
|
GLIBC_CONF_ENV += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib
|
2018-10-21 21:12:01 +02:00
|
|
|
else
|
|
|
|
GLIBC_CONF_ENV += libc_cv_slibdir=/lib32 libc_cv_rtlddir=/lib
|
|
|
|
endif
|
2018-09-12 12:22:54 +02:00
|
|
|
endif
|
|
|
|
|
2018-11-19 17:25:13 +01:00
|
|
|
# glibc requires make >= 4.0 since 2.28 release.
|
|
|
|
# https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html
|
|
|
|
GLIBC_MAKE = $(BR2_MAKE)
|
|
|
|
GLIBC_CONF_ENV += ac_cv_prog_MAKE="$(BR2_MAKE)"
|
|
|
|
|
package/glibc: allow runing on kernels older than used for the headers
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>
2022-02-02 14:48:38 +01:00
|
|
|
ifeq ($(BR2_PACKAGE_GLIBC_KERNEL_COMPAT),)
|
|
|
|
GLIBC_CONF_OPTS += --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))
|
|
|
|
endif
|
|
|
|
|
2013-06-30 21:29:11 +02:00
|
|
|
# Even though we use the autotools-package infrastructure, we have to
|
|
|
|
# override the default configure commands for several reasons:
|
|
|
|
#
|
|
|
|
# 1. We have to build out-of-tree, but we can't use the same
|
|
|
|
# 'symbolic link to configure' used with the gcc packages.
|
|
|
|
#
|
|
|
|
# 2. We have to execute the configure script with bash and not sh.
|
|
|
|
#
|
2022-02-15 12:18:02 +01:00
|
|
|
# Glibc nowadays can be build with optimization flags f.e. -Os
|
|
|
|
|
|
|
|
GLIBC_CFLAGS = $(TARGET_OPTIMIZATION)
|
|
|
|
# crash in qemu-system-nios2 with -Os
|
|
|
|
ifeq ($(BR2_nios2),y)
|
|
|
|
GLIBC_CFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
2022-05-15 11:02:29 +02:00
|
|
|
# glibc can't be built without optimization
|
|
|
|
ifeq ($(BR2_OPTIMIZE_0),y)
|
|
|
|
GLIBC_CFLAGS += -O1
|
|
|
|
endif
|
|
|
|
|
2022-05-15 11:02:28 +02:00
|
|
|
# glibc can't be built with Optimize for fast
|
|
|
|
ifeq ($(BR2_OPTIMIZE_FAST),y)
|
|
|
|
GLIBC_CFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
2013-09-02 18:06:33 +02:00
|
|
|
define GLIBC_CONFIGURE_CMDS
|
2013-06-30 21:29:11 +02:00
|
|
|
mkdir -p $(@D)/build
|
|
|
|
# Do the configuration
|
|
|
|
(cd $(@D)/build; \
|
|
|
|
$(TARGET_CONFIGURE_OPTS) \
|
2022-02-15 12:18:02 +01:00
|
|
|
CFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" CPPFLAGS="" \
|
|
|
|
CXXFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" \
|
2018-09-23 22:54:57 +02:00
|
|
|
$(GLIBC_CONF_ENV) \
|
2018-02-05 21:57:15 +01:00
|
|
|
$(SHELL) $(@D)/configure \
|
2013-06-30 21:29:11 +02:00
|
|
|
--target=$(GNU_TARGET_NAME) \
|
|
|
|
--host=$(GNU_TARGET_NAME) \
|
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--prefix=/usr \
|
|
|
|
--enable-shared \
|
2015-03-18 23:01:09 +01:00
|
|
|
$(if $(BR2_x86_64),--enable-lock-elision) \
|
2013-06-30 21:29:11 +02:00
|
|
|
--with-pkgversion="Buildroot" \
|
|
|
|
--disable-profile \
|
2020-06-28 22:16:12 +02:00
|
|
|
--disable-werror \
|
2013-06-30 21:29:11 +02:00
|
|
|
--without-gd \
|
package/glibc: allow runing on kernels older than used for the headers
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>
2022-02-02 14:48:38 +01:00
|
|
|
--with-headers=$(STAGING_DIR)/usr/include \
|
|
|
|
$(GLIBC_CONF_OPTS))
|
2013-10-08 20:16:59 +02:00
|
|
|
$(GLIBC_ADD_MISSING_STUB_H)
|
2013-06-30 21:29:11 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
#
|
|
|
|
# We also override the install to target commands since we only want
|
|
|
|
# to install the libraries, and nothing more.
|
|
|
|
#
|
|
|
|
|
2013-09-02 18:06:33 +02:00
|
|
|
GLIBC_LIBS_LIB = \
|
2017-02-24 10:03:07 +01:00
|
|
|
ld*.so.* libanl.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* \
|
2018-05-19 20:58:27 +02:00
|
|
|
libm.so.* libpthread.so.* libresolv.so.* librt.so.* \
|
2017-02-24 10:03:07 +01:00
|
|
|
libutil.so.* libnss_files.so.* libnss_dns.so.* libmvec.so.*
|
2013-06-30 21:29:11 +02:00
|
|
|
|
2013-10-29 21:54:02 +01:00
|
|
|
ifeq ($(BR2_PACKAGE_GDB),y)
|
2013-10-08 20:17:06 +02:00
|
|
|
GLIBC_LIBS_LIB += libthread_db.so.*
|
2013-06-30 21:29:11 +02:00
|
|
|
endif
|
|
|
|
|
2019-11-21 13:31:20 +01:00
|
|
|
ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y)
|
2019-11-23 13:40:15 +01:00
|
|
|
GLIBC_TARGET_UTILS_USR_BIN = posix/getconf elf/ldd
|
|
|
|
GLIBC_TARGET_UTILS_SBIN = elf/ldconfig
|
2019-11-26 09:55:41 +01:00
|
|
|
ifeq ($(BR2_SYSTEM_ENABLE_NLS),y)
|
|
|
|
GLIBC_TARGET_UTILS_USR_BIN += locale/locale
|
2019-11-21 13:31:20 +01:00
|
|
|
endif
|
2019-11-26 15:59:03 +01:00
|
|
|
endif
|
2019-11-21 13:31:20 +01:00
|
|
|
|
2013-09-02 18:06:33 +02:00
|
|
|
define GLIBC_INSTALL_TARGET_CMDS
|
2017-02-07 22:56:48 +01:00
|
|
|
for libpattern in $(GLIBC_LIBS_LIB); do \
|
|
|
|
$(call copy_toolchain_lib_root,$$libpattern) ; \
|
2013-06-30 21:29:11 +02:00
|
|
|
done
|
2019-11-23 13:40:15 +01:00
|
|
|
$(foreach util,$(GLIBC_TARGET_UTILS_USR_BIN), \
|
|
|
|
$(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/usr/bin/$(notdir $(util))
|
|
|
|
)
|
|
|
|
$(foreach util,$(GLIBC_TARGET_UTILS_SBIN), \
|
|
|
|
$(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/sbin/$(notdir $(util))
|
2019-11-21 13:31:20 +01:00
|
|
|
)
|
2013-06-30 21:29:11 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(autotools-package))
|