authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-17 19:03:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-17 19:03:37-07:00
log35d6ee08c468642969b594b711dd6448bbaefa89
treeb1f7bd48fdf271568b791221d1213659a46c5ad1
parent76b382072ae632d8f113bcf151976f140566e699

stage2: default to LLVM backend

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

2 files changed, 19 insertions(+), 3 deletions(-)

src/Compilation.zig+10-3
...@@ -943,11 +943,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -943,11 +943,18 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
943 if (use_stage1)943 if (use_stage1)
944 break :blk true;944 break :blk true;
945945
946 // Prefer LLVM for release builds as long as it supports the target architecture.946 // If LLVM does not support the target, then we can't use it.
947 if (options.optimize_mode != .Debug and target_util.hasLlvmSupport(options.target))947 if (!target_util.hasLlvmSupport(options.target))
948 break :blk false;
949
950 // Prefer LLVM for release builds.
951 if (options.optimize_mode != .Debug)
948 break :blk true;952 break :blk true;
949953
950 break :blk false;954 // At this point we would prefer to use our own self-hosted backend,
955 // because the compilation speed is better than LLVM. But only do it if
956 // we are confident in the robustness of the backend.
957 break :blk !target_util.selfHostedBackendIsAsRobustAsLlvm(options.target);
951 };958 };
952 if (!use_llvm) {959 if (!use_llvm) {
953 if (options.use_llvm == true) {960 if (options.use_llvm == true) {
src/target.zig+9
...@@ -268,6 +268,15 @@ pub fn hasLlvmSupport(target: std.Target) bool {...@@ -268,6 +268,15 @@ pub fn hasLlvmSupport(target: std.Target) bool {
268 };268 };
269}269}
270270
271/// The set of targets that our own self-hosted backends have robust support for.
272/// Used to select between LLVM backend and self-hosted backend when compiling in
273/// debug mode. A given target should only return true here if it is passing greater
274/// than or equal to the number of behavior tests as the respective LLVM backend.
275pub fn selfHostedBackendIsAsRobustAsLlvm(target: std.Target) bool {
276 _ = target;
277 return false;
278}
279
271pub fn supportsStackProbing(target: std.Target) bool {280pub fn supportsStackProbing(target: std.Target) bool {
272 return target.os.tag != .windows and target.os.tag != .uefi and281 return target.os.tag != .windows and target.os.tag != .uefi and
273 (target.cpu.arch == .i386 or target.cpu.arch == .x86_64);282 (target.cpu.arch == .i386 or target.cpu.arch == .x86_64);