linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] objtool: Move sync check to a script
Date: Tue, 7 Nov 2017 10:46:21 +0100	[thread overview]
Message-ID: <20171107094621.kfpykhbncikmeyms@gmail.com> (raw)
In-Reply-To: <ab015f15ccd8c0c6008493c3c6ee3d495eaf2927.1509974346.git.jpoimboe@redhat.com>


* Josh Poimboeuf <jpoimboe@redhat.com> wrote:

> Replace the nasty diff checks in the objtool Makefile with a clean bash
> script, and make the warnings more specific.
> 
> Heavily inspired by tools/perf/check-headers.sh.
> 
> Suggested-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  tools/objtool/Makefile      | 16 +---------------
>  tools/objtool/sync-check.sh | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 15 deletions(-)
>  create mode 100755 tools/objtool/sync-check.sh
> 
> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> index c6a19d946ec1..6aaed251b4ed 100644
> --- a/tools/objtool/Makefile
> +++ b/tools/objtool/Makefile
> @@ -43,22 +43,8 @@ include $(srctree)/tools/build/Makefile.include
>  $(OBJTOOL_IN): fixdep FORCE
>  	@$(MAKE) $(build)=objtool
>  
> -# Busybox's diff doesn't have -I, avoid warning in that case
> -#
>  $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
> -	@(diff -I 2>&1 | grep -q 'option requires an argument' && \
> -	test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
> -	diff arch/x86/lib/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
> -	diff arch/x86/lib/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
> -	diff arch/x86/lib/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
> -	diff arch/x86/tools/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
> -	diff arch/x86/include/asm/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
> -	diff arch/x86/include/asm/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
> -	diff arch/x86/include/asm/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
> -	|| echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
> -	@(test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
> -	diff ../../arch/x86/include/asm/orc_types.h arch/x86/include/asm/orc_types.h >/dev/null) \
> -	|| echo "warning: objtool: orc_types.h differs from kernel" >&2 )) || true
> +	@./sync-check.sh
>  	$(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
>  
>  
> diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh
> new file mode 100755
> index 000000000000..f2e5f8b0460c
> --- /dev/null
> +++ b/tools/objtool/sync-check.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +
> +FILES='
> +arch/x86/lib/insn.c
> +arch/x86/lib/inat.c
> +arch/x86/lib/x86-opcode-map.txt
> +arch/x86/tools/gen-insn-attr-x86.awk
> +arch/x86/include/asm/insn.h
> +arch/x86/include/asm/inat.h
> +arch/x86/include/asm/inat_types.h
> +arch/x86/include/asm/orc_types.h
> +'
> +
> +check()
> +{
> +	local file=$1
> +
> +	diff $file ../../$file &> /dev/null ||
> +		echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'"
> +}
> +
> +if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then
> +	exit 0
> +fi
> +
> +for i in $FILES; do
> +  check $i
> +done

Hm, this doesn't actually warn - it outputs the diff:

 triton:~/tip/tools/objtool> ./sync-check.sh 
 triton:~/tip/tools/objtool> 99a100,109
 > /* Identifiers for segment registers */
 > #define INAT_SEG_REG_IGNORE   0
 > #define INAT_SEG_REG_DEFAULT  1
 > #define INAT_SEG_REG_CS               2
 > #define INAT_SEG_REG_SS               3
 > #define INAT_SEG_REG_DS               4
 > #define INAT_SEG_REG_ES               5
 > #define INAT_SEG_REG_FS               6
 > #define INAT_SEG_REG_GS               7
 > 

I fixed it to do:

        diff $file ../../$file > /dev/null ||

(note the removal of '&')

Then it outputs the right thing:

  triton:~/tip/tools/objtool> ./sync-check.sh 
  Warning: synced file at 'tools/objtool/arch/x86/include/asm/inat.h' differs from latest kernel version at 'arch/x86/include/asm/inat.h'

Thanks,

	Ingo

  reply	other threads:[~2017-11-07  9:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 13:21 [PATCH v2 0/2] objtool: sync cleanups Josh Poimboeuf
2017-11-06 13:21 ` [PATCH v2 1/2] objtool: Move synced files to their original relative locations Josh Poimboeuf
2017-11-07  9:52   ` [tip:core/objtool] " tip-bot for Josh Poimboeuf
2017-11-06 13:21 ` [PATCH v2 2/2] objtool: Move sync check to a script Josh Poimboeuf
2017-11-07  9:46   ` Ingo Molnar [this message]
2017-11-07 13:31     ` Josh Poimboeuf
2017-11-07 15:05       ` Ingo Molnar
2017-11-07 15:11         ` Josh Poimboeuf
2017-11-07 16:01           ` Ingo Molnar
2017-11-07  9:53   ` [tip:core/objtool] objtool: Move kernel headers/code " tip-bot for Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171107094621.kfpykhbncikmeyms@gmail.com \
    --to=mingo@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).