Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage reports can't be generated on MacOS #3

Open
0xOmarA opened this issue Jan 21, 2024 · 4 comments
Open

Coverage reports can't be generated on MacOS #3

0xOmarA opened this issue Jan 21, 2024 · 4 comments

Comments

@0xOmarA
Copy link

0xOmarA commented Jan 21, 2024

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.

@bbarwik
Copy link

bbarwik commented Jan 22, 2024

I don't have mac to test it, but probably clang command building object file should have parameter -arch x86_64 to work correctly. I'll ask someone with mac to test it.

@0xOmarA
Copy link
Author

0xOmarA commented Jan 22, 2024

Sounds good, thanks @bbarwik! I've tried the -arch x86_64 and I still get the same issue.

Error
omarabdulla@Omars-MacBook-Pro-2 temp % clang-17 new.ll -c -Wno-override-module -arch x86_64 -o file.o
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 new.ll -c -Wno-override-module -arch x86_64 -o file.o
1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'new.ll'.
3.	Running pass 'X86 Assembly Printer' on function '@__llvm_profile_runtime_user'
 #0 0x00000001161171dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3ddb1dc)
 #1 0x000000011543fb8c llvm::sys::CleanupOnSignal(unsigned long) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3103b8c)
 #2 0x00000001160e7f74 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dabf74)
 #3 0x00000001160e7f24 llvm::CrashRecoveryContext::HandleExit(int) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dabf24)
 #4 0x00000001161167c8 llvm::sys::Process::Exit(int, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3dda7c8)
 #5 0x0000000100abe3fc LLVMErrorHandler(void*, char const*, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x1000063fc)
 #6 0x000000011491f2cc llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x25e32cc)
 #7 0x00000001149bffe8 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 0x000000011337145c 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 0x0000000113ba96e0 llvm::AsmPrinter::emitFunctionHeader() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x186d6e0)
#10 0x0000000115298724 llvm::AsmPrinter::emitFunctionBody() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x2f5c724)
#11 0x00000001157b2f10 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x3476f10)
#12 0x0000000115be1234 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x38a5234)
#13 0x00000001143aaafc llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x206eafc)
#14 0x00000001132d9d78 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0xf9dd78)
#15 0x0000000106765b24 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 0x0000000105fd75e0 clang::CodeGenAction::ExecuteAction() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xbbf5e0)
#17 0x0000000106276ad4 clang::FrontendAction::Execute() (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xe5ead4)
#18 0x0000000105b46584 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0x72e584)
#19 0x000000010628dde0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libclang-cpp.dylib+0xe75de0)
#20 0x0000000100abdb48 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x100005b48)
#21 0x0000000100ac29d0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x10000a9d0)
#22 0x00000001055dc52c 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 0x0000000115cddc7c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/homebrew/Cellar/llvm/17.0.6_1/lib/libLLVM.dylib+0x39a1c7c)
#24 0x0000000106116a40 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 0x0000000105abfc4c 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 0x0000000105ac45b4 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 0x0000000100ac141c clang_main(int, char**, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang-17+0x10000941c)
#28 0x0000000100acbe38 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: x86_64-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.
omarabdulla@Omars-MacBook-Pro-2 temp %

I'm afraid that the issue might be in the IR generated when a WASM is built using the Rust toolchain on MacOS, it seems like this is where the COMDAT sections and __llvm_profile_runtime_user comes from. I am also unsure if this issue also happens on Windows.

I suspect that if the LLVM IR is emitted when building the WASM on a linux machine with the linux rust toolchain then the above command would succeed.

@njelich-hacken
Copy link
Contributor

@0xOmarA Try switching your entire shell to x86_64 and then running all commands.

@0xOmarA
Copy link
Author

0xOmarA commented Jan 22, 2024

@njelich-hacken I just tried that and it didn't work. I've tried the following:

  • Switching the shell to x86_64.
  • Switching the shell to x86_64 and the toolchain to the x86 apple darwin toolchain.
  • Switching the shell to x86_64 and the toolchain to the x86 linux toolchain.

None of the above worked and I still pretty much run into the same issue. Also, just to make sure that this is not an individual issue I've reproduced this on a second macbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants