diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-08-06 11:06:35 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-08-11 09:14:21 -0700 |
commit | 1e6cf8073b6996ae173242991facae058db37bcf (patch) | |
tree | 8b0054778e8ed9c2e3ab7419d0be8c4ffcdd6423 | |
parent | edf27485eb566abae809517520a9adbc242b8b39 (diff) |
When building the dbg package, we use a large 'for module in $(find' loop that
can be easily parallelized by using 'find | xargs'. This patch modifies this
loop to use the later paradigm.
In addition, check if the user has requested a parallel build with make. If so,
add the appropriate flags to xargs to set MAXPROCS (-P) equal to the number of
processing units on the system.
Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
-rwxr-xr-x | scripts/package/builddeb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 91a502bb97e8..99b15fd8eb6b 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -165,16 +165,21 @@ if is_enabled CONFIG_MODULES; then rmdir "$tmpdir/lib/modules/$version" fi if [ -n "$BUILD_DEBUG" ] ; then - for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do - module=lib/modules/$module - mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) + # If we've invoked make with -j, then parallelize; otherwise + # just use a single process. + procs=1 + test "${MAKEFLAGS#*-j}" != "${MAKEFLAGS}" && procs=`getconf _NPROCESSORS_ONLN` + find $tmpdir/lib/modules/ -name *.ko -printf '%P\n' | xargs -n1 -P${procs} -I {} sh -c ' + mkdir -p $(dirname '"$dbg_dir"'/usr/lib/debug/lib/modules/$1);'" # only keep debug symbols in the debug file - $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module + $OBJCOPY --only-keep-debug $tmpdir/lib/modules/{} \ + $dbg_dir/usr/lib/debug/lib/modules/{}; # strip original module from debug symbols - $OBJCOPY --strip-debug $tmpdir/$module + $OBJCOPY --strip-debug $tmpdir/lib/modules/{}; # then add a link to those - $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module - done + $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/lib/modules/{} \ + $tmpdir/lib/modules/{}; + " -- {} # resign stripped modules if is_enabled CONFIG_MODULE_SIG_ALL; then |