llvm / llvm-project

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

Clang 10 fails compiling Swift on Fedora Linux on s390x architecture #45152

Open tachoknight opened 4 years ago

tachoknight commented 4 years ago
Bugzilla Link 45807
Version 10.0
OS Linux
Attachments Clang-generated shell script and affected cpp file
CC @zygoloid

Extended Description

Hi-

I am trying to build Swift 5.3 on Fedora Linux 32 using Clang 10 in a s390x environment. It crashes with the following message:

FAILED: stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o /builddir/build/BUILD/swift-source/build/buildbot_linux/llvm-linux-s390x/./bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -D_DEBUG -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Istdlib/public/stubs -I/builddir/build/BUILD/swift-source/swift/stdlib/public/stubs -Iinclude -I/builddir/build/BUILD/swift-source/swift/include -I/builddir/build/BUILD/swift-source/llvm-project/llvm/include -I/builddir/build/BUILD/swift-source/build/buildbot_linux/llvm-linux-s390x/include -I/builddir/build/BUILD/swift-source/llvm-project/clang/include -I/builddir/build/BUILD/swift-source/build/buildbot_linux/llvm-linux-s390x/tools/clang/include -I/builddir/build/BUILD/swift-source/cmark/src -I/builddir/build/BUILD/swift-source/build/buildbot_linux/cmark-linux-s390x/src -I/builddir/build/BUILD/swift-source/swift-corelibs-libdispatch/src/BlocksRuntime -I/builddir/build/BUILD/swift-source/swift-corelibs-libdispatch -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O2 -UNDEBUG -fno-exceptions -fno-rtti -Werror=gnu -fno-sanitize=all -Wall -Wg lobal-constructors -Wexit-time-destructors -fvisibility=hidden -DswiftCore_EXPORTS -I/builddir/build/BUILD/swift-source/swift/include -DSWIFT_TARGET_LIBRARY_NAME=swiftStdlibStubs -target s390x-unknown-linux-gnu -O2 -g0 -DNDEBUG -std=c++14 -MD -MT stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o -MF stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o.d -o stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o -c /builddir/build/BUILD/swift-source/swift/stdlib/public/stubs/Stubs.cpp fatal error: error in backend: Cannot select: t37: ch = store<(store 2 into %ir.v, !tbaa !​6), trunc to f16> t11, t6, FrameIndex:i64<0>, undef:i64 t6: f32,ch = CopyFromReg t0, Register:f32 %2 t5: f32 = Register %2 t9: i64 = FrameIndex<0> t16: i64 = undef In function: swift_float16ToString clang-10: error: clang frontend command failed with exit code 70 (use -v to see invocation) clang version 10.0.0 Target: s390x-unknown-linux-gnu Thread model: posix InstalledDir: /builddir/build/BUILD/swift-source/build/buildbot_linux/llvm-linux-s390x/./bin clang-10: 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-10: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-10: note: diagnostic msg: /tmp/Stubs-e5538b.cpp clang-10: note: diagnostic msg: /tmp/Stubs-e5538b.sh clang-10: note: diagnostic msg:


Endilll commented 10 months ago

Still crashing as of post-17 trunk: https://godbolt.org/z/46no54q8Y

fatal error: error in backend: Cannot select: t12: ch = store<(store (s16) into @swift_float16ToString_v), trunc to f16> t4:1, t4, t14, undef:i64, example.cpp:0
  t4: f32,ch = load<(dereferenceable load (s32) from @swift_float16ToString_Value)> t0, t16, undef:i64, example.cpp:2:34
    t16: i64 = SystemZISD::PCREL_WRAPPER TargetGlobalAddress:i64<ptr @swift_float16ToString_Value> 0, example.cpp:2:34
      t15: i64 = TargetGlobalAddress<ptr @swift_float16ToString_Value> 0, example.cpp:2:34
    t3: i64 = undef
  t14: i64 = SystemZISD::PCREL_WRAPPER TargetGlobalAddress:i64<ptr @swift_float16ToString_v> 0, example.cpp:0
    t13: i64 = TargetGlobalAddress<ptr @swift_float16ToString_v> 0, example.cpp:0
  t3: i64 = undef
In function: __cxx_global_var_init
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -target s390x-unknown-linux-gnu <source>
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '<source>'.
4.  Running pass 'SystemZ DAG->DAG Pattern Instruction Selection' on function '@__cxx_global_var_init'
 #0 0x00000000036bc8f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36bc8f8)
 #1 0x00000000036ba5bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ba5bc)
 #2 0x0000000003603f46 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3603f46)
 #3 0x00000000036b190e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b190e)
 #4 0x0000000000bd36ea LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x000000000360e943 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x360e943)
 #6 0x00000000047ac49d llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ac49d)
 #7 0x00000000047ae129 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ae129)
 #8 0x000000000201be03 (anonymous namespace)::SystemZDAGToDAGISel::Select(llvm::SDNode*) SystemZISelDAGToDAG.cpp:0:0
 #9 0x00000000047a8c4f llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47a8c4f)
#10 0x00000000047b5c29 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47b5c29)
#11 0x00000000047b9438 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47b9438)
#12 0x00000000047bb132 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x000000000201e412 (anonymous namespace)::SystemZDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) SystemZISelDAGToDAG.cpp:0:0
#14 0x0000000002aa31f9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x00000000030484e9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30484e9)
#16 0x0000000003048721 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3048721)
#17 0x0000000003048f42 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3048f42)
#18 0x0000000003930b80 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0
#19 0x00000000039314a9 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39314a9)
#20 0x000000000491f61f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491f61f)
#21 0x0000000005e15379 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e15379)
#22 0x000000000491dcf8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491dcf8)
#23 0x000000000417be69 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x417be69)
#24 0x00000000040fe7be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40fe7be)
#25 0x000000000425c386 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x425c386)
#26 0x0000000000bd4b6e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd4b6e)
#27 0x0000000000bcd22a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000000003f5f5f9 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) Job.cpp:0:0
#29 0x0000000003603e84 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3603e84)
#30 0x0000000003f5fbef 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) Job.cpp:0:0
#31 0x0000000003f27f75 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f27f75)
#32 0x0000000003f289dd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f289dd)
#33 0x0000000003f30905 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f30905)
#34 0x0000000000bd2e0c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd2e0c)
#35 0x0000000000aced61 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xaced61)
#36 0x00007f75c323f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#37 0x0000000000bccd0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbccd0e)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Endilll commented 10 months ago

Reduced by C-Reduce:

float swift_float16ToString_Value;
__fp16 swift_float16ToString_v = swift_float16ToString_Value;
melizasw commented 8 months ago

Also running into this bug on Debian unstable when trying to build Swift 5.6.3 for s390x using the modified Clang 13.0.0 that is included with Swift.

__swift_ssize_t swift_float16ToString(char *Buffer, size_t BufferLength,
                                      float Value, bool Debug) {
  __fp16 v = Value;
  return swift_dtoa_optimal_binary16_p(&v, Buffer, BufferLength);
}
[175/1333][ 13%][182.733s] Building CXX object stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o
FAILED: stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o 
/<<PKGBUILDDIR>>/build/buildbot_linux/llvm-linux-s390x/./bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 -DSWIFT_INLINE_NAMESPACE=__runtime -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-s390x/stdlib/public/stubs -I/<<PKGBUILDDIR>>/swift/stdlib/public/stubs -I/<<PKGBUILDDIR>>/swift/stdlib/include -I/<<PKGBUILDDIR>>/build/buildbot_linux/swift-linux-s390x/include -I/<<PKGBUILDDIR>>/swift/include -I/<<PKGBUILDDIR>>/build/buildbot_linux/llvm-linux-s390x/include -I/<<PKGBUILDDIR>>/llvm-project/clang/include -I/<<PKGBUILDDIR>>/build/buildbot_linux/llvm-linux-s390x/tools/clang/include -I/<<PKGBUILDDIR>>/cmark/src -I/<<PKGBUILDDIR>>/build/buildbot_linux/cmark-linux-s390x/src -I/<<PKGBUILDDIR>>/swift-corelibs-libdispatch/src/BlocksRuntime -I/<<PKGBUILDDIR>>/swift-corelibs-libdispatch -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O3 -DNDEBUG -std=c++14 -fvisibility=hidden -fvisibility-inlines-hidden  -fno-exceptions -fno-rtti -Werror=gnu -Werror=c++98-compat-extra-semi -UNDEBUG -fno-sanitize=all -Wall -Wformat-nonliteral -Werror=format-nonliteral -Wglobal-constructors -Werror=global-constructors -Wexit-time-destructors -Werror=exit-time-destructors -DswiftCore_EXPORTS -I/<<PKGBUILDDIR>>/swift/include -DSWIFT_TARGET_LIBRARY_NAME=swiftStdlibStubs -DSWIFT_RUNTIME -target s390x-ibm-linux-gnu -O2 -g0 -DNDEBUG -DSWIFT_OBJC_INTEROP=0 -DSWIFT_LIBRARY_EVOLUTION=1 -DSWIFT_ENABLE_REFLECTION -DSWIFT_STDLIB_HAS_DLADDR -DSWIFT_STDLIB_HAS_DARWIN_LIBMALLOC=1 -DSWIFT_STDLIB_HAS_STDIN -DSWIFT_STDLIB_HAS_ENVIRON -DSWIFT_RUNTIME_OS_VERSIONING -DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS -DSWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING -MD -MT stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o -MF stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o.d -o stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-s390x.dir/Stubs.cpp.o -c /<<PKGBUILDDIR>>/swift/stdlib/public/stubs/Stubs.cpp
fatal error: error in backend: Cannot select: t37: ch = store<(store (s16) into %ir.v, !tbaa !10), trunc to f16> t11, t6, FrameIndex:i64<0>, undef:i64
  t6: f32,ch = CopyFromReg t0, Register:f32 %2
    t5: f32 = Register %2
  t9: i64 = FrameIndex<0>
  t16: i64 = undef
In function: swift_float16ToString