toolchain-wrapper.mk 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
  21. # separate argument when used in execv() by the toolchain wrapper.
  22. TOOLCHAIN_WRAPPER_ARGS += \
  23. -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))'
  24. ifeq ($(BR2_CCACHE),y)
  25. TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
  26. endif
  27. ifeq ($(BR2_x86_x1000),y)
  28. TOOLCHAIN_WRAPPER_ARGS += -DBR_OMIT_LOCK_PREFIX
  29. endif
  30. # Avoid FPU bug on XBurst CPUs
  31. ifeq ($(BR2_mips_xburst),y)
  32. # Before gcc 4.6, -mno-fused-madd was needed, after -ffp-contract is
  33. # needed
  34. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_6),y)
  35. TOOLCHAIN_WRAPPER_ARGS += -DBR_FP_CONTRACT_OFF
  36. else
  37. TOOLCHAIN_WRAPPER_ARGS += -DBR_NO_FUSED_MADD
  38. endif
  39. endif
  40. ifeq ($(BR2_CCACHE_USE_BASEDIR),y)
  41. TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_BASEDIR='"$(BASE_DIR)"'
  42. endif
  43. ifeq ($(BR2_PIC_PIE),y)
  44. TOOLCHAIN_WRAPPER_ARGS += -DBR2_PIC_PIE
  45. endif
  46. ifeq ($(BR2_RELRO_PARTIAL),y)
  47. TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_PARTIAL
  48. else ifeq ($(BR2_RELRO_FULL),y)
  49. TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL
  50. endif
  51. define TOOLCHAIN_WRAPPER_BUILD
  52. $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
  53. -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \
  54. toolchain/toolchain-wrapper.c \
  55. -o $(@D)/toolchain-wrapper
  56. endef
  57. define TOOLCHAIN_WRAPPER_INSTALL
  58. $(INSTALL) -D -m 0755 $(@D)/toolchain-wrapper \
  59. $(HOST_DIR)/bin/toolchain-wrapper
  60. endef