mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-13 04:30:16 +08:00
* feat(compiler): add native LLVM object emission - ship the pinned macOS arm64 LLVM helper and platform package - add assembly/object CLI outputs, caching, diagnostics, and runtime ABI checks - validate helper artifacts through CI, packaging, docs, and differential coverage * fix(compiler): harden native LLVM emission * fix(compiler): harden LLVM helper packaging * fix(compiler): stabilize LLVM helper package size * fix(compiler): harden native helper validation * fix(compiler): harden LLVM helper verification * fix(compiler): harden native object emission
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include "diagnostics.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include "llvm/Support/FormatVariadic.h"
|
|
#include "llvm/Support/JSON.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
using namespace llvm;
|
|
|
|
namespace scriptc {
|
|
|
|
int reportError(StringRef Code, const Twine &Message,
|
|
StringRef DiagnosticFormat) {
|
|
if (DiagnosticFormat == "json") {
|
|
json::Object Diagnostic{
|
|
{"ok", false},
|
|
{"code", Code},
|
|
{"message", Message.str()},
|
|
};
|
|
errs() << formatv("{0}\n", json::Value(std::move(Diagnostic)));
|
|
} else {
|
|
errs() << "scriptc-llvm-codegen: " << Message << '\n';
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void fatalDiagnostic(void *, const char *Reason, bool) {
|
|
json::Object Diagnostic{
|
|
{"ok", false},
|
|
{"code", "llvm_fatal"},
|
|
{"message", Reason == nullptr ? "LLVM reported a fatal error" : Reason},
|
|
};
|
|
errs() << formatv("{0}\n", json::Value(std::move(Diagnostic)));
|
|
errs().flush();
|
|
std::_Exit(70);
|
|
}
|
|
|
|
void installFatalDiagnosticHandler() {
|
|
install_fatal_error_handler(fatalDiagnostic, nullptr);
|
|
}
|
|
|
|
} // namespace scriptc
|