Format linker script error backtraces the same way as others (#1792)

This commit is contained in:
Rangi
2025-08-12 16:58:17 -04:00
committed by GitHub
parent 1bf1219e07
commit 50d0b101c3
28 changed files with 181 additions and 101 deletions

View File

@@ -8,6 +8,7 @@
#include "style.hpp"
#include "link/fstack.hpp"
#include "link/lexer.hpp"
// clang-format off: nested initializers
Diagnostics<WarningLevel, WarningID> warnings = {
@@ -102,17 +103,13 @@ void error(char const *fmt, ...) {
warnings.incrementErrors();
}
void scriptError(char const *name, uint32_t lineNo, char const *fmt, va_list args) {
style_Set(stderr, STYLE_RED, true);
fputs("error: ", stderr);
style_Set(stderr, STYLE_CYAN, true);
fputs(name, stderr);
style_Set(stderr, STYLE_CYAN, false);
fprintf(stderr, "(%" PRIu32 ")", lineNo);
style_Reset(stderr);
fputs(": ", stderr);
vfprintf(stderr, fmt, args);
putc('\n', stderr);
void scriptError(char const *fmt, ...) {
va_list args;
va_start(args, fmt);
printDiag(nullptr, 0, fmt, args, "error", STYLE_RED, nullptr, nullptr);
va_end(args);
lexer_TraceCurrent();
warnings.incrementErrors();
}