authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-05 14:24:00-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-06-05 14:24:00-04:00
log8f27fdb84e3788bf6ea9ae7c992f3cf667a4f9ed
tree4166501a408f6e7310b9165c5d367a22f76f2c7d
parent8c04ffba86dd3b09c1fccab91ed42b2ec63b4815
parentc01d8c8b20514add5bb7b7a10ab570d2ae72df4d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #20120 from vahur/move-consts-to-rdata

mark anondecls as constants in llvm ir

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

build.zig+2
......@@ -489,6 +489,7 @@ pub fn build(b: *std.Build) !void {
489489 .skip_single_threaded = true,
490490 .skip_non_native = skip_non_native,
491491 .skip_libc = true,
492 .no_builtin = true,
492493 }));
493494
494495 test_step.dependOn(tests.addModuleTests(b, .{
......@@ -501,6 +502,7 @@ pub fn build(b: *std.Build) !void {
501502 .skip_single_threaded = true,
502503 .skip_non_native = skip_non_native,
503504 .skip_libc = true,
505 .no_builtin = true,
504506 }));
505507
506508 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,
211211/// Computed during make().
212212is_linking_libcpp: bool = false,
213213
214no_builtin: bool = false,
215
214216pub const ExpectedCompileErrors = union(enum) {
215217 contains: []const u8,
216218 exact: []const []const u8,
......@@ -1572,6 +1574,10 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
15721574 }
15731575 }
15741576
1577 if (compile.no_builtin) {
1578 try zig_args.append("-fno-builtin");
1579 }
1580
15751581 if (b.sysroot) |sysroot| {
15761582 try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
15771583 }
src/codegen/llvm.zig+1
......@@ -3126,6 +3126,7 @@ pub const Object = struct {
31263126
31273127 try variable_index.setInitializer(try o.lowerValue(decl_val), &o.builder);
31283128 variable_index.setLinkage(.internal, &o.builder);
3129 variable_index.setMutability(.constant, &o.builder);
31293130 variable_index.setUnnamedAddr(.unnamed_addr, &o.builder);
31303131 variable_index.setAlignment(alignment.toLlvm(), &o.builder);
31313132 return variable_index;
test/tests.zig+2
......@@ -984,6 +984,7 @@ const ModuleTestOptions = struct {
984984 skip_non_native: bool,
985985 skip_libc: bool,
986986 max_rss: usize = 0,
987 no_builtin: bool = false,
987988};
988989
989990pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
......@@ -1070,6 +1071,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10701071 .pic = test_target.pic,
10711072 .strip = test_target.strip,
10721073 });
1074 if (options.no_builtin) these_tests.no_builtin = true;
10731075 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
10741076 const backend_suffix = if (test_target.use_llvm == true)
10751077 "-llvm"