blob: 898663eadc029eeed6dba6f0790c36d0b1d25ea8 [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001#
2# Configuration to use an external Arm binary toolchain
3#
4
5EXTERNAL_TOOLCHAIN ?= "/usr/local/arm-binary-toolchain/${TARGET_ARCH}"
6
Patrick Williams520786c2023-06-25 16:20:36 -05007# oe-core passes this by default because it assumes GCC 13. This can be removed when Arm GCC is 13.1+.
8DEBUG_PREFIX_MAP:remove = "-fcanon-prefix-map"
9
Brad Bishopbec4ebc2022-08-03 09:55:16 -040010TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:"
11PATH =. "${TOOLCHAIN_PATH_ADD}"
12
13EAT_TARGET_SYS:arm ?= "${@ 'arm-none-linux-gnueabihf' if os.path.exists('${EXTERNAL_TOOLCHAIN}/bin/arm-none-linux-gnueabihf-gcc') else 'arm-linux-gnueabihf'}"
14EAT_TARGET_SYS:aarch64 ?= "${@ 'aarch64-none-linux-gnu' if os.path.exists('${EXTERNAL_TOOLCHAIN}/bin/aarch64-none-linux-gnu-gcc') else 'aarch64-linux-gnu'}"
15EAT_TARGET_SYS = "${TARGET_SYS}"
16TARGET_PREFIX = "${EAT_TARGET_SYS}-"
17
18EAT_LIBDIR:arm = "lib"
19EAT_LIBDIR:aarch64 = "lib64"
20
21GCCMULTILIB:forcevariable = "--disable-multilib"
22IMAGE_LINGUAS:forcevariable = ""
23
24# Blacklist toolchain recipes as a belt-and-suspenders way to use the external toolchain
25SKIP_RECIPE[glibc] = "Using external toolchain"
26SKIP_RECIPE[libgcc] = "Using external toolchain"
27SKIP_RECIPE[gcc-cross] = "Using external toolchain"
28SKIP_RECIPE[gcc-cross-aarch64] = "Using external toolchain"
29SKIP_RECIPE[gcc-cross-arm] = "Using external toolchain"
30SKIP_RECIPE[gcc-runtime] = "Using external toolchain"
31SKIP_RECIPE[gcc-sanitizers] = "Using external toolchain"
32
33PREFERRED_PROVIDER_linux-libc-headers = "external-arm-toolchain"
34PREFERRED_PROVIDER_linux-libc-headers-dev = "external-arm-toolchain"
35PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-arm-toolchain"
36PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-arm-toolchain"
37PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-arm-toolchain"
38PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-arm-toolchain"
39PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-arm-toolchain"
40PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-arm-toolchain"
41PREFERRED_PROVIDER_glibc = "external-arm-toolchain"
42PREFERRED_PROVIDER_libgcc = "external-arm-toolchain"
43PREFERRED_PROVIDER_virtual/libc = "external-arm-toolchain"
44PREFERRED_PROVIDER_virtual/libc-locale = "external-arm-toolchain"
45PREFERRED_PROVIDER_virtual/libintl = "external-arm-toolchain"
46PREFERRED_PROVIDER_virtual/libiconv = "external-arm-toolchain"
47PREFERRED_PROVIDER_virtual/crypt = "external-arm-toolchain"
48PREFERRED_PROVIDER_glibc-thread-db = "external-arm-toolchain"
49PREFERRED_PROVIDER_glibc-mtrace = "external-arm-toolchain"
50PREFERRED_PROVIDER_libc-mtrace = "external-arm-toolchain"
51PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-arm-toolchain"
52
53PREFERRED_PROVIDER_gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}"
54PREFERRED_PROVIDER_binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}"
55PREFERRED_PROVIDER_gdb-cross-canadian-${TRANSLATED_TARGET_ARCH} ?= "external-arm-sdk-toolchain-${TRANSLATED_TARGET_ARCH}"
56
57TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}"
58
59DISTRO_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
67ENABLE_BINARY_LOCALE_GENERATION = "0"
68GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled"
69LIBCOVERRIDE = ":libc-glibc"
70LIBC_DEPENDENCIES:remove = "glibc-gconv-cp1252 glibc-gconv-ibm850 glibc-gconv-iso8859-1 glibc-gconv-iso8859-15 glibc-localedata-i18n"
71
72ERROR_QA[type] ?= "list"
73python 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 Bishopbec4ebc2022-08-03 09:55:16 -040080
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 Williams520786c2023-06-25 16:20:36 -050085 if not os.path.isabs(external_toolchain):
86 bb.fatal("Error: EXTERNAL_TOOLCHAIN path '%s' must be absolute path" % external_toolchain)
87
Brad Bishopbec4ebc2022-08-03 09:55:16 -040088 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}
98addhandler toolchain_metadata_setup
99
100def populate_toolchain_links(d):
101 import errno
102 import os
103 from glob import glob
104
105 d = d.createCopy()
Brad Bishopbec4ebc2022-08-03 09:55:16 -0400106
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
124require conf/distro/include/external-arm-toolchain-versions.inc