From 5399eb9b39081d6d2fc1a13d4ea85f1ceb2c8b44 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 20 Oct 2015 14:01:32 +0100 Subject: dtbsinstall: don't move target directory out of the way No other kernel installation target moves the target directory out of the way, even deleting an old version of it. These are destructive operations, ones which the kernel build system should not be making. This behaviour prevents being able to do: make install INSTALL_PATH=/some/path/boot make dtbs_install INSTALL_DTBS_PATH=/some/path/boot As it causes the boot directory containing the kernel installed in step 1 to be moved to /some/path/boot.old. Things get even more fun if you do: make install dtbs_install INSTALL_PATH=/some/path/boot INSTALL_DTBS_PATH=/some/path/boot The kernel gets installed into /some/path/boot, then the directory gets renamed to /some/path/boot.old, and a new directory created to hold the dtbs. Even more fun if you supply -j2 when we end up with races in make. Remove this behaviour. If this behaviour is required at installation time, this should be done by the installation external to the kernel makefiles, just like it would be done for 'make modules_install'. Signed-off-by: Russell King Acked-by: Jason Cooper Acked-by: Rob Herring Signed-off-by: Michal Marek diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 1c15717..a1be75d 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst @@ -23,8 +23,6 @@ include $(src)/Makefile PHONY += __dtbs_install_prep __dtbs_install_prep: ifeq ("$(dtbinst-root)", "$(obj)") - $(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi - $(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi $(Q)mkdir -p $(INSTALL_DTBS_PATH) endif -- cgit v0.10.2 From b41c29b0527c7fd6a95d0f71274abb79933bf960 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 8 Feb 2016 15:38:32 +0100 Subject: Kbuild: provide a __UNIQUE_ID for clang The default __UNIQUE_ID macro in compiler.h fails to work for some drivers: drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:615:1: error: redefinition of '__UNIQUE_ID_firmware615' BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt"); This adds a copy of the version we use for gcc-4.3 and higher, as the same one works with all versions of clang that I could find in svn (2.6 and higher). Signed-off-by: Arnd Bergmann Signed-off-by: Michal Marek diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index d1e49d5..de17999 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -10,3 +10,8 @@ #undef uninitialized_var #define uninitialized_var(x) x = *(&(x)) #endif + +/* same as gcc, this was present in clang-2.6 so we can assume it works + * with any version that can compile the kernel + */ +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) -- cgit v0.10.2 From a043934207c5eb271deeaed2e9bd019c3be92cad Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 5 Feb 2016 11:25:05 +0100 Subject: scripts/link-vmlinux.sh: force error on kallsyms failure Since the output of the invocation of scripts/kallsyms is piped directly into the assembler, error messages it emits are visible on stderr, but a non-zero return code is ignored, and the build simply proceeds in that case. However, the resulting kernel is most likely broken, and will crash at boot. So instead, capture the output of kallsyms in a separate .S file, and pass that to the assembler in a separate step. Signed-off-by: Ard Biesheuvel Signed-off-by: Michal Marek diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index ba6c34e..8f22654 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -93,9 +93,10 @@ kallsyms() local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" - ${NM} -n ${1} | \ - scripts/kallsyms ${kallsymopt} | \ - ${CC} ${aflags} -c -o ${2} -x assembler-with-cpp - + local afile="`basename ${2} .o`.S" + + ${NM} -n ${1} | scripts/kallsyms ${kallsymopt} > ${afile} + ${CC} ${aflags} -c -o ${2} ${afile} } # Create map file with all symbols from ${1} -- cgit v0.10.2 From 46fe94ad18aa7ce6b3dad8c035fb538942020f2b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 7 Dec 2015 16:26:08 -0500 Subject: kbuild: fixdep: Check fstat(2) return value Coverity has recently added a check that will find when we don't check the return code from fstat(2). Copy/paste the checking logic that print_deps() has with an appropriate re-wording of the perror() message. Signed-off-by: Tom Rini Signed-off-by: Michal Marek diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 5b327c6..caef815 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -274,7 +274,11 @@ static void do_config_file(const char *filename) perror(filename); exit(2); } - fstat(fd, &st); + if (fstat(fd, &st) < 0) { + fprintf(stderr, "fixdep: error fstat'ing config file: "); + perror(filename); + exit(2); + } if (st.st_size == 0) { close(fd); return; -- cgit v0.10.2 From 2aedcd098a9448b11eab895ee79acf519686555a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 3 Mar 2016 17:36:30 +0900 Subject: kbuild: suppress annoying "... is up to date." message Under certain conditions, Kbuild shows "... is up to date" where if_changed or friends are used. For example, the incremental build of ARM64 Linux shows this message when the kernel image has not been updated. $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CHK include/generated/bounds.h CHK include/generated/timeconst.h CHK include/generated/asm-offsets.h CALL scripts/checksyscalls.sh CHK include/generated/compile.h CHK kernel/config_data.h make[1]: `arch/arm64/boot/Image.gz' is up to date. Building modules, stage 2. MODPOST 0 modules The following is the build rule in arch/arm64/boot/Makefile: $(obj)/Image.gz: $(obj)/Image FORCE $(call if_changed,gzip) If the Image.gz is newer than the Image and the command line has not changed (i.e., $(any-prereq) and $(arg-check) are both empty), the build rule $(call if_changed,gzip) is evaluated to be empty, then GNU Make reports the target is up to date. In order to make GNU Make quiet, we need to give it something to do, for example, "@:". This should be fixed in the Kbuild core part rather than in each Makefile. Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 1db6d73..b2ab2a9 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -251,7 +251,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ - printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @@ -259,14 +259,14 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd) + mv -f $(dot-target).tmp $(dot-target).cmd, @:) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, # and if so will execute $(rule_foo). if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ - $(rule_$(1))) + $(rule_$(1)), @:) ### # why - tell why a a target got build -- cgit v0.10.2 From ea8daa7b97842aab8507b5b5b1e3226cf2d514a6 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 8 Mar 2016 09:29:09 +0100 Subject: kbuild: Add option to turn incompatible pointer check into error With the introduction of the simple wait API we have two very similar APIs in the kernel. For example wake_up() and swake_up() is only one character away. Although the compiler will warn happily the wrong usage it keeps on going an even links the kernel. Thomas and Peter would rather like to see early missuses reported as error early on. In a first attempt we tried to wrap all swait and wait calls into a macro which has an compile time type assertion. The result was pretty ugly and wasn't able to catch all wrong usages. woken_wake_function(), autoremove_wake_function() and wake_bit_function() are assigned as function pointers. Wrapping them with a macro around is not possible. Prefixing them with '_' was also not a real option because there some users in the kernel which do use them as well. All in all this attempt looked to intrusive and too ugly. An alternative is to turn the pointer type check into an error which catches wrong type uses. Obviously not only the swait/wait ones. That isn't a bad thing either. Signed-off-by: Daniel Wagner Acked-by: Peter Zijlstra (Intel) Acked-by: Thomas Gleixner Acked-by: Ingo Molnar Signed-off-by: Michal Marek diff --git a/Makefile b/Makefile index c65fe37..453fe00 100644 --- a/Makefile +++ b/Makefile @@ -773,6 +773,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) # Prohibit date/time macros, which would make the build non-deterministic KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) +# enforce correct pointer usage +KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D) -- cgit v0.10.2