toolchain-wrapper.mk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ################################################################################
  2. #
  3. # definition of the toolchain wrapper build commands
  4. #
  5. ################################################################################
  6. # We use --hash-style=both to increase the compatibility of the generated
  7. # binary with older platforms, except for MIPS, where the only acceptable
  8. # hash style is 'sysv'
  9. ifeq ($(findstring mips,$(HOSTARCH)),mips)
  10. TOOLCHAIN_WRAPPER_HASH_STYLE = sysv
  11. else
  12. TOOLCHAIN_WRAPPER_HASH_STYLE = both
  13. endif
  14. TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS)
  15. TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
  16. TOOLCHAIN_WRAPPER_OPTS = \
  17. $(ARCH_TOOLCHAIN_WRAPPER_OPTS) \
  18. $(call qstrip,$(BR2_SSP_OPTION)) \
  19. $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
  20. ifeq ($(BR2_REPRODUCIBLE),y)
  21. TOOLCHAIN_WRAPPER_OPTS += -Wl,--build-id=none
  22. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
  23. TOOLCHAIN_WRAPPER_OPTS += -ffile-prefix-map=$(BASE_DIR)=buildroot
  24. else
  25. TOOLCHAIN_WRAPPER_OPTS += -D__FILE__=\"\" -D__BASE_FILE__=\"\" -Wno-builtin-macro-redefined
  26. endif
  27. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_7),)
  28. TOOLCHAIN_WRAPPER_OPTS += -DBR_NEED_SOURCE_DATE_EPOCH
  29. endif
  30. endif
  31. # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
  32. # separate argument when used in execv() by the toolchain wrapper.
  33. TOOLCHAIN_WRAPPER_ARGS += \
  34. -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))'
  35. ifeq ($(BR2_CCACHE),y)
  36. TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
  37. endif
  38. ifeq ($(BR2_x86_x1000),y)
  39. TOOLCHAIN_WRAPPER_ARGS += -DBR_OMIT_LOCK_PREFIX
  40. endif
  41. # Avoid FPU bug on XBurst CPUs
  42. ifeq ($(BR2_mips_xburst),y)
  43. # Before gcc 4.6, -mno-fused-madd was needed, after -ffp-contract is
  44. # needed
  45. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_6),y)
  46. TOOLCHAIN_WRAPPER_ARGS += -DBR_FP_CONTRACT_OFF
  47. else
  48. TOOLCHAIN_WRAPPER_ARGS += -DBR_NO_FUSED_MADD
  49. endif
  50. endif
  51. ifeq ($(BR2_CCACHE_USE_BASEDIR),y)
  52. TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_BASEDIR='"$(BASE_DIR)"'
  53. endif
  54. ifeq ($(BR2_PIC_PIE),y)
  55. TOOLCHAIN_WRAPPER_ARGS += -DBR2_PIC_PIE
  56. endif
  57. ifeq ($(BR2_RELRO_PARTIAL),y)
  58. TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_PARTIAL
  59. else ifeq ($(BR2_RELRO_FULL),y)
  60. TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL
  61. endif
  62. define TOOLCHAIN_WRAPPER_BUILD
  63. $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
  64. -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \
  65. toolchain/toolchain-wrapper.c \
  66. -o $(@D)/toolchain-wrapper
  67. endef
  68. define TOOLCHAIN_WRAPPER_INSTALL
  69. $(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper \
  70. $(HOST_DIR)/bin/toolchain-wrapper
  71. endef