glibc.mk 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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.38-81-gc8cb4d2b86ece572793e31a3422ea29e88d77df5
  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 b25508dd774b617f99419bdc3cf2ace4560cd2d6, which is between
  24. # 2.38 and the version we're really using
  25. GLIBC_IGNORE_CVES += CVE-2023-4527
  26. # Fixed by 5ee59ca371b99984232d7584fe2b1a758b4421d3, which is between
  27. # 2.38 and the version we're really using
  28. GLIBC_IGNORE_CVES += CVE-2023-4806
  29. # Fixed by 750a45a783906a19591fb8ff6b7841470f1f5710, which is between
  30. # 2.38 and the version we're really using.
  31. GLIBC_IGNORE_CVES += CVE-2023-4911
  32. # Fixed by 5ee59ca371b99984232d7584fe2b1a758b4421d3, which is between
  33. # 2.38 and the version we're really using.
  34. GLIBC_IGNORE_CVES += CVE-2023-5156
  35. # Fixed by 23514c72b780f3da097ecf33a793b7ba9c2070d2, which is between
  36. # 2.38 and the version we're really using.
  37. GLIBC_IGNORE_CVES += CVE-2023-6246
  38. # Fixed by d0338312aace5bbfef85e03055e1212dd0e49578, which is between
  39. # 2.38 and the version we're really using.
  40. GLIBC_IGNORE_CVES += CVE-2023-6779
  41. # Fixed by d37c2b20a4787463d192b32041c3406c2bd91de0, which is between
  42. # 2.38 and the version we're really using.
  43. GLIBC_IGNORE_CVES += CVE-2023-6780
  44. # Fixed by glibc-2.38-66-ge1135387deded5d73924f6ca20c72a35dc8e1bda
  45. GLIBC_IGNORE_CVES += CVE-2024-2961
  46. # Fixed by glibc-2.38-72-g5968aebb86164034b8f8421b4abab2f837a5bdaf
  47. GLIBC_IGNORE_CVES += CVE-2024-33599
  48. # Fixed by glibc-2.38-73-g541ea5172aa658c4bd5c6c6d6fd13903c3d5bb0a +
  49. # glibc-2.38-74-g2ae9446c1b7a3064743b4a51c0bbae668ee43e4c
  50. GLIBC_IGNORE_CVES += CVE-2024-33600
  51. # Fixed by glibc-2.38-75-g71af8ca864345d39b746d5cee84b94b430fad5db
  52. GLIBC_IGNORE_CVES += CVE-2024-33601 CVE-2024-33602
  53. # All these CVEs are considered as not being security issues by
  54. # upstream glibc:
  55. # https://security-tracker.debian.org/tracker/CVE-2010-4756
  56. # https://security-tracker.debian.org/tracker/CVE-2019-1010022
  57. # https://security-tracker.debian.org/tracker/CVE-2019-1010023
  58. # https://security-tracker.debian.org/tracker/CVE-2019-1010024
  59. # https://security-tracker.debian.org/tracker/CVE-2019-1010025
  60. GLIBC_IGNORE_CVES += \
  61. CVE-2010-4756 \
  62. CVE-2019-1010022 \
  63. CVE-2019-1010023 \
  64. CVE-2019-1010024 \
  65. CVE-2019-1010025
  66. # glibc is part of the toolchain so disable the toolchain dependency
  67. GLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO
  68. # Before glibc is configured, we must have the first stage
  69. # cross-compiler and the kernel headers
  70. GLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-bison host-gawk \
  71. $(BR2_MAKE_HOST_DEPENDENCY) $(BR2_PYTHON3_HOST_DEPENDENCY)
  72. GLIBC_SUBDIR = build
  73. GLIBC_INSTALL_STAGING = YES
  74. GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
  75. # Thumb build is broken, build in ARM mode
  76. ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
  77. GLIBC_EXTRA_CFLAGS += -marm
  78. endif
  79. # MIPS64 defaults to n32 so pass the correct -mabi if
  80. # we are using a different ABI. OABI32 is also used
  81. # in MIPS so we pass -mabi=32 in this case as well
  82. # even though it's not strictly necessary.
  83. ifeq ($(BR2_MIPS_NABI64),y)
  84. GLIBC_EXTRA_CFLAGS += -mabi=64
  85. else ifeq ($(BR2_MIPS_OABI32),y)
  86. GLIBC_EXTRA_CFLAGS += -mabi=32
  87. endif
  88. ifeq ($(BR2_ENABLE_DEBUG),y)
  89. GLIBC_EXTRA_CFLAGS += -g
  90. endif
  91. # glibc explicitly requires compile barriers between files
  92. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
  93. GLIBC_EXTRA_CFLAGS += -fno-lto
  94. endif
  95. # The stubs.h header is not installed by install-headers, but is
  96. # needed for the gcc build. An empty stubs.h will work, as explained
  97. # in http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html. The same trick
  98. # is used by Crosstool-NG.
  99. ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GLIBC),y)
  100. define GLIBC_ADD_MISSING_STUB_H
  101. mkdir -p $(STAGING_DIR)/usr/include/gnu
  102. touch $(STAGING_DIR)/usr/include/gnu/stubs.h
  103. endef
  104. endif
  105. GLIBC_CONF_ENV = \
  106. ac_cv_path_BASH_SHELL=/bin/$(if $(BR2_PACKAGE_BASH),bash,sh) \
  107. libc_cv_forced_unwind=yes \
  108. libc_cv_ssp=no
  109. # POSIX shell does not support localization, so remove the corresponding
  110. # syntax from ldd if bash is not selected.
  111. ifeq ($(BR2_PACKAGE_BASH),)
  112. define GLIBC_LDD_NO_BASH
  113. $(SED) 's/$$"/"/g' $(@D)/elf/ldd.bash.in
  114. endef
  115. GLIBC_POST_PATCH_HOOKS += GLIBC_LDD_NO_BASH
  116. endif
  117. # Override the default library locations of /lib64/<abi> and
  118. # /usr/lib64/<abi>/ for RISC-V.
  119. ifeq ($(BR2_riscv),y)
  120. ifeq ($(BR2_RISCV_64),y)
  121. GLIBC_CONF_ENV += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib
  122. else
  123. GLIBC_CONF_ENV += libc_cv_slibdir=/lib32 libc_cv_rtlddir=/lib
  124. endif
  125. endif
  126. # glibc requires make >= 4.0 since 2.28 release.
  127. # https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html
  128. GLIBC_MAKE = $(BR2_MAKE)
  129. GLIBC_CONF_ENV += ac_cv_prog_MAKE="$(BR2_MAKE)"
  130. ifeq ($(BR2_PACKAGE_GLIBC_KERNEL_COMPAT),)
  131. GLIBC_CONF_OPTS += --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))
  132. endif
  133. # Even though we use the autotools-package infrastructure, we have to
  134. # override the default configure commands for several reasons:
  135. #
  136. # 1. We have to build out-of-tree, but we can't use the same
  137. # 'symbolic link to configure' used with the gcc packages.
  138. #
  139. # 2. We have to execute the configure script with bash and not sh.
  140. #
  141. # Glibc nowadays can be build with optimization flags f.e. -Os
  142. GLIBC_CFLAGS = $(TARGET_OPTIMIZATION)
  143. # crash in qemu-system-nios2 with -Os
  144. ifeq ($(BR2_nios2),y)
  145. GLIBC_CFLAGS += -O2
  146. endif
  147. # glibc can't be built without optimization
  148. ifeq ($(BR2_OPTIMIZE_0),y)
  149. GLIBC_CFLAGS += -O1
  150. endif
  151. # glibc can't be built with Optimize for fast
  152. ifeq ($(BR2_OPTIMIZE_FAST),y)
  153. GLIBC_CFLAGS += -O2
  154. endif
  155. define GLIBC_CONFIGURE_CMDS
  156. mkdir -p $(@D)/build
  157. # Do the configuration
  158. (cd $(@D)/build; \
  159. $(TARGET_CONFIGURE_OPTS) \
  160. CFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" CPPFLAGS="" \
  161. CXXFLAGS="$(GLIBC_CFLAGS) $(GLIBC_EXTRA_CFLAGS)" \
  162. $(GLIBC_CONF_ENV) \
  163. $(SHELL) $(@D)/configure \
  164. --target=$(GNU_TARGET_NAME) \
  165. --host=$(GNU_TARGET_NAME) \
  166. --build=$(GNU_HOST_NAME) \
  167. --prefix=/usr \
  168. --enable-shared \
  169. $(if $(BR2_x86_64),--enable-lock-elision) \
  170. --with-pkgversion="Buildroot" \
  171. --disable-profile \
  172. --disable-werror \
  173. --without-gd \
  174. --with-headers=$(STAGING_DIR)/usr/include \
  175. $(if $(BR2_aarch64)$(BR2_aarch64_be),--enable-mathvec) \
  176. --enable-crypt \
  177. $(GLIBC_CONF_OPTS))
  178. $(GLIBC_ADD_MISSING_STUB_H)
  179. endef
  180. #
  181. # We also override the install to target commands since we only want
  182. # to install the libraries, and nothing more.
  183. #
  184. GLIBC_LIBS_LIB = \
  185. ld*.so.* libanl.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* \
  186. libm.so.* libpthread.so.* libresolv.so.* librt.so.* \
  187. libutil.so.* libnss_files.so.* libnss_dns.so.* libmvec.so.*
  188. ifeq ($(BR2_PACKAGE_GDB),y)
  189. GLIBC_LIBS_LIB += libthread_db.so.*
  190. endif
  191. ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y)
  192. GLIBC_TARGET_UTILS_USR_BIN = posix/getconf elf/ldd
  193. GLIBC_TARGET_UTILS_SBIN = elf/ldconfig
  194. ifeq ($(BR2_SYSTEM_ENABLE_NLS),y)
  195. GLIBC_TARGET_UTILS_USR_BIN += locale/locale
  196. endif
  197. endif
  198. define GLIBC_INSTALL_TARGET_CMDS
  199. for libpattern in $(GLIBC_LIBS_LIB); do \
  200. $(call copy_toolchain_lib_root,$$libpattern) ; \
  201. done
  202. $(foreach util,$(GLIBC_TARGET_UTILS_USR_BIN), \
  203. $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/usr/bin/$(notdir $(util))
  204. )
  205. $(foreach util,$(GLIBC_TARGET_UTILS_SBIN), \
  206. $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/sbin/$(notdir $(util))
  207. )
  208. endef
  209. $(eval $(autotools-package))