Merge tag 'kbuild-fixes-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

- fix linker script regression caused by dead code elimination support

- fix typos and outdated comments

- specify kselftest-clean as a PHONY target

- fix "make dtbs_install" when $(srctree) includes shell special
characters like '~'

- Move -fshort-wchar to the global option list because defining it
partially emits warnings

* tag 'kbuild-fixes-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kbuild: update comments of Makefile.asm-generic
kbuild: Do not use hyphen in exported variable name
Makefile: add kselftest-clean to PHONY target list
Kbuild: use -fshort-wchar globally
fixdep: trivial: typo fix and correction
kbuild: trivial cleanups on the comments
kbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is configured

+48 -37
+7 -6
Makefile
··· 396 396 KBUILD_CPPFLAGS := -D__KERNEL__ 397 397 398 398 KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 399 - -fno-strict-aliasing -fno-common \ 399 + -fno-strict-aliasing -fno-common -fshort-wchar \ 400 400 -Werror-implicit-function-declaration \ 401 401 -Wno-format-security \ 402 402 -std=gnu89 $(call cc-option,-fno-PIE) ··· 442 442 # =========================================================================== 443 443 # Rules shared between *config targets and build targets 444 444 445 - # Basic helpers built in scripts/ 445 + # Basic helpers built in scripts/basic/ 446 446 PHONY += scripts_basic 447 447 scripts_basic: 448 448 $(Q)$(MAKE) $(build)=scripts/basic ··· 505 505 endif 506 506 endif 507 507 endif 508 - # install and module_install need also be processed one by one 508 + # install and modules_install need also be processed one by one 509 509 ifneq ($(filter install,$(MAKECMDGOALS)),) 510 510 ifneq ($(filter modules_install,$(MAKECMDGOALS)),) 511 511 mixed-targets := 1 ··· 964 964 export KBUILD_VMLINUX_LIBS := $(libs-y1) 965 965 export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 966 966 export LDFLAGS_vmlinux 967 - # used by scripts/pacmage/Makefile 967 + # used by scripts/package/Makefile 968 968 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) 969 969 970 970 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) ··· 992 992 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 993 993 994 994 # Final link of vmlinux with optional arch pass after final link 995 - cmd_link-vmlinux = \ 996 - $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ 995 + cmd_link-vmlinux = \ 996 + $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ 997 997 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 998 998 999 999 vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE ··· 1184 1184 kselftest: 1185 1185 $(Q)$(MAKE) -C tools/testing/selftests run_tests 1186 1186 1187 + PHONY += kselftest-clean 1187 1188 kselftest-clean: 1188 1189 $(Q)$(MAKE) -C tools/testing/selftests clean 1189 1190
-3
drivers/xen/Makefile
··· 7 7 nostackp := $(call cc-option, -fno-stack-protector) 8 8 CFLAGS_features.o := $(nostackp) 9 9 10 - CFLAGS_efi.o += -fshort-wchar 11 - LDFLAGS += $(call ld-option, --no-wchar-size-warning) 12 - 13 10 dom0-$(CONFIG_ARM64) += arm-device.o 14 11 dom0-$(CONFIG_PCI) += pci.o 15 12 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
+26 -12
include/asm-generic/vmlinux.lds.h
··· 60 60 #define ALIGN_FUNCTION() . = ALIGN(8) 61 61 62 62 /* 63 + * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which 64 + * generates .data.identifier sections, which need to be pulled in with 65 + * .data. We don't want to pull in .data..other sections, which Linux 66 + * has defined. Same for text and bss. 67 + */ 68 + #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION 69 + #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* 70 + #define DATA_MAIN .data .data.[0-9a-zA-Z_]* 71 + #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* 72 + #else 73 + #define TEXT_MAIN .text 74 + #define DATA_MAIN .data 75 + #define BSS_MAIN .bss 76 + #endif 77 + 78 + /* 63 79 * Align to a 32 byte boundary equal to the 64 80 * alignment gcc 4.5 uses for a struct 65 81 */ ··· 214 198 215 199 /* 216 200 * .data section 217 - * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections generates 218 - * .data.identifier which needs to be pulled in with .data, but don't want to 219 - * pull in .data..stuff which has its own requirements. Same for bss. 220 201 */ 221 202 #define DATA_DATA \ 222 - *(.data .data.[0-9a-zA-Z_]*) \ 203 + *(DATA_MAIN) \ 223 204 *(.ref.data) \ 224 205 *(.data..shared_aligned) /* percpu related */ \ 225 206 MEM_KEEP(init.data) \ ··· 447 434 VMLINUX_SYMBOL(__security_initcall_end) = .; \ 448 435 } 449 436 450 - /* .text section. Map to function alignment to avoid address changes 437 + /* 438 + * .text section. Map to function alignment to avoid address changes 451 439 * during second ld run in second ld pass when generating System.map 452 - * LD_DEAD_CODE_DATA_ELIMINATION option enables -ffunction-sections generates 453 - * .text.identifier which needs to be pulled in with .text , but some 454 - * architectures define .text.foo which is not intended to be pulled in here. 455 - * Those enabling LD_DEAD_CODE_DATA_ELIMINATION must ensure they don't have 456 - * conflicting section names, and must pull in .text.[0-9a-zA-Z_]* */ 440 + * 441 + * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead 442 + * code elimination is enabled, so these sections should be converted 443 + * to use ".." first. 444 + */ 457 445 #define TEXT_TEXT \ 458 446 ALIGN_FUNCTION(); \ 459 - *(.text.hot .text .text.fixup .text.unlikely) \ 447 + *(.text.hot TEXT_MAIN .text.fixup .text.unlikely) \ 460 448 *(.ref.text) \ 461 449 MEM_KEEP(init.text) \ 462 450 MEM_KEEP(exit.text) \ ··· 627 613 BSS_FIRST_SECTIONS \ 628 614 *(.bss..page_aligned) \ 629 615 *(.dynbss) \ 630 - *(.bss .bss.[0-9a-zA-Z_]*) \ 616 + *(BSS_MAIN) \ 631 617 *(COMMON) \ 632 618 } 633 619
+3 -4
scripts/Kbuild.include
··· 85 85 86 86 # try-run 87 87 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 88 - # Exit code chooses option. "$$TMP" is can be used as temporary file and 89 - # is automatically cleaned up. 88 + # Exit code chooses option. "$$TMP" serves as a temporary file and is 89 + # automatically cleaned up. 90 90 try-run = $(shell set -e; \ 91 91 TMP="$(TMPOUT).$$$$.tmp"; \ 92 92 TMPO="$(TMPOUT).$$$$.o"; \ ··· 261 261 any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) 262 262 263 263 # Execute command if command has changed or prerequisite(s) are updated. 264 - # 265 264 if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ 266 265 @set -e; \ 267 266 $(echo-cmd) $(cmd_$(1)); \ ··· 314 315 $(rule_$(1)), @:) 315 316 316 317 ### 317 - # why - tell why a a target got build 318 + # why - tell why a target got built 318 319 # enabled by make V=2 319 320 # Output (listed in the order they are checked): 320 321 # (1) - due to target is PHONY
+2 -2
scripts/Makefile.asm-generic
··· 1 1 # include/asm-generic contains a lot of files that are used 2 2 # verbatim by several architectures. 3 3 # 4 - # This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild 4 + # This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild 5 5 # and for each file listed in this file with generic-y creates 6 - # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) 6 + # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) 7 7 8 8 kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild 9 9 -include $(kbuild-file)
+4 -4
scripts/Makefile.build
··· 229 229 endif 230 230 # Due to recursion, we must skip empty.o. 231 231 # The empty.o file is created in the make process in order to determine 232 - # the target endianness and word size. It is made before all other C 233 - # files, including recordmcount. 232 + # the target endianness and word size. It is made before all other C 233 + # files, including recordmcount. 234 234 sub_cmd_record_mcount = \ 235 235 if [ $(@) != "scripts/mod/empty.o" ]; then \ 236 236 $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ ··· 245 245 "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ 246 246 "$(if $(part-of-module),1,0)" "$(@)"; 247 247 recordmcount_source := $(srctree)/scripts/recordmcount.pl 248 - endif 248 + endif # BUILD_C_RECORDMCOUNT 249 249 cmd_record_mcount = \ 250 250 if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ 251 251 "$(CC_FLAGS_FTRACE)" ]; then \ 252 252 $(sub_cmd_record_mcount) \ 253 253 fi; 254 - endif 254 + endif # CONFIG_FTRACE_MCOUNT_RECORD 255 255 256 256 ifdef CONFIG_STACK_VALIDATION 257 257 ifneq ($(SKIP_STACK_VALIDATION),1)
+2 -2
scripts/Makefile.dtbinst
··· 14 14 PHONY := __dtbs_install 15 15 __dtbs_install: 16 16 17 - export dtbinst-root ?= $(obj) 17 + export dtbinst_root ?= $(obj) 18 18 19 19 include include/config/auto.conf 20 20 include scripts/Kbuild.include ··· 27 27 quiet_cmd_dtb_install = INSTALL $< 28 28 cmd_dtb_install = mkdir -p $(2); cp $< $(2) 29 29 30 - install-dir = $(patsubst $(dtbinst-root)%,$(INSTALL_DTBS_PATH)%,$(obj)) 30 + install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj)) 31 31 32 32 $(dtbinst-files): %.dtb: $(obj)/%.dtb 33 33 $(call cmd,dtb_install,$(install-dir))
+1 -1
scripts/basic/Makefile
··· 1 1 ### 2 - # Makefile.basic lists the most basic programs used during the build process. 2 + # This Makefile lists the most basic programs used during the build process. 3 3 # The programs listed herein are what are needed to do the basic stuff, 4 4 # such as fix file dependencies. 5 5 # This initial step is needed to avoid files to be recompiled
+3 -3
scripts/basic/fixdep.c
··· 25 25 * 26 26 * So we play the same trick that "mkdep" played before. We replace 27 27 * the dependency on autoconf.h by a dependency on every config 28 - * option which is mentioned in any of the listed prequisites. 28 + * option which is mentioned in any of the listed prerequisites. 29 29 * 30 30 * kconfig populates a tree in include/config/ with an empty file 31 31 * for each config symbol and when the configuration is updated ··· 34 34 * the config symbols are rebuilt. 35 35 * 36 36 * So if the user changes his CONFIG_HIS_DRIVER option, only the objects 37 - * which depend on "include/linux/config/his/driver.h" will be rebuilt, 37 + * which depend on "include/config/his/driver.h" will be rebuilt, 38 38 * so most likely only his driver ;-) 39 39 * 40 40 * The idea above dates, by the way, back to Michael E Chastain, AFAIK. ··· 75 75 * and then basically copies the .<target>.d file to stdout, in the 76 76 * process filtering out the dependency on autoconf.h and adding 77 77 * dependencies on include/config/my/option.h for every 78 - * CONFIG_MY_OPTION encountered in any of the prequisites. 78 + * CONFIG_MY_OPTION encountered in any of the prerequisites. 79 79 * 80 80 * It will also filter out all the dependencies on *.ver. We need 81 81 * to make sure that the generated version checksum are globally up