toolchain-wrapper.mk 2.0 KB

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