stage2: default to LLVM backend

on targets for which self-hosted backends are not up to par.

See #89
This commit is contained in:
Andrew Kelley 2022-03-17 19:03:37 -07:00
parent 76b382072a
commit 35d6ee08c4
2 changed files with 19 additions and 3 deletions

View File

@ -943,11 +943,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
if (use_stage1)
break :blk true;
// Prefer LLVM for release builds as long as it supports the target architecture.
if (options.optimize_mode != .Debug and target_util.hasLlvmSupport(options.target))
// If LLVM does not support the target, then we can't use it.
if (!target_util.hasLlvmSupport(options.target))
break :blk false;
// Prefer LLVM for release builds.
if (options.optimize_mode != .Debug)
break :blk true;
break :blk false;
// At this point we would prefer to use our own self-hosted backend,
// because the compilation speed is better than LLVM. But only do it if
// we are confident in the robustness of the backend.
break :blk !target_util.selfHostedBackendIsAsRobustAsLlvm(options.target);
};
if (!use_llvm) {
if (options.use_llvm == true) {

View File

@ -268,6 +268,15 @@ pub fn hasLlvmSupport(target: std.Target) bool {
};
}
/// The set of targets that our own self-hosted backends have robust support for.
/// Used to select between LLVM backend and self-hosted backend when compiling in
/// debug mode. A given target should only return true here if it is passing greater
/// than or equal to the number of behavior tests as the respective LLVM backend.
pub fn selfHostedBackendIsAsRobustAsLlvm(target: std.Target) bool {
_ = target;
return false;
}
pub fn supportsStackProbing(target: std.Target) bool {
return target.os.tag != .windows and target.os.tag != .uefi and
(target.cpu.arch == .i386 or target.cpu.arch == .x86_64);