summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/buildhistory.bbclass74
-rw-r--r--meta/classes/create-spdx-2.2.bbclass9
-rw-r--r--meta/classes/devtool-source.bbclass4
-rw-r--r--meta/classes/icecc.bbclass443
-rw-r--r--meta/classes/multilib.bbclass1
-rw-r--r--meta/classes/spdx-common.bbclass3
-rw-r--r--meta/classes/toaster.bbclass2
-rw-r--r--meta/classes/toolchain/clang.bbclass37
-rw-r--r--meta/classes/toolchain/gcc-native.bbclass15
-rw-r--r--meta/classes/toolchain/gcc.bbclass33
10 files changed, 107 insertions, 514 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index e970182620..4a380c10c6 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -16,28 +16,6 @@ BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" 16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" 17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
18 18
19# Setting this to non-empty will remove the old content of the buildhistory as part of
20# the current bitbake invocation and replace it with information about what was built
21# during the build.
22#
23# This is meant to be used in continuous integration (CI) systems when invoking bitbake
24# for full world builds. The effect in that case is that information about packages
25# that no longer get build also gets removed from the buildhistory, which is not
26# the case otherwise.
27#
28# The advantage over manually cleaning the buildhistory outside of bitbake is that
29# the "version-going-backwards" check still works. When relying on that, be careful
30# about failed world builds: they will lead to incomplete information in the
31# buildhistory because information about packages that could not be built will
32# also get removed. A CI system should handle that by discarding the buildhistory
33# of failed builds.
34#
35# The expected usage is via auto.conf, but passing via the command line also works
36# with: BB_ENV_PASSTHROUGH_ADDITIONS=BUILDHISTORY_RESET BUILDHISTORY_RESET=1
37BUILDHISTORY_RESET ?= ""
38
39BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}"
40BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
41BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" 19BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}"
42BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" 20BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
43BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" 21BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf"
@@ -70,9 +48,10 @@ SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs"
70# necessary because some of these items (package directories, files that 48# necessary because some of these items (package directories, files that
71# we no longer emit) might be obsolete. 49# we no longer emit) might be obsolete.
72# 50#
73# When extending build history, derive your class from buildhistory.bbclass 51# The files listed here are either written by tasks that aren't do_package (e.g.
74# and extend this list here with the additional files created by the derived 52# latest_srcrev from do_fetch) so do_package must not remove them, or, they're
75# class. 53# used to read values in do_package before always being overwritten, e.g. latest,
54# for version backwards checks.
76BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot" 55BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot"
77 56
78PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" 57PATCH_GIT_USER_EMAIL ?= "buildhistory@oe"
@@ -108,7 +87,6 @@ python buildhistory_emit_pkghistory() {
108 return 0 87 return 0
109 88
110 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') 89 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
111 oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
112 90
113 class RecipeInfo: 91 class RecipeInfo:
114 def __init__(self, name): 92 def __init__(self, name):
@@ -203,7 +181,7 @@ python buildhistory_emit_pkghistory() {
203 181
204 def getlastpkgversion(pkg): 182 def getlastpkgversion(pkg):
205 try: 183 try:
206 histfile = os.path.join(oldpkghistdir, pkg, "latest") 184 histfile = os.path.join(pkghistdir, pkg, "latest")
207 return readPackageInfo(pkg, histfile) 185 return readPackageInfo(pkg, histfile)
208 except EnvironmentError: 186 except EnvironmentError:
209 return None 187 return None
@@ -219,20 +197,6 @@ python buildhistory_emit_pkghistory() {
219 items.sort() 197 items.sort()
220 return ' '.join(items) 198 return ' '.join(items)
221 199
222 def preservebuildhistoryfiles(pkg, preserve):
223 if os.path.exists(os.path.join(oldpkghistdir, pkg)):
224 listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg))
225 for obj in listofobjs:
226 if obj not in preserve:
227 continue
228 try:
229 bb.utils.mkdirhier(os.path.join(pkghistdir, pkg))
230 shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj))
231 except IOError as e:
232 bb.note("Unable to copy file. %s" % e)
233 except EnvironmentError as e:
234 bb.note("Unable to copy file. %s" % e)
235
236 pn = d.getVar('PN') 200 pn = d.getVar('PN')
237 pe = d.getVar('PE') or "0" 201 pe = d.getVar('PE') or "0"
238 pv = d.getVar('PV') 202 pv = d.getVar('PV')
@@ -260,14 +224,6 @@ python buildhistory_emit_pkghistory() {
260 if not os.path.exists(pkghistdir): 224 if not os.path.exists(pkghistdir):
261 bb.utils.mkdirhier(pkghistdir) 225 bb.utils.mkdirhier(pkghistdir)
262 else: 226 else:
263 # We need to make sure that all files kept in
264 # buildhistory/old are restored successfully
265 # otherwise next block of code wont have files to
266 # check and purge
267 if d.getVar("BUILDHISTORY_RESET"):
268 for pkg in packagelist:
269 preservebuildhistoryfiles(pkg, preserve)
270
271 # Remove files for packages that no longer exist 227 # Remove files for packages that no longer exist
272 for item in os.listdir(pkghistdir): 228 for item in os.listdir(pkghistdir):
273 if item not in preserve: 229 if item not in preserve:
@@ -887,25 +843,7 @@ END
887 843
888python buildhistory_eventhandler() { 844python buildhistory_eventhandler() {
889 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip(): 845 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip():
890 reset = e.data.getVar("BUILDHISTORY_RESET") 846 if isinstance(e, bb.event.BuildCompleted):
891 olddir = e.data.getVar("BUILDHISTORY_OLD_DIR")
892 if isinstance(e, bb.event.BuildStarted):
893 if reset:
894 import shutil
895 # Clean up after potentially interrupted build.
896 if os.path.isdir(olddir):
897 shutil.rmtree(olddir)
898 rootdir = e.data.getVar("BUILDHISTORY_DIR")
899 bb.utils.mkdirhier(rootdir)
900 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
901 bb.utils.mkdirhier(olddir)
902 for entry in entries:
903 bb.utils.rename(os.path.join(rootdir, entry),
904 os.path.join(olddir, entry))
905 elif isinstance(e, bb.event.BuildCompleted):
906 if reset:
907 import shutil
908 shutil.rmtree(olddir)
909 if e.data.getVar("BUILDHISTORY_COMMIT") == "1": 847 if e.data.getVar("BUILDHISTORY_COMMIT") == "1":
910 bb.note("Writing buildhistory") 848 bb.note("Writing buildhistory")
911 bb.build.exec_func("buildhistory_write_sigs", d) 849 bb.build.exec_func("buildhistory_write_sigs", d)
diff --git a/meta/classes/create-spdx-2.2.bbclass b/meta/classes/create-spdx-2.2.bbclass
index 7e8f8b9ff5..6fc60a1d97 100644
--- a/meta/classes/create-spdx-2.2.bbclass
+++ b/meta/classes/create-spdx-2.2.bbclass
@@ -137,6 +137,11 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
137 spdx_files = [] 137 spdx_files = []
138 138
139 file_counter = 1 139 file_counter = 1
140
141 check_compiled_sources = d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1"
142 if check_compiled_sources:
143 compiled_sources, types = oe.spdx_common.get_compiled_sources(d)
144 bb.debug(1, f"Total compiled files: {len(compiled_sources)}")
140 for subdir, dirs, files in os.walk(topdir): 145 for subdir, dirs, files in os.walk(topdir):
141 dirs[:] = [d for d in dirs if d not in ignore_dirs] 146 dirs[:] = [d for d in dirs if d not in ignore_dirs]
142 if subdir == str(topdir): 147 if subdir == str(topdir):
@@ -147,6 +152,10 @@ def add_package_files(d, doc, spdx_pkg, topdir, get_spdxid, get_types, *, archiv
147 filename = str(filepath.relative_to(topdir)) 152 filename = str(filepath.relative_to(topdir))
148 153
149 if not filepath.is_symlink() and filepath.is_file(): 154 if not filepath.is_symlink() and filepath.is_file():
155 # Check if file is compiled
156 if check_compiled_sources:
157 if not oe.spdx_common.is_compiled_source(filename, compiled_sources, types):
158 continue
150 spdx_file = oe.spdx.SPDXFile() 159 spdx_file = oe.spdx.SPDXFile()
151 spdx_file.SPDXID = get_spdxid(file_counter) 160 spdx_file.SPDXID = get_spdxid(file_counter)
152 for t in get_types(filepath): 161 for t in get_types(filepath):
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass
index 9762003ba7..2e0070486b 100644
--- a/meta/classes/devtool-source.bbclass
+++ b/meta/classes/devtool-source.bbclass
@@ -92,9 +92,9 @@ python devtool_post_unpack() {
92 for fname in local_files: 92 for fname in local_files:
93 f.write('%s\n' % fname) 93 f.write('%s\n' % fname)
94 94
95 if os.path.dirname(srcsubdir) != workdir: 95 if srcsubdir.startswith(unpackdir) and os.path.dirname(srcsubdir) != unpackdir:
96 # Handle if S is set to a subdirectory of the source 96 # Handle if S is set to a subdirectory of the source
97 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 97 srcsubdir = os.path.normpath(os.path.join(unpackdir, os.path.relpath(srcsubdir, unpackdir).split(os.sep)[0]))
98 98
99 scriptutils.git_convert_standalone_clone(srcsubdir) 99 scriptutils.git_convert_standalone_clone(srcsubdir)
100 100
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass
deleted file mode 100644
index 8a48f2ad63..0000000000
--- a/meta/classes/icecc.bbclass
+++ /dev/null
@@ -1,443 +0,0 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# Icecream distributed compiling support
8#
9# Stages directories with symlinks from gcc/g++ to icecc, for both
10# native and cross compilers. Depending on each configure or compile,
11# the directories are added at the head of the PATH list and ICECC_CXX
12# and ICECC_CC are set.
13#
14# For the cross compiler, creates a tar.gz of our toolchain and sets
15# ICECC_VERSION accordingly.
16#
17# The class now handles all 3 different compile 'stages' (i.e native ,cross-kernel and target) creating the
18# necessary environment tar.gz file to be used by the remote machines.
19# It also supports meta-toolchain generation.
20#
21# If ICECC_PATH is not set in local.conf then the class will try to locate it using 'bb.utils.which'
22# but nothing is sure. ;)
23#
24# If ICECC_ENV_EXEC is set in local.conf, then it should point to the icecc-create-env script provided by the user
25# or the default one provided by icecc-create-env_0.1.bb will be used.
26# (NOTE that this is a modified version of the needed script and *not the one that comes with icecream*).
27#
28# User can specify if specific recipes or recipes inheriting specific classes should not use icecc to distribute
29# compile jobs to remote machines, but handle them locally by defining ICECC_CLASS_DISABLE and ICECC_RECIPE_DISABLE
30# with the appropriate values in local.conf. In addition the user can force to enable icecc for recipes
31# which set an empty PARALLEL_MAKE variable by defining ICECC_RECIPE_ENABLE.
32#
33#########################################################################################
34# Error checking is kept to minimum so double check any parameters you pass to the class
35#########################################################################################
36
37BB_BASEHASH_IGNORE_VARS += "ICECC_PARALLEL_MAKE ICECC_DISABLED ICECC_RECIPE_DISABLE \
38 ICECC_CLASS_DISABLE ICECC_RECIPE_ENABLE ICECC_PATH ICECC_ENV_EXEC \
39 ICECC_CARET_WORKAROUND ICECC_CFLAGS ICECC_ENV_VERSION \
40 ICECC_DEBUG ICECC_LOGFILE ICECC_REPEAT_RATE ICECC_PREFERRED_HOST \
41 ICECC_CLANG_REMOTE_CPP ICECC_IGNORE_UNVERIFIED ICECC_TEST_SOCKET \
42 ICECC_ENV_DEBUG ICECC_REMOTE_CPP \
43 "
44
45ICECC_ENV_EXEC ?= "${STAGING_BINDIR_NATIVE}/icecc-create-env"
46
47HOSTTOOLS_NONFATAL += "icecc patchelf"
48
49# This version can be incremented when changes are made to the environment that
50# invalidate the version on the compile nodes. Changing it will cause a new
51# environment to be created.
52#
53# A useful thing to do for testing icecream changes locally is to add a
54# subversion in local.conf:
55# ICECC_ENV_VERSION:append = "-my-ver-1"
56ICECC_ENV_VERSION = "2"
57
58# Default to disabling the caret workaround, If set to "1" in local.conf, icecc
59# will locally recompile any files that have warnings, which can adversely
60# affect performance.
61#
62# See: https://github.com/icecc/icecream/issues/190
63export ICECC_CARET_WORKAROUND ??= "0"
64
65export ICECC_REMOTE_CPP ??= "0"
66
67ICECC_CFLAGS = ""
68CFLAGS += "${ICECC_CFLAGS}"
69CXXFLAGS += "${ICECC_CFLAGS}"
70
71# Debug flags when generating environments
72ICECC_ENV_DEBUG ??= ""
73
74# Disable recipe list contains a list of recipes that can not distribute
75# compile tasks for one reason or the other. When adding a new entry, please
76# document why (how it failed) so that we can re-evaluate it later e.g. when
77# there is a new version.
78#
79# libgcc-initial - fails with CPP sanity check error if host sysroot contains
80# cross gcc built for another target tune/variant.
81# pixman - prng_state: TLS reference mismatches non-TLS reference, possibly due to
82# pragma omp threadprivate(prng_state).
83# systemtap - _HelperSDT.c undefs macros and uses the identifiers in macros emitting
84# inline assembly.
85# target-sdk-provides-dummy - ${HOST_PREFIX} is empty which triggers the "NULL
86# prefix" error.
87ICECC_RECIPE_DISABLE += "\
88 libgcc-initial \
89 pixman \
90 systemtap \
91 target-sdk-provides-dummy \
92 "
93
94# Classes that should not use icecc. When adding a new entry, please
95# document why (how it failed) so that we can re-evaluate it later.
96#
97# image - images aren't compiling, but the testing framework for images captures
98# PARALLEL_MAKE as part of the test environment. Many tests won't use
99# icecream, but leaving the high level of parallelism can cause them to
100# consume an unnecessary amount of resources.
101ICECC_CLASS_DISABLE += "\
102 image \
103 "
104
105def get_icecc_dep(d):
106 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
107 # we need that built is the responsibility of the patch function / class, not
108 # the application.
109 if not d.getVar('INHIBIT_DEFAULT_DEPS'):
110 return "icecc-create-env-native"
111 return ""
112
113DEPENDS:prepend = "${@get_icecc_dep(d)} "
114
115get_cross_kernel_cc[vardepsexclude] += "KERNEL_CC"
116def get_cross_kernel_cc(bb,d):
117 if not icecc_is_kernel(bb, d):
118 return None
119
120 # evaluate the expression by the shell if necessary
121 kernel_cc = d.getVar('KERNEL_CC')
122 if '`' in kernel_cc or '$(' in kernel_cc:
123 import subprocess
124 kernel_cc = subprocess.check_output("echo %s" % kernel_cc, shell=True).decode("utf-8")[:-1]
125
126 kernel_cc = kernel_cc.replace('ccache', '').strip()
127 kernel_cc = kernel_cc.split(' ')[0]
128 kernel_cc = kernel_cc.strip()
129 return kernel_cc
130
131def get_icecc(d):
132 return d.getVar('ICECC_PATH') or bb.utils.which(os.getenv("PATH"), "icecc")
133
134def use_icecc(bb,d):
135 if d.getVar('ICECC_DISABLED') == "1":
136 # don't even try it, when explicitly disabled
137 return "no"
138
139 # allarch recipes don't use compiler
140 if icecc_is_allarch(bb, d):
141 return "no"
142
143 if icecc_is_cross_canadian(bb, d):
144 return "no"
145
146 pn = d.getVar('PN')
147 bpn = d.getVar('BPN')
148
149 # Enable/disable checks are made against BPN, because there is a good
150 # chance that if icecc should be skipped for a recipe, it should be skipped
151 # for all the variants of that recipe. PN is still checked in case a user
152 # specified a more specific recipe.
153 check_pn = set([pn, bpn])
154
155 class_disable = (d.getVar('ICECC_CLASS_DISABLE') or "").split()
156
157 for bbclass in class_disable:
158 if bb.data.inherits_class(bbclass, d):
159 bb.debug(1, "%s: bbclass %s found in disable, disable icecc" % (pn, bbclass))
160 return "no"
161
162 disabled_recipes = (d.getVar('ICECC_RECIPE_DISABLE') or "").split()
163 enabled_recipes = (d.getVar('ICECC_RECIPE_ENABLE') or "").split()
164
165 if check_pn & set(disabled_recipes):
166 bb.debug(1, "%s: found in disable list, disable icecc" % pn)
167 return "no"
168
169 if check_pn & set(enabled_recipes):
170 bb.debug(1, "%s: found in enabled recipes list, enable icecc" % pn)
171 return "yes"
172
173 if d.getVar('PARALLEL_MAKE') == "":
174 bb.debug(1, "%s: has empty PARALLEL_MAKE, disable icecc" % pn)
175 return "no"
176
177 return "yes"
178
179def icecc_is_allarch(bb, d):
180 return d.getVar("PACKAGE_ARCH") == "all"
181
182def icecc_is_kernel(bb, d):
183 return \
184 bb.data.inherits_class("kernel", d);
185
186def icecc_is_native(bb, d):
187 return \
188 bb.data.inherits_class("cross", d) or \
189 bb.data.inherits_class("native", d);
190
191def icecc_is_cross_canadian(bb, d):
192 return bb.data.inherits_class("cross-canadian", d)
193
194def icecc_dir(bb, d):
195 return d.expand('${TMPDIR}/work-shared/ice')
196
197# Don't pollute allarch signatures with TARGET_FPU
198icecc_version[vardepsexclude] += "TARGET_FPU"
199def icecc_version(bb, d):
200 if use_icecc(bb, d) == "no":
201 return ""
202
203 parallel = d.getVar('ICECC_PARALLEL_MAKE') or ""
204 if not d.getVar('PARALLEL_MAKE') == "" and parallel:
205 d.setVar("PARALLEL_MAKE", parallel)
206
207 # Disable showing the caret in the GCC compiler output if the workaround is
208 # disabled
209 if d.getVar('ICECC_CARET_WORKAROUND') == '0':
210 d.setVar('ICECC_CFLAGS', '-fno-diagnostics-show-caret')
211
212 if icecc_is_native(bb, d):
213 archive_name = "local-host-env"
214 elif d.expand('${HOST_PREFIX}') == "":
215 bb.fatal(d.expand("${PN}"), " NULL prefix")
216 else:
217 prefix = d.expand('${HOST_PREFIX}' )
218 distro = d.expand('${DISTRO}')
219 target_sys = d.expand('${TARGET_SYS}')
220 float = d.getVar('TARGET_FPU') or "hard"
221 archive_name = prefix + distro + "-" + target_sys + "-" + float
222 if icecc_is_kernel(bb, d):
223 archive_name += "-kernel"
224
225 import socket
226 ice_dir = icecc_dir(bb, d)
227 tar_file = os.path.join(ice_dir, "{archive}-{version}-@VERSION@-{hostname}.tar.gz".format(
228 archive=archive_name,
229 version=d.getVar('ICECC_ENV_VERSION'),
230 hostname=socket.gethostname()
231 ))
232
233 return tar_file
234
235def icecc_path(bb,d):
236 if use_icecc(bb, d) == "no":
237 # don't create unnecessary directories when icecc is disabled
238 return
239
240 staging = os.path.join(d.expand('${STAGING_BINDIR}'), "ice")
241 if icecc_is_kernel(bb, d):
242 staging += "-kernel"
243
244 return staging
245
246def icecc_get_external_tool(bb, d, tool):
247 external_toolchain_bindir = d.expand('${EXTERNAL_TOOLCHAIN}${bindir_cross}')
248 target_prefix = d.expand('${TARGET_PREFIX}')
249 return os.path.join(external_toolchain_bindir, '%s%s' % (target_prefix, tool))
250
251def icecc_get_tool_link(tool, d):
252 import subprocess
253 try:
254 return subprocess.check_output("readlink -f %s" % tool, shell=True).decode("utf-8")[:-1]
255 except subprocess.CalledProcessError as e:
256 bb.note("icecc: one of the tools probably disappeared during recipe parsing, cmd readlink -f %s returned %d:\n%s" % (tool, e.returncode, e.output.decode("utf-8")))
257 return tool
258
259def icecc_get_path_tool(tool, d):
260 # This is a little ugly, but we want to make sure we add an actual
261 # compiler to the toolchain, not ccache. Some distros (e.g. Fedora)
262 # have ccache enabled by default using symlinks in PATH, meaning ccache
263 # would be found first when looking for the compiler.
264 paths = os.getenv("PATH").split(':')
265 while True:
266 p, hist = bb.utils.which(':'.join(paths), tool, history=True)
267 if not p or os.path.basename(icecc_get_tool_link(p, d)) != 'ccache':
268 return p
269 paths = paths[len(hist):]
270
271 return ""
272
273# Don't pollute native signatures with target TUNE_PKGARCH through STAGING_BINDIR_TOOLCHAIN
274icecc_get_tool[vardepsexclude] += "STAGING_BINDIR_TOOLCHAIN"
275def icecc_get_tool(bb, d, tool):
276 if icecc_is_native(bb, d):
277 return icecc_get_path_tool(tool, d)
278 elif icecc_is_kernel(bb, d):
279 return icecc_get_path_tool(get_cross_kernel_cc(bb, d), d)
280 else:
281 ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}')
282 target_sys = d.expand('${TARGET_SYS}')
283 for p in ice_dir.split(':'):
284 tool_bin = os.path.join(p, "%s-%s" % (target_sys, tool))
285 if os.path.isfile(tool_bin):
286 return tool_bin
287 external_tool_bin = icecc_get_external_tool(bb, d, tool)
288 if os.path.isfile(external_tool_bin):
289 return external_tool_bin
290 return ""
291
292def icecc_get_and_check_tool(bb, d, tool):
293 # Check that g++ or gcc is not a symbolic link to icecc binary in
294 # PATH or icecc-create-env script will silently create an invalid
295 # compiler environment package.
296 t = icecc_get_tool(bb, d, tool)
297 if t:
298 link_path = icecc_get_tool_link(t, d)
299 if link_path == get_icecc(d):
300 bb.error("%s is a symlink to %s in PATH and this prevents icecc from working" % (t, link_path))
301 return ""
302 else:
303 return t
304 else:
305 return t
306
307set_icecc_env[vardepsexclude] += "KERNEL_CC"
308python set_icecc_env() {
309 import os
310 import subprocess
311
312 if use_icecc(bb, d) == "no":
313 return
314 ICECC_VERSION = icecc_version(bb, d)
315 if not ICECC_VERSION:
316 bb.warn("Cannot use icecc: could not get ICECC_VERSION")
317 return
318
319 ICE_PATH = icecc_path(bb, d)
320 if not ICE_PATH:
321 bb.warn("Cannot use icecc: could not get ICE_PATH")
322 return
323
324 ICECC_BIN = get_icecc(d)
325 if not ICECC_BIN:
326 bb.warn("Cannot use icecc: icecc binary not found")
327 return
328
329 if (not bb.utils.which(os.getenv("PATH"), "patchelf") and
330 not bb.utils.which(os.getenv("PATH"), "patchelf-uninative")):
331 bb.warn("Cannot use icecc: patchelf not found")
332 return
333
334 ICECC_CC = icecc_get_and_check_tool(bb, d, "gcc")
335 ICECC_CXX = icecc_get_and_check_tool(bb, d, "g++")
336 # cannot use icecc_get_and_check_tool here because it assumes as without target_sys prefix
337 ICECC_WHICH_AS = bb.utils.which(os.getenv('PATH'), 'as')
338 if (not os.access(ICECC_CC, os.X_OK) or
339 not os.access(ICECC_CXX, os.X_OK)):
340 bb.note("Cannot use icecc: could not get ICECC_CC or ICECC_CXX")
341 return
342
343 cmd = []
344 try:
345 cmd = [ICECC_CC, '-dumpversion']
346 ICE_VERSION = subprocess.check_output(cmd).decode("utf-8").strip()
347 except subprocess.CalledProcessError as e:
348 bb.warn("icecc: '{}' returned {}:\n{}".format(cmd, e.returncode, e.output.decode("utf-8")))
349 return
350
351 ICECC_VERSION = ICECC_VERSION.replace("@VERSION@", ICE_VERSION)
352
353 if not os.access(d.getVar('ICECC_ENV_EXEC'), os.X_OK):
354 bb.warn("Cannot use icecc: invalid ICECC_ENV_EXEC")
355 return
356
357 # Create symlinks to icecc and wrapper-scripts in the recipe-sysroot directory
358 symlink_path = os.path.join(ICE_PATH, "symlinks")
359 bb.utils.mkdirhier(symlink_path)
360 compilers = []
361 if icecc_is_kernel(bb, d):
362 compilers.append(get_cross_kernel_cc(bb,d))
363 else:
364 host_prefix = d.getVar('HOST_PREFIX')
365 compilers.extend([host_prefix + 'gcc', host_prefix + 'g++'])
366
367 for compiler in compilers:
368 try:
369 os.symlink(ICECC_BIN, symlink_path + '/' + compiler)
370 except FileExistsError:
371 pass
372 wrapper_script = os.path.join(ICE_PATH, compiler)
373 with open(wrapper_script, 'w') as fd:
374 fd.write("#!/bin/sh -e\n")
375 fd.write("export ICECC_VERSION={}\n".format(ICECC_VERSION))
376 fd.write("export ICECC_CC={}\n".format(ICECC_CC))
377 fd.write("export ICECC_CXX={}\n".format(ICECC_CXX))
378 fd.write("{} \"$@\"\n".format(os.path.join(ICE_PATH, "symlinks", compiler)))
379 os.chmod(wrapper_script, 0o755)
380
381 try:
382 cmd = [ICECC_CC, '-print-prog-name=as']
383 ICECC_AS = subprocess.check_output(cmd).decode("utf-8").strip()
384 except subprocess.CalledProcessError as e:
385 bb.warn("icecc: '{}' returned {}:\n{}".format(cmd, e.returncode, e.output.decode("utf-8")))
386 return
387 # for target recipes should return something like:
388 # /OE/tmp-eglibc/sysroots/x86_64-linux/usr/libexec/arm920tt-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.8.2/as
389 # and just "as" for native, if it returns "as" in current directory (for whatever reason) use "as" from PATH
390 if not os.path.dirname(ICECC_AS):
391 ICECC_AS = ICECC_WHICH_AS
392
393 if not os.path.isfile(ICECC_VERSION + ".done"):
394 bb.utils.mkdirhier(os.path.dirname(ICECC_VERSION))
395
396 # the ICECC_VERSION generation step must be locked by a mutex
397 # in order to prevent race conditions
398 lock = bb.utils.lockfile(ICECC_VERSION + '.lock')
399 try:
400 cmd = [d.getVar('ICECC_ENV_EXEC')]
401 if d.getVar('ICECC_ENV_DEBUG'):
402 cmd.append(d.getVar('ICECC_ENV_DEBUG'))
403 cmd.extend([ICECC_CC, ICECC_CXX, ICECC_AS, ICECC_VERSION])
404 subprocess.check_output(cmd)
405 cmd = ['touch', ICECC_VERSION + '.done']
406 subprocess.check_output(cmd)
407 except subprocess.CalledProcessError as e:
408 bb.warn("icecc: '{}' returned {}:\n{}".format(cmd, e.returncode, e.output.decode("utf-8")))
409 bb.utils.unlockfile(lock)
410 return
411 bb.utils.unlockfile(lock)
412
413 # Don't let ccache find the icecream compiler links that have been created, otherwise
414 # it can end up invoking icecream recursively.
415 d.setVar('CCACHE_PATH', d.getVar('PATH'))
416 d.setVar('CCACHE_DISABLE', '1')
417
418 d.prependVar('PATH', ICE_PATH + ':')
419
420 bb.note("Using icecc path: {}".format(ICE_PATH))
421 bb.note("Using icecc tarball: {}".format(ICECC_VERSION))
422}
423
424do_configure[prefuncs] += "set_icecc_env"
425do_compile[prefuncs] += "set_icecc_env"
426do_compile_kernelmodules[prefuncs] += "set_icecc_env"
427do_install[prefuncs] += "set_icecc_env"
428
429# Icecream is not (currently) supported in the extensible SDK
430ICECC_SDK_HOST_TASK = "nativesdk-icecc-toolchain"
431ICECC_SDK_HOST_TASK:task-populate-sdk-ext = ""
432
433# Don't include icecream in uninative tarball
434ICECC_SDK_HOST_TASK:pn-uninative-tarball = ""
435
436# Add the toolchain scripts to the SDK
437TOOLCHAIN_HOST_TASK:append = " ${ICECC_SDK_HOST_TASK}"
438
439python () {
440 if d.getVar('ICECC_DISABLED') != "1":
441 for task in ['do_configure', 'do_compile', 'do_compile_kernelmodules', 'do_install']:
442 d.setVarFlag(task, 'network', '1')
443}
diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass
index a4151658a6..b959bbd93c 100644
--- a/meta/classes/multilib.bbclass
+++ b/meta/classes/multilib.bbclass
@@ -21,6 +21,7 @@ python multilib_virtclass_handler () {
21 bpn = d.getVar("BPN") 21 bpn = d.getVar("BPN")
22 if ("virtual/kernel" in provides 22 if ("virtual/kernel" in provides
23 or bb.data.inherits_class('module-base', d) 23 or bb.data.inherits_class('module-base', d)
24 or bb.data.inherits_class('kernel-fit-image', d)
24 or bpn in non_ml_recipes): 25 or bpn in non_ml_recipes):
25 raise bb.parse.SkipRecipe("We shouldn't have multilib variants for %s" % bpn) 26 raise bb.parse.SkipRecipe("We shouldn't have multilib variants for %s" % bpn)
26 27
diff --git a/meta/classes/spdx-common.bbclass b/meta/classes/spdx-common.bbclass
index 713a7fc651..ca0416d1c7 100644
--- a/meta/classes/spdx-common.bbclass
+++ b/meta/classes/spdx-common.bbclass
@@ -26,6 +26,7 @@ SPDX_TOOL_VERSION ??= "1.0"
26SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy" 26SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"
27 27
28SPDX_INCLUDE_SOURCES ??= "0" 28SPDX_INCLUDE_SOURCES ??= "0"
29SPDX_INCLUDE_COMPILED_SOURCES ??= "0"
29 30
30SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org" 31SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org"
31SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs" 32SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs"
@@ -40,6 +41,8 @@ SPDX_MULTILIB_SSTATE_ARCHS ??= "${SSTATE_ARCHS}"
40python () { 41python () {
41 from oe.cve_check import extend_cve_status 42 from oe.cve_check import extend_cve_status
42 extend_cve_status(d) 43 extend_cve_status(d)
44 if d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1":
45 d.setVar("SPDX_INCLUDE_SOURCES", "1")
43} 46}
44 47
45def create_spdx_source_deps(d): 48def create_spdx_source_deps(d):
diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass
index 03c4f3a930..af7c457808 100644
--- a/meta/classes/toaster.bbclass
+++ b/meta/classes/toaster.bbclass
@@ -84,7 +84,7 @@ python toaster_layerinfo_dumpdata() {
84 84
85 llayerinfo = {} 85 llayerinfo = {}
86 86
87 for layer in { l for l in bblayers.strip().split(" ") if len(l) }: 87 for layer in { l for l in bblayers.strip().split() if len(l) }:
88 llayerinfo[layer] = _get_layer_dict(layer) 88 llayerinfo[layer] = _get_layer_dict(layer)
89 89
90 90
diff --git a/meta/classes/toolchain/clang.bbclass b/meta/classes/toolchain/clang.bbclass
new file mode 100644
index 0000000000..d7b8a3657c
--- /dev/null
+++ b/meta/classes/toolchain/clang.bbclass
@@ -0,0 +1,37 @@
1CC = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
2CXX = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
3FC = "${HOST_PREFIX}gfortran ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
4CPP = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} -E"
5LD = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', '${HOST_PREFIX}ld.lld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', '${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}', d)}"
6CCLD = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
7RANLIB = "${HOST_PREFIX}llvm-ranlib"
8AR = "${HOST_PREFIX}llvm-ar"
9AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
10STRIP = "${HOST_PREFIX}llvm-strip"
11OBJCOPY = "${HOST_PREFIX}llvm-objcopy"
12OBJDUMP = "${HOST_PREFIX}llvm-objdump"
13STRINGS = "${HOST_PREFIX}llvm-strings"
14NM = "${HOST_PREFIX}llvm-nm"
15READELF = "${HOST_PREFIX}llvm-readelf"
16
17PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-cc = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
18PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-c++ = "${MLPREFIX}clang-cross-${TARGET_ARCH}"
19PREFERRED_PROVIDER_virtual/${MLPREFIX}compilerlibs = "${MLPREFIX}gcc-runtime"
20PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-cc:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
21PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-c++:class-nativesdk = "clang-crosssdk-${SDK_SYS}"
22
23PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-crosssdk = "clang-crosssdk-${SDK_SYS}"
24PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-crosssdk = "clang-crosssdk-${SDK_SYS}"
25
26PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "clang-crosssdk-${SDK_SYS}"
27PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "clang-crosssdk-${SDK_SYS}"
28
29
30BASE_DEFAULT_DEPS:append:class-target = " compiler-rt"
31
32TUNE_CCARGS += "${@bb.utils.contains("DISTRO_FEATURES", "usrmerge", " --dyld-prefix=/usr", "", d)}"
33
34LDFLAGS:append:class-nativesdk:x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
35LDFLAGS:append:class-nativesdk:aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
36
37TCOVERRIDE = "toolchain-clang"
diff --git a/meta/classes/toolchain/gcc-native.bbclass b/meta/classes/toolchain/gcc-native.bbclass
new file mode 100644
index 0000000000..a708bd0389
--- /dev/null
+++ b/meta/classes/toolchain/gcc-native.bbclass
@@ -0,0 +1,15 @@
1BUILD_CC = "${CCACHE}${BUILD_PREFIX}gcc ${BUILD_CC_ARCH}"
2BUILD_CXX = "${CCACHE}${BUILD_PREFIX}g++ ${BUILD_CC_ARCH}"
3BUILD_FC = "${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}"
4BUILD_CPP = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH} -E"
5BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}"
6BUILD_CCLD = "${BUILD_PREFIX}gcc ${BUILD_CC_ARCH}"
7BUILD_AR = "${BUILD_PREFIX}ar"
8BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}"
9BUILD_RANLIB = "${BUILD_PREFIX}ranlib -D"
10BUILD_STRIP = "${BUILD_PREFIX}strip"
11BUILD_OBJCOPY = "${BUILD_PREFIX}objcopy"
12BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
13BUILD_NM = "${BUILD_PREFIX}nm"
14BUILD_READELF = "${BUILD_PREFIX}readelf"
15
diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
new file mode 100644
index 0000000000..a5adb5ca37
--- /dev/null
+++ b/meta/classes/toolchain/gcc.bbclass
@@ -0,0 +1,33 @@
1CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
2CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
3FC = "${HOST_PREFIX}gfortran ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
4CPP = "${HOST_PREFIX}gcc -E${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}"
5LD = "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
6CCLD = "${CC}"
7AR = "${HOST_PREFIX}gcc-ar"
8AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
9RANLIB = "${HOST_PREFIX}gcc-ranlib"
10STRIP = "${HOST_PREFIX}strip"
11OBJCOPY = "${HOST_PREFIX}objcopy"
12OBJDUMP = "${HOST_PREFIX}objdump"
13STRINGS = "${HOST_PREFIX}strings"
14NM = "${HOST_PREFIX}gcc-nm"
15READELF = "${HOST_PREFIX}readelf"
16
17PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-cc = "${MLPREFIX}gcc-cross-${TARGET_ARCH}"
18PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-c++ = "${MLPREFIX}gcc-cross-${TARGET_ARCH}"
19PREFERRED_PROVIDER_virtual/${MLPREFIX}compilerlibs = "${MLPREFIX}gcc-runtime"
20
21PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-cc:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
22PREFERRED_PROVIDER_virtual/${MLPREFIX}cross-c++:class-nativesdk = "gcc-crosssdk-${SDK_SYS}"
23PREFERRED_PROVIDER_virtual/${MLPREFIX}compilerlibs:class-nativesdk = "nativesdk-gcc-runtime"
24
25PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-crosssdk = "gcc-crosssdk-${SDK_SYS}"
26PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-crosssdk = "gcc-crosssdk-${SDK_SYS}"
27PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-crosssdk = "nativesdk-gcc-runtime"
28
29PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
30PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
31PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "nativesdk-gcc-runtime"
32
33TCOVERRIDE = "toolchain-gcc"