1################################################################################ 2# 3# glibc 4# 5################################################################################ 6 7# Generate version string using: 8# git describe --match 'glibc-*' --abbrev=40 origin/release/MAJOR.MINOR/master | cut -d '-' -f 2- 9# When updating the version, please also update localedef 10ifeq ($(BR2_PACKAGE_GLIBC_2_28),y) 11GLIBC_VERSION = 2.28-69-g1e5c5303a522764d7e9d2302a60e4a32cdb902f1 12else 13GLIBC_VERSION = 2.36-81-g4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c 14endif 15# Upstream doesn't officially provide an https download link. 16# There is one (https://sourceware.org/git/glibc.git) but it's not reliable, 17# sometimes the connection times out. So use an unofficial github mirror. 18# When updating the version, check it on the official repository; 19# *NEVER* decide on a version string by looking at the mirror. 20# Then check that the mirror has been synced already (happens once a day.) 21GLIBC_SITE = $(call github,bminor,glibc,$(GLIBC_VERSION)) 22 23GLIBC_LICENSE = GPL-2.0+ (programs), LGPL-2.1+, BSD-3-Clause, MIT (library) 24GLIBC_LICENSE_FILES = COPYING COPYING.LIB LICENSES 25GLIBC_CPE_ID_VENDOR = gnu 26 27# glibc is part of the toolchain so disable the toolchain dependency 28GLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO 29 30# Before glibc is configured, we must have the first stage 31# cross-compiler and the kernel headers 32GLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-bison host-gawk \ 33 $(BR2_MAKE_HOST_DEPENDENCY) $(BR2_PYTHON3_HOST_DEPENDENCY) 34 35GLIBC_SUBDIR = build 36 37GLIBC_INSTALL_STAGING = YES 38 39GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install 40 41# Thumb build is broken, build in ARM mode 42ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y) 43GLIBC_EXTRA_CFLAGS += -marm 44endif 45 46# MIPS64 defaults to n32 so pass the correct -mabi if 47# we are using a different ABI. OABI32 is also used 48# in MIPS so we pass -mabi=32 in this case as well 49# even though it's not strictly necessary. 50ifeq ($(BR2_MIPS_NABI64),y) 51GLIBC_EXTRA_CFLAGS += -mabi=64 52else ifeq ($(BR2_MIPS_OABI32),y) 53GLIBC_EXTRA_CFLAGS += -mabi=32 54endif 55 56ifeq ($(BR2_ENABLE_DEBUG),y) 57GLIBC_EXTRA_CFLAGS += -g 58endif 59 60# glibc explicitly requires compile barriers between files 61ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y) 62GLIBC_EXTRA_CFLAGS += -fno-lto 63endif 64 65# The stubs.h header is not installed by install-headers, but is 66# needed for the gcc build. An empty stubs.h will work, as explained 67# in http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html. The same trick 68# is used by Crosstool-NG. 69ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GLIBC),y) 70define GLIBC_ADD_MISSING_STUB_H 71 mkdir -p $(STAGING_DIR)/usr/include/gnu 72 touch $(STAGING_DIR)/usr/include/gnu/stubs.h 73endef 74endif 75 76GLIBC_CONF_ENV = \ 77 ac_cv_path_BASH_SHELL=/bin/$(if $(BR2_PACKAGE_BASH),bash,sh) \ 78 libc_cv_forced_unwind=yes \ 79 libc_cv_ssp=no 80 81# POSIX shell does not support localization, so remove the corresponding 82# syntax from ldd if bash is not selected. 83ifeq ($(BR2_PACKAGE_BASH),) 84define GLIBC_LDD_NO_BASH 85 $(SED) 's/$$"/"/g' $(@D)/elf/ldd.bash.in 86endef 87GLIBC_POST_PATCH_HOOKS += GLIBC_LDD_NO_BASH 88endif 89 90# Override the default library locations of /lib64/<abi> and 91# /usr/lib64/<abi>/ for RISC-V. 92ifeq ($(BR2_riscv),y) 93ifeq ($(BR2_RISCV_64),y) 94GLIBC_CONF_ENV += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib 95else 96GLIBC_CONF_ENV += libc_cv_slibdir=/lib32 libc_cv_rtlddir=/lib 97endif 98endif 99 100# glibc requires make >= 4.0 since 2.28 release. 101# https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html 102GLIBC_MAKE = $(BR2_MAKE) 103GLIBC_CONF_ENV += ac_cv_prog_MAKE="$(BR2_MAKE)" 104 105ifeq ($(BR2_PACKAGE_GLIBC_KERNEL_COMPAT),) 106ifeq ($(BR2_PACKAGE_LINUX_HEADERS_AUTO_VERSION),y) 107GLIBC_CONF_OPTS += --enable-kernel=$(LINUX_HEADERS_VERSION_REAL) 108else 109GLIBC_CONF_OPTS += --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) 110endif 111endif 112 113# Even though we use the autotools-package infrastructure, we have to 114# override the default configure commands for several reasons: 115# 116# 1. We have to build out-of-tree, but we can't use the same 117# 'symbolic link to configure' used with the gcc packages. 118# 119# 2. We have to execute the configure script with bash and not sh. 120# 121# Glibc nowadays can be build with optimization flags f.e. -Os 122 123GLIBC_CFLAGS = $(TARGET_OPTIMIZATION) 124# crash in qemu-system-nios2 with -Os 125ifeq ($(BR2_nios2),y) 126GLIBC_CFLAGS += -O2 127endif 128 129# glibc can't be built without optimization 130ifeq ($(BR2_OPTIMIZE_0),y) 131GLIBC_CFLAGS += -O1 132endif 133 134# glibc can't be built with Optimize for fast 135ifeq ($(BR2_OPTIMIZE_FAST),y) 136GLIBC_CFLAGS += -O2 137endif 138 139define GLIBC_CONFIGURE_CMDS 140 mkdir -p $(@D)/build 141 # Do the configuration 142 (cd $(@D)/build; \ 143 $(TARGET_CONFIGURE_OPTS) \ 144 CFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" CPPFLAGS="" \ 145 CXXFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" \ 146 $(GLIBC_CONF_ENV) \ 147 $(SHELL) $(@D)/configure \ 148 --target=$(GNU_TARGET_NAME) \ 149 --host=$(GNU_TARGET_NAME) \ 150 --build=$(GNU_HOST_NAME) \ 151 --prefix=/usr \ 152 --enable-shared \ 153 $(if $(BR2_x86_64),--enable-lock-elision) \ 154 --with-pkgversion="Buildroot" \ 155 --disable-profile \ 156 --disable-werror \ 157 --without-gd \ 158 --with-headers=$(STAGING_DIR)/usr/include \ 159 $(GLIBC_CONF_OPTS)) 160 $(GLIBC_ADD_MISSING_STUB_H) 161endef 162 163# 164# We also override the install to target commands since we only want 165# to install the libraries, and nothing more. 166# 167 168GLIBC_LIBS_LIB = \ 169 ld*.so.* libanl.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* \ 170 libm.so.* libpthread.so.* libresolv.so.* librt.so.* \ 171 libutil.so.* libnss_files.so.* libnss_dns.so.* libmvec.so.* 172 173ifeq ($(BR2_PACKAGE_GDB),y) 174GLIBC_LIBS_LIB += libthread_db.so.* 175endif 176 177ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y) 178GLIBC_TARGET_UTILS_USR_BIN = posix/getconf elf/ldd 179GLIBC_TARGET_UTILS_SBIN = elf/ldconfig 180ifeq ($(BR2_SYSTEM_ENABLE_NLS),y) 181GLIBC_TARGET_UTILS_USR_BIN += locale/locale 182endif 183endif 184 185define GLIBC_INSTALL_TARGET_CMDS 186 for libpattern in $(GLIBC_LIBS_LIB); do \ 187 $(call copy_toolchain_lib_root,$$libpattern) ; \ 188 done 189 $(foreach util,$(GLIBC_TARGET_UTILS_USR_BIN), \ 190 $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/usr/bin/$(notdir $(util)) 191 ) 192 $(foreach util,$(GLIBC_TARGET_UTILS_SBIN), \ 193 $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/sbin/$(notdir $(util)) 194 ) 195endef 196 197ifeq ($(BR2_PACKAGE_GLIBC_GEN_LD_CACHE),y) 198GLIBC_DEPENDENCIES += host-qemu 199 200define GLIBC_GEN_LD_CACHE 201 mkdir -p $(TARGET_DIR)/etc $(TARGET_DIR)/tmp 202 $(QEMU_USER) $(GLIBC_DIR)/build/elf/ldconfig -r $(TARGET_DIR) || true 203endef 204GLIBC_TARGET_FINALIZE_HOOKS += GLIBC_GEN_LD_CACHE 205endif 206 207$(eval $(autotools-package)) 208