Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang crashes when compiling MIPS kernel #571

Closed
tpimh opened this issue Jun 24, 2019 · 15 comments
Closed

Clang crashes when compiling MIPS kernel #571

tpimh opened this issue Jun 24, 2019 · 15 comments
Labels
[ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM Compiler crash This bug makes Clang crash, emitting a backtrace [FIXED][LLVM] 9 This bug was fixed in LLVM 9.0

Comments

@tpimh
Copy link

tpimh commented Jun 24, 2019

0.	Program arguments: /usr/lib/llvm-9/bin/clang -cc1 -triple mipsel-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ioctl.c -mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks -mllvm -warn-stack-size=1024 -relaxed-aliasing -fmath-errno -masm-verbose -no-integrated-as -mconstructor-aliases -ffreestanding -fuse-init-array -target-cpu mips32r2 -target-feature +noabicalls -target-feature +soft-float -target-abi o32 -msoft-float -mfloat-abi soft -mllvm -mno-check-zero-division -mllvm -mips-ssection-threshold=0 -mllvm -mgpopt -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /continuous-integration/linux/fs/ext4/ioctl.gcno -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-9/lib/clang/9.0.0 -isystem /usr/lib/llvm-9/lib/clang/9.0.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/mips/include -I ./arch/mips/include/generated -I ./include -I ./arch/mips/include/uapi -I ./arch/mips/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D __KERNEL__ -D VMLINUX_LOAD_ADDRESS=0xffffffff80100000 -D DATAOFFSET=0 -D GAS_HAS_SET_HARDFLOAT -D TOOLCHAIN_SUPPORTS_VIRT -D TOOLCHAIN_SUPPORTS_CRC -D TOOLCHAIN_SUPPORTS_DSP -D TOOLCHAIN_SUPPORTS_GINV -I ./arch/mips/include/asm/mach-malta -I ./arch/mips/include/asm/mach-generic -D KBUILD_BASENAME="ioctl" -D KBUILD_MODNAME="ext4" -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -Wno-address-of-packed-member -Wno-format-invalid-specifier -Wno-gnu -Wno-tautological-compare -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir /continuous-integration/linux -ferror-limit 19 -fmessage-length 0 -fwrapv -stack-protector 2 -fwchar-type=short -fno-signed-wchar -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /tmp/ioctl-501db4.s -x c fs/ext4/ioctl.c 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'fs/ext4/ioctl.c'.
4.	Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@ext4_ioctl'
 #0 0x00007f7b606524ff llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xb394ff)
 #1 0x00007f7b60650940 llvm::sys::RunSignalHandlers() (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xb37940)
 #2 0x00007f7b60652901 (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xb39901)
 #3 0x00007f7b63c8f730 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
 #4 0x00007f7b61ec2753 llvm::MipsSEDAGToDAGISel::SelectInlineAsmMemoryOperand(llvm::SDValue const&, unsigned int, std::vector<llvm::SDValue, std::allocator<llvm::SDValue> >&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x23a9753)
 #5 0x00007f7b60c060b7 llvm::SelectionDAGISel::SelectInlineAsmMemoryOperands(std::vector<llvm::SDValue, std::allocator<llvm::SDValue> >&, llvm::SDLoc const&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10ed0b7)
 #6 0x00007f7b60c06a14 llvm::SelectionDAGISel::Select_INLINEASM(llvm::SDNode*, bool) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10eda14)
 #7 0x00007f7b60c03ac7 llvm::SelectionDAGISel::DoInstructionSelection() (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10eaac7)
 #8 0x00007f7b60c03170 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10ea170)
 #9 0x00007f7b60c02837 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10e9837)
#10 0x00007f7b60c00226 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x10e7226)
#11 0x00007f7b61e900da llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0x23770da)
#12 0x00007f7b608d6428 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xdbd428)
#13 0x00007f7b6074ecf6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xc35cf6)
#14 0x00007f7b6074efa3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xc35fa3)
#15 0x00007f7b6074f44a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xc3644a)
#16 0x00000000007253a6 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/usr/lib/llvm-9/bin/clang+0x7253a6)
#17 0x0000000000de35fd (/usr/lib/llvm-9/bin/clang+0xde35fd)
#18 0x0000000001296133 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-9/bin/clang+0x1296133)
#19 0x0000000000b5b28f clang::FrontendAction::Execute() (/usr/lib/llvm-9/bin/clang+0xb5b28f)
#20 0x0000000000b181b1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-9/bin/clang+0xb181b1)
#21 0x0000000000be4d60 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-9/bin/clang+0xbe4d60)
#22 0x00000000006eda30 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-9/bin/clang+0x6eda30)
#23 0x00000000006ebe40 main (/usr/lib/llvm-9/bin/clang+0x6ebe40)
#24 0x00007f7b5f65b09b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409b)
#25 0x00000000006e917a _start (/usr/lib/llvm-9/bin/clang+0x6e917a)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.0-svn364127-1~exp1+0~20190622095755.118~1.gbp9b9451 (trunk)
Target: mipsel-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/ioctl-8c74cc.c
clang: note: diagnostic msg: /tmp/ioctl-8c74cc.sh
clang: note: diagnostic msg: 

********************

ioctl-8c74cc.zip

@tpimh tpimh added [BUG] llvm A bug that should be fixed in upstream LLVM Compiler crash This bug makes Clang crash, emitting a backtrace [ARCH] mips This bug impacts ARCH=mips labels Jun 24, 2019
@nickdesaulniers
Copy link
Member

Needs to be creduce'd; ext4_ioctl is problematic somehow.

@nathanchance
Copy link
Member

@tpimh what defconfig are you using?

@nathanchance
Copy link
Member

I assumed it was 32r2el_defconfig based on the flags.

creduce spits out:

a() { __asm__("" : "=ro"(*(int *)0)); }

with the following interestingness case:

#!/bin/bash

mipsel-linux-gnu-gcc -O2 -c -o /dev/null ioctl.i || exit 1

clang-9 -Qunused-arguments -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -std=gnu89 --target=mipsel-linux-gnu --prefix=/usr/bin/ --gcc-toolchain=/usr -no-integrated-as -mno-check-zero-division -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -Wa,-msoft-float -ffreestanding -EL -fno-stack-check -march=mips32r2 -Wa,--trap -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -mno-global-merge -fomit-frame-pointer -g -fno-var-tracking -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -c -o /dev/null ioctl.i |& grep "llvm::MipsSEDAGToDAGISel::SelectInlineAsmMemoryOperand"

This occurs on tip of tree clang-9 and llvmorg-8.0.1-rc3.

@tpimh
Copy link
Author

tpimh commented Jul 11, 2019

If I recall correctly it was malta_defconfig(or maybe malta_qemu_32r6_defconfig).

@nickdesaulniers
Copy link
Member

@nathanchance nice find. Please file a bug in upstream llvm's issue tracker.

@nathanchance
Copy link
Member

Will do.

@nathanchance
Copy link
Member

https://llvm.org/pr42589

@nathanchance
Copy link
Member

Fixed: llvm/llvm-project@7f308af

I'll build and test here shortly.

@nathanchance nathanchance added the [FIXED][LLVM] 9 This bug was fixed in LLVM 9.0 label Jul 17, 2019
@nathanchance
Copy link
Member

After fixing some warnings/errors (which I will be filing issues and sending patches for), I can compile and link a malta_defconfig kernel.

@nickdesaulniers
Copy link
Member

I can compile and link a malta_defconfig kernel.

Does it boot?

@nathanchance
Copy link
Member

Have not tested since we don't have a buildroot image for it yet

@tpimh
Copy link
Author

tpimh commented Jul 17, 2019

If it panics because of no init, should be good enough to proceed.

@nathanchance
Copy link
Member

That’s a fair point, I will try later tonight.

@nickdesaulniers
Copy link
Member

If it panics because of no init, should be good enough to proceed.

Yep, that's usually a good sign.

@nathanchance
Copy link
Member

nathanchance commented Jul 18, 2019

See #610 for follow up on booting the kernel.

nathanchance added a commit to nathanchance/tc-build that referenced this issue Jul 27, 2019
Now that the two blocking issues have been triaged/dealt with.

ClangBuiltLinux/linux#571
ClangBuiltLinux/linux#610

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit to nathanchance/tc-build that referenced this issue Jul 30, 2019
Now that the two blocking issues have been triaged/dealt with.

ClangBuiltLinux/linux#571
ClangBuiltLinux/linux#610

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM Compiler crash This bug makes Clang crash, emitting a backtrace [FIXED][LLVM] 9 This bug was fixed in LLVM 9.0
Projects
None yet
Development

No branches or pull requests

3 participants