summaryrefslogtreecommitdiffstats
path: root/meta/classes/autotools.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-07 13:54:35 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:17 +0000
commit9107d6ca144ac1f6169830dee25dae2dad775333 (patch)
treeec2f5662f8cea5a380ce1a86e249d08e1d0ca14f /meta/classes/autotools.bbclass
parent45df694a9f472ac2f684aadac4d864c3dfdc48a7 (diff)
downloadpoky-9107d6ca144ac1f6169830dee25dae2dad775333.tar.gz
Switch to Recipe Specific Sysroots
This patch is comparatively large and invasive. It does only do one thing, switching the system to build using recipe specific sysroots and where changes could be isolated from it, that has been done. With the current single sysroot approach, its possible for software to find things which aren't in their dependencies. This leads to a determinism problem and is a growing issue in several of the market segments where OE makes sense. The way to solve this problem for OE is to have seperate sysroots for each recipe and these will only contain the dependencies for that recipe. Its worth noting that this is not task specific sysroots and that OE's dependencies do vary enormously by task. This did result in some implementation challenges. There is nothing stopping the implementation of task specific sysroots at some later point based on this work but that as deemed a bridge too far right now. Implementation details: * Rather than installing the sysroot artefacts into a combined sysroots, they are now placed in TMPDIR/sysroot-components/PACKAGE_ARCH/PN. * WORKDIR/recipe-sysroot and WORKDIR/recipe-sysroot-native are built by hardlinking in files from the sysroot-component trees. These new directories are known as RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE. * This construction is primarily done by a new do_prepare_recipe_sysroot task which runs before do_configure and consists of a call to the extend_recipe_sysroot function. * Other tasks need things in the sysroot before/after this, e.g. do_patch needs quilt-native and do_package_write_deb needs dpkg-native. The code therefore inspects the dependencies for each task and adds extend_recipe_sysroot as a prefunc if it has populate_sysroot dependencies. * We have to do a search/replace 'fixme' operation on the files installed into the sysroot to change hardcoded paths into the correct ones. We create a fixmepath file in the component directory which lists the files which need this operation. * Some files have "postinstall" commands which need to run against them, e.g. gdk-pixbuf each time a new loader is added. These are handled by adding files in bindir with the name prefixed by "postinst-" and are run in each sysroot as its created if they're present. This did mean most sstate postinstalls have to be rewritten but there shouldn't be many of them. * Since a recipe can have multiple tasks and these tasks can run against each other at the same time we have to have a lock when we perform write operations against the sysroot. We also have to maintain manifests of what we install against a task checksum of the dependency. If the checksum changes, we remove its files and then add the new ones. * The autotools logic for filtering the view of m4 files is no longer needed (and was the model for the way extend_recipe_sysroot works). * For autotools, we used to build a combined m4 macros directory which had both the native and target m4 files. We can no longer do this so we use the target sysroot as the default and add the native sysroot as an extra backup include path. If we don't do this, we'd have to build target pkg-config before we could built anything using pkg-config for example (ditto gettext). Such dependencies would be painful so we haven't required that. * PKDDATA_DIR was moved out the sysroot and works as before using sstate to build a hybrid copy for each machine. The paths therefore changed, the behaviour did not. * The ccache class had to be reworked to function with rss. * The TCBOOTSTRAP sysroot for compiler bootstrap is no longer needed but the -initial data does have to be filtered out from the main recipe sysroots. Putting "-initial" in a normal recipe name therefore remains a bad idea. * The logic in insane needed tweaks to deal with the new path layout, as did the debug source file extraction code in package.bbclass. * The logic in sstate.bbclass had to be rewritten since it previously only performed search and replace on extracted sstate and we now need this to happen even if the compiled path was "correct". This in theory could cause a mild performance issue but since the sysroot data was the main data that needed this and we'd have to do it there regardless with rss, I've opted just to change the way the class for everything. The built output used to build the sstate output is now retained and installed rather than deleted. * The search and replace logic used in sstate objects also seemed weak/incorrect and didn't hold up against testing. This has been rewritten too. There are some assumptions made about paths, we save the 'proper' search and replace operations to fixmepath.cmd but then ignore this. What is here works but is a little hardcoded and an area for future improvement. * In order to work with eSDK we need a way to build something that looks like the old style sysroot. "bitbake build-sysroots" will construct such a sysroot based on everything in the components directory that matches the current MACHINE. It will allow transition of external tools and can built target or native variants or both. It also supports a clean task. I'd suggest not relying on this for anything other than transitional purposes though. To see XXX in that sysroot, you'd have to have built that in a previous bitbake invocation. * pseudo is run out of its components directory. This is fine as its statically linked. * The hacks for wayland to see allarch dependencies in the multilib case are no longer needed and can be dropped. * wic needed more extensive changes to work with rss and the fixes are in a separate commit series * Various oe-selftest tweaks were needed since tests did assume the location to binaries and the combined sysroot in several cases. * Most missing dependencies this work found have been sent out as separate patches as they were found but a few tweaks are still included here. * A late addition is that extend_recipe_sysroot became multilib aware and able to populate multilib sysroots. I had hoped not to have to add that complexity but the meta-environment recipe forced my hand. That implementation can probably be neater but this is on the list of things to cleanup later at this point. In summary, the impact people will likely see after this change: * Recipes may fail with missing dependencies, particularly native tools like gettext-native, glib-2.0-native and libxml2.0-native. Some hosts have these installed and will mask these errors * Any recipe/class using SSTATEPOSTINSTFUNCS will need that code rewriting into a postinst * There was a separate patch series dealing with roots postinst native dependency issues. Any postinst which expects native tools at rootfs time will need to mark that dependency with PACKAGE_WRITE_DEPS. There could well be other issues. This has been tested repeatedly against our autobuilders and oe-selftest and issues found have been fixed. We believe at least OE-Core is in good shape but that doesn't mean we've found all the issues. Also, the logging is a bit chatty at the moment. It does help if something goes wrong and goes to the task logfiles, not the console so I've intentionally left this like that for now. We can turn it down easily enough in due course. (From OE-Core rev: 809746f56df4b91af014bf6a3f28997d6698ac78) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/autotools.bbclass')
-rw-r--r--meta/classes/autotools.bbclass128
1 files changed, 8 insertions, 120 deletions
diff --git a/meta/classes/autotools.bbclass b/meta/classes/autotools.bbclass
index c43531b050..3741d09706 100644
--- a/meta/classes/autotools.bbclass
+++ b/meta/classes/autotools.bbclass
@@ -131,129 +131,15 @@ EXTRACONFFUNCS ??= ""
131 131
132EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}" 132EXTRA_OECONF_append = " ${PACKAGECONFIG_CONFARGS}"
133 133
134do_configure[prefuncs] += "autotools_preconfigure autotools_copy_aclocals ${EXTRACONFFUNCS}" 134do_configure[prefuncs] += "autotools_preconfigure autotools_aclocals ${EXTRACONFFUNCS}"
135do_configure[postfuncs] += "autotools_postconfigure" 135do_configure[postfuncs] += "autotools_postconfigure"
136 136
137ACLOCALDIR = "${WORKDIR}/aclocal-copy" 137ACLOCALDIR = "${STAGING_DATADIR}/aclocal"
138 138ACLOCALEXTRAPATH = ""
139python autotools_copy_aclocals () { 139ACLOCALEXTRAPATH_class-target = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
140 import copy 140ACLOCALEXTRAPATH_class-nativesdk = " -I ${STAGING_DATADIR_NATIVE}/aclocal/"
141
142 s = d.getVar("AUTOTOOLS_SCRIPT_PATH")
143 if not os.path.exists(s + "/configure.in") and not os.path.exists(s + "/configure.ac"):
144 if not d.getVar("AUTOTOOLS_COPYACLOCAL", False):
145 return
146
147 taskdepdata = d.getVar("BB_TASKDEPDATA", False)
148 #bb.warn(str(taskdepdata))
149 pn = d.getVar("PN")
150 aclocaldir = d.getVar("ACLOCALDIR")
151 oe.path.remove(aclocaldir)
152 bb.utils.mkdirhier(aclocaldir)
153 start = None
154 configuredeps = []
155 # Detect bitbake -b usage
156 # Everything but quilt-native would have dependencies
157 nodeps = (pn != "quilt-native")
158
159 for dep in taskdepdata:
160 data = taskdepdata[dep]
161 if data[1] == "do_configure" and data[0] == pn:
162 start = dep
163 if not nodeps and start:
164 break
165 if nodeps and data[0] != pn:
166 nodeps = False
167 if start is None:
168 bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?")
169
170 # We need to figure out which m4 files we need to expose to this do_configure task.
171 # This needs to match what would get restored from sstate, which is controlled
172 # ultimately by calls from bitbake to setscene_depvalid().
173 # That function expects a setscene dependency tree. We build a dependency tree
174 # condensed to do_populate_sysroot -> do_populate_sysroot dependencies, similar to
175 # that used by setscene tasks. We can then call into setscene_depvalid() and decide
176 # which dependencies we can "see" and should expose the m4 files for.
177 setscenedeps = copy.deepcopy(taskdepdata)
178
179 start = set([start])
180
181 # Create collapsed do_populate_sysroot -> do_populate_sysroot tree
182 for dep in taskdepdata:
183 data = setscenedeps[dep]
184 if data[1] != "do_populate_sysroot":
185 for dep2 in setscenedeps:
186 data2 = setscenedeps[dep2]
187 if dep in data2[3]:
188 data2[3].update(setscenedeps[dep][3])
189 data2[3].remove(dep)
190 if dep in start:
191 start.update(setscenedeps[dep][3])
192 start.remove(dep)
193 del setscenedeps[dep]
194
195 # Remove circular references
196 for dep in setscenedeps:
197 if dep in setscenedeps[dep][3]:
198 setscenedeps[dep][3].remove(dep)
199
200 # Direct dependencies should be present and can be depended upon
201 for dep in start:
202 configuredeps.append(setscenedeps[dep][0])
203
204 # Call into setscene_depvalid for each sub-dependency and only copy m4 files
205 # for ones that would be restored from sstate.
206 done = list(start)
207 next = list(start)
208 while next:
209 new = []
210 for dep in next:
211 data = setscenedeps[dep]
212 for datadep in data[3]:
213 if datadep in done:
214 continue
215 taskdeps = {}
216 taskdeps[dep] = setscenedeps[dep][:2]
217 taskdeps[datadep] = setscenedeps[datadep][:2]
218 retval = setscene_depvalid(datadep, taskdeps, [], d)
219 if retval:
220 bb.note("Skipping setscene dependency %s for m4 macro copying" % datadep)
221 continue
222 done.append(datadep)
223 new.append(datadep)
224 configuredeps.append(setscenedeps[datadep][0])
225 next = new
226
227 cp = []
228 if nodeps:
229 bb.warn("autotools: Unable to find task dependencies, -b being used? Pulling in all m4 files")
230 for l in [d.expand("${STAGING_DATADIR_NATIVE}/aclocal/"), d.expand("${STAGING_DATADIR}/aclocal/")]:
231 cp.extend(os.path.join(l, f) for f in os.listdir(l))
232
233 for c in configuredeps:
234 if c.endswith("-native"):
235 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${BUILD_ARCH}-%s.populate_sysroot" % c)
236 elif c.startswith("nativesdk-"):
237 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${SDK_ARCH}_${SDK_OS}-%s.populate_sysroot" % c)
238 elif "-cross-" in c or "-crosssdk" in c:
239 continue
240 else:
241 manifest = d.expand("${SSTATE_MANIFESTS}/manifest-${MACHINE}-%s.populate_sysroot" % c)
242 try:
243 f = open(manifest, "r")
244 for l in f:
245 if "/aclocal/" in l and l.strip().endswith(".m4"):
246 cp.append(l.strip())
247 elif "config_site.d/" in l:
248 cp.append(l.strip())
249 except:
250 bb.warn("%s not found" % manifest)
251
252 for c in cp:
253 t = os.path.join(aclocaldir, os.path.basename(c))
254 if not os.path.exists(t):
255 os.symlink(c, t)
256 141
142python autotools_aclocals () {
257 # Refresh variable with cache files 143 # Refresh variable with cache files
258 d.setVar("CONFIG_SITE", siteinfo_get_files(d, aclocalcache=True)) 144 d.setVar("CONFIG_SITE", siteinfo_get_files(d, aclocalcache=True))
259} 145}
@@ -279,6 +165,7 @@ autotools_do_configure() {
279 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then 165 if [ -e ${AUTOTOOLS_SCRIPT_PATH}/configure.in -o -e ${AUTOTOOLS_SCRIPT_PATH}/configure.ac ]; then
280 olddir=`pwd` 166 olddir=`pwd`
281 cd ${AUTOTOOLS_SCRIPT_PATH} 167 cd ${AUTOTOOLS_SCRIPT_PATH}
168 mkdir -p ${ACLOCALDIR}
282 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/" 169 ACLOCAL="aclocal --system-acdir=${ACLOCALDIR}/"
283 if [ x"${acpaths}" = xdefault ]; then 170 if [ x"${acpaths}" = xdefault ]; then
284 acpaths= 171 acpaths=
@@ -289,6 +176,7 @@ autotools_do_configure() {
289 else 176 else
290 acpaths="${acpaths}" 177 acpaths="${acpaths}"
291 fi 178 fi
179 acpaths="$acpaths ${ACLOCALEXTRAPATH}"
292 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'` 180 AUTOV=`automake --version | sed -e '1{s/.* //;s/\.[0-9]\+$//};q'`
293 automake --version 181 automake --version
294 echo "AUTOV is $AUTOV" 182 echo "AUTOV is $AUTOV"