[llvm-bugs] [Bug 49685] New: cross compiling with arm-unknown-linux-musl and some features crashes clang

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 22 10:28:39 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49685

            Bug ID: 49685
           Summary: cross compiling with arm-unknown-linux-musl and some
                    features crashes clang
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vincent at rischmann.fr
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 24678
  --> https://bugs.llvm.org/attachment.cgi?id=24678&action=edit
code archive to reproduce

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'
     #0 0x0000000002336d3a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/vincent/local/bin/clang-11+0x2336d3a)
     #1 0x0000000002334ef4 llvm::sys::RunSignalHandlers()
(/home/vincent/local/bin/clang-11+0x2334ef4)
     #2 0x00000000022c5df8 CrashRecoverySignalHandler(int)
(/home/vincent/local/bin/clang-11+0x22c5df8)
     #3 0x00007f61849301e0 __restore_rt (/lib64/libpthread.so.0+0x141e0)
     #4 0x0000000002f27137
llvm::DAGTypeLegalizer::SoftenFloatOp_BR_CC(llvm::SDNode*)
(/home/vincent/local/bin/clang-11+0x2f27137)
     #5 0x0000000002f28325
llvm::DAGTypeLegalizer::SoftenFloatOperand(llvm::SDNode*, unsigned int)
(/home/vincent/local/bin/clang-11+0x2f28325)
     #6 0x0000000002eceb95 llvm::DAGTypeLegalizer::run()
(/home/vincent/local/bin/clang-11+0x2eceb95)
     #7 0x0000000002ecefa9 llvm::SelectionDAG::LegalizeTypes()
(/home/vincent/local/bin/clang-11+0x2ecefa9)
     #8 0x0000000002e7f191 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/vincent/local/bin/clang-11+0x2e7f191)
     #9 0x0000000002e82416
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/vincent/local/bin/clang-11+0x2e82416)
    #10 0x0000000002e845aa
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/vincent/local/bin/clang-11+0x2e845aa)
    #11 0x0000000000dfab14 (anonymous
namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/vincent/local/bin/clang-11+0xdfab14)
    #12 0x0000000001a3af90
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0)
(/home/vincent/local/bin/clang-11+0x1a3af90)
    #13 0x0000000001d34268 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/vincent/local/bin/clang-11+0x1d34268)
    #14 0x0000000001d34993 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/vincent/local/bin/clang-11+0x1d34993)
    #15 0x0000000001d330bd llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/vincent/local/bin/clang-11+0x1d330bd)
    #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)
    #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)
    #18 0x0000000002f634ef
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/vincent/local/bin/clang-11+0x2f634ef)
    #19 0x0000000003700f79 clang::ParseAST(clang::Sema&, bool, bool)
(/home/vincent/local/bin/clang-11+0x3700f79)
    #20 0x0000000002a135b1 clang::FrontendAction::Execute()
(/home/vincent/local/bin/clang-11+0x2a135b1)
    #21 0x00000000029d210b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/vincent/local/bin/clang-11+0x29d210b)
    #22 0x0000000002aaa47b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/vincent/local/bin/clang-11+0x2aaa47b)
    #23 0x0000000000932fa8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/vincent/local/bin/clang-11+0x932fa8)
    #24 0x0000000000930e53 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/vincent/local/bin/clang-11+0x930e53)
    #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)
    #26 0x00000000022c5ef3
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/vincent/local/bin/clang-11+0x22c5ef3)
    #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)
    #28 0x00000000028a6c39
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/vincent/local/bin/clang-11+0x28a6c39)
    #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)
    #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)
    #31 0x000000000089124d main (/home/vincent/local/bin/clang-11+0x89124d)
    #32 0x00007f61843d31e2 __libc_start_main (/lib64/libc.so.6+0x281e2)
    #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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210322/1c360634/attachment.html>


More information about the llvm-bugs mailing list