diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-11-29 20:05:26 -0500 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-01 09:13:14 -0500 |
| commit | bbda5ec671d3fe62faefa1cab7270aa586042a4b (patch) | |
| tree | a1d375f74ad25efd2797bffaadfb0dc5fc1f65fe /scripts/Kbuild.include | |
| parent | ee3e46b7efd2954479f87030d31fda3c22bbc763 (diff) | |
kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS
My main motivation of this commit is to clean up scripts/Kbuild.include
and scripts/Makefile.build.
Currently, CONFIG_TRIM_UNUSED_KSYMS works with a tricky gimmick;
possibly exported symbols are detected by letting $(CPP) replace
EXPORT_SYMBOL* with a special string '=== __KSYM_*===', which is
post-processed by sed, and passed to fixdep. The extra preprocessing
is costly, and hacking cmd_and_fixdep is ugly.
I came up with a new way to find exported symbols; insert a dummy
symbol __ksym_marker_* to each potentially exported symbol. Those
dummy symbols are picked up by $(NM), post-processed by sed, then
appended to .*.cmd files. I collected the post-process part to a
new shell script scripts/gen_ksymdeps.sh for readability. The dummy
symbols are put into the .discard.* section so that the linker
script rips them off the final vmlinux or modules.
A nice side-effect is building with CONFIG_TRIM_UNUSED_KSYMS will
be much faster.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Diffstat (limited to 'scripts/Kbuild.include')
| -rw-r--r-- | scripts/Kbuild.include | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6cf6a8b83b97..4b943f4d2226 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -260,39 +260,11 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ | |||
| 260 | @set -e; \ | 260 | @set -e; \ |
| 261 | $(cmd_and_fixdep), @:) | 261 | $(cmd_and_fixdep), @:) |
| 262 | 262 | ||
| 263 | ifndef CONFIG_TRIM_UNUSED_KSYMS | ||
| 264 | |||
| 265 | cmd_and_fixdep = \ | 263 | cmd_and_fixdep = \ |
| 266 | $(echo-cmd) $(cmd_$(1)); \ | 264 | $(echo-cmd) $(cmd_$(1)); \ |
| 267 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ | 265 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ |
| 268 | rm -f $(depfile); | 266 | rm -f $(depfile); |
| 269 | 267 | ||
| 270 | else | ||
| 271 | |||
| 272 | # Filter out exported kernel symbol names from the preprocessor output. | ||
| 273 | # See also __KSYM_DEPS__ in include/linux/export.h. | ||
| 274 | # We disable the depfile generation here, so as not to overwrite the existing | ||
| 275 | # depfile while fixdep is parsing it. | ||
| 276 | flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1))) | ||
| 277 | ksym_dep_filter = \ | ||
| 278 | case "$(1)" in \ | ||
| 279 | cc_*_c|cpp_i_c) \ | ||
| 280 | $(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;; \ | ||
| 281 | as_*_S|cpp_s_S) \ | ||
| 282 | $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ | ||
| 283 | boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \ | ||
| 284 | *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ | ||
| 285 | esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p' | ||
| 286 | |||
| 287 | cmd_and_fixdep = \ | ||
| 288 | $(echo-cmd) $(cmd_$(1)); \ | ||
| 289 | $(ksym_dep_filter) | \ | ||
| 290 | scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \ | ||
| 291 | > $(dot-target).cmd; \ | ||
| 292 | rm -f $(depfile); | ||
| 293 | |||
| 294 | endif | ||
| 295 | |||
| 296 | # Usage: $(call if_changed_rule,foo) | 268 | # Usage: $(call if_changed_rule,foo) |
| 297 | # Will check if $(cmd_foo) or any of the prerequisites changed, | 269 | # Will check if $(cmd_foo) or any of the prerequisites changed, |
| 298 | # and if so will execute $(rule_foo). | 270 | # and if so will execute $(rule_foo). |
