Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | # |
| 2 | # Configuration to use an external Arm binary toolchain |
| 3 | # |
| 4 | |
| 5 | EXTERNAL_TOOLCHAIN ?= "/usr/local/arm-binary-toolchain/${TARGET_ARCH}" |
| 6 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 7 | # oe-core passes this by default because it assumes GCC 13. This can be removed when Arm GCC is 13.1+. |
| 8 | DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map" |
| 9 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 10 | TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:" |
| 11 | PATH =. "${TOOLCHAIN_PATH_ADD}" |
| 12 | |
| 13 | EAT_TARGET_SYS:arm ?= "${@ 'arm-none-linux-gnueabihf' if os.path.exists('${EXTERNAL_TOOLCHAIN}/bin/arm-none-linux-gnueabihf-gcc') else 'arm-linux-gnueabihf'}" |
| 14 | EAT_TARGET_SYS:aarch64 ?= "${@ 'aarch64-none-linux-gnu' if os.path.exists('${EXTERNAL_TOOLCHAIN}/bin/aarch64-none-linux-gnu-gcc') else 'aarch64-linux-gnu'}" |
| 15 | EAT_TARGET_SYS = "${TARGET_SYS}" |
| 16 | TARGET_PREFIX = "${EAT_TARGET_SYS}-" |
| 17 | |
| 18 | EAT_LIBDIR:arm = "lib" |
| 19 | EAT_LIBDIR:aarch64 = "lib64" |
| 20 | |
| 21 | GCCMULTILIB:forcevariable = "--disable-multilib" |
| 22 | IMAGE_LINGUAS:forcevariable = "" |
| 23 | |
| 24 | # Blacklist toolchain recipes as a belt-and-suspenders way to use the external toolchain |
| 25 | SKIP_RECIPE[glibc] = "Using external toolchain" |
| 26 | SKIP_RECIPE[libgcc] = "Using external toolchain" |
| 27 | SKIP_RECIPE[gcc-cross] = "Using external toolchain" |
| 28 | SKIP_RECIPE[gcc-cross-aarch64] = "Using external toolchain" |
| 29 | SKIP_RECIPE[gcc-cross-arm] = "Using external toolchain" |
| 30 | SKIP_RECIPE[gcc-runtime] = "Using external toolchain" |
| 31 | SKIP_RECIPE[gcc-sanitizers] = "Using external toolchain" |
| 32 | |
| 33 | PREFERRED_PROVIDER_linux-libc-headers = "external-arm-toolchain" |
| 34 | PREFERRED_PROVIDER_linux-libc-headers-dev = "external-arm-toolchain" |
| 35 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-arm-toolchain" |
| 36 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-arm-toolchain" |
| 37 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-arm-toolchain" |
| 38 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-arm-toolchain" |
| 39 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-arm-toolchain" |
| 40 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-arm-toolchain" |
| 41 | PREFERRED_PROVIDER_glibc = "external-arm-toolchain" |
| 42 | PREFERRED_PROVIDER_libgcc = "external-arm-toolchain" |
| 43 | PREFERRED_PROVIDER_virtual/libc = "external-arm-toolchain" |
| 44 | PREFERRED_PROVIDER_virtual/libc-locale = "external-arm-toolchain" |
| 45 | PREFERRED_PROVIDER_virtual/libintl = "external-arm-toolchain" |
| 46 | PREFERRED_PROVIDER_virtual/libiconv = "external-arm-toolchain" |
| 47 | PREFERRED_PROVIDER_virtual/crypt = "external-arm-toolchain" |
| 48 | PREFERRED_PROVIDER_glibc-thread-db = "external-arm-toolchain" |
| 49 | PREFERRED_PROVIDER_glibc-mtrace = "external-arm-toolchain" |
| 50 | PREFERRED_PROVIDER_libc-mtrace = "external-arm-toolchain" |
| 51 | PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-arm-toolchain" |
| 52 | |
| 53 | PREFERRED_PROVIDER_gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}" |
| 54 | PREFERRED_PROVIDER_binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}" |
| 55 | PREFERRED_PROVIDER_gdb-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}" |
| 56 | |
| 57 | TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}" |
| 58 | |
| 59 | DISTRO_FEATURES_LIBC = "ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-crypt \ |
| 60 | libc-crypt-ufc libc-db-aliases libc-envz libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse \ |
| 61 | libc-getlogin libc-idn libc-inet-anl libc-libm libc-libm-big \ |
| 62 | libc-locales libc-locale-code libc-charsets \ |
| 63 | libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug libc-spawn libc-streams libc-sunrpc \ |
| 64 | libc-utmp libc-utmpx libc-wordexp libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc \ |
| 65 | libc-posix-wchar-io" |
| 66 | |
| 67 | ENABLE_BINARY_LOCALE_GENERATION = "0" |
| 68 | GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled" |
| 69 | LIBCOVERRIDE = ":libc-glibc" |
| 70 | LIBC_DEPENDENCIES:remove = "glibc-gconv-cp1252 glibc-gconv-ibm850 glibc-gconv-iso8859-1 glibc-gconv-iso8859-15 glibc-localedata-i18n" |
| 71 | |
| 72 | ERROR_QA[type] ?= "list" |
| 73 | python toolchain_metadata_setup () { |
| 74 | import subprocess |
| 75 | if not isinstance(e, bb.event.ConfigParsed): |
| 76 | return |
| 77 | |
| 78 | d = e.data |
| 79 | l = d.createCopy() |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 80 | |
| 81 | external_toolchain = l.getVar('EXTERNAL_TOOLCHAIN', True) |
| 82 | if not external_toolchain or external_toolchain == 'UNDEFINED': |
| 83 | bb.fatal("Error: EXTERNAL_TOOLCHAIN must be set to the path to your arm toolchain") |
| 84 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 85 | if not os.path.isabs(external_toolchain): |
| 86 | bb.fatal("Error: EXTERNAL_TOOLCHAIN path '%s' must be absolute path" % external_toolchain) |
| 87 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 88 | if not os.path.exists(external_toolchain): |
| 89 | bb.fatal("Error: EXTERNAL_TOOLCHAIN path '%s' does not exist" % external_toolchain) |
| 90 | |
| 91 | # The external toolchain may not have been built with the oe-core preferred |
| 92 | # gnu hash setting, so ensure that the corresponding sanity check is not an error. |
| 93 | error_qa = oe.data.typed_value('ERROR_QA', l) |
| 94 | if 'ldflags' in error_qa: |
| 95 | error_qa.remove('ldflags') |
| 96 | d.setVar('ERROR_QA', ' '.join(error_qa)) |
| 97 | } |
| 98 | addhandler toolchain_metadata_setup |
| 99 | |
| 100 | def populate_toolchain_links(d): |
| 101 | import errno |
| 102 | import os |
| 103 | from glob import glob |
| 104 | |
| 105 | d = d.createCopy() |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 106 | |
| 107 | pattern = bb.data.expand('${EXTERNAL_TOOLCHAIN}/bin/${TARGET_PREFIX}*', d) |
| 108 | files = glob(pattern) |
| 109 | if not files: |
| 110 | bb.fatal("Unable to populate toolchain binary symlinks") |
| 111 | |
| 112 | bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) |
| 113 | bb.mkdirhier(bindir) |
| 114 | for f in files: |
| 115 | base = os.path.basename(f) |
| 116 | newpath = os.path.join(bindir, base) |
| 117 | try: |
| 118 | os.symlink(f, newpath) |
| 119 | except OSError as exc: |
| 120 | if exc.errno == errno.EEXIST: |
| 121 | break |
| 122 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) |
| 123 | |
| 124 | require conf/distro/include/external-arm-toolchain-versions.inc |