Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Linux kernel is incompatible with busybox diff. Help? #326

Closed
KSPAtlas opened this issue Sep 1, 2021 · 5 comments
Closed

Linux kernel is incompatible with busybox diff. Help? #326

KSPAtlas opened this issue Sep 1, 2021 · 5 comments

Comments

@KSPAtlas
Copy link

KSPAtlas commented Sep 1, 2021

log:
` DESCEND objtool
CALL scripts/atomic/check-atomics.sh
CALL scripts/checksyscalls.sh
diff: unrecognized option: I
BusyBox v1.34.0 (2021-09-01 16:43:49 UTC) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

-a	Treat all files as text
-b	Ignore changes in the amount of whitespace
-B	Ignore changes whose lines are all blank
-d	Try hard to find a smaller set of changes
-i	Ignore case differences
-L	Use LABEL instead of the filename in the unified header
-N	Treat absent files as empty
-q	Output only whether files differ
-r	Recurse
-S	Start with FILE when comparing directories
-T	Make tabs line up by prefixing a tab when necessary
-s	Report when two files are the same
-t	Expand tabs to spaces in output
-U	Output LINES lines of context
-w	Ignore all whitespace

Warning: Kernel ABI header at 'tools/arch/x86/include/asm/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h'
diff -u tools/arch/x86/include/asm/inat.h arch/x86/include/asm/inat.h
diff: unrecognized option: I
BusyBox v1.34.0 (2021-09-01 16:43:49 UTC) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

-a	Treat all files as text
-b	Ignore changes in the amount of whitespace
-B	Ignore changes whose lines are all blank
-d	Try hard to find a smaller set of changes
-i	Ignore case differences
-L	Use LABEL instead of the filename in the unified header
-N	Treat absent files as empty
-q	Output only whether files differ
-r	Recurse
-S	Start with FILE when comparing directories
-T	Make tabs line up by prefixing a tab when necessary
-s	Report when two files are the same
-t	Expand tabs to spaces in output
-U	Output LINES lines of context
-w	Ignore all whitespace

Warning: Kernel ABI header at 'tools/arch/x86/include/asm/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'
diff -u tools/arch/x86/include/asm/insn.h arch/x86/include/asm/insn.h
diff: unrecognized option: I
BusyBox v1.34.0 (2021-09-01 16:43:49 UTC) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

-a	Treat all files as text
-b	Ignore changes in the amount of whitespace
-B	Ignore changes whose lines are all blank
-d	Try hard to find a smaller set of changes
-i	Ignore case differences
-L	Use LABEL instead of the filename in the unified header
-N	Treat absent files as empty
-q	Output only whether files differ
-r	Recurse
-S	Start with FILE when comparing directories
-T	Make tabs line up by prefixing a tab when necessary
-s	Report when two files are the same
-t	Expand tabs to spaces in output
-U	Output LINES lines of context
-w	Ignore all whitespace

Warning: Kernel ABI header at 'tools/arch/x86/lib/inat.c' differs from latest version at 'arch/x86/lib/inat.c'
diff -u tools/arch/x86/lib/inat.c arch/x86/lib/inat.c
diff: unrecognized option: I
BusyBox v1.34.0 (2021-09-01 16:43:49 UTC) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

-a	Treat all files as text
-b	Ignore changes in the amount of whitespace
-B	Ignore changes whose lines are all blank
-d	Try hard to find a smaller set of changes
-i	Ignore case differences
-L	Use LABEL instead of the filename in the unified header
-N	Treat absent files as empty
-q	Output only whether files differ
-r	Recurse
-S	Start with FILE when comparing directories
-T	Make tabs line up by prefixing a tab when necessary
-s	Report when two files are the same
-t	Expand tabs to spaces in output
-U	Output LINES lines of context
-w	Ignore all whitespace

Warning: Kernel ABI header at 'tools/arch/x86/lib/insn.c' differs from latest version at 'arch/x86/lib/insn.c'
diff -u tools/arch/x86/lib/insn.c arch/x86/lib/insn.c
CC /root/linux-5.14/tools/objtool/arch/x86/decode.o
In file included from /usr/include/linux/byteorder/little_endian.h:13,
from /usr/include/asm/byteorder.h:5,
from /root/linux-5.14/tools/arch/x86/include/asm/insn.h:10,
from arch/x86/decode.c:10:
/usr/include/linux/swab.h:136:23: error: expected ';' before 'unsigned'
136 | static __always_inline unsigned long __swab(const unsigned long y)
| ^~~~~~~~~
| ;
/usr/include/linux/swab.h:171:8: error: unknown type name '__always_inline'
171 | static __always_inline __u16 __swab16p(const __u16 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/swab.h:171:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__swab16p'
171 | static __always_inline __u16 __swab16p(const __u16 *p)
| ^~~~~~~~~
/usr/include/linux/swab.h:184:8: error: unknown type name '__always_inline'
184 | static __always_inline __u32 __swab32p(const __u32 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/swab.h:184:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__swab32p'
184 | static __always_inline __u32 __swab32p(const __u32 *p)
| ^~~~~~~~~
/usr/include/linux/swab.h:197:8: error: unknown type name '__always_inline'
197 | static __always_inline __u64 __swab64p(const __u64 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/swab.h:197:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__swab64p'
197 | static __always_inline __u64 __swab64p(const __u64 *p)
| ^~~~~~~~~
/usr/include/linux/swab.h:252:23: error: expected ';' before 'void'
252 | static __always_inline void __swab32s(__u32 *p)
| ^~~~~
| ;
/usr/include/linux/swab.h:265:23: error: expected ';' before 'void'
265 | static __always_inline void __swab64s(__u64 *p)
| ^~~~~
| ;
In file included from /usr/include/asm/byteorder.h:5,
from /root/linux-5.14/tools/arch/x86/include/asm/insn.h:10,
from arch/x86/decode.c:10:
/usr/include/linux/byteorder/little_endian.h:44:8: error: unknown type name '__always_inline'
44 | static __always_inline __le64 __cpu_to_le64p(const __u64 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:44:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_le64p'
44 | static __always_inline __le64 __cpu_to_le64p(const __u64 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:48:8: error: unknown type name '__always_inline'
48 | static __always_inline __u64 __le64_to_cpup(const __le64 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:48:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__le64_to_cpup'
48 | static __always_inline __u64 __le64_to_cpup(const __le64 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:52:8: error: unknown type name '__always_inline'
52 | static __always_inline __le32 __cpu_to_le32p(const __u32 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:52:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_le32p'
52 | static __always_inline __le32 __cpu_to_le32p(const __u32 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:56:8: error: unknown type name '__always_inline'
56 | static __always_inline __u32 __le32_to_cpup(const __le32 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:56:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__le32_to_cpup'
56 | static __always_inline __u32 __le32_to_cpup(const __le32 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:60:8: error: unknown type name '__always_inline'
60 | static __always_inline __le16 __cpu_to_le16p(const __u16 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:60:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_le16p'
60 | static __always_inline __le16 __cpu_to_le16p(const __u16 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:64:8: error: unknown type name '__always_inline'
64 | static __always_inline __u16 __le16_to_cpup(const __le16 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:64:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__le16_to_cpup'
64 | static __always_inline __u16 __le16_to_cpup(const __le16 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:68:8: error: unknown type name '__always_inline'
68 | static __always_inline __be64 __cpu_to_be64p(const __u64 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:68:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_be64p'
68 | static __always_inline __be64 __cpu_to_be64p(const __u64 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:72:8: error: unknown type name '__always_inline'
72 | static __always_inline __u64 __be64_to_cpup(const __be64 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:72:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__be64_to_cpup'
72 | static __always_inline __u64 __be64_to_cpup(const __be64 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:76:8: error: unknown type name '__always_inline'
76 | static __always_inline __be32 __cpu_to_be32p(const __u32 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:76:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_be32p'
76 | static __always_inline __be32 __cpu_to_be32p(const __u32 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:80:8: error: unknown type name '__always_inline'
80 | static __always_inline __u32 __be32_to_cpup(const __be32 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:80:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__be32_to_cpup'
80 | static __always_inline __u32 __be32_to_cpup(const __be32 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:84:8: error: unknown type name '__always_inline'
84 | static __always_inline __be16 __cpu_to_be16p(const __u16 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:84:31: error: expected '=', ',', ';', 'asm' or 'attribute' before '__cpu_to_be16p'
84 | static __always_inline __be16 __cpu_to_be16p(const __u16 *p)
| ^~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:88:8: error: unknown type name '__always_inline'
88 | static __always_inline __u16 __be16_to_cpup(const __be16 *p)
| ^~~~~~~~~~~~~~~
/usr/include/linux/byteorder/little_endian.h:88:30: error: expected '=', ',', ';', 'asm' or 'attribute' before '__be16_to_cpup'
88 | static __always_inline __u16 __be16_to_cpup(const __be16 *p)
| ^~~~~~~~~~~~~~
make[4]: *** [/root/linux-5.14/tools/build/Makefile.build:97: /root/linux-5.14/tools/objtool/arch/x86/decode.o] Error 1
make[3]: *** [/root/linux-5.14/tools/build/Makefile.build:139: arch/x86] Error 2
make[2]: *** [Makefile:56: /root/linux-5.14/tools/objtool/objtool-in.o] Error 2
make[1]: *** [Makefile:69: objtool] Error 2
make: *** [Makefile:1364: tools/objtool] Error 2
`

@dylanaraps
Copy link
Member

The diff errors are "harmless" (they don't cause build error or any known issues). The error you are seeing is actually unrelated. The error you are seeing is related to libelf and is mentioned in the installation guide here: https://kisslinux.org/install#024
Your choices are to run the fix in the above link or uninstall libelf.

@dylanaraps
Copy link
Member

The diff calls come from tools/objtool/sync-check.sh.

You can reproduce the errors with the following snippet:

cd tools/objtool
SRCARCH=x86 ./sync-check.sh

@dylanaraps
Copy link
Member

dylanaraps commented Sep 1, 2021

The calls themselves:

  diff  tools/include/linux/objtool.h include/linux/objtool.h > /dev/null         
  diff  tools/arch/x86/include/asm/inat_types.h arch/x86/include/asm/inat_types.h > /dev/null
  diff  tools/arch/x86/include/asm/orc_types.h arch/x86/include/asm/orc_types.h > /dev/null
  diff  tools/arch/x86/include/asm/emulate_prefix.h arch/x86/include/asm/emulate_prefix.h > /dev/null
  diff  tools/arch/x86/lib/x86-opcode-map.txt arch/x86/lib/x86-opcode-map.txt > /dev/null
  diff  tools/arch/x86/tools/gen-insn-attr-x86.awk arch/x86/tools/gen-insn-attr-x86.awk > /dev/null
  diff  tools/include/linux/static_call_types.h include/linux/static_call_types.h > /dev/null

  # Problematic calls below.
  diff -I '^#include ["<]\(asm/\)*inat_types.h[">]' tools/arch/x86/include/asm/inat.h arch/x86/include/asm/inat.h > /dev/null
  diff -I '^#include ["<]\(asm/\)*inat.h[">]' tools/arch/x86/include/asm/insn.h arch/x86/include/asm/insn.h > /dev/null
  diff -I '^#include ["<]\(../include/\)*asm/insn.h[">]' tools/arch/x86/lib/inat.c arch/x86/lib/inat.c > /dev/null
  diff -I '^#include ["<]\(../include/\)*asm/in\(at\|sn\).h[">]' -I '^#include ["<]\(../include/\)*asm/emulate_prefix.h[">]' tools/arch/x86/lib/insn.c arch/x86/lib/insn.c > /dev/null

@dylanaraps
Copy link
Member

dylanaraps commented Sep 1, 2021

The -I flag controls the following behavior:

       -I, --ignore-matching-lines=RE
              ignore changes where all lines match RE

From: https://man7.org/linux/man-pages/man1/diff.1.html

@dylanaraps
Copy link
Member

dylanaraps commented Sep 1, 2021

In fact... older versions of the kernel hid the errors (when using busybox diff, etc is used):


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 $@

From: https://lore.kernel.org/lkml/ab015f15ccd8c0c6008493c3c6ee3d495eaf2927.1509974346.git.jpoimboe@redhat.com/

Again, the diff errors are "harmless". They can be fixed with a patch that filters both files (using the same regex) before passing them to diff. It's just a matter of someone doing this (and if it's worthwhile anyway as this has no bearing on the resulting kernel image).

Thanks for opening this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants