glibc.mk 5.0 KB

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