glibc.mk 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ################################################################################
  2. #
  3. # glibc
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_arc),y)
  7. GLIBC_VERSION = arc-2020.03-release
  8. GLIBC_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,glibc,$(GLIBC_VERSION))
  9. else ifeq ($(BR2_RISCV_32),y)
  10. GLIBC_VERSION = 06983fe52cfe8e4779035c27e8cc5d2caab31531
  11. GLIBC_SITE = $(call github,riscv,riscv-glibc,$(GLIBC_VERSION))
  12. else ifeq ($(BR2_csky),y)
  13. GLIBC_VERSION = 7630ed2fa60caea98f500e4a7a51b88f9bf1e176
  14. GLIBC_SITE = $(call github,c-sky,glibc,$(GLIBC_VERSION))
  15. else
  16. # Generate version string using:
  17. # git describe --match 'glibc-*' --abbrev=40 origin/release/MAJOR.MINOR/master | cut -d '-' -f 2-
  18. # When updating the version, please also update localedef
  19. GLIBC_VERSION = 2.30-67-g4748829f86a458b76642f3e98b1d80f7b868e427
  20. # Upstream doesn't officially provide an https download link.
  21. # There is one (https://sourceware.org/git/glibc.git) but it's not reliable,
  22. # sometimes the connection times out. So use an unofficial github mirror.
  23. # When updating the version, check it on the official repository;
  24. # *NEVER* decide on a version string by looking at the mirror.
  25. # Then check that the mirror has been synced already (happens once a day.)
  26. GLIBC_SITE = $(call github,bminor,glibc,$(GLIBC_VERSION))
  27. endif
  28. GLIBC_LICENSE = GPL-2.0+ (programs), LGPL-2.1+, BSD-3-Clause, MIT (library)
  29. GLIBC_LICENSE_FILES = COPYING COPYING.LIB LICENSES
  30. # glibc is part of the toolchain so disable the toolchain dependency
  31. GLIBC_ADD_TOOLCHAIN_DEPENDENCY = NO
  32. # Before glibc is configured, we must have the first stage
  33. # cross-compiler and the kernel headers
  34. GLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-bison host-gawk \
  35. $(BR2_MAKE_HOST_DEPENDENCY) $(BR2_PYTHON3_HOST_DEPENDENCY)
  36. GLIBC_SUBDIR = build
  37. GLIBC_INSTALL_STAGING = YES
  38. GLIBC_INSTALL_STAGING_OPTS = install_root=$(STAGING_DIR) install
  39. # Thumb build is broken, build in ARM mode
  40. ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
  41. GLIBC_EXTRA_CFLAGS += -marm
  42. endif
  43. # MIPS64 defaults to n32 so pass the correct -mabi if
  44. # we are using a different ABI. OABI32 is also used
  45. # in MIPS so we pass -mabi=32 in this case as well
  46. # even though it's not strictly necessary.
  47. ifeq ($(BR2_MIPS_NABI64),y)
  48. GLIBC_EXTRA_CFLAGS += -mabi=64
  49. else ifeq ($(BR2_MIPS_OABI32),y)
  50. GLIBC_EXTRA_CFLAGS += -mabi=32
  51. endif
  52. ifeq ($(BR2_ENABLE_DEBUG),y)
  53. GLIBC_EXTRA_CFLAGS += -g
  54. endif
  55. # The stubs.h header is not installed by install-headers, but is
  56. # needed for the gcc build. An empty stubs.h will work, as explained
  57. # in http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html. The same trick
  58. # is used by Crosstool-NG.
  59. ifeq ($(BR2_TOOLCHAIN_BUILDROOT_GLIBC),y)
  60. define GLIBC_ADD_MISSING_STUB_H
  61. mkdir -p $(STAGING_DIR)/usr/include/gnu
  62. touch $(STAGING_DIR)/usr/include/gnu/stubs.h
  63. endef
  64. endif
  65. GLIBC_CONF_ENV = \
  66. ac_cv_path_BASH_SHELL=/bin/$(if $(BR2_PACKAGE_BASH),bash,sh) \
  67. libc_cv_forced_unwind=yes \
  68. libc_cv_ssp=no
  69. # POSIX shell does not support localization, so remove the corresponding
  70. # syntax from ldd if bash is not selected.
  71. ifeq ($(BR2_PACKAGE_BASH),)
  72. define GLIBC_LDD_NO_BASH
  73. $(SED) 's/$$"/"/g' $(@D)/elf/ldd.bash.in
  74. endef
  75. GLIBC_POST_PATCH_HOOKS += GLIBC_LDD_NO_BASH
  76. endif
  77. # Override the default library locations of /lib64/<abi> and
  78. # /usr/lib64/<abi>/ for RISC-V.
  79. ifeq ($(BR2_riscv),y)
  80. ifeq ($(BR2_RISCV_64),y)
  81. GLIBC_CONF_ENV += libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib
  82. else
  83. GLIBC_CONF_ENV += libc_cv_slibdir=/lib32 libc_cv_rtlddir=/lib
  84. endif
  85. endif
  86. # glibc requires make >= 4.0 since 2.28 release.
  87. # https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html
  88. GLIBC_MAKE = $(BR2_MAKE)
  89. GLIBC_CONF_ENV += ac_cv_prog_MAKE="$(BR2_MAKE)"
  90. # Even though we use the autotools-package infrastructure, we have to
  91. # override the default configure commands for several reasons:
  92. #
  93. # 1. We have to build out-of-tree, but we can't use the same
  94. # 'symbolic link to configure' used with the gcc packages.
  95. #
  96. # 2. We have to execute the configure script with bash and not sh.
  97. #
  98. # Note that as mentionned in
  99. # http://patches.openembedded.org/patch/38849/, glibc must be
  100. # built with -O2, so we pass our own CFLAGS and CXXFLAGS below.
  101. define GLIBC_CONFIGURE_CMDS
  102. mkdir -p $(@D)/build
  103. # Do the configuration
  104. (cd $(@D)/build; \
  105. $(TARGET_CONFIGURE_OPTS) \
  106. CFLAGS="-O2 $(GLIBC_EXTRA_CFLAGS)" CPPFLAGS="" \
  107. CXXFLAGS="-O2 $(GLIBC_EXTRA_CFLAGS)" \
  108. $(GLIBC_CONF_ENV) \
  109. $(SHELL) $(@D)/configure \
  110. --target=$(GNU_TARGET_NAME) \
  111. --host=$(GNU_TARGET_NAME) \
  112. --build=$(GNU_HOST_NAME) \
  113. --prefix=/usr \
  114. --enable-shared \
  115. $(if $(BR2_x86_64),--enable-lock-elision) \
  116. --with-pkgversion="Buildroot" \
  117. --without-cvs \
  118. --disable-profile \
  119. --without-gd \
  120. --enable-obsolete-rpc \
  121. --enable-kernel=$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)) \
  122. --with-headers=$(STAGING_DIR)/usr/include)
  123. $(GLIBC_ADD_MISSING_STUB_H)
  124. endef
  125. #
  126. # We also override the install to target commands since we only want
  127. # to install the libraries, and nothing more.
  128. #
  129. GLIBC_LIBS_LIB = \
  130. ld*.so.* libanl.so.* libc.so.* libcrypt.so.* libdl.so.* libgcc_s.so.* \
  131. libm.so.* libpthread.so.* libresolv.so.* librt.so.* \
  132. libutil.so.* libnss_files.so.* libnss_dns.so.* libmvec.so.*
  133. ifeq ($(BR2_PACKAGE_GDB),y)
  134. GLIBC_LIBS_LIB += libthread_db.so.*
  135. endif
  136. ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y)
  137. GLIBC_TARGET_UTILS_USR_BIN = posix/getconf elf/ldd
  138. GLIBC_TARGET_UTILS_SBIN = elf/ldconfig
  139. ifeq ($(BR2_SYSTEM_ENABLE_NLS),y)
  140. GLIBC_TARGET_UTILS_USR_BIN += locale/locale
  141. endif
  142. endif
  143. define GLIBC_INSTALL_TARGET_CMDS
  144. for libpattern in $(GLIBC_LIBS_LIB); do \
  145. $(call copy_toolchain_lib_root,$$libpattern) ; \
  146. done
  147. $(foreach util,$(GLIBC_TARGET_UTILS_USR_BIN), \
  148. $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/usr/bin/$(notdir $(util))
  149. )
  150. $(foreach util,$(GLIBC_TARGET_UTILS_SBIN), \
  151. $(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/sbin/$(notdir $(util))
  152. )
  153. endef
  154. $(eval $(autotools-package))