ClangBuiltLinux / linux

Linux kernel source tree
Other
239 stars 14 forks source link

[kernel posttest] llvm-objdump - unknown command line argument #1130

Closed ghost closed 3 years ago

ghost commented 3 years ago

compiling kernel 5.9.-rc1 with LLVM-10 produces

HOSTCC arch/x86/tools/insn_sanity TEST posttest llvm-objdump-10: Unknown command line argument '-v'. Try: 'llvm-objdump-10 --help' llvm-objdump-10: Did you mean '-C'? TEST posttest arch/x86/tools/insn_sanity: Success: decoded and checked 1000000 random instructions with 0 errors (seed:0x307cbccf)

nickdesaulniers commented 3 years ago

In arch/x86/tools/Makefile, there's an invocation of $(OBJDUMP) that uses -v. It can be changed to --version for now.

nickdesaulniers commented 3 years ago

Also, is there a config to enable posttest? Maybe it's new in 5.9, but I've never heard of it before.

ghost commented 3 years ago

x86 decoder sanity test https://cateee.net/lkddb/web-lkddb/X86_DECODER_SELFTEST.html, has been there for a while

ghost commented 3 years ago

Having patched that Makefile the output now exhibits

HOSTCC arch/x86/tools/insn_decoder_test HOSTCC arch/x86/tools/insn_sanity TEST posttest TEST posttest arch/x86/tools/insn_sanity: Success: decoded and checked 1000000 random instructions with 0 errors (seed:0x151b2cfb)

nathanchance commented 3 years ago

@n8v8R were you planning on sending a patch? If not, I can do so tomorrow.

ihalip commented 3 years ago

There are multiple issues here.

  1. obviously, --version parameter should be used for compatibility between the two

  2. LLVM objdump version is not detected anyway, because the checkobjdump.awk script uses a regexp which doesn't match its output. So the script needs to be changed. In addition, LLVM objdump versions 9 to 12 do not correctly recognize/disassemble the 0x40 0x42 bytes, which is a REX prefix appearing twice for some reason (more info here: https://wiki.osdev.org/X86-64_Instruction_Encoding#REX_prefix and http://staffwww.fullcoll.edu/aclifton/cs241/lecture-instruction-format.html). Could be a codegen issue with clang, though.

  3. The LLVM objdump output needs to be reformatted to match what the insn_decoder_test expects. So the objdump_reformat.awk script needs to be changed too.

nickdesaulniers commented 3 years ago

Reproducible via CONFIG_X86_DECODER_SELFTEST=y on top of defconfig, then building bzImage. https://reviews.llvm.org/D101483

nickdesaulniers commented 3 years ago

Let's use additional issues to follow up on anything else. It makes it easier to track where we are when there are multiple things going wrong.

nickdesaulniers commented 3 years ago

-v support: https://reviews.llvm.org/rGdde24a87c55f82d8c7b3bf3eafb10f2b9b2b9a01

closing, let's track @ihalip 's sugguestions in #1362 .