Skip to content

Commit 55e1f32

Browse files
committed
std: use std.ArrayList(u8) instead of std.Buffer in std/build.zig
1 parent 1c56e99 commit 55e1f32

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/std/build.zig

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ pub const LibExeObjStep = struct {
11391139
out_lib_filename: []const u8,
11401140
out_pdb_filename: []const u8,
11411141
packages: ArrayList(Pkg),
1142-
build_options_contents: std.Buffer,
1142+
build_options_contents: std.ArrayList(u8),
11431143
system_linker_hack: bool = false,
11441144

11451145
object_src: []const u8,
@@ -1274,7 +1274,7 @@ pub const LibExeObjStep = struct {
12741274
.lib_paths = ArrayList([]const u8).init(builder.allocator),
12751275
.framework_dirs = ArrayList([]const u8).init(builder.allocator),
12761276
.object_src = undefined,
1277-
.build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable,
1277+
.build_options_contents = std.ArrayList(u8).init(builder.allocator),
12781278
.c_std = Builder.CStd.C99,
12791279
.override_lib_dir = null,
12801280
.main_pkg_path = null,
@@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct {
18471847
}
18481848
}
18491849

1850-
if (self.build_options_contents.len() > 0) {
1850+
if (self.build_options_contents.len > 0) {
18511851
const build_options_file = try fs.path.join(
18521852
builder.allocator,
18531853
&[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
@@ -1960,22 +1960,23 @@ pub const LibExeObjStep = struct {
19601960
try zig_args.append(cross.cpu.model.name);
19611961
}
19621962
} else {
1963-
var mcpu_buffer = try std.Buffer.init(builder.allocator, "-mcpu=");
1964-
try mcpu_buffer.append(cross.cpu.model.name);
1963+
var mcpu_buffer = std.ArrayList(u8).init(builder.allocator);
1964+
errdefer mcpu_buffer.deinit();
1965+
1966+
try mcpu_buffer.outStream().print("-mcpu={}", .{cross.cpu.model.name});
19651967

19661968
for (all_features) |feature, i_usize| {
19671969
const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize);
19681970
const in_cpu_set = populated_cpu_features.isEnabled(i);
19691971
const in_actual_set = cross.cpu.features.isEnabled(i);
19701972
if (in_cpu_set and !in_actual_set) {
1971-
try mcpu_buffer.appendByte('-');
1972-
try mcpu_buffer.append(feature.name);
1973+
try mcpu_buffer.outStream().print("-{}", .{feature.name});
19731974
} else if (!in_cpu_set and in_actual_set) {
1974-
try mcpu_buffer.appendByte('+');
1975-
try mcpu_buffer.append(feature.name);
1975+
try mcpu_buffer.outStream().print("+{}", .{feature.name});
19761976
}
19771977
}
1978-
try zig_args.append(mcpu_buffer.span());
1978+
1979+
try zig_args.append(mcpu_buffer.toOwnedSlice());
19791980
}
19801981

19811982
if (self.target.dynamic_linker.get()) |dynamic_linker| {

0 commit comments

Comments
 (0)