Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,8 @@ pub const DeclGen = struct {
if (variable.data.is_weak_linkage) llvm_global.setLinkage(.ExternalWeak);
}
} else {
// Ensure the llvm module remains valid even if we decide to not codegen an initializer.
llvm_global.setInitializer(llvm_type.getUndef());
llvm_global.setLinkage(.Internal);
llvm_global.setUnnamedAddr(.True);
}
Expand Down
1 change: 1 addition & 0 deletions test/behavior.zig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ test {
_ = @import("behavior/bugs/11213.zig");
_ = @import("behavior/bugs/11816.zig");
_ = @import("behavior/bugs/12003.zig");
_ = @import("behavior/bugs/12025.zig");
_ = @import("behavior/bugs/12033.zig");
_ = @import("behavior/bugs/12430.zig");
_ = @import("behavior/bugs/12486.zig");
Expand Down
10 changes: 10 additions & 0 deletions test/behavior/bugs/12025.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test {
comptime var st = .{
.foo = &1,
.bar = &2,
};

inline for (@typeInfo(@TypeOf(st)).Struct.fields) |field| {
_ = field;
}
}
1 change: 1 addition & 0 deletions test/standalone.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
//cases.add("tools/update_spirv_features.zig");

cases.addBuildFile("test/standalone/issue_13030/build.zig", .{ .build_modes = true });
cases.addBuildFile("test/standalone/issue_12588/build.zig", .{});
}
18 changes: 18 additions & 0 deletions test/standalone/issue_12588/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const std = @import("std");
const Builder = std.build.Builder;

pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});

const obj = b.addObject("main", "main.zig");
obj.setBuildMode(mode);
obj.setTarget(target);
obj.emit_llvm_ir = .{ .emit_to = b.pathFromRoot("main.ll") };
obj.emit_llvm_bc = .{ .emit_to = b.pathFromRoot("main.bc") };
obj.emit_bin = .no_emit;
b.default_step.dependOn(&obj.step);

const test_step = b.step("test", "Test the program");
test_step.dependOn(&obj.step);
}
6 changes: 6 additions & 0 deletions test/standalone/issue_12588/main.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const std = @import("std");

export fn strFromFloatHelp(float: f64) void {
var buf: [400]u8 = undefined;
_ = std.fmt.bufPrint(&buf, "{d}", .{float}) catch unreachable;
}