From 598e2d33886568442ac52b60ae6f493158670e18 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 15 Apr 2014 13:29:00 +0900 Subject: kbuild: sync with Linux Kernel v3.15-rc1 This commit imports Kbuild-related updates from v3.14 to v3.15-rc1. - commit 3d3d6b8474204b6819688c9800774d52d370a538 kbuild: LLVMLinux: Adapt warnings for compilation with clang - commit 61163efae02040f66a95c8ed17f4407951ba58fa kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang - commit 79192ca8ebd9a25c583aa46024a250fef1e7766f scripts: objdiff: detect object code changes between two commits - commit 1c9e70a55b088d97a59241744fe459409d0c3582 kbuild: create a build directory automatically for out-of-tree build - commit a03fcb50e816a69acffb13b5e56db75063aeba8a kbuild: remove redundant '.*.cmd' pattern from make distclean - commit 13338935f1574a2dcd1c891461b0dcc42f8cff42 kbuild: move "quote" to Kbuild.include to be consistent - commit bfdfaeae500a3b194b73b01e92a8034791a58b7f kbuild: specify build_docproc as a phony target - commit f4d4ffc03efc864645b990e1d579bbe1b8e358a4 kbuild: dtbs_install: new make target - commit 1e64ff42ea3d8d2fc8aa71f9717b3c1cb6c2f893 Kbuild, lto: Disable LTO for asm-offsets.c - commit ccbef1674a1579842c7dbdf554efca85d2cd245a Kbuild, lto: add ld-version and ld-ifversion macros - commit ae63b2d7bdd9bd66b88843be0daf8e37d8f0b574 scripts/tags.sh: Ignore *.mod.c - commit e36aaea28972c57a32a3ba5365e61633739719b9 kbuild: Fix silent builds with make-4 Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 10 ++++ scripts/Makefile | 2 +- scripts/Makefile.build | 14 ++++- scripts/Makefile.lib | 16 ++++-- scripts/ld-version.sh | 8 +++ scripts/objdiff | 141 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 184 insertions(+), 7 deletions(-) create mode 100755 scripts/ld-version.sh create mode 100755 scripts/objdiff (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6504571..c664e39 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -3,6 +3,7 @@ # Convenient variables comma := , +quote := " squote := ' empty := space := $(empty) $(empty) @@ -161,6 +162,15 @@ ld-option = $(call try-run,\ # Important: no spaces around options ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) +# ld-version +# Usage: $(call ld-version) +# Note this is mainly for HJ Lu's 3 number binutil versions +ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) + +# ld-ifversion +# Usage: $(call ld-ifversion, -ge, 22252, y) +ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3)) + ###### ### diff --git a/scripts/Makefile b/scripts/Makefile index 242e3a0..68c998e 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -9,7 +9,7 @@ hostprogs-y += docproc # These targets are used internally to avoid "is up to date" messages PHONY += build_docproc -build_docproc: scripts/docproc +build_docproc: $(obj)/docproc @: # Let clean descend into subdirs diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 36346fd..6416c1a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -90,12 +90,22 @@ warning- := $(empty) warning-1 := -Wextra -Wunused -Wno-unused-parameter warning-1 += -Wmissing-declarations warning-1 += -Wmissing-format-attribute -warning-1 += -Wmissing-prototypes +warning-1 += $(call cc-option, -Wmissing-prototypes) warning-1 += -Wold-style-definition warning-1 += $(call cc-option, -Wmissing-include-dirs) warning-1 += $(call cc-option, -Wunused-but-set-variable) warning-1 += $(call cc-disable-warning, missing-field-initializers) +# Clang +warning-1 += $(call cc-disable-warning, initializer-overrides) +warning-1 += $(call cc-disable-warning, unused-value) +warning-1 += $(call cc-disable-warning, format) +warning-1 += $(call cc-disable-warning, unknown-warning-option) +warning-1 += $(call cc-disable-warning, sign-compare) +warning-1 += $(call cc-disable-warning, format-zero-length) +warning-1 += $(call cc-disable-warning, uninitialized) +warning-1 += $(call cc-option, -fcatch-undefined-behavior) + warning-2 := -Waggregate-return warning-2 += -Wcast-align warning-2 += -Wdisabled-optimization @@ -225,7 +235,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi) $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index d568fde..a04439d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -273,6 +273,18 @@ $(obj)/%.dtb: $(src)/%.dts FORCE dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) +# Helper targets for Installing DTBs into the boot directory +quiet_cmd_dtb_install = INSTALL $< + cmd_dtb_install = cp $< $(2) + +_dtbinst_pre_: + $(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) + +%.dtb_dtbinst_: $(obj)/%.dtb _dtbinst_pre_ + $(call cmd,dtb_install,$(INSTALL_DTBS_PATH)) + # Bzip2 # --------------------------------------------------------------------------- @@ -367,7 +379,3 @@ quiet_cmd_xzmisc = XZMISC $@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ (rm -f $@ ; false) - -# misc stuff -# --------------------------------------------------------------------------- -quote:=" diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh new file mode 100755 index 0000000..198580d --- /dev/null +++ b/scripts/ld-version.sh @@ -0,0 +1,8 @@ +#!/usr/bin/awk -f +# extract linker version number from stdin and turn into single number + { + gsub(".*)", ""); + split($1,a, "."); + print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5]; + exit + } diff --git a/scripts/objdiff b/scripts/objdiff new file mode 100755 index 0000000..b3e4f10 --- /dev/null +++ b/scripts/objdiff @@ -0,0 +1,141 @@ +#!/bin/bash + +# objdiff - a small script for validating that a commit or series of commits +# didn't change object code. +# +# Copyright 2014, Jason Cooper +# +# Licensed under the terms of the GNU GPL version 2 + +# usage example: +# +# $ git checkout COMMIT_A +# $ +# $ ./scripts/objdiff record path/to/*.o +# +# $ git checkout COMMIT_B +# $ +# $ ./scripts/objdiff record path/to/*.o +# +# $ ./scripts/objdiff diff COMMIT_A COMMIT_B +# $ + +# And to clean up (everything is in .tmp_objdiff/*) +# $ ./scripts/objdiff clean all +# +# Note: 'make mrproper' will also remove .tmp_objdiff + +GIT_DIR="`git rev-parse --git-dir`" + +if [ -d "$GIT_DIR" ]; then + TMPD="${GIT_DIR%git}tmp_objdiff" + + [ -d "$TMPD" ] || mkdir "$TMPD" +else + echo "ERROR: git directory not found." + exit 1 +fi + +usage() { + echo "Usage: $0 " + echo " record " + echo " diff " + echo " clean all | " + exit 1 +} + +dorecord() { + [ $# -eq 0 ] && usage + + FILES="$*" + + CMT="`git rev-parse --short HEAD`" + + OBJDUMP="${CROSS_COMPILE}objdump" + OBJDIFFD="$TMPD/$CMT" + + [ ! -d "$OBJDIFFD" ] && mkdir -p "$OBJDIFFD" + + for f in $FILES; do + dn="${f%/*}" + bn="${f##*/}" + + [ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn" + + # remove addresses for a more clear diff + # http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and + $OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \ + >"$OBJDIFFD/$dn/$bn" + done +} + +dodiff() { + [ $# -ne 2 ] && [ $# -ne 0 ] && usage + + if [ $# -eq 0 ]; then + SRC="`git rev-parse --short HEAD^`" + DST="`git rev-parse --short HEAD`" + else + SRC="`git rev-parse --short $1`" + DST="`git rev-parse --short $2`" + fi + + DIFF="`which colordiff`" + + if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then + DIFF="`which diff`" + fi + + SRCD="$TMPD/$SRC" + DSTD="$TMPD/$DST" + + if [ ! -d "$SRCD" ]; then + echo "ERROR: $SRCD doesn't exist" + exit 1 + fi + + if [ ! -d "$DSTD" ]; then + echo "ERROR: $DSTD doesn't exist" + exit 1 + fi + + $DIFF -Nurd $SRCD $DSTD +} + +doclean() { + [ $# -eq 0 ] && usage + [ $# -gt 1 ] && usage + + if [ "x$1" = "xall" ]; then + rm -rf $TMPD/* + else + CMT="`git rev-parse --short $1`" + + if [ -d "$TMPD/$CMT" ]; then + rm -rf $TMPD/$CMT + else + echo "$CMT not found" + fi + fi +} + +[ $# -eq 0 ] && usage + +case "$1" in + record) + shift + dorecord $* + ;; + diff) + shift + dodiff $* + ;; + clean) + shift + doclean $* + ;; + *) + echo "Unrecognized command '$1'" + exit 1 + ;; +esac -- cgit v1.1