0011-buildroot-native-gcc.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. diff --git a/Makefile b/Makefile
  2. index a7b7729946..55adae35dd 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -722,13 +722,13 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
  6. @$(call MESSAGE,"Finalizing target directory")
  7. $(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR))
  8. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  9. - rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  10. + rm -rf $(TARGET_DIR)/usr/share/aclocal \
  11. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  12. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
  13. $(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc
  14. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  15. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  16. - \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
  17. + \( -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
  18. ifneq ($(BR2_PACKAGE_GDB),y)
  19. rm -rf $(TARGET_DIR)/usr/share/gdb
  20. endif
  21. diff --git a/package/Config.in b/package/Config.in
  22. index e9e8d93d6b..f971bae27b 100644
  23. --- a/package/Config.in
  24. +++ b/package/Config.in
  25. @@ -183,6 +183,7 @@ menu "Development tools"
  26. source "package/findutils/Config.in"
  27. source "package/flex/Config.in"
  28. source "package/gawk/Config.in"
  29. + source "package/gcc/Config.in"
  30. source "package/gettext/Config.in"
  31. source "package/gettext-gnu/Config.in"
  32. source "package/gettext-tiny/Config.in"
  33. diff --git a/package/gcc/Config.in b/package/gcc/Config.in
  34. new file mode 100644
  35. index 0000000000..40cd1730a1
  36. --- /dev/null
  37. +++ b/package/gcc/Config.in
  38. @@ -0,0 +1,21 @@
  39. +config BR2_PACKAGE_GCC_TARGET
  40. + bool "gcc"
  41. + depends on BR2_TOOLCHAIN_BUILDROOT
  42. + select BR2_PACKAGE_BINUTILS
  43. + select BR2_PACKAGE_BINUTILS_TARGET
  44. + select BR2_PACKAGE_GMP
  45. + select BR2_PACKAGE_MPFR
  46. + select BR2_PACKAGE_MPC
  47. + help
  48. + If you want the target system to be able to run
  49. + binutils/gcc and compile native code, say Y here.
  50. +
  51. +config BR2_EXTRA_TARGET_GCC_CONFIG_OPTIONS
  52. + string "Additional target gcc options"
  53. + default ""
  54. + depends on BR2_PACKAGE_GCC_TARGET
  55. + help
  56. + Any additional target gcc options you may want to include....
  57. + Including, but not limited to --disable-checking etc.
  58. + Refer to */configure in your gcc sources.
  59. +
  60. diff --git a/package/gcc/gcc-target/gcc-target.hash b/package/gcc/gcc-target/gcc-target.hash
  61. new file mode 120000
  62. index 0000000000..7ac9361ab2
  63. --- /dev/null
  64. +++ b/package/gcc/gcc-target/gcc-target.hash
  65. @@ -0,0 +1 @@
  66. +../gcc.hash
  67. \ No newline at end of file
  68. diff --git a/package/gcc/gcc-target/gcc-target.mk b/package/gcc/gcc-target/gcc-target.mk
  69. new file mode 100644
  70. index 0000000000..56673f390c
  71. --- /dev/null
  72. +++ b/package/gcc/gcc-target/gcc-target.mk
  73. @@ -0,0 +1,78 @@
  74. +################################################################################
  75. +#
  76. +# gcc-target
  77. +#
  78. +################################################################################
  79. +
  80. +GCC_TARGET_VERSION = $(GCC_VERSION)
  81. +GCC_TARGET_SITE = $(GCC_SITE)
  82. +GCC_TARGET_SOURCE = $(GCC_SOURCE)
  83. +
  84. +# Use the same archive as gcc-initial and gcc-final
  85. +GCC_TARGET_DL_SUBDIR = gcc
  86. +
  87. +GCC_TARGET_DEPENDENCIES = gmp mpfr mpc
  88. +
  89. +# First, we use HOST_GCC_COMMON_MAKE_OPTS to get a lot of correct flags (such as
  90. +# the arch, abi, float support, etc.) which are based on the config used to
  91. +# build the internal toolchain
  92. +GCC_TARGET_CONF_OPTS = $(HOST_GCC_COMMON_CONF_OPTS)
  93. +# Then, we modify incorrect flags from HOST_GCC_COMMON_CONF_OPTS
  94. +GCC_TARGET_CONF_OPTS += \
  95. + --with-sysroot=/ \
  96. + --with-build-sysroot=$(STAGING_DIR) \
  97. + --disable-__cxa_atexit \
  98. + --with-gmp=$(STAGING_DIR) \
  99. + --with-mpc=$(STAGING_DIR) \
  100. + --with-mpfr=$(STAGING_DIR)
  101. +# Then, we force certain flags that may appear in HOST_GCC_COMMON_CONF_OPTS
  102. +GCC_TARGET_CONF_OPTS += \
  103. + --disable-libquadmath \
  104. + --disable-libsanitizer \
  105. + --disable-plugin \
  106. + --disable-lto
  107. +# Finally, we add some of our own flags
  108. +GCC_TARGET_CONF_OPTS += \
  109. + --enable-languages=c \
  110. + --disable-boostrap \
  111. + --disable-libgomp \
  112. + --disable-nls \
  113. + --disable-libmpx \
  114. + --disable-gcov \
  115. + $(EXTRA_TARGET_GCC_CONFIG_OPTIONS)
  116. +
  117. +GCC_TARGET_CONF_ENV = $(HOST_GCC_COMMON_CONF_ENV)
  118. +
  119. +GCC_TARGET_MAKE_OPTS += $(HOST_GCC_COMMON_MAKE_OPTS)
  120. +
  121. +# Install standard C headers (from glibc)
  122. +define GCC_TARGET_INSTALL_HEADERS
  123. + find $(TARGET_DIR)/usr/include -perm 0444 -exec chmod u+w {} \;
  124. + cp -r $(STAGING_DIR)/usr/include $(TARGET_DIR)/usr
  125. +endef
  126. +GCC_TARGET_POST_INSTALL_TARGET_HOOKS += GCC_TARGET_INSTALL_HEADERS
  127. +
  128. +# Install standard C libraries (from glibc)
  129. +GCC_TARGET_GLIBC_LIBS = \
  130. + *crt*.o *_nonshared.a \
  131. + libBrokenLocale.so libanl.so libbfd.so libc.so libcrypt.so libdl.so \
  132. + libm.so libnss_compat.so libnss_db.so libnss_files.so libnss_hesiod.so \
  133. + libpthread.so libresolv.so librt.so libthread_db.so libutil.so
  134. +
  135. +define GCC_TARGET_INSTALL_LIBS
  136. + for libpattern in $(GCC_TARGET_GLIBC_LIBS); do \
  137. + $(call copy_toolchain_lib_root,$$libpattern) ; \
  138. + done
  139. +endef
  140. +GCC_TARGET_POST_INSTALL_TARGET_HOOKS += GCC_TARGET_INSTALL_LIBS
  141. +
  142. +# Remove unnecessary files (extra links to gcc binaries, and libgcc which is
  143. +# already in `/lib`)
  144. +define GCC_TARGET_RM_FILES
  145. + rm -f $(TARGET_DIR)/usr/bin/$(ARCH)-buildroot-linux-gnu-gcc*
  146. + rm -f $(TARGET_DIR)/usr/lib/libgcc_s*.so*
  147. + rm -f $(TARGET_DIR)/usr/$(ARCH)-buildroot-linux-gnu/lib/ldscripts/elf32*
  148. + rm -f $(TARGET_DIR)/usr/$(ARCH)-buildroot-linux-gnu/lib/ldscripts/elf64b*
  149. +endef
  150. +GCC_TARGET_POST_INSTALL_TARGET_HOOKS += GCC_TARGET_RM_FILES
  151. +
  152. +$(eval $(autotools-package))