Pull Kbuild updates from Masahiro Yamada: - do not generate unneeded top-level built-in.a - let git ignore O= directory entirely - optimize scripts/kallsyms slightly - exclude DWARF info from *.s regardless of config options - fix GCC toolchain search path for Clang to prepare ld.lld support - do not generate modules.order when CONFIG_MODULES is disabled - simplify single target rules and remove VPATH for external module build - allow to add optional flags to dpkg-buildpackage when building deb-pkg - move some compiler option tests from Makefile to Kconfig - various Makefile cleanups * tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits) kbuild: remove scripts/basic/% build target kbuild: use -Werror=implicit-... instead of -Werror-implicit-... kbuild: clean up scripts/gcc-version.sh kbuild: remove cc-version macro kbuild: update comment block of scripts/clang-version.sh kbuild: remove commented-out INITRD_COMPRESS kbuild: move -gsplit-dwarf, -gdwarf-4 option tests to Kconfig kbuild: [bin]deb-pkg: add DPKG_FLAGS variable kbuild: move ".config not found!" message from Kconfig to Makefile kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing kbuild: simplify single target rules kbuild: remove empty rules for makefiles kbuild: make -r/-R effective in top Makefile for old Make versions kbuild: move tools_silent to a more relevant place kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig kbuild: refactor cc-cross-prefix implementation kbuild: hardcode genksyms path and remove GENKSYMS variable scripts/gdb: refactor rules for symlink creation kbuild: create symlink to vmlinux-gdb.py in scripts_gdb target scripts/gdb: do not descend into scripts/gdb from scripts ...
Showing the changes to scripts (18 of 33 files). Show all
Unified · Split
| @@ -23,6 +23,10 @@ depfile = $(subst $(comma),_,$(dot-target).d) · 22 unmodified lines | ||
| 23 | 23 | # filename of target with directory and extension stripped |
| 24 | 24 | basetarget = $(basename $(notdir $@)) |
| 25 | 25 | |
| 26 | +### | |
| 27 | +# real prerequisites without phony targets | |
| 28 | +real-prereqs = $(filter-out $(PHONY), $^) | |
| 29 | + | |
| 26 | 30 | ### |
| 27 | 31 | # Escape single quote for use in echo statements |
| 28 | 32 | escsq = $(subst $(squote),'\$(squote)',$1) |
| @@ -67,14 +71,10 @@ endef · 38 unmodified lines | ||
| 67 | 71 | |
| 68 | 72 | # cc-cross-prefix |
| 69 | 73 | # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) |
| 70 | −# Return first prefix where a prefix$(CC) is found in PATH. | |
| 71 | −# If no $(CC) found in PATH with listed prefixes return nothing | |
| 72 | −cc-cross-prefix = \ | |
| 73 | − $(word 1, $(foreach c,$(1), \ | |
| 74 | − $(shell set -e; \ | |
| 75 | − if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ | |
| 76 | − echo $(c); \ | |
| 77 | − fi))) | |
| 74 | +# Return first <prefix> where a <prefix>gcc is found in PATH. | |
| 75 | +# If no gcc found in PATH with listed prefixes return nothing | |
| 76 | +cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \ | |
| 77 | + $(if $(shell which $(c)gcc), $(c)))) | |
| 78 | 78 | |
| 79 | 79 | # output directory for tests below |
| 80 | 80 | TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) |
| @@ -134,12 +134,9 @@ cc-option-yn = $(call try-run,\ · 53 unmodified lines | ||
| 134 | 134 | cc-disable-warning = $(call try-run,\ |
| 135 | 135 | $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) |
| 136 | 136 | |
| 137 | −# cc-version | |
| 138 | −cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) | |
| 139 | − | |
| 140 | 137 | # cc-ifversion |
| 141 | 138 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) |
| 142 | −cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) | |
| 139 | +cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) | |
| 143 | 140 | |
| 144 | 141 | # cc-ldoption |
| 145 | 142 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) |
| @@ -27,4 +27,4 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) · 26 unmodified lines | ||
| 27 | 27 | ld-option = $(success,$(LD) -v $(1)) |
| 28 | 28 | |
| 29 | 29 | # gcc version including patch level |
| 30 | −gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') | |
| 30 | +gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) | |
| @@ -39,7 +39,6 @@ build_unifdef: $(obj)/unifdef · 38 unmodified lines | ||
| 39 | 39 | subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins |
| 40 | 40 | subdir-$(CONFIG_MODVERSIONS) += genksyms |
| 41 | 41 | subdir-$(CONFIG_SECURITY_SELINUX) += selinux |
| 42 | −subdir-$(CONFIG_GDB_SCRIPTS) += gdb | |
| 43 | 42 | |
| 44 | 43 | # Let clean descend into subdirs |
| 45 | −subdir- += basic dtc kconfig mod package | |
| 44 | +subdir- += basic dtc gdb kconfig mod package | |
| @@ -63,7 +63,9 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),) · 62 unmodified lines | ||
| 63 | 63 | builtin-target := $(obj)/built-in.a |
| 64 | 64 | endif |
| 65 | 65 | |
| 66 | +ifdef CONFIG_MODULES | |
| 66 | 67 | modorder-target := $(obj)/modules.order |
| 68 | +endif | |
| 67 | 69 | |
| 68 | 70 | # We keep a list of all modules in $(MODVERDIR) |
| 69 | 71 | |
| @@ -104,7 +106,7 @@ modkern_cflags = \ · 34 unmodified lines | ||
| 104 | 106 | quiet_modtag = $(if $(part-of-module),[M], ) |
| 105 | 107 | |
| 106 | 108 | quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ |
| 107 | −cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< | |
| 109 | + cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< | |
| 108 | 110 | |
| 109 | 111 | $(obj)/%.s: $(src)/%.c FORCE |
| 110 | 112 | $(call if_changed_dep,cc_s_c) |
| @@ -118,7 +120,7 @@ $(obj)/%.i: $(src)/%.c FORCE · 7 unmodified lines | ||
| 118 | 120 | # These mirror gensymtypes_S and co below, keep them in synch. |
| 119 | 121 | cmd_gensymtypes_c = \ |
| 120 | 122 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
| 121 | − $(GENKSYMS) $(if $(1), -T $(2)) \ | |
| 123 | + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ | |
| 122 | 124 | $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ |
| 123 | 125 | $(if $(KBUILD_PRESERVE),-p) \ |
| 124 | 126 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
| @@ -312,13 +314,13 @@ $(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) · 187 unmodified lines | ||
| 312 | 314 | # |
| 313 | 315 | # These mirror gensymtypes_c and co above, keep them in synch. |
| 314 | 316 | cmd_gensymtypes_S = \ |
| 315 | − (echo "\#include <linux/kernel.h>" ; \ | |
| 317 | + { echo "\#include <linux/kernel.h>" ; \ | |
| 316 | 318 | echo "\#include <asm/asm-prototypes.h>" ; \ |
| 317 | 319 | $(CPP) $(a_flags) $< | \ |
| 318 | 320 | grep "\<___EXPORT_SYMBOL\>" | \ |
| 319 | − sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ | |
| 321 | + sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ | |
| 320 | 322 | $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ |
| 321 | − $(GENKSYMS) $(if $(1), -T $(2)) \ | |
| 323 | + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ | |
| 322 | 324 | $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ |
| 323 | 325 | $(if $(KBUILD_PRESERVE),-p) \ |
| 324 | 326 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
| @@ -394,17 +396,12 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler · 69 unmodified lines | ||
| 394 | 396 | $(sort $(subdir-obj-y)): $(subdir-ym) ; |
| 395 | 397 | |
| 396 | 398 | # |
| 397 | −# Rule to compile a set of .o files into one .o file | |
| 399 | +# Rule to compile a set of .o files into one .a file (without symbol table) | |
| 398 | 400 | # |
| 399 | 401 | ifdef builtin-target |
| 400 | 402 | |
| 401 | −# built-in.a archives are made with no symbol table or index which | |
| 402 | −# makes them small and fast, but unable to be used by the linker. | |
| 403 | −# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol | |
| 404 | −# table and index. | |
| 405 | 403 | quiet_cmd_ar_builtin = AR $@ |
| 406 | − cmd_ar_builtin = rm -f $@; \ | |
| 407 | − $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^) | |
| 404 | + cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 408 | 405 | |
| 409 | 406 | $(builtin-target): $(real-obj-y) FORCE |
| 410 | 407 | $(call if_changed,ar_builtin) |
| @@ -426,13 +423,13 @@ $(modorder-target): $(subdir-ym) FORCE · 15 unmodified lines | ||
| 426 | 423 | $(Q)(cat /dev/null; $(modorder-cmds)) > $@ |
| 427 | 424 | |
| 428 | 425 | # |
| 429 | −# Rule to compile a set of .o files into one .a file | |
| 426 | +# Rule to compile a set of .o files into one .a file (with symbol table) | |
| 430 | 427 | # |
| 431 | 428 | ifdef lib-target |
| 432 | 429 | quiet_cmd_link_l_target = AR $@ |
| 433 | 430 | |
| 434 | 431 | # lib target archives do get a symbol table and index |
| 435 | −cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) | |
| 432 | +cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) | |
| 436 | 433 | |
| 437 | 434 | $(lib-target): $(lib-y) FORCE |
| 438 | 435 | $(call if_changed,link_l_target) |
| @@ -457,6 +454,10 @@ targets += $(obj)/lib-ksyms.o · 18 unmodified lines | ||
| 457 | 454 | |
| 458 | 455 | endif |
| 459 | 456 | |
| 457 | +# NOTE: | |
| 458 | +# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object | |
| 459 | +# module is turned into a multi object module, $^ will contain header file | |
| 460 | +# dependencies recorded in the .*.cmd file. | |
| 460 | 461 | quiet_cmd_link_multi-m = LD [M] $@ |
| 461 | 462 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) |
| 462 | 463 | |
| @@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ · 66 unmodified lines | ||
| 67 | 67 | _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ |
| 68 | 68 | $(HOSTCXXFLAGS_$(basetarget).o) |
| 69 | 69 | |
| 70 | −ifeq ($(KBUILD_SRC),) | |
| 71 | 70 | __hostc_flags = $(_hostc_flags) |
| 72 | 71 | __hostcxx_flags = $(_hostcxx_flags) |
| 73 | −else | |
| 72 | + | |
| 73 | +ifeq ($(KBUILD_EXTMOD),) | |
| 74 | +ifneq ($(KBUILD_SRC),) | |
| 74 | 75 | __hostc_flags = -I$(obj) $(call flags,_hostc_flags) |
| 75 | 76 | __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) |
| 76 | 77 | endif |
| 78 | +endif | |
| 77 | 79 | |
| 78 | 80 | hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) |
| 79 | 81 | hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) |
| @@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \ · 136 unmodified lines | ||
| 137 | 137 | $(CFLAGS_KCOV)) |
| 138 | 138 | endif |
| 139 | 139 | |
| 140 | −# If building the kernel in a separate objtree expand all occurrences | |
| 141 | −# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). | |
| 142 | − | |
| 143 | −ifeq ($(KBUILD_SRC),) | |
| 144 | 140 | __c_flags = $(_c_flags) |
| 145 | 141 | __a_flags = $(_a_flags) |
| 146 | 142 | __cpp_flags = $(_cpp_flags) |
| 147 | −else | |
| 143 | + | |
| 144 | +# If building the kernel in a separate objtree expand all occurrences | |
| 145 | +# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). | |
| 146 | +ifeq ($(KBUILD_EXTMOD),) | |
| 147 | +ifneq ($(KBUILD_SRC),) | |
| 148 | 148 | |
| 149 | 149 | # -I$(obj) locates generated .h files |
| 150 | 150 | # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files |
| @@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ · 4 unmodified lines | ||
| 155 | 155 | __a_flags = $(call flags,_a_flags) |
| 156 | 156 | __cpp_flags = $(call flags,_cpp_flags) |
| 157 | 157 | endif |
| 158 | +endif | |
| 158 | 159 | |
| 159 | 160 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 160 | 161 | -include $(srctree)/include/linux/compiler_types.h \ |
| @@ -230,7 +231,7 @@ $(obj)/%: $(src)/%_shipped · 69 unmodified lines | ||
| 230 | 231 | # --------------------------------------------------------------------------- |
| 231 | 232 | |
| 232 | 233 | quiet_cmd_ld = LD $@ |
| 233 | −cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ | |
| 234 | + cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ | |
| 234 | 235 | |
| 235 | 236 | # Objcopy |
| 236 | 237 | # --------------------------------------------------------------------------- |
| @@ -242,7 +243,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ · 5 unmodified lines | ||
| 242 | 243 | # --------------------------------------------------------------------------- |
| 243 | 244 | |
| 244 | 245 | quiet_cmd_gzip = GZIP $@ |
| 245 | − cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ | |
| 246 | + cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ | |
| 246 | 247 | |
| 247 | 248 | # DTC |
| 248 | 249 | # --------------------------------------------------------------------------- |
| @@ -270,7 +271,7 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) · 21 unmodified lines | ||
| 270 | 271 | # Generate an assembly file to wrap the output of the device tree compiler |
| 271 | 272 | quiet_cmd_dt_S_dtb= DTB $@ |
| 272 | 273 | cmd_dt_S_dtb= \ |
| 273 | −( \ | |
| 274 | +{ \ | |
| 274 | 275 | echo '\#include <asm-generic/vmlinux.lds.h>'; \ |
| 275 | 276 | echo '.section .dtb.init.rodata,"a"'; \ |
| 276 | 277 | echo '.balign STRUCT_ALIGNMENT'; \ |
| @@ -280,7 +281,7 @@ cmd_dt_S_dtb= \ · 3 unmodified lines | ||
| 280 | 281 | echo '__dtb_$(subst -,_,$(*F))_end:'; \ |
| 281 | 282 | echo '.global __dtb_$(subst -,_,$(*F))_end'; \ |
| 282 | 283 | echo '.balign STRUCT_ALIGNMENT'; \ |
| 283 | −) > $@ | |
| 284 | +} > $@ | |
| 284 | 285 | |
| 285 | 286 | $(obj)/%.dtb.S: $(obj)/%.dtb FORCE |
| 286 | 287 | $(call if_changed,dt_S_dtb) |
| @@ -320,7 +321,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) · 33 unmodified lines | ||
| 320 | 321 | # append the size as a 32-bit littleendian number as gzip does. |
| 321 | 322 | size_append = printf $(shell \ |
| 322 | 323 | dec_size=0; \ |
| 323 | −for F in $1; do \ | |
| 324 | +for F in $(real-prereqs); do \ | |
| 324 | 325 | fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ |
| 325 | 326 | dec_size=$$(expr $$dec_size + $$fsize); \ |
| 326 | 327 | done; \ |
| @@ -334,23 +335,20 @@ printf "%08x\n" $$dec_size | \ · 7 unmodified lines | ||
| 334 | 335 | ) |
| 335 | 336 | |
| 336 | 337 | quiet_cmd_bzip2 = BZIP2 $@ |
| 337 | −cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ | |
| 338 | − bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ | |
| 338 | + cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@ | |
| 339 | 339 | |
| 340 | 340 | # Lzma |
| 341 | 341 | # --------------------------------------------------------------------------- |
| 342 | 342 | |
| 343 | 343 | quiet_cmd_lzma = LZMA $@ |
| 344 | −cmd_lzma = (cat $(filter-out FORCE,$^) | \ | |
| 345 | − lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ | |
| 344 | + cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@ | |
| 346 | 345 | |
| 347 | 346 | quiet_cmd_lzo = LZO $@ |
| 348 | −cmd_lzo = (cat $(filter-out FORCE,$^) | \ | |
| 349 | − lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ | |
| 347 | + cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@ | |
| 350 | 348 | |
| 351 | 349 | quiet_cmd_lz4 = LZ4 $@ |
| 352 | −cmd_lz4 = (cat $(filter-out FORCE,$^) | \ | |
| 353 | − lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ | |
| 350 | + cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \ | |
| 351 | + $(size_append); } > $@ | |
| 354 | 352 | |
| 355 | 353 | # U-Boot mkimage |
| 356 | 354 | # --------------------------------------------------------------------------- |
| @@ -392,13 +390,11 @@ quiet_cmd_uimage = UIMAGE $@ · 35 unmodified lines | ||
| 392 | 390 | # big dictionary would increase the memory usage too much in the multi-call |
| 393 | 391 | # decompression mode. A BCJ filter isn't used either. |
| 394 | 392 | quiet_cmd_xzkern = XZKERN $@ |
| 395 | −cmd_xzkern = (cat $(filter-out FORCE,$^) | \ | |
| 396 | − sh $(srctree)/scripts/xz_wrap.sh && \ | |
| 397 | − $(call size_append, $(filter-out FORCE,$^))) > $@ | |
| 393 | + cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh && \ | |
| 394 | + $(size_append); } > $@ | |
| 398 | 395 | |
| 399 | 396 | quiet_cmd_xzmisc = XZMISC $@ |
| 400 | −cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ | |
| 401 | − xz --check=crc32 --lzma2=dict=1MiB) > $@ | |
| 397 | + cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ | |
| 402 | 398 | |
| 403 | 399 | # ASM offsets |
| 404 | 400 | # --------------------------------------------------------------------------- |
| @@ -122,7 +122,7 @@ quiet_cmd_ld_ko_o = LD [M] $@ · 121 unmodified lines | ||
| 122 | 122 | cmd_ld_ko_o = \ |
| 123 | 123 | $(LD) -r $(KBUILD_LDFLAGS) \ |
| 124 | 124 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
| 125 | − -o $@ $(filter-out FORCE,$^) ; \ | |
| 125 | + -o $@ $(real-prereqs) ; \ | |
| 126 | 126 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) |
| 127 | 127 | |
| 128 | 128 | $(modules): %.ko :%.o %.mod.o FORCE |
| @@ -1,14 +1,10 @@ | ||
| 1 | 1 | #!/bin/sh |
| 2 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | # |
| 4 | −# clang-version [-p] clang-command | |
| 5 | −# | |
| 6 | −# Prints the compiler version of `clang-command' in a canonical 4-digit form | |
| 7 | −# such as `0500' for clang-5.0 etc. | |
| 8 | −# | |
| 9 | −# With the -p option, prints the patchlevel as well, for example `050001' for | |
| 10 | −# clang-5.0.1 etc. | |
| 4 | +# clang-version clang-command | |
| 11 | 5 | # |
| 6 | +# Print the compiler version of `clang-command' in a 5 or 6-digit form | |
| 7 | +# such as `50001' for clang-5.0.1 etc. | |
| 12 | 8 | |
| 13 | 9 | compiler="$*" |
| 14 | 10 | |
| @@ -1,33 +1,20 @@ | ||
| 1 | 1 | #!/bin/sh |
| 2 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | # |
| 4 | −# gcc-version [-p] gcc-command | |
| 5 | −# | |
| 6 | −# Prints the gcc version of `gcc-command' in a canonical 4-digit form | |
| 7 | −# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. | |
| 8 | −# | |
| 9 | −# With the -p option, prints the patchlevel as well, for example `029503' for | |
| 10 | −# gcc-2.95.3, `030301' for gcc-3.3.1, etc. | |
| 4 | +# gcc-version gcc-command | |
| 11 | 5 | # |
| 12 | − | |
| 13 | −if [ "$1" = "-p" ] ; then | |
| 14 | − with_patchlevel=1; | |
| 15 | − shift; | |
| 16 | −fi | |
| 6 | +# Print the gcc version of `gcc-command' in a 5 or 6-digit form | |
| 7 | +# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc. | |
| 17 | 8 | |
| 18 | 9 | compiler="$*" |
| 19 | 10 | |
| 20 | 11 | if [ ${#compiler} -eq 0 ]; then |
| 21 | − echo "Error: No compiler specified." | |
| 22 | − printf "Usage:\n\t$0 <gcc-command>\n" | |
| 12 | + echo "Error: No compiler specified." >&2 | |
| 13 | + printf "Usage:\n\t$0 <gcc-command>\n" >&2 | |
| 23 | 14 | exit 1 |
| 24 | 15 | fi |
| 25 | 16 | |
| 26 | 17 | MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) |
| 27 | 18 | MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) |
| 28 | −if [ "x$with_patchlevel" != "x" ] ; then | |
| 29 | − PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) | |
| 30 | − printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | |
| 31 | −else | |
| 32 | − printf "%02d%02d\\n" $MAJOR $MINOR | |
| 33 | −fi | |
| 19 | +PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) | |
| 20 | +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | |
| @@ -1,24 +1,25 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | −always := gdb-scripts | |
| 3 | 2 | |
| 4 | −SRCTREE := $(abspath $(srctree)) | |
| 5 | − | |
| 6 | −$(obj)/gdb-scripts: | |
| 7 | 3 | ifneq ($(KBUILD_SRC),) |
| 8 | − $(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj) | |
| 4 | + | |
| 5 | +symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py)) | |
| 6 | + | |
| 7 | +quiet_cmd_symlink = SYMLINK $@ | |
| 8 | + cmd_symlink = ln -fsn $(patsubst $(obj)/%,$(abspath $(srctree))/$(src)/%,$@) $@ | |
| 9 | + | |
| 10 | +extra-y += $(symlinks) | |
| 11 | +$(addprefix $(obj)/, $(symlinks)): FORCE | |
| 12 | + $(call if_changed,symlink) | |
| 13 | + | |
| 9 | 14 | endif |
| 10 | − @: | |
| 11 | 15 | |
| 12 | 16 | quiet_cmd_gen_constants_py = GEN $@ |
| 13 | 17 | cmd_gen_constants_py = \ |
| 14 | 18 | $(CPP) -E -x c -P $(c_flags) $< > $@ ;\ |
| 15 | 19 | sed -i '1,/<!-- end-c-headers -->/d;' $@ |
| 16 | 20 | |
| 17 | −targets += constants.py | |
| 18 | −$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in FORCE | |
| 21 | +extra-y += constants.py | |
| 22 | +$(obj)/constants.py: $(src)/constants.py.in FORCE | |
| 19 | 23 | $(call if_changed_dep,gen_constants_py) |
| 20 | 24 | |
| 21 | −build_constants_py: $(obj)/constants.py | |
| 22 | − @: | |
| 23 | − | |
| 24 | −clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py | |
| 25 | +clean-files := *.pyc *.pyo | |
| @@ -62,11 +62,11 @@ static int all_symbols = 0; · 61 unmodified lines | ||
| 62 | 62 | static int absolute_percpu = 0; |
| 63 | 63 | static int base_relative = 0; |
| 64 | 64 | |
| 65 | −int token_profit[0x10000]; | |
| 65 | +static int token_profit[0x10000]; | |
| 66 | 66 | |
| 67 | 67 | /* the table that holds the result of the compression */ |
| 68 | −unsigned char best_table[256][2]; | |
| 69 | −unsigned char best_table_len[256]; | |
| 68 | +static unsigned char best_table[256][2]; | |
| 69 | +static unsigned char best_table_len[256]; | |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | static void usage(void) |
| @@ -80,7 +80,7 @@ static void usage(void) · 7 unmodified lines | ||
| 80 | 80 | * This ignores the intensely annoying "mapping symbols" found |
| 81 | 81 | * in ARM ELF files: $a, $t and $d. |
| 82 | 82 | */ |
| 83 | −static inline int is_arm_mapping_symbol(const char *str) | |
| 83 | +static int is_arm_mapping_symbol(const char *str) | |
| 84 | 84 | { |
| 85 | 85 | return str[0] == '$' && strchr("axtd", str[1]) |
| 86 | 86 | && (str[2] == '\0' || str[2] == '.'); |
| @@ -331,7 +331,7 @@ static void write_src(void) · 244 unmodified lines | ||
| 331 | 331 | unsigned int *markers; |
| 332 | 332 | char buf[KSYM_NAME_LEN]; |
| 333 | 333 | |
| 334 | − printf("#include <asm/types.h>\n"); | |
| 334 | + printf("#include <asm/bitsperlong.h>\n"); | |
| 335 | 335 | printf("#if BITS_PER_LONG == 64\n"); |
| 336 | 336 | printf("#define PTR .quad\n"); |
| 337 | 337 | printf("#define ALGN .balign 8\n"); |
| @@ -596,9 +596,6 @@ static void insert_real_symbols_in_table(void) · 258 unmodified lines | ||
| 596 | 596 | { |
| 597 | 597 | unsigned int i, j, c; |
| 598 | 598 | |
| 599 | − memset(best_table, 0, sizeof(best_table)); | |
| 600 | − memset(best_table_len, 0, sizeof(best_table_len)); | |
| 601 | − | |
| 602 | 599 | for (i = 0; i < table_cnt; i++) { |
| 603 | 600 | for (j = 0; j < table[i].len; j++) { |
| 604 | 601 | c = table[i].sym[j]; |
| @@ -488,7 +488,6 @@ int main(int ac, char **av) · 487 unmodified lines | ||
| 488 | 488 | const char *progname = av[0]; |
| 489 | 489 | int opt; |
| 490 | 490 | const char *name, *defconfig_file = NULL /* gcc uninit */; |
| 491 | − struct stat tmpstat; | |
| 492 | 491 | int no_conf_write = 0; |
| 493 | 492 | |
| 494 | 493 | tty_stdio = isatty(0) && isatty(1); |
| @@ -560,18 +559,6 @@ int main(int ac, char **av) · 65 unmodified lines | ||
| 560 | 559 | name = av[optind]; |
| 561 | 560 | conf_parse(name); |
| 562 | 561 | //zconfdump(stdout); |
| 563 | − if (sync_kconfig) { | |
| 564 | − name = conf_get_configname(); | |
| 565 | − if (stat(name, &tmpstat)) { | |
| 566 | − fprintf(stderr, "***\n" | |
| 567 | − "*** Configuration file \"%s\" not found!\n" | |
| 568 | − "***\n" | |
| 569 | − "*** Please run some configurator (e.g. \"make oldconfig\" or\n" | |
| 570 | − "*** \"make menuconfig\" or \"make xconfig\").\n" | |
| 571 | − "***\n", name); | |
| 572 | − exit(1); | |
| 573 | − } | |
| 574 | − } | |
| 575 | 562 | |
| 576 | 563 | switch (input_mode) { |
| 577 | 564 | case defconfig: |
| @@ -3,22 +3,17 @@ · 2 unmodified lines | ||
| 3 | 3 | # |
| 4 | 4 | # link vmlinux |
| 5 | 5 | # |
| 6 | −# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and | |
| 7 | −# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files | |
| 8 | −# from top-level directories in the kernel tree, others are specified in | |
| 9 | −# arch/$(ARCH)/Makefile. Ordering when linking is important, and | |
| 10 | −# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives | |
| 11 | −# which are linked conditionally (not within --whole-archive), and do not | |
| 12 | −# require symbol indexes added. | |
| 6 | +# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and | |
| 7 | +# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories | |
| 8 | +# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. | |
| 9 | +# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally | |
| 10 | +# (not within --whole-archive), and do not require symbol indexes added. | |
| 13 | 11 | # |
| 14 | 12 | # vmlinux |
| 15 | 13 | # ^ |
| 16 | 14 | # | |
| 17 | −# +-< $(KBUILD_VMLINUX_INIT) | |
| 18 | −# | +--< init/version.o + more | |
| 19 | −# | | |
| 20 | −# +--< $(KBUILD_VMLINUX_MAIN) | |
| 21 | −# | +--< drivers/built-in.a mm/built-in.a + more | |
| 15 | +# +--< $(KBUILD_VMLINUX_OBJS) | |
| 16 | +# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more | |
| 22 | 17 | # | |
| 23 | 18 | # +--< $(KBUILD_VMLINUX_LIBS) |
| 24 | 19 | # | +--< lib/lib.a + more |
| @@ -44,24 +39,6 @@ info() · 19 unmodified lines | ||
| 44 | 39 | fi |
| 45 | 40 | } |
| 46 | 41 | |
| 47 | −# Thin archive build here makes a final archive with symbol table and indexes | |
| 48 | −# from vmlinux objects INIT and MAIN, which can be used as input to linker. | |
| 49 | −# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes | |
| 50 | −# added. | |
| 51 | −# | |
| 52 | −# Traditional incremental style of link does not require this step | |
| 53 | −# | |
| 54 | −# built-in.a output file | |
| 55 | −# | |
| 56 | −archive_builtin() | |
| 57 | −{ | |
| 58 | − info AR built-in.a | |
| 59 | − rm -f built-in.a; | |
| 60 | − ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \ | |
| 61 | − ${KBUILD_VMLINUX_INIT} \ | |
| 62 | − ${KBUILD_VMLINUX_MAIN} | |
| 63 | −} | |
| 64 | − | |
| 65 | 42 | # Link of vmlinux.o used for section mismatch analysis |
| 66 | 43 | # ${1} output file |
| 67 | 44 | modpost_link() |
| @@ -69,7 +46,7 @@ modpost_link() · 1 unmodified line | ||
| 69 | 46 | local objects |
| 70 | 47 | |
| 71 | 48 | objects="--whole-archive \ |
| 72 | − built-in.a \ | |
| 49 | + ${KBUILD_VMLINUX_OBJS} \ | |
| 73 | 50 | --no-whole-archive \ |
| 74 | 51 | --start-group \ |
| 75 | 52 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -88,7 +65,7 @@ vmlinux_link() · 12 unmodified lines | ||
| 88 | 65 | |
| 89 | 66 | if [ "${SRCARCH}" != "um" ]; then |
| 90 | 67 | objects="--whole-archive \ |
| 91 | − built-in.a \ | |
| 68 | + ${KBUILD_VMLINUX_OBJS} \ | |
| 92 | 69 | --no-whole-archive \ |
| 93 | 70 | --start-group \ |
| 94 | 71 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -99,7 +76,7 @@ vmlinux_link() · 4 unmodified lines | ||
| 99 | 76 | -T ${lds} ${objects} |
| 100 | 77 | else |
| 101 | 78 | objects="-Wl,--whole-archive \ |
| 102 | − built-in.a \ | |
| 79 | + ${KBUILD_VMLINUX_OBJS} \ | |
| 103 | 80 | -Wl,--no-whole-archive \ |
| 104 | 81 | -Wl,--start-group \ |
| 105 | 82 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -160,7 +137,6 @@ cleanup() · 54 unmodified lines | ||
| 160 | 137 | rm -f .tmp_System.map |
| 161 | 138 | rm -f .tmp_kallsyms* |
| 162 | 139 | rm -f .tmp_vmlinux* |
| 163 | − rm -f built-in.a | |
| 164 | 140 | rm -f System.map |
| 165 | 141 | rm -f vmlinux |
| 166 | 142 | rm -f vmlinux.o |
| @@ -217,8 +193,6 @@ fi; · 50 unmodified lines | ||
| 217 | 193 | # final build of init/ |
| 218 | 194 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init |
| 219 | 195 | |
| 220 | −archive_builtin | |
| 221 | − | |
| 222 | 196 | #link vmlinux.o |
| 223 | 197 | info LD vmlinux.o |
| 224 | 198 | modpost_link vmlinux.o |
| @@ -62,7 +62,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" · 61 unmodified lines | ||
| 62 | 62 | |
| 63 | 63 | # Generate a temporary compile.h |
| 64 | 64 | |
| 65 | −( echo /\* This file is auto generated, version $VERSION \*/ | |
| 65 | +{ echo /\* This file is auto generated, version $VERSION \*/ | |
| 66 | 66 | if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi |
| 67 | 67 | |
| 68 | 68 | echo \#define UTS_MACHINE \"$ARCH\" |
| @@ -73,7 +73,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" · 4 unmodified lines | ||
| 73 | 73 | echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" |
| 74 | 74 | |
| 75 | 75 | echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" |
| 76 | −) > .tmpcompile | |
| 76 | +} > .tmpcompile | |
| 77 | 77 | |
| 78 | 78 | # Only replace the real compile.h if the new one is different, |
| 79 | 79 | # in order to preserve the timestamp and avoid unnecessary |
| @@ -59,7 +59,7 @@ rpm-pkg: FORCE · 58 unmodified lines | ||
| 59 | 59 | # binrpm-pkg |
| 60 | 60 | # --------------------------------------------------------------------------- |
| 61 | 61 | binrpm-pkg: FORCE |
| 62 | − $(MAKE) KBUILD_SRC= | |
| 62 | + $(MAKE) -f $(srctree)/Makefile | |
| 63 | 63 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec |
| 64 | 64 | +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
| 65 | 65 | $(UTS_MACHINE) -bb $(objtree)/binkernel.spec |
| @@ -72,11 +72,11 @@ deb-pkg: FORCE · 6 unmodified lines | ||
| 72 | 72 | $(call cmd,src_tar,$(KDEB_SOURCENAME)) |
| 73 | 73 | origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ |
| 74 | 74 | mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz |
| 75 | − +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc | |
| 75 | + +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc | |
| 76 | 76 | |
| 77 | 77 | bindeb-pkg: FORCE |
| 78 | 78 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
| 79 | − +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc | |
| 79 | + +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc | |
| 80 | 80 | |
| 81 | 81 | intdeb-pkg: FORCE |
| 82 | 82 | +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb |
| @@ -102,7 +102,7 @@ clean-dirs += $(objtree)/snap/ · 19 unmodified lines | ||
| 102 | 102 | # tarball targets |
| 103 | 103 | # --------------------------------------------------------------------------- |
| 104 | 104 | tar%pkg: FORCE |
| 105 | − $(MAKE) KBUILD_SRC= | |
| 105 | + $(MAKE) -f $(srctree)/Makefile | |
| 106 | 106 | $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ |
| 107 | 107 | |
| 108 | 108 | clean-dirs += $(objtree)/tar-install/ |
| @@ -86,12 +86,12 @@ cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path" · 85 unmodified lines | ||
| 86 | 86 | if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then |
| 87 | 87 | # Only some architectures with OF support have this target |
| 88 | 88 | if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then |
| 89 | − $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install | |
| 89 | + $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install | |
| 90 | 90 | fi |
| 91 | 91 | fi |
| 92 | 92 | |
| 93 | 93 | if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then |
| 94 | − INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install | |
| 94 | + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install | |
| 95 | 95 | rm -f "$tmpdir/lib/modules/$version/build" |
| 96 | 96 | rm -f "$tmpdir/lib/modules/$version/source" |
| 97 | 97 | if [ "$ARCH" = "um" ] ; then |
| @@ -113,14 +113,14 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then · 15 unmodified lines | ||
| 113 | 113 | # resign stripped modules |
| 114 | 114 | MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" |
| 115 | 115 | if [ -n "$MODULE_SIG_ALL" ]; then |
| 116 | − INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign | |
| 116 | + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign | |
| 117 | 117 | fi |
| 118 | 118 | fi |
| 119 | 119 | fi |
| 120 | 120 | |
| 121 | 121 | if [ "$ARCH" != "um" ]; then |
| 122 | − $MAKE headers_check KBUILD_SRC= | |
| 123 | − $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" | |
| 122 | + $MAKE -f $srctree/Makefile headers_check | |
| 123 | + $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" | |
| 124 | 124 | fi |
| 125 | 125 | |
| 126 | 126 | # Install the maintainer scripts |
| @@ -57,7 +57,7 @@ dirs=boot · 56 unmodified lines | ||
| 57 | 57 | # Try to install modules |
| 58 | 58 | # |
| 59 | 59 | if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then |
| 60 | − make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install | |
| 60 | + make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install | |
| 61 | 61 | dirs="$dirs lib" |
| 62 | 62 | fi |
| 63 | 63 | |
| @@ -205,13 +205,15 @@ EOF · 204 unmodified lines | ||
| 205 | 205 | cat <<EOF > debian/rules |
| 206 | 206 | #!$(command -v $MAKE) -f |
| 207 | 207 | |
| 208 | +srctree ?= . | |
| 209 | + | |
| 208 | 210 | build: |
| 209 | 211 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ |
| 210 | − KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= | |
| 212 | + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile | |
| 211 | 213 | |
| 212 | 214 | binary-arch: |
| 213 | 215 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ |
| 214 | − KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg | |
| 216 | + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg | |
| 215 | 217 | |
| 216 | 218 | clean: |
| 217 | 219 | rm -rf debian/*tmp debian/files |