Commit 6936243ee1
Changed files (5)
src-self-hosted/arg.zig
@@ -178,7 +178,7 @@ pub const Args = struct {
else => @panic("attempted to retrieve flag with wrong type"),
}
} else {
- return [_][]const u8{};
+ return &[_][]const u8{};
}
}
};
src-self-hosted/compilation.zig
@@ -103,8 +103,8 @@ pub const ZigCompiler = struct {
/// Must be called only once, ever. Sets global state.
pub fn setLlvmArgv(allocator: *Allocator, llvm_argv: []const []const u8) !void {
if (llvm_argv.len != 0) {
- var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(allocator, [_][]const []const u8{
- [_][]const u8{"zig (LLVM option parsing)"},
+ var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(allocator, &[_][]const []const u8{
+ &[_][]const u8{"zig (LLVM option parsing)"},
llvm_argv,
});
defer c_compatible_args.deinit();
@@ -359,7 +359,11 @@ pub const Compilation = struct {
is_static,
zig_lib_dir,
);
- return optional_comp orelse if (await frame) |_| unreachable else |err| err;
+ if (optional_comp) |comp| {
+ return comp;
+ } else {
+ if (await frame) |_| unreachable else |err| return err;
+ }
}
async fn createAsync(
@@ -412,20 +416,20 @@ pub const Compilation = struct {
.strip = false,
.is_static = is_static,
.linker_rdynamic = false,
- .clang_argv = [_][]const u8{},
- .lib_dirs = [_][]const u8{},
- .rpath_list = [_][]const u8{},
- .assembly_files = [_][]const u8{},
- .link_objects = [_][]const u8{},
+ .clang_argv = &[_][]const u8{},
+ .lib_dirs = &[_][]const u8{},
+ .rpath_list = &[_][]const u8{},
+ .assembly_files = &[_][]const u8{},
+ .link_objects = &[_][]const u8{},
.fn_link_set = event.Locked(FnLinkSet).init(FnLinkSet.init()),
.windows_subsystem_windows = false,
.windows_subsystem_console = false,
.link_libs_list = undefined,
.libc_link_lib = null,
.err_color = errmsg.Color.Auto,
- .darwin_frameworks = [_][]const u8{},
+ .darwin_frameworks = &[_][]const u8{},
.darwin_version_min = DarwinVersionMin.None,
- .test_filters = [_][]const u8{},
+ .test_filters = &[_][]const u8{},
.test_name_prefix = null,
.emit_file_type = Emit.Binary,
.link_out_file = null,
@@ -478,7 +482,7 @@ pub const Compilation = struct {
comp.name = try Buffer.init(comp.arena(), name);
comp.llvm_triple = try util.getTriple(comp.arena(), target);
comp.llvm_target = try util.llvmTargetFromTriple(comp.llvm_triple);
- comp.zig_std_dir = try std.fs.path.join(comp.arena(), [_][]const u8{ zig_lib_dir, "std" });
+ comp.zig_std_dir = try std.fs.path.join(comp.arena(), &[_][]const u8{ zig_lib_dir, "std" });
const opt_level = switch (build_mode) {
.Debug => llvm.CodeGenLevelNone,
@@ -520,7 +524,7 @@ pub const Compilation = struct {
comp.events = try allocator.create(event.Channel(Event));
defer allocator.destroy(comp.events);
- comp.events.init([0]Event{});
+ comp.events.init(&[0]Event{});
defer comp.events.deinit();
if (root_src_path) |root_src| {
src-self-hosted/introspect.zig
@@ -8,10 +8,10 @@ const warn = std.debug.warn;
/// Caller must free result
pub fn testZigInstallPrefix(allocator: *mem.Allocator, test_path: []const u8) ![]u8 {
- const test_zig_dir = try fs.path.join(allocator, [_][]const u8{ test_path, "lib", "zig" });
+ const test_zig_dir = try fs.path.join(allocator, &[_][]const u8{ test_path, "lib", "zig" });
errdefer allocator.free(test_zig_dir);
- const test_index_file = try fs.path.join(allocator, [_][]const u8{ test_zig_dir, "std", "std.zig" });
+ const test_index_file = try fs.path.join(allocator, &[_][]const u8{ test_zig_dir, "std", "std.zig" });
defer allocator.free(test_index_file);
var file = try fs.File.openRead(test_index_file);
src-self-hosted/libc_installation.zig
@@ -193,7 +193,7 @@ pub const LibCInstallation = struct {
"/dev/null",
};
// TODO make this use event loop
- const errorable_result = std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
+ const errorable_result = std.ChildProcess.exec(allocator, &argv, null, null, 1024 * 1024);
const exec_result = if (std.debug.runtime_safety) blk: {
break :blk errorable_result catch unreachable;
} else blk: {
@@ -233,7 +233,7 @@ pub const LibCInstallation = struct {
while (path_i < search_paths.len) : (path_i += 1) {
const search_path_untrimmed = search_paths.at(search_paths.len - path_i - 1);
const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " ");
- const stdlib_path = try fs.path.join(allocator, [_][]const u8{ search_path, "stdlib.h" });
+ const stdlib_path = try fs.path.join(allocator, &[_][]const u8{ search_path, "stdlib.h" });
defer allocator.free(stdlib_path);
if (try fileExists(stdlib_path)) {
@@ -401,7 +401,7 @@ async fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname
// TODO This simulates evented I/O for the child process exec
std.event.Loop.instance.?.yield();
- const errorable_result = std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
+ const errorable_result = std.ChildProcess.exec(allocator, &argv, null, null, 1024 * 1024);
const exec_result = if (std.debug.runtime_safety) blk: {
break :blk errorable_result catch unreachable;
} else blk: {
src-self-hosted/main.zig
@@ -191,12 +191,12 @@ const usage_build_generic =
const args_build_generic = [_]Flag{
Flag.Bool("--help"),
- Flag.Option("--color", [_][]const u8{
+ Flag.Option("--color", &[_][]const u8{
"auto",
"off",
"on",
}),
- Flag.Option("--mode", [_][]const u8{
+ Flag.Option("--mode", &[_][]const u8{
"debug",
"release-fast",
"release-safe",
@@ -204,7 +204,7 @@ const args_build_generic = [_]Flag{
}),
Flag.ArgMergeN("--assembly", 1),
- Flag.Option("--emit", [_][]const u8{
+ Flag.Option("--emit", &[_][]const u8{
"asm",
"bin",
"llvm-ir",
@@ -252,7 +252,7 @@ const args_build_generic = [_]Flag{
};
fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Compilation.Kind) !void {
- var flags = try Args.parse(allocator, args_build_generic, args);
+ var flags = try Args.parse(allocator, &args_build_generic, args);
defer flags.deinit();
if (flags.present("help")) {
@@ -579,7 +579,7 @@ async fn findLibCAsync(zig_compiler: *ZigCompiler) void {
}
fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
- var flags = try Args.parse(allocator, args_fmt_spec, args);
+ var flags = try Args.parse(allocator, &args_fmt_spec, args);
defer flags.deinit();
if (flags.present("help")) {