llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.76k stars 11.89k forks source link

cross compiling with arm-unknown-linux-musl and some features crashes clang #49029

Open vrischmann opened 3 years ago

vrischmann commented 3 years ago
Bugzilla Link 49685
Version 11.0
OS Linux
Attachments code archive to reproduce, crash backtrace
CC @DougGregor,@zygoloid

Extended Description

Hello,

cross compiling with arm-unknown-linux-musl and the following features:

-Xclang -target-feature -Xclang +d32 \ -Xclang -target-feature -Xclang +fp64 \ -Xclang -target-feature -Xclang +fpregs \ -Xclang -target-feature -Xclang +neon \ -Xclang -target-feature -Xclang +vfp2 \ -Xclang -target-feature -Xclang +vfp2sp \ -Xclang -target-feature -Xclang +vfp3 \ -Xclang -target-feature -Xclang +vfp3d16 \ -Xclang -target-feature -Xclang +vfp3d16sp \ -Xclang -target-feature -Xclang +vfp3sp \

crashes the compiler in some cases:

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -target arm-unknown-linux-musl -nostdinc -Xclang -target-feature -Xclang +d32 -Xclang -target-feature -Xclang +fp64 -Xclang -target-feature -Xclang +fpregs -Xclang -target-feature -Xclang +neon -Xclang -target-feature -Xclang +vfp2 -Xclang -target-feature -Xclang +vfp2sp -Xclang -target-feature -Xclang +vfp3 -Xclang -target-feature -Xclang +vfp3d16 -Xclang -target-feature -Xclang +vfp3d16sp -Xclang -target-feature -Xclang +vfp3sp -c alarm.c -ffreestanding -w -I musl/arch/arm -I musl/arch/generic -I musl/src/include -I musl/src/internal -I musl/include -I include/arm-linux-musl -I include/generic-musl
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'alarm.c'.
4.      Running pass 'ARM Instruction Selection' on function '@alarm'
 #&#8203;0 0x0000000002336d3a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/vincent/local/bin/clang-11+0x2336d3a)
 #&#8203;1 0x0000000002334ef4 llvm::sys::RunSignalHandlers() (/home/vincent/local/bin/clang-11+0x2334ef4)
 #&#8203;2 0x00000000022c5df8 CrashRecoverySignalHandler(int) (/home/vincent/local/bin/clang-11+0x22c5df8)
 #&#8203;3 0x00007f61849301e0 __restore_rt (/lib64/libpthread.so.0+0x141e0)
 #&#8203;4 0x0000000002f27137 llvm::DAGTypeLegalizer::SoftenFloatOp_BR_CC(llvm::SDNode*) (/home/vincent/local/bin/clang-11+0x2f27137)
 #&#8203;5 0x0000000002f28325 llvm::DAGTypeLegalizer::SoftenFloatOperand(llvm::SDNode*, unsigned int) (/home/vincent/local/bin/clang-11+0x2f28325)
 #&#8203;6 0x0000000002eceb95 llvm::DAGTypeLegalizer::run() (/home/vincent/local/bin/clang-11+0x2eceb95)
 #&#8203;7 0x0000000002ecefa9 llvm::SelectionDAG::LegalizeTypes() (/home/vincent/local/bin/clang-11+0x2ecefa9)
 #&#8203;8 0x0000000002e7f191 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/vincent/local/bin/clang-11+0x2e7f191)
 #&#8203;9 0x0000000002e82416 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/vincent/local/bin/clang-11+0x2e82416)
#&#8203;10 0x0000000002e845aa llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/vincent/local/bin/clang-11+0x2e845aa)
#&#8203;11 0x0000000000dfab14 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/vincent/local/bin/clang-11+0xdfab14)
#&#8203;12 0x0000000001a3af90 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) (/home/vincent/local/bin/clang-11+0x1a3af90)
#&#8203;13 0x0000000001d34268 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/vincent/local/bin/clang-11+0x1d34268)
#&#8203;14 0x0000000001d34993 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/vincent/local/bin/clang-11+0x1d34993)
#&#8203;15 0x0000000001d330bd llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/vincent/local/bin/clang-11+0x1d330bd)
#&#8203;16 0x000000000252658e (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/vincent/local/bin/clang-11+0x252658e)
#&#8203;17 0x0000000002527b8f 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> >) (/home/vincent/local/bin/clang-11+0x2527b8f)
#&#8203;18 0x0000000002f634ef clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/vincent/local/bin/clang-11+0x2f634ef)
#&#8203;19 0x0000000003700f79 clang::ParseAST(clang::Sema&, bool, bool) (/home/vincent/local/bin/clang-11+0x3700f79)
#&#8203;20 0x0000000002a135b1 clang::FrontendAction::Execute() (/home/vincent/local/bin/clang-11+0x2a135b1)
#&#8203;21 0x00000000029d210b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/vincent/local/bin/clang-11+0x29d210b)
#&#8203;22 0x0000000002aaa47b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/vincent/local/bin/clang-11+0x2aaa47b)
#&#8203;23 0x0000000000932fa8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/vincent/local/bin/clang-11+0x932fa8)
#&#8203;24 0x0000000000930e53 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/home/vincent/local/bin/clang-11+0x930e53)
#&#8203;25 0x00000000028cb685 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) (/home/vincent/local/bin/clang-11+0x28cb685)
#&#8203;26 0x00000000022c5ef3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/vincent/local/bin/clang-11+0x22c5ef3)
#&#8203;27 0x00000000028cc331 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (.part.0) (/home/vincent/local/bin/clang-11+0x28cc331)
#&#8203;28 0x00000000028a6c39 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/vincent/local/bin/clang-11+0x28a6c39)
#&#8203;29 0x00000000028a713d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/vincent/local/bin/clang-11+0x28a713d)
#&#8203;30 0x00000000028b0d49 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/vincent/local/bin/clang-11+0x28b0d49)
#&#8203;31 0x000000000089124d main (/home/vincent/local/bin/clang-11+0x89124d)
#&#8203;32 0x00007f61843d31e2 __libc_start_main (/lib64/libc.so.6+0x281e2)
#&#8203;33 0x000000000093035e _start (/home/vincent/local/bin/clang-11+0x93035e)
clang-11: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 11.0.1
Target: arm-unknown-linux-musl
Thread model: posix
InstalledDir: /home/vincent/local/bin

Removing any of the feature flag makes it work.

I don't know if these flags make sense as is, I encountered this with Zig building musl, however it's easily reproducible with just clang.

I've attached an archive with the code and a script to reproduce.

I've also tested with clang 12.0.0rc3, it crashes too.

llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-arm