diff --git a/src/codegen.cpp b/src/codegen.cpp index 517577df0f324..cfd0e7154ce68 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8258,13 +8258,20 @@ extern "C" void jl_init_llvm(void) 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