Bug 6390 - Add section on fixing parallel make races
Summary: Add section on fixing parallel make races
Status: RESOLVED FIXED
Alias: None
Product: Development Manual
Classification: Documentation
Component: development (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 1.7 M3
Assignee: Scott Rifenbark
QA Contact:
URL:
Whiteboard: 31 July 2014: RESOLVED
Depends on:
Blocks:
 
Reported: 2014-05-30 10:25 UTC by Richard Purdie
Modified: 2014-07-31 09:20 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Done (doc changes complete)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Purdie 2014-05-30 10:25:43 UTC
We should have a section in the development about debugging parallel make races. Some proposed text follows from a real world example:

Case study in a parallel make race
==================================

Parallel make races are annoying but there are some simple tips and tricks which can help debug and fix them. What follows is a real world example of an error encountered on the Yocto Project autobuilder and the steps through the process of fixing it. The failure was:

"""
Log data follows:
| DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
| DEBUG: Executing shell function do_compile
| NOTE: make -j 16
| make --no-print-directory all-am
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/types.h include/near/types.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/log.h include/near/log.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/tag.h include/near/tag.h
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/setting.h include/near/setting.h
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| /bin/mkdir -p include/near
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/device.h include/near/device.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/snep.h include/near/snep.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/version.h include/near/version.h
| ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
| ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
| i586-poky-linux-gcc  -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I.  -I./include -I./src -I./gdbus  -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/glib-2.0/include  -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include  -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3   -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\" -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c -o tools/snep-send.o tools/snep-send.c
| In file included from tools/snep-send.c:16:0:
| tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
|  #include <near/dbus.h>
|                        ^
| compilation terminated.
| make[1]: *** [tools/snep-send.o] Error 1
| make[1]: *** Waiting for unfinished jobs....
| make: *** [all] Error 2
| ERROR: oe_runmake failed
"""

The error occurred in "neard". The first thing to note is that whilst this has failed once, in general it builds fine with no errors. The first question is therefore how do you reproduce it?

Firstly, you need a build, a:

$ bitbake neard

in a local build is the place to start with PARALLEL_MAKE set to something high like 20. This build will still likely succeed. You can then start a devshell in this build with:

$ bitbake neard -c devshell

in the devshell:

$ make clean
$ make tools/snep-send.o

which causes the failure to be clearly visible. There is a missing dependency for this makefile target. The Makefile is generated from Makefile.in which is generated from Makefile.am. We therefore need to patch Makefile.am to add that missing dependency.

$ quilt new parallelmake.patch
$ quilt add Makefile.am
<edit Makefile.am to add missing dependency>
<in this case we need to add the line "tools/snep-send.$(OBJEXT): include/near/dbus.h"
$ quilt refresh

We now have a parallelmake.patch file which we can add back to the 
origin recipe. We therefore cp patches/parallelmake.patch back to the 
neard recipe directory and add it as a patch to SRC_URI in the recipe. 
We can exit the devshell.

We can then try an rebuild neard:

$ bitbake neard

which succeeds. We can then test our fix by running devshell again, repeating our "make clean; make tools/snep-send.o" and this time we find the build works. We can then submit the fix both to the recipe in OE-Core and to upstream to get the problem fixed there.
Comment 1 Scott Rifenbark 2014-06-12 15:23:39 UTC
Hi, 

There is a new section in place named "Debugging Parallel Make Races" at http://www.yoctoproject.org/docs/1.7/dev-manual/dev-manual.html#debugging-parallel-make-races.

The section has been tested by me and it works.  It needs a review.

Thanks, 
Scott
Comment 2 Scott Rifenbark 2014-06-19 04:49:17 UTC
Changing the target milestone to M3 for 1.7 since M1 has passed.  Still needs reviewed.

Scott
Comment 3 Scott Rifenbark 2014-07-29 06:38:00 UTC
Hi, 

Refreshing this comment string and adding Richard Purdie to list.  I need a review of this new section. 

Thanks, 
Scott
Comment 4 Richard Purdie 2014-07-31 08:48:58 UTC
Section looks good to me, thanks Scott!
Comment 5 Scott Rifenbark 2014-07-31 09:20:24 UTC
Hi, 

Richard has approved this section.  I am marking the status RESOLVED and turning the documentation flag to "Done."

Thanks, 
Scott