ziglang / zig-bootstrap

take off every zig
379 stars 91 forks source link

riscv64-linux-musl #4

Closed andrewrk closed 3 years ago

andrewrk commented 4 years ago
lld: error: /home/andy/.cache/zig/stage1/o/idTlYJzLF5JDepr0OBQiZEUxpNLOfZLOLICfh_CQDzGq4eT7v8CtG_4dBaZAqBT2/libcompiler_rt.a(/home/andy/.cache/zig/stage1/o/idTlYJzLF5JDepr0OBQiZEUxpNLOfZLOLICfh_CQDzGq4eT7v8CtG_4dBaZAqBT2/compiler_rt.o): cannot link object files with different floating-point ABI

lld: error: /home/andy/.cache/zig/stage1/o/idTlYJzLF5JDepr0OBQiZEUxpNLOfZLOLICfh_CQDzGq4eT7v8CtG_4dBaZAqBT2/libcompiler_rt.a(/home/andy/.cache/zig/stage1/o/idTlYJzLF5JDepr0OBQiZEUxpNLOfZLOLICfh_CQDzGq4eT7v8CtG_4dBaZAqBT2/compiler_rt.o): cannot link object files with different floating-point ABI
lld: error: undefined symbol: _Unwind_Resume
>>> referenced by ios.cpp
>>>               /home/andy/.cache/zig/stage1/o/VXVFC-R6rO1gnod_SD4DUfoX4wA9ftIZncqL5nvl-MQO2dNiKBz5JfxuI9x6Fg8V/ios.o:(std::__1::ios_base::copyfmt(std::__1::ios_base const&)) in archive /home/andy/.cache/zig/stage1/o/sGdJPGnwDYy7qkUqURlEuf-c0KopUXXBRGm_eNwQxazi9ZnVK9qwkL_p3y4R0lrV/libc++.a
>>> referenced by ios.cpp
andrewrk commented 4 years ago

Solved with upstream commit https://github.com/ziglang/zig/commit/6408766d6b55d228a305b877f28f45c1587f7d39

New problem:

[  5%] Linking CXX executable ../../bin/llvm-tblgen
warning: unsupported linker arg: -allow-shlib-undefined
warning: unsupported linker arg: -O3
warning: unsupported linker arg: --gc-sections
lld: error: /home/andy/.cache/zig/stage1/o/FGuRvRGKrl_4zkUKAdtf0kXXDVP1ml-q0FHf98FQiHyNVwqbMldflHkan0xfp-6r/libcompiler_rt.a(/home/andy/.cache/zig/stage1/o/FGuRvRGKrl_4zkUKAdtf0kXXDVP1ml-q0FHf98FQiHyNVwqbMldflHkan0xfp-6r/compiler_rt.o): cannot link object files with different floating-point ABI

I believe this is https://github.com/ziglang/zig/issues/4863

andrewrk commented 4 years ago

With that issue fixed, the next one is:

fatal error: error in backend: Unable to insert indirect branch
Stack dump:
0.  Program arguments: /home/andy/dev/bootstrap-zig/out/host/bin/zig clang -c -nostdinc -fno-spell-checking -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/libcxx/include -D_LIBCPP_HAS_MUSL_LIBC -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -target riscv64-unknown-linux-musl -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/include -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/libc/include/riscv64-linux-musl -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/libc/include/generic-musl -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/libc/include/riscv64-linux-any -isystem /home/andy/dev/bootstrap-zig/out/host/lib/zig/libc/include/any-linux-any -Xclang -target-feature -Xclang +64bit,+a,+c,+d,-e,+f,+m,-relax,-reserve-x1,-reserve-x10,-reserve-x11,-reserve-x12,-reserve-x13,-reserve-x14,-reserve-x15,-reserve-x16,-reserve-x17,-reserve-x18,-reserve-x19,-reserve-x2,-reserve-x20,-reserve-x21,-reserve-x22,-reserve-x23,-reserve-x24,-reserve-x25,-reserve-x26,-reserve-x27,-reserve-x28,-reserve-x29,-reserve-x3,-reserve-x30,-reserve-x31,-reserve-x4,-reserve-x5,-reserve-x6,-reserve-x7,-reserve-x8,-reserve-x9,-rvc-hints -MD -MV -MF zig-cache/tmp/xq3RKAPzCgm1-NVPTXInstPrinter.o.d -mno-relax -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/andy/dev/bootstrap-zig/out/build-llvm-riscv64-linux-musl/lib/Target/NVPTX/MCTargetDesc -I/home/andy/dev/bootstrap-zig/llvm/lib/Target/NVPTX/MCTargetDesc -I/home/andy/dev/bootstrap-zig/llvm/lib/Target/NVPTX -I/home/andy/dev/bootstrap-zig/out/build-llvm-riscv64-linux-musl/lib/Target/NVPTX -I/home/andy/dev/bootstrap-zig/out/build-llvm-riscv64-linux-musl/include -I/home/andy/dev/bootstrap-zig/llvm/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden -fno-exceptions -fno-rtti -std=c++14 -o zig-cache/tmp/xq3RKAPzCgm1-NVPTXInstPrinter.o /home/andy/dev/bootstrap-zig/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp 
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module '/home/andy/dev/bootstrap-zig/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp'.
4.  Running pass 'Branch relaxation pass' on function '@_ZN4llvm16NVPTXInstPrinter16printInstructionEPKNS_6MCInstEmRNS_11raw_ostreamE'
 #0 0x00000000058a4cea llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x58a4cea)
 #1 0x00000000058a2a54 llvm::sys::RunSignalHandlers() (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x58a2a54)
 #2 0x00000000058a2ce1 llvm::sys::CleanupOnSignal(unsigned long) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x58a2ce1)
 #3 0x00000000057e1864 llvm::CrashRecoveryContext::HandleExit(int) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x57e1864)
 #4 0x000000000589bc27 llvm::sys::Process::Exit(int) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x589bc27)
 #5 0x0000000000c31f33 LLVMErrorHandler(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc31f33)
 #6 0x00000000057e8a87 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x57e8a87)
 #7 0x00000000057e8bd0 llvm::report_fatal_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x57e8bd0)
 #8 0x0000000003605384 llvm::RISCVInstrInfo::insertIndirectBranch(llvm::MachineBasicBlock&, llvm::MachineBasicBlock&, llvm::DebugLoc const&, long, llvm::RegScavenger*) const (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x3605384)
 #9 0x00000000047a99db (anonymous namespace)::BranchRelaxation::runOnMachineFunction(llvm::MachineFunction&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x47a99db)
#10 0x00000000048c5474 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x48c5474)
#11 0x000000000557b6b8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x557b6b8)
#12 0x000000000557cc51 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x557cc51)
#13 0x000000000557d008 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x557d008)
#14 0x0000000000c9996c 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/andy/dev/bootstrap-zig/out/host/bin/zig+0xc9996c)
#15 0x0000000000c4bd81 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc4bd81)
#16 0x00000000027215e1 clang::ParseAST(clang::Sema&, bool, bool) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x27215e1)
#17 0x000000000112a1a9 clang::FrontendAction::Execute() (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x112a1a9)
#18 0x00000000010e5a03 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x10e5a03)
#19 0x0000000000c3d94b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc3d94b)
#20 0x0000000000c326ca cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc326ca)
#21 0x0000000000c2d262 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc2d262)
#22 0x000000000122d275 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/andy/dev/bootstrap-zig/out/host/bin/zig+0x122d275)
#23 0x00000000057e16f3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x57e16f3)
#24 0x000000000122de6e 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/andy/dev/bootstrap-zig/out/host/bin/zig+0x122de6e)
#25 0x0000000001204f38 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x1204f38)
#26 0x0000000001205839 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x1205839)
#27 0x000000000120d5ef clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x120d5ef)
#28 0x0000000000c30641 ZigClang_main (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xc30641)
#29 0x0000000000a305f6 main0(int, char**) (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0xa305f6)
#30 0x00000000009a31e7 main (/home/andy/dev/bootstrap-zig/out/host/bin/zig+0x9a31e7)
#31 0x00007f10bfd1eb8e __libc_start_main (/nix/store/y9zg6ryffgc5c9y67fcmfdkyyiivjzpj-glibc-2.27/lib/libc.so.6+0x22b8e)
#32 0x0000000000a2eefa _start /build/glibc-2.27/csu/../sysdeps/x86_64/start.S:122:0
zig: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 10.0.0 (git@github.com:ziglang/bootstrap.git fcb81df448efa3f414166feafc7bbab72c4654b0)
Target: riscv64-unknown-linux-musl
Thread model: posix
InstalledDir: /run/current-system/sw/bin

Upstream bug report

andrewrk commented 4 years ago

cc @luismarques

andrewrk commented 4 years ago

With this workaround, it builds:

--- a/build
+++ b/build
@@ -44,6 +44,7 @@ mkdir -p "$ROOTDIR/out/build-llvm-$TARGET"
 cd "$ROOTDIR/out/build-llvm-$TARGET"
 cmake "$ROOTDIR/llvm" \
   -DLLVM_ENABLE_PROJECTS="lld;clang" \
+  -DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;BPF;Hexagon;Lanai;Mips;MSP430;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86;XCore" \
   -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" \
   -DLLVM_ENABLE_LIBXML2=OFF \
   -DCMAKE_INSTALL_PREFIX="$ROOTDIR/out/$TARGET" \
--- a/zig/cmake/Findllvm.cmake
+++ b/zig/cmake/Findllvm.cmake
@@ -58,7 +58,6 @@ if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
   NEED_TARGET("Lanai")
   NEED_TARGET("Mips")
   NEED_TARGET("MSP430")
-  NEED_TARGET("NVPTX")
   NEED_TARGET("PowerPC")
   NEED_TARGET("RISCV")
   NEED_TARGET("Sparc")

So the upstream Clang issue is the last problem to solve.

luismarques commented 4 years ago

I'm confused by this. There was an issue in llvm::RISCVInstrInfo::insertIndirectBranch, but that was solved by removing the NVPTX target? BTW, does this still occur? Is there a reduction or an easy way to reproduce?

luismarques commented 4 years ago

Ah, you're compiling LLVM in/for a RISCV64 host, right?

andrewrk commented 4 years ago

BTW, does this still occur? Is there a reduction or an easy way to reproduce?

It did with LLVM 10. I haven't tried with any commits since then. The reduction is (replace -j1 with an appropriate arg to make):

build -j1 riscv64-linux-musl baseline

Ah, you're compiling LLVM in/for a RISCV64 host, right?

No, any host. I did it on an x86_64 host to discover this issue.

andrewrk commented 3 years ago

Appears to be solved with LLVM 11.