wasmcov
wasmcov copied to clipboard
Coverage reports can't be generated on MacOS
Hi, this is an issue in radixdlt/radixdlt-scrypto
but I'm opening an issue here as, to my understanding, you provided the implementation of coverage in that repo.
I've been trying to get code coverage to work for sometime now and have unfortunately not been able to. The issues I'm running into seem to be specific to MacOS as I don't seem to run into those issues in a Linux VM.
The error that I run into happens when your tool invokes clang-17 file.ll -c -Wno-override-module -o file.o
or a variant of that, we get the error seen in the "Error" section.
Environment
- Operating System: MacOS 14.1.1
- Machine Target Triple: aarch64-apple-darwin
- Processor: M1
- LLVM version: 17.0.6
- LLVM installation: homebrew
- Scryto Version: Newest from
develop
branch. - Rust toolchain version:
rustc 1.77.0-nightly (25f8d01fd 2024-01-18)
Steps to reproduce
scrypto new-package coverage; cd coverage; scrypto coverage
Error
clang failed: fatal error: error in backend: MachO doesn't support COMDATs, '__llvm_profile_runtime_user' cannot be lowered.
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang-17 /Users/omarabdulla/Radix/coverage/coverage/data/coverage.ll -Wno-override-module -c -o /Users/omarabdulla/Radix/coverage/coverage/data/coverage.o
1. Code generation
2. Running pass 'Function Pass Manager' on module '/Users/omarabdulla/Radix/coverage/coverage/data/coverage.ll'.
3. Running pass 'AArch64 Assembly Printer' on function '@__llvm_profile_runtime_user'
#0 0x0000000119a6f1dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3ddb1dc)
#1 0x0000000118d97b8c llvm::sys::CleanupOnSignal(unsigned long) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3103b8c)
#2 0x0000000119a3ff74 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dabf74)
#3 0x0000000119a3ff24 llvm::CrashRecoveryContext::HandleExit(int) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dabf24)
#4 0x0000000119a6e7c8 llvm::sys::Process::Exit(int, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dda7c8)
#5 0x00000001044163fc LLVMErrorHandler(void*, char const*, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x1000063fc)
#6 0x00000001182772cc llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x25e32cc)
#7 0x0000000118317fe8 llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal(llvm::GlobalObject const*, llvm::SectionKind, llvm::TargetMachine const&) const (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x2683fe8)
#8 0x0000000116cc945c llvm::TargetLoweringObjectFile::SectionForGlobal(llvm::GlobalObject const*, llvm::SectionKind, llvm::TargetMachine const&) const (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x103545c)
#9 0x00000001175016e0 llvm::AsmPrinter::emitFunctionHeader() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x186d6e0)
#10 0x0000000118bf0724 llvm::AsmPrinter::emitFunctionBody() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x2f5c724)
#11 0x0000000116cf57f4 (anonymous namespace)::AArch64AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x10617f4)
#12 0x0000000119539234 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x38a5234)
#13 0x0000000117d02afc llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x206eafc)
#14 0x0000000116c31d78 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0xf9dd78)
#15 0x000000010a0bdb24 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::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x134db24)
#16 0x000000010992f5e0 clang::CodeGenAction::ExecuteAction() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xbbf5e0)
#17 0x0000000109bcead4 clang::FrontendAction::Execute() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xe5ead4)
#18 0x000000010949e584 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x72e584)
#19 0x0000000109be5de0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xe75de0)
#20 0x0000000104415b48 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x100005b48)
#21 0x000000010441a9d0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x10000a9d0)
#22 0x0000000108f3452c void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x1c452c)
#23 0x0000000119635c7c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x39a1c7c)
#24 0x0000000109a6ea40 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xcfea40)
#25 0x0000000109417c4c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x6a7c4c)
#26 0x000000010941c5b4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x6ac5b4)
#27 0x000000010441941c clang_main(int, char**, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x10000941c)
#28 0x0000000104423e38 main (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x100013e38)
#29 0x0000000187d190e0
clang-17: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Homebrew clang version 17.0.6
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
clang-17: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
Error: CoverageError(ClangFailed)
Expected Behavior
I expected the above commands to generate the coverage report.
Edit 1: Added the rust toolchain version I have installed.