tcmode-external.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Configuration to use external Sourcery G++ toolchain
  2. EXTERNAL_TOOLCHAIN ?= "UNDEFINED"
  3. EXTERNAL_TARGET_SYS ??= "${TARGET_ARCH}-${TARGET_OS}"
  4. EXTERNAL_TOOLCHAIN_BIN ??= "${EXTERNAL_TOOLCHAIN}/bin"
  5. # Prefer our recipes which extract files from the external toolchain
  6. PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc ?= "gcc-external-cross-${TARGET_ARCH}"
  7. PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-intermediate ?= "gcc-external-cross-${TARGET_ARCH}"
  8. PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ ?= "gcc-external-cross-${TARGET_ARCH}"
  9. PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils ?= "binutils-external-cross-${TARGET_ARCH}"
  10. PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs ?= "gcc-runtime-external"
  11. PREFERRED_PROVIDER_gcc-runtime = "gcc-runtime-external"
  12. PREFERRED_PROVIDER_gcc-sanitizers ?= "gcc-sanitizers-external"
  13. PREFERRED_PROVIDER_libgcc-initial = "libgcc-external"
  14. PREFERRED_PROVIDER_libnsl2 = "libnsl2-external"
  15. PREFERRED_PROVIDER_libgfortran = "libgfortran-external"
  16. PREFERRED_PROVIDER_glibc ?= "glibc-external"
  17. PREFERRED_PROVIDER_virtual/libc ?= "glibc-external"
  18. PREFERRED_PROVIDER_virtual/libintl ?= "glibc-external"
  19. PREFERRED_PROVIDER_virtual/libiconv ?= "glibc-external"
  20. PREFERRED_PROVIDER_virtual/crypt ?= "glibc-external"
  21. PREFERRED_PROVIDER_gdb-cross-${TARGET_ARCH} ?= "gdb-external-cross-${TARGET_ARCH}"
  22. PREFERRED_PROVIDER_oprofile ??= "oprofile"
  23. # Work around bug where the implicitly created mlprefix preference isn't being
  24. # obeyed for the runtime package installation.
  25. PREFERRED_PROVIDER_${MLPREFIX}gdbserver ?= "${MLPREFIX}gdb"
  26. PREFERRED_PROVIDER_gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} ??= "gcc-external-cross-canadian-${TRANSLATED_TARGET_ARCH}"
  27. PREFERRED_PROVIDER_binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} ??= "binutils-external-cross-canadian-${TRANSLATED_TARGET_ARCH}"
  28. PREFERRED_PROVIDER_gdb-cross-canadian-${TRANSLATED_TARGET_ARCH} ??= "gdb-external-cross-canadian-${TRANSLATED_TARGET_ARCH}"
  29. # This is defined in default-providers.inc, which is parsed before the tcmode,
  30. # so we can't use ?=
  31. PREFERRED_PROVIDER_libgcc = "libgcc-external"
  32. # Pass --no-sysroot-suffix when using an external toolchain with the SDK
  33. TOOLCHAIN_TARGET_TASK_append = " sdk-env-external-toolchain"
  34. # Sanity check the toolchain configuration and toolchain
  35. INHERIT += "sanity-external-toolchain"
  36. # Pull in our utility functions for use elsewhere
  37. INHERIT += "external-common"
  38. # Ensure that we don't pull in any internal toolchain recipes
  39. INHERIT += "blacklist blacklist_dynamic"
  40. PNBLACKLIST[uclibc] = "not building with an external toolchain"
  41. PNBLACKLIST[glibc] = "not building with an external toolchain"
  42. PNBLACKLIST[glibc-intermediate] = "not building with an external toolchain"
  43. PNBLACKLIST[gcc-runtime] = "not building with an external toolchain"
  44. PNBLACKLIST[gcc-sanitizers] = "not building with an external toolchain"
  45. PNBLACKLIST[gcc-source] = "not building with an external toolchain"
  46. PNBLACKLIST[libgcc-initial] = "not building with an external toolchain"
  47. PNBLACKLIST[libgcc] = "not building with an external toolchain"
  48. PNBLACKLIST[libgfortran] = "not building with an external toolchain"
  49. PNBLACKLIST_DYNAMIC += "\
  50. ${MLPREFIX}gcc-cross-${TARGET_ARCH} \
  51. \
  52. binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} \
  53. gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} \
  54. gdb-cross-canadian-${TRANSLATED_TARGET_ARCH} \
  55. \
  56. gcc-source-${@'${GCCVERSION}'.replace('%', '')} \
  57. "
  58. # We need our -cross recipes to rebuild when the external toolchain changes,
  59. # to recreate the links / wrapper scripts
  60. BB_HASHBASE_WHITELIST_remove = "EXTERNAL_TOOLCHAIN"
  61. # For a toolchain built with multilibs, we don't want any suffix implicitly
  62. # added to the oe sysroot path, as those dirs will not exist.
  63. # TOOLCHAIN_OPTIONS would seem more appropriate, but that gets added to LD as
  64. # well, and --no-sysroot-suffix only works for gcc, not binutils.
  65. HOST_CC_ARCH += "--no-sysroot-suffix"
  66. # Certain recipes call ld directly, so ensure the correct emulation is used,
  67. # particularly for multilib toolchains, since we can't rely on the default
  68. LDEMULATION = ""
  69. LDEMULATION_ENDIAN = "${@'bt' if 'bigendian' in '${TUNE_FEATURES}'.split() else 'lt'}"
  70. LDEMULATION_BITS = "${@'64' if 'n64' in '${TUNE_FEATURES}'.split() else '32'}"
  71. LDEMULATION_mips64 = "elf${LDEMULATION_BITS}${LDEMULATION_ENDIAN}smip${@bb.utils.contains('TUNE_FEATURES', 'n32', 'n32', '', d)}"
  72. LDEMULATION_x86-64 = "elf_${TARGET_ARCH}"
  73. LDEMULATION_x86-64_linux-gnux32 = "elf32_${TARGET_ARCH}"
  74. TUNE_LDARGS += "${@'-m ${LDEMULATION}' if '${LDEMULATION}' else ''}"
  75. # Additional search path for compiler component programs, to let us rebuild
  76. # binutils if necessary.
  77. gcc_bindir = "${STAGING_BINDIR_TOOLCHAIN}/gcc"
  78. TUNE_CCARGS .= "${@' -B${gcc_bindir}' if d.getVar('PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils') != 'binutils-external-cross-${TARGET_ARCH}' else ''}"
  79. TCMODEOVERRIDES = "tcmode-external"
  80. TCMODEOVERRIDES_append = ":tcmode-${TCMODE}"
  81. OVERRIDES =. "${TCMODEOVERRIDES}:"
  82. python toolchain_metadata_setup () {
  83. # The external toolchain may not have been built with the yocto preferred
  84. # gnu hash setting, so ensure that the corresponding sanity check is a
  85. # warning, not an error.
  86. error_qa = (d.getVar('ERROR_QA', True) or '').split()
  87. if 'ldflags' in error_qa:
  88. error_qa.remove('ldflags')
  89. d.setVar('ERROR_QA', ' '.join(error_qa))
  90. d.appendVar('WARN_QA', ' ldflags')
  91. }
  92. toolchain_metadata_setup[eventmask] = "bb.event.ConfigParsed"
  93. addhandler toolchain_metadata_setup
  94. GCCVERSION ?= "${@'.'.join('${GCC_VERSION}'.split('.')[:2])}%"
  95. GCC_VERSION = "${@external_run(d, 'gcc', '-dumpversion').rstrip()}"
  96. GCC_VERSION_allarch = ""
  97. GCC_VERSION[vardepvalue] = "${GCC_VERSION}"
  98. # macro-prefix-map was introduced in gcc 8
  99. REMOVE_MACRO_PREFIX_MAP = "-fmacro-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
  100. DEBUG_PREFIX_MAP_remove = "${@'${REMOVE_MACRO_PREFIX_MAP}' if '${GCC_VERSION}' and [int(v) for v in '${GCC_VERSION}'.split('.')] < [8,0] else ''}"
  101. BUILDCFG_VARS += "EXTERNAL_TOOLCHAIN EXTERNAL_TARGET_SYS GCC_VERSION"