Skip to content

[Mips] Cannot select: t28: i64 = MipsISD::GPRel TargetGlobalAddress:i64<ptr @.str.5> 0 [TF=3] when building musl libc.a with -mno-abicalls #142060

Open
@alexrp

Description

@alexrp

Repro:

$ git clone https://git.musl-libc.org/git/musl
$ cd musl
$ ./configure --disable-shared --target=mips64-linux-muslabi64 AR="llvm-ar" CC="clang" RANLIB="llvm-ranlib" CFLAGS="--target=mips64-linux-muslabi64 -mno-abicalls"
$ make lib/libc.a -j$(nproc)

Crash:

clang -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math -fno-strict-aliasing -Wa,--noexecstack -D_XOPEN_SOURCE=700 -I./arch/mips64 -I./arch/generic -Iobj/src/internal -I./src/include -I./src/internal -Iobj/include -I./include  -O2 -fno-align-functions -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -w -Wno-pointer-to-int-cast -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -Werror=int-conversion -Werror=incompatible-pointer-types -Qunused-arguments -Waddress -Warray-bounds -Wchar-subscripts -Wduplicate-decl-specifier -Winit-self -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wunused-function -Wunused-label -Wunused-variable --target=mips64-linux-muslabi64 -mno-abicalls -c -o obj/src/crypt/crypt_des.o src/crypt/crypt_des.c
fatal error: error in backend: Cannot select: t28: i64 = MipsISD::GPRel TargetGlobalAddress:i64<ptr @.str.5> 0 [TF=3]
  t27: i64 = TargetGlobalAddress<ptr @.str.5> 0 [TF=3]
In function: __crypt_des
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math -fno-strict-aliasing -Wa,--noexecstack -D_XOPEN_SOURCE=700 -I./arch/mips64 -I./arch/generic -Iobj/src/internal -I./src/include -I./src/internal -Iobj/include -I./include -O2 -fno-align-functions -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -w -Wno-pointer-to-int-cast -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -Werror=int-conversion -Werror=incompatible-pointer-types -Qunused-arguments -Waddress -Warray-bounds -Wchar-subscripts -Wduplicate-decl-specifier -Winit-self -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wunused-function -Wunused-label -Wunused-variable --target=mips64-linux-muslabi64 -mno-abicalls -c -o obj/src/crypt/crypt_des.o src/crypt/crypt_des.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'src/crypt/crypt_des.c'.
4.      Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@__crypt_des'
 #0 0x000079e5603c4a00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Source/llvm-project/llvm/lib/Support/Unix/Signals.inc:803:3
 #1 0x000079e5603c2204 llvm::sys::RunSignalHandlers() /home/alexrp/Source/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #2 0x000079e5602cab12 HandleCrash /home/alexrp/Source/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x000079e5602cab12 llvm::CrashRecoveryContext::HandleExit(int) /home/alexrp/Source/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:444:20
 #4 0x000079e5603bc3d2 llvm::sys::Process::ExitNoCleanup(int) /home/alexrp/Source/llvm-project/llvm/lib/Support/Unix/Process.inc:414:62
 #5 0x000079e5603bc3d2 llvm::sys::Process::Exit(int, bool) /home/alexrp/Source/llvm-project/llvm/lib/Support/Process.cpp:115:18
 #6 0x000061107e87eed3 clang::DiagStorageAllocator::Deallocate(clang::DiagnosticStorage*) /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:217:16
 #7 0x000061107e87eed3 clang::DiagStorageAllocator::Deallocate(clang::DiagnosticStorage*) /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:215:8
 #8 0x000061107e87eed3 clang::StreamingDiagnostic::freeStorageSlow() /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:1143:26
 #9 0x000061107e87eed3 clang::StreamingDiagnostic::freeStorage() /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:1137:20
#10 0x000061107e87eed3 clang::StreamingDiagnostic::~StreamingDiagnostic() /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:1205:39
#11 0x000061107e87eed3 clang::DiagnosticBuilder::~DiagnosticBuilder() /home/alexrp/Source/llvm-project/clang/include/clang/Basic/Diagnostic.h:1316:34
#12 0x000061107e87eed3 LLVMErrorHandler(void*, char const*, bool) /home/alexrp/Source/llvm-project/clang/tools/driver/cc1_main.cpp:71:15
#13 0x000079e5602e218e std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_data() const /usr/include/c++/14/bits/basic_string.h:228:28
#14 0x000079e5602e218e std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_is_local() const /usr/include/c++/14/bits/basic_string.h:269:13
#15 0x000079e5602e218e std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_dispose() /usr/include/c++/14/bits/basic_string.h:287:18
#16 0x000079e5602e218e std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string() /usr/include/c++/14/bits/basic_string.h:809:19
#17 0x000079e5602e218e llvm::report_fatal_error(llvm::Twine const&, bool) /home/alexrp/Source/llvm-project/llvm/lib/Support/ErrorHandling.cpp:105:36
#18 0x000079e560f73332 llvm::SDNode::getOperand(unsigned int) const /home/alexrp/Source/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:993:5
#19 0x000079e560f73332 llvm::SDNode::getConstantOperandVal(unsigned int) const /home/alexrp/Source/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1724:61
#20 0x000079e560f73332 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:4424:44
#21 0x000079e560f7b844 GetVBR /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:2647:7
#22 0x000079e560f7b844 getSimpleVT /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:2666:22
#23 0x000079e560f7b844 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:3634:25
#24 0x000079e560f6f5c7 llvm::SmallVectorTemplateCommon<llvm::SDNode*, void>::isSmall() const /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:143:39
#25 0x000079e560f6f5c7 llvm::SmallVectorImpl<llvm::SDNode*>::~SmallVectorImpl() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:603:23
#26 0x000079e560f6f5c7 llvm::SmallVector<llvm::SDNode*, 4u>::~SmallVector() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1203:3
#27 0x000079e560f6f5c7 llvm::SelectionDAGISel::DoInstructionSelection() /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1354:5
#28 0x000079e560f7f26d llvm::TimeRegion::~TimeRegion() /home/alexrp/Source/llvm-project/llvm/include/llvm/Support/Timer.h:160:9
#29 0x000079e560f7f26d llvm::NamedRegionTimer::~NamedRegionTimer() /home/alexrp/Source/llvm-project/llvm/include/llvm/Support/Timer.h:168:8
#30 0x000079e560f7f26d llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1123:3
#31 0x000079e560f82843 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1904:33
#32 0x000079e560f83efa llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:616:22
#33 0x000079e563eb573e llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project/llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp:53:27
#34 0x000079e560f76537 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:269:11
#35 0x000079e560f76537 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:376:1
#36 0x000079e560f76537 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:347:6
#37 0x000079e5608f5795 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Source/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:33
#38 0x000079e56056b474 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Source/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1416:7
#39 0x000079e56056b685 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#40 0x000079e56056b685 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/ilist_node.h:117:66
#41 0x000079e56056b685 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#42 0x000079e56056b685 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Source/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1451:22
#43 0x000079e56056becd runOnModule /home/alexrp/Source/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1528:7
#44 0x000079e56056becd llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Source/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:55
#45 0x000079e56c5da861 RunCodegenPipeline /home/alexrp/Source/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1229:9
#46 0x000079e56c5da861 emitAssembly /home/alexrp/Source/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1252:21
#47 0x000079e56c5da861 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) /home/alexrp/Source/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1416:25
#48 0x000079e56ca91062 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>::release() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:232:9
#49 0x000079e56ca91062 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>::~IntrusiveRefCntPtr() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:196:34
#50 0x000079e56ca91062 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/alexrp/Source/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:315:20
#51 0x000079e56b18038c clang::ParseAST(clang::Sema&, bool, bool) /home/alexrp/Source/llvm-project/clang/lib/Parse/ParseAST.cpp:184:34
#52 0x000079e56d481695 clang::FrontendAction::Execute() /home/alexrp/Source/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1076:38
#53 0x000079e56d4132e2 llvm::Error::getPtr() const /home/alexrp/Source/llvm-project/llvm/include/llvm/Support/Error.h:279:51
#54 0x000079e56d4132e2 llvm::Error::operator bool() /home/alexrp/Source/llvm-project/llvm/include/llvm/Support/Error.h:242:22
#55 0x000079e56d4132e2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/alexrp/Source/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1056:42
#56 0x000079e56d50e1a0 std::__shared_ptr<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2>::get() const /usr/include/c++/14/bits/shared_ptr_base.h:1667:16
#57 0x000079e56d50e1a0 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const /usr/include/c++/14/bits/shared_ptr_base.h:1364:69
#58 0x000079e56d50e1a0 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::operator*() const /usr/include/c++/14/bits/shared_ptr_base.h:1350:2
#59 0x000079e56d50e1a0 clang::CompilerInvocation::getFrontendOpts() /home/alexrp/Source/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h:259:48
#60 0x000079e56d50e1a0 clang::CompilerInstance::getFrontendOpts() /home/alexrp/Source/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:313:39
#61 0x000079e56d50e1a0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/alexrp/Source/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:297:29
#62 0x000061107e88179c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/alexrp/Source/llvm-project/clang/tools/driver/cc1_main.cpp:290:40
#63 0x000061107e87a288 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /home/alexrp/Source/llvm-project/clang/tools/driver/driver.cpp:218:20
#64 0x000079e56d0319fd operator() /home/alexrp/Source/llvm-project/clang/lib/Driver/Job.cpp:437:32
#65 0x000079e56d0319fd void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:52
#66 0x000079e5602caa5e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/alexrp/Source/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:10
#67 0x000079e56d031ff4 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) /home/alexrp/Source/llvm-project/clang/lib/Driver/Job.cpp:441:10
#68 0x000079e56cff3731 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /home/alexrp/Source/llvm-project/clang/lib/Driver/Compilation.cpp:197:3
#69 0x000079e56cff3cff clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /home/alexrp/Source/llvm-project/clang/lib/Driver/Compilation.cpp:251:5
#70 0x000079e56d005334 llvm::SmallVectorBase<unsigned int>::empty() const /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:81:46
#71 0x000079e56d005334 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /home/alexrp/Source/llvm-project/clang/lib/Driver/Driver.cpp:2190:28
#72 0x000061107e87d78b llvm::SmallVectorBase<unsigned int>::size() const /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:78:32
#73 0x000061107e87d78b llvm::SmallVectorTemplateCommon<std::pair<int, clang::driver::Command const*>, void>::end() /home/alexrp/Source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:269:41
#74 0x000061107e87d78b clang_main(int, char**, llvm::ToolContext const&) /home/alexrp/Source/llvm-project/clang/tools/driver/driver.cpp:404:26
#75 0x000061107e879828 main /home/alexrp/Source/llvm-project/build-20/tools/clang/tools/driver/clang-driver.cpp:18:1
#76 0x000079e55e82a338 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#77 0x000079e55e82a3fb call_init ./csu/../csu/libc-start.c:128:20
#78 0x000079e55e82a3fb __libc_start_main ./csu/../csu/libc-start.c:347:5
#79 0x000061107e879885 _start (/opt/llvm-20/bin/clang-20+0xf885)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 20.1.7 (git@github.com:llvm/llvm-project.git 7cf14539b644fd29d1c2a60f335d80d34f269f21)
Target: mips64-unknown-linux-muslabi64
Thread model: posix
InstalledDir: /opt/llvm-20/bin
Build config: +assertions

Preprocessed source + run script:

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions