glibc.mk 4.8 KB

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