authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-06-02 10:10:35+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-06-02 10:10:35+03:00
logc01d8c8b20514add5bb7b7a10ab570d2ae72df4d
tree36c554d3f8ab5fc4bd9b3b5a72fcd5f06e2080e4
parent06d9f88f971143db8adca936aa9dddf74f564729

pass `-fno-builtin` when testing `lib/c.zig`, `lib/compiler_rt.zig`


4 files changed, 11 insertions(+), 2 deletions(-)

build.zig+2
...@@ -489,6 +489,7 @@ pub fn build(b: *std.Build) !void {...@@ -489,6 +489,7 @@ pub fn build(b: *std.Build) !void {
489 .skip_single_threaded = true,489 .skip_single_threaded = true,
490 .skip_non_native = skip_non_native,490 .skip_non_native = skip_non_native,
491 .skip_libc = true,491 .skip_libc = true,
492 .no_builtin = true,
492 }));493 }));
493494
494 test_step.dependOn(tests.addModuleTests(b, .{495 test_step.dependOn(tests.addModuleTests(b, .{
...@@ -501,6 +502,7 @@ pub fn build(b: *std.Build) !void {...@@ -501,6 +502,7 @@ pub fn build(b: *std.Build) !void {
501 .skip_single_threaded = true,502 .skip_single_threaded = true,
502 .skip_non_native = skip_non_native,503 .skip_non_native = skip_non_native,
503 .skip_libc = true,504 .skip_libc = true,
505 .no_builtin = true,
504 }));506 }));
505507
506 test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));508 test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));
lib/std/Build/Step/Compile.zig+6
...@@ -211,6 +211,8 @@ is_linking_libc: bool = false,...@@ -211,6 +211,8 @@ is_linking_libc: bool = false,
211/// Computed during make().211/// Computed during make().
212is_linking_libcpp: bool = false,212is_linking_libcpp: bool = false,
213213
214no_builtin: bool = false,
215
214pub const ExpectedCompileErrors = union(enum) {216pub const ExpectedCompileErrors = union(enum) {
215 contains: []const u8,217 contains: []const u8,
216 exact: []const []const u8,218 exact: []const []const u8,
...@@ -1572,6 +1574,10 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {...@@ -1572,6 +1574,10 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
1572 }1574 }
1573 }1575 }
15741576
1577 if (compile.no_builtin) {
1578 try zig_args.append("-fno-builtin");
1579 }
1580
1575 if (b.sysroot) |sysroot| {1581 if (b.sysroot) |sysroot| {
1576 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });1582 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
1577 }1583 }
src/codegen/llvm.zig+1-2
...@@ -3115,8 +3115,7 @@ pub const Object = struct {...@@ -3115,8 +3115,7 @@ pub const Object = struct {
31153115
3116 try variable_index.setInitializer(try o.lowerValue(decl_val), &o.builder);3116 try variable_index.setInitializer(try o.lowerValue(decl_val), &o.builder);
3117 variable_index.setLinkage(.internal, &o.builder);3117 variable_index.setLinkage(.internal, &o.builder);
3118 const llvm_miscompiles_const_anon = o.module.getTarget().isDarwin();3118 variable_index.setMutability(.constant, &o.builder);
3119 if (!llvm_miscompiles_const_anon) variable_index.setMutability(.constant, &o.builder);
3120 variable_index.setUnnamedAddr(.unnamed_addr, &o.builder);3119 variable_index.setUnnamedAddr(.unnamed_addr, &o.builder);
3121 variable_index.setAlignment(alignment.toLlvm(), &o.builder);3120 variable_index.setAlignment(alignment.toLlvm(), &o.builder);
3122 return variable_index;3121 return variable_index;
test/tests.zig+2
...@@ -984,6 +984,7 @@ const ModuleTestOptions = struct {...@@ -984,6 +984,7 @@ const ModuleTestOptions = struct {
984 skip_non_native: bool,984 skip_non_native: bool,
985 skip_libc: bool,985 skip_libc: bool,
986 max_rss: usize = 0,986 max_rss: usize = 0,
987 no_builtin: bool = false,
987};988};
988989
989pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {990pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
...@@ -1070,6 +1071,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1070,6 +1071,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1070 .pic = test_target.pic,1071 .pic = test_target.pic,
1071 .strip = test_target.strip,1072 .strip = test_target.strip,
1072 });1073 });
1074 if (options.no_builtin) these_tests.no_builtin = true;
1073 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";1075 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
1074 const backend_suffix = if (test_target.use_llvm == true)1076 const backend_suffix = if (test_target.use_llvm == true)
1075 "-llvm"1077 "-llvm"