toolchain-wrapper.mk 2.2 KB

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