diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index eda841cbadb73..50316c258d3a0 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -814,13 +814,20 @@ namespace { SmallVector targetFeatures(target.second.begin(), target.second.end()); std::string errorstr; const Target *TheTarget = TargetRegistry::lookupTarget("", TheTriple, errorstr); - if (!TheTarget) - jl_errorf("%s", errorstr.c_str()); + if (!TheTarget) { + // Note we are explicitly not using `jl_errorf()` here, as it will attempt to + // collect a backtrace, but we're too early in LLVM initialization for that. + jl_printf(JL_STDERR, "ERROR: %s", errorstr.c_str()); + exit(1); + } if (jl_processor_print_help || (target_flags & JL_TARGET_UNKNOWN_NAME)) { std::unique_ptr MSTI( TheTarget->createMCSubtargetInfo(TheTriple.str(), "", "")); - if (!MSTI->isCPUStringValid(TheCPU)) - jl_errorf("Invalid CPU name \"%s\".", TheCPU.c_str()); + if (!MSTI->isCPUStringValid(TheCPU)) { + // Same as above, we are too early to use `jl_errorf()` here. + jl_printf(JL_STDERR, "ERROR: Invalid CPU name \"%s\".", TheCPU.c_str()); + exit(1); + } if (jl_processor_print_help) { // This is the only way I can find to print the help message once. // It'll be nice if we can iterate through the features and print our own help