glibc.mk 6.9 KB

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