mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
scripts: kconfig: merge_config.sh: use awk in checks too
Converting from shell/sed/grep loop to awk improves runtime checks of Yocto genericarm64 kernel config from 20 seconds to under 1 second. The checks catch this kind of issues: WARNING: CONFIG_BLK_DEV_DM differs: Requested value: CONFIG_BLK_DEV_DM=y Actual value: CONFIG_BLK_DEV_DM=m WARNING: CONFIG_SECURITY_NETWORK differs: Requested value: CONFIG_SECURITY_NETWORK=n Actual value: CONFIG_SECURITY_NETWORK=y WARNING: Value requested for CONFIG_ARM64_BTI_KERNEL not in final .config Requested value: CONFIG_ARM64_BTI_KERNEL=y Actual value: Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> Link: https://patch.msgid.link/20260122105751.2186609-2-mikko.rapeli@linaro.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This commit is contained in:
parent
5fa9b82cbc
commit
dfc97e1c5d
|
|
@ -286,16 +286,91 @@ fi
|
||||||
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
|
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
|
||||||
make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
|
make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
|
||||||
|
|
||||||
|
# Check all specified config values took effect (might have missed-dependency issues)
|
||||||
|
if ! "$AWK" -v prefix="$CONFIG_PREFIX" \
|
||||||
|
-v warnoverride="$WARNOVERRIDE" \
|
||||||
|
-v strict="$STRICT" \
|
||||||
|
-v warnredun="$WARNREDUN" '
|
||||||
|
BEGIN {
|
||||||
|
strict_violated = 0
|
||||||
|
cfg_regex = "^" prefix "[a-zA-Z0-9_]+"
|
||||||
|
notset_regex = "^# " prefix "[a-zA-Z0-9_]+ is not set$"
|
||||||
|
}
|
||||||
|
|
||||||
# Check all specified config values took (might have missed-dependency issues)
|
# Extract config name from a line, returns "" if not a config line
|
||||||
for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
|
function get_cfg(line) {
|
||||||
|
if (match(line, cfg_regex)) {
|
||||||
|
return substr(line, RSTART, RLENGTH)
|
||||||
|
} else if (match(line, notset_regex)) {
|
||||||
|
# Extract CONFIG_FOO from "# CONFIG_FOO is not set"
|
||||||
|
sub(/^# /, "", line)
|
||||||
|
sub(/ is not set$/, "", line)
|
||||||
|
return line
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
|
function warn_mismatch(cfg, merged, final) {
|
||||||
ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG" || true)
|
if (warnredun == "true") return
|
||||||
if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
|
if (final == "" && !(merged ~ / is not set$/ || merged ~ /=n$/)) {
|
||||||
echo "Value requested for $CFG not in final .config"
|
print "WARNING: Value requested for " cfg " not in final .config"
|
||||||
echo "Requested value: $REQUESTED_VAL"
|
print "Requested value: " merged
|
||||||
echo "Actual value: $ACTUAL_VAL"
|
print "Actual value: " final
|
||||||
echo ""
|
} else if (final == "" && merged ~ / is not set$/) {
|
||||||
|
# not set, pass
|
||||||
|
} else if (merged == "" && final != "") {
|
||||||
|
print "WARNING: " cfg " not in merged config but added in final .config:"
|
||||||
|
print "Requested value: " merged
|
||||||
|
print "Actual value: " final
|
||||||
|
} else {
|
||||||
|
print "WARNING: " cfg " differs:"
|
||||||
|
print "Requested value: " merged
|
||||||
|
print "Actual value: " final
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# First pass: read effective config file, store all lines
|
||||||
|
FILENAME == ARGV[1] {
|
||||||
|
cfg = get_cfg($0)
|
||||||
|
if (cfg != "") {
|
||||||
|
config_cfg[cfg] = $0
|
||||||
|
}
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
# Second pass: process merged config and compare against effective config
|
||||||
|
{
|
||||||
|
cfg = get_cfg($0)
|
||||||
|
if (cfg == "") next
|
||||||
|
|
||||||
|
# strip trailing comment
|
||||||
|
sub(/[[:space:]]+#.*/, "", $0)
|
||||||
|
merged_val = $0
|
||||||
|
final_val = config_cfg[cfg]
|
||||||
|
|
||||||
|
if (merged_val == final_val) next
|
||||||
|
|
||||||
|
if (merged_val ~ /=n$/ && final_val ~ / is not set$/) next
|
||||||
|
if (merged_val ~ /=n$/ && final_val == "") next
|
||||||
|
|
||||||
|
warn_mismatch(cfg, merged_val, final_val)
|
||||||
|
|
||||||
|
if (strict == "true") {
|
||||||
|
strict_violated = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
if (strict_violated) {
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}' \
|
||||||
|
"$KCONFIG_CONFIG" "$TMP_FILE"; then
|
||||||
|
# awk exited non-zero, strict mode was violated
|
||||||
|
STRICT_MODE_VIOLATED=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$STRICT" == "true" ] && [ "$STRICT_MODE_VIOLATED" == "true" ]; then
|
||||||
|
echo "Requested and effective config differ"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user