Description
the .weak
assembler directive is currently not supported by LLVM (although it is documented https://www.ibm.com/docs/en/ssw_aix_71/assembler/assembler_pdf.pdf).
In contrast, the .weak_definition
directive is accepted by the assembly parser, but crashes LLVM later on.
Therefore it is currently impossible to define weak symbols using inline assembly.
the .weak_definition
attribute fails with (https://godbolt.org/z/rderToPx4)
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 5422e2c)
Target: powerpc64-ibm-aix
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk-20250306/bin
(in-process)
"/opt/compiler-explorer/clang-trunk-20250306/bin/clang-21" -cc1 -triple powerpc64-ibm-aix -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name example.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -fxl-pragma-pack -fno-sized-deallocation -target-cpu pwr7 -mfloat-abi hard -gstrict-dwarf -gno-column-info -debug-info-kind=constructor -dwarf-version=3 -fdebug-compilation-dir=/app -v -fdata-sections -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20250306/lib/clang/21 -internal-isystem /opt/compiler-explorer/clang-trunk-20250306/lib/clang/21/include/ppc_wrappers -internal-isystem /opt/compiler-explorer/clang-trunk-20250306/lib/clang/21/include -internal-isystem /usr/include -ferror-limit 19 -fno-signed-char -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -o /app/output.s -x c
clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
/opt/compiler-explorer/clang-trunk-20250306/lib/clang/21/include/ppc_wrappers
/opt/compiler-explorer/clang-trunk-20250306/lib/clang/21/include
/usr/include
End of search list.
fatal error: error in backend: Not implemented yet.
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-trunk/bin/clang -g -o /app/output.s -fno-verbose-asm -c -target powerpc64 -fcolor-diagnostics -fno-crash-diagnostics -target powerpc64-ibm-aix -v <source>
1. <eof> parser at end of file
2. Code generation
#0 0x0000000003b50668 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b50668)
#1 0x0000000003b4e7ac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b4e7ac)
#2 0x0000000003a9e083 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3a9e083)
#3 0x0000000003b4623e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b4623e)
#4 0x0000000000d611db LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
#5 0x0000000003aa8153 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3aa8153)
#6 0x0000000003aa82b8 (/opt/compiler-explorer/clang-trunk/bin/clang+0x3aa82b8)
#7 0x00000000038740e0 llvm::MCXCOFFStreamer::emitXCOFFRefDirective(llvm::MCSymbol const*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38740e0)
#8 0x00000000038cb850 bool llvm::function_ref<bool ()>::callback_fn<(anonymous namespace)::AsmParser::parseDirectiveSymbolAttribute(llvm::MCSymbolAttr)::'lambda'()>(long) AsmParser.cpp:0:0
#9 0x00000000038f0fec llvm::MCAsmParser::parseMany(llvm::function_ref<bool ()>, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38f0fec)
#10 0x00000000038defb0 (anonymous namespace)::AsmParser::parseStatement((anonymous namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) AsmParser.cpp:0:0
#11 0x00000000038d1e62 (anonymous namespace)::AsmParser::Run(bool, bool) AsmParser.cpp:0:0
#12 0x0000000004a7ab6c llvm::AsmPrinter::emitInlineAsm(llvm::StringRef, llvm::MCSubtargetInfo const&, llvm::MCTargetOptions const&, llvm::MDNode const*, llvm::InlineAsm::AsmDialect) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a7ab6c)
#13 0x0000000004a6fc39 llvm::AsmPrinter::doInitialization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4a6fc39)
#14 0x0000000001ef16f9 (anonymous namespace)::PPCAIXAsmPrinter::doInitialization(llvm::Module&) PPCAsmPrinter.cpp:0:0
#15 0x00000000034aec28 llvm::FPPassManager::doInitialization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x34aec28)
#16 0x00000000034ba02e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x34ba02e)
#17 0x0000000003df7c2e 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*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3df7c2e)
#18 0x00000000044cbac5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44cbac5)
#19 0x000000000603bfcc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x603bfcc)
#20 0x00000000044cc1e5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x44cc1e5)
#21 0x00000000047a6431 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47a6431)
#22 0x000000000472706b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x472706b)
#23 0x0000000004893423 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4893423)
#24 0x0000000000d63411 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd63411)
#25 0x0000000000d5bc1d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000000004518759 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
#27 0x0000000003a9df83 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3a9df83)
#28 0x0000000004518979 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
#29 0x00000000044dc79d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x44dc79d)
#30 0x00000000044dd731 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x44dd731)
#31 0x00000000044e7b6c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44e7b6c)
#32 0x0000000000d600d1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd600d1)
#33 0x0000000000c21ad4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xc21ad4)
#34 0x00007e785ce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007e785ce29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000000000d5b6b5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xd5b6b5)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
this came up here rust-lang/rust#137816
cc @daltenty