From ee4eb20dbce91751c248399e8a0cf9b8813adf5a Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Fri, 17 Apr 2015 23:35:04 +0200 Subject: Makefile: Fix detection of clang when cross-compiling When the host's C compiler is clang, and when attempting to cross-compile Linux e.g. to MIPS with mipsel-linux-gcc, the Makefile would incorrectly detect the use of clang, which resulted in clang-specific flags being passed to mipsel-linux-gcc. This can be verified under Debian by installing the "clang" package, and then using it as the default compiler with: sudo update-alternatives --config cc This patch moves the detection of clang after the $(CC) variable is initialized to the name of the cross-compiler, so that the check applies to the cross-compiler and not the host's C compiler. v2: Move the detection of clang after the inclusion of the arch/*/Makefile (as they might set $(CROSS_COMPILE)) Signed-off-by: Paul Cercueil Signed-off-by: Michal Marek --- Makefile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 7ff1239f9cd2..2d225aa4d7e3 100644 --- a/Makefile +++ b/Makefile @@ -336,15 +336,6 @@ endif export KBUILD_MODULES KBUILD_BUILTIN export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD -ifneq ($(CC),) -ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) -COMPILER := clang -else -COMPILER := gcc -endif -export COMPILER -endif - # We need some generic definitions (do not try to remake the file). scripts/Kbuild.include: ; include scripts/Kbuild.include @@ -671,6 +662,13 @@ endif endif KBUILD_CFLAGS += $(stackp-flag) +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) +COMPILER := clang +else +COMPILER := gcc +endif +export COMPILER + ifeq ($(COMPILER),clang) KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) -- cgit v1.2.3 From ab160dbbc4ba71a4e339382d37b31ea44fd43e86 Mon Sep 17 00:00:00 2001 From: Sylvain BERTRAND Date: Thu, 7 May 2015 00:36:04 +0000 Subject: scripts: fix link-vmlinux.sh bash-ism While building linux with dash shell: LINK vmlinux trap: SIGHUP: bad trap /src/linux-4.0/Makefile:933: recipe for target 'vmlinux' failed make[1]: *** [vmlinux] Error 1 See the following document for behavior of posix shell trap instruction: http://pubs.opengroup.org/onlinepubs/000095399/utilities/trap.html Cc: Ingo Molnar Signed-off-by: Sylvain BERTRAND Signed-off-by: Michal Marek --- scripts/link-vmlinux.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 86a4fe75f453..c9a11d15d228 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -111,7 +111,6 @@ sortextable() } # Delete output files in case of error -trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR cleanup() { rm -f .old_version @@ -124,6 +123,20 @@ cleanup() rm -f vmlinux.o } +on_exit() +{ + if [ $? -ne 0 ]; then + cleanup + fi +} +trap on_exit EXIT + +on_signals() +{ + exit 1 +} +trap on_signals HUP INT QUIT TERM + # # # Use "make V=1" to debug this script @@ -231,7 +244,6 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then if ! cmp -s System.map .tmp_System.map; then echo >&2 Inconsistent kallsyms data echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround - cleanup exit 1 fi fi -- cgit v1.2.3 From cc8475305203ddfd117b81e2e732194b67d8f310 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Thu, 21 May 2015 19:17:44 +0800 Subject: scripts: link-vmlinux: Don't pass page offset to kallsyms if XIP Kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Kernel is executed in place from ROM, the symbol addresses can be lower than the page offset. Tested-by: Chanwoo Choi Signed-off-by: Maxime Coquelin Tested-by: Andreas Färber Signed-off-by: Michal Marek --- scripts/link-vmlinux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index c9a11d15d228..1a10d8ac8162 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -82,7 +82,7 @@ kallsyms() kallsymopt="${kallsymopt} --all-symbols" fi - if [ -n "${CONFIG_ARM}" ] && [ -n "${CONFIG_PAGE_OFFSET}" ]; then + if [ -n "${CONFIG_ARM}" ] && [ -z "${CONFIG_XIP_KERNEL}" ] && [ -n "${CONFIG_PAGE_OFFSET}" ]; then kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" fi -- cgit v1.2.3 From 50ab9a69275dca588cb5ad5038657f069bbdeb56 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Sat, 21 Mar 2015 02:50:01 +0100 Subject: kbuild: include core debug info when DEBUG_INFO_REDUCED With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info (around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the "basenames must match" rule used by -femit-struct-debug-baseonly option means that we miss some core data structures, such as struct {device, file, inode, mm_struct, page} etc. We can easily get these included as well, while still getting the benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller individual object files): All it takes is a dummy translation unit including a few strategic headers and compiled with a flag overriding -femit-struct-debug-baseonly. This increases the size of .debug_info by ~0.3%, but these 90 KB contain some rather useful info. Signed-off-by: Rasmus Villemoes Signed-off-by: Michal Marek --- lib/Makefile | 3 +++ lib/debug_info.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 lib/debug_info.c diff --git a/lib/Makefile b/lib/Makefile index 6c37933336a0..c918538110ed 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,6 +45,9 @@ CFLAGS_kobject.o += -DDEBUG CFLAGS_kobject_uevent.o += -DDEBUG endif +obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o +CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) + obj-$(CONFIG_GENERIC_IOMAP) += iomap.o obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o diff --git a/lib/debug_info.c b/lib/debug_info.c new file mode 100644 index 000000000000..2edbe27517ed --- /dev/null +++ b/lib/debug_info.c @@ -0,0 +1,27 @@ +/* + * This file exists solely to ensure debug information for some core + * data structures is included in the final image even for + * CONFIG_DEBUG_INFO_REDUCED. Please do not add actual code. However, + * adding appropriate #includes is fine. + */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -- cgit v1.2.3