History

kbuild: split adjust_autoksyms.sh in two parts

In order to prepare the ground for a build-time optimization, split adjust_autoksyms.sh into two scripts: one that generates autoksyms.h based on all currently available information (whitelist, and .mod files), and the other to inspect the diff between two versions of autoksyms.h and trigger appropriate rebuilds.

Quentin Perret committed 6 years ago

Commit cd195bc1 parent 1518c632 files · +55 −32Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/adjust_autoksyms.sh +4 −32
  2. scripts/gen_autoksyms.sh +51 −0
scripts/adjust_autoksyms.sh+4−32
@@ -1,14 +1,13 @@
1#!/bin/sh1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-only2# SPDX-License-Identifier: GPL-2.0-only
3 3
4# Script to create/update include/generated/autoksyms.h and dependency files4# Script to update include/generated/autoksyms.h and dependency files
5#5#
6# Copyright: (C) 2016 Linaro Limited6# Copyright: (C) 2016 Linaro Limited
7# Created by: Nicolas Pitre, January 20167# Created by: Nicolas Pitre, January 2016
8#8#
9 9
10# Create/update the include/generated/autoksyms.h file from the list10# Update the include/generated/autoksyms.h file.
11# of all module's needed symbols as recorded on the second line of *.mod files.
12#11#
13# For each symbol being added or removed, the corresponding dependency12# For each symbol being added or removed, the corresponding dependency
14# file's timestamp is updated to force a rebuild of the affected source13# file's timestamp is updated to force a rebuild of the affected source
@@ -38,35 +37,8 @@ esac · 23 unmodified lines
38# We need access to CONFIG_ symbols37# We need access to CONFIG_ symbols
39. include/config/auto.conf38. include/config/auto.conf
40 39
41ksym_wl=/dev/null40# Generate a new symbol list file
42if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then41$CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file"
43 # Use 'eval' to expand the whitelist path and check if it is relative
44 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
45 [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
46 if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
47 echo "ERROR: '$ksym_wl' whitelist file not found" >&2
48 exit 1
49 fi
50fi
51
52# Generate a new ksym list file with symbols needed by the current
53# set of modules.
54cat > "$new_ksyms_file" << EOT
55/*
56 * Automatically generated file; DO NOT EDIT.
57 */
58
59EOT
60sed 's/ko$/mod/' modules.order |
61xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
62cat - "$ksym_wl" |
63sort -u |
64sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$new_ksyms_file"
65
66# Special case for modversions (see modpost.c)
67if [ -n "$CONFIG_MODVERSIONS" ]; then
68 echo "#define __KSYM_module_layout 1" >> "$new_ksyms_file"
69fi
70 42
71# Extract changes between old and new list and touch corresponding43# Extract changes between old and new list and touch corresponding
72# dependency files.44# dependency files.
scripts/gen_autoksyms.sh+51−0
@@ -0,0 +1,51 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-only
3
4# Create an autoksyms.h header file from the list of all module's needed symbols
5# as recorded on the second line of *.mod files and the user-provided symbol
6# whitelist.
7
8set -e
9
10output_file="$1"
11
12# Use "make V=1" to debug this script.
13case "$KBUILD_VERBOSE" in
14*1*)
15 set -x
16 ;;
17esac
18
19# We need access to CONFIG_ symbols
20. include/config/auto.conf
21
22ksym_wl=/dev/null
23if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
24 # Use 'eval' to expand the whitelist path and check if it is relative
25 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
26 [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
27 if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
28 echo "ERROR: '$ksym_wl' whitelist file not found" >&2
29 exit 1
30 fi
31fi
32
33# Generate a new ksym list file with symbols needed by the current
34# set of modules.
35cat > "$output_file" << EOT
36/*
37 * Automatically generated file; DO NOT EDIT.
38 */
39
40EOT
41
42sed 's/ko$/mod/' modules.order |
43xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
44cat - "$ksym_wl" |
45sort -u |
46sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
47
48# Special case for modversions (see modpost.c)
49if [ -n "$CONFIG_MODVERSIONS" ]; then
50 echo "#define __KSYM_module_layout 1" >> "$output_file"
51fi