Open etcimon opened 4 years ago
Posted a $300 bounty https://www.bountysource.com/issues/88985269-no-stack-trace-when-llvm-fails
What you need here is not a stacktrace, because LLVM is not crashing. It is reporting the error (error: couldn't allocate output register for constraint '{eax}'
) and what you need here is source location, for example the function in which that asm output constraint was found.
I'm compiling Botan for iOS
I assume no x86 target, but AArch64, so any inline asm using the x86 eax
register cannot work. So this might mean revising all existing inline asm.
clang does support this (https://cpp.godbolt.org/z/vfYQ-n), apparently by attaching some srcloc
IR metadata.
I've quickly looked into this; srcloc
(+ custom InlineAsmDiagnosticHandler
for LLVMContext
) would indeed be helpful for errors in the template string, additionally displaying the LOC of the D expression/statement. Validation (in terms of valid codes) for inline asm constraint strings isn't part of that; clang does it all in the frontend, with clang-specific TargetInfo
classes validating register names etc (validateOutputConstraint()
...). So these LLVM errors (wrt. wrong register names in constraints) unfortunately don't pass through InlineAsmDiagnosticHandler
, and so the IR metadata isn't available.
The actual inline asm diagnostics have been extended in #3339. Manual validation of the constraints isn't feasible / not worth the cost IMO. If you don't expect a lot of these errors and just want to locate them, there are little tricks that can help, like running dub with -v
for the failing cmdline, then outputting the textual IR (only) via -output-ll
(possibly adding -disable-verify
to skip LLVM validation passes), and finally grepping the generated .ll file for the problematic constraint string.
I'm compiling Botan for iOS and there's about 500,000 LOC. I get the following output from LDC:
The issue is that LLVM failures should be caught and a stack trace generated in order to be useful