Commit 4af5c38674

Andrew Kelley <andrew@ziglang.org>
2019-12-02 01:22:03
fixes for self-hosted compiler
1 parent 080316c
Changed files (4)
lib
std
event
src-self-hosted
lib/std/event/fs.zig
@@ -695,7 +695,7 @@ pub fn readFile(allocator: *Allocator, file_path: []const u8, max_size: usize) !
         try list.ensureCapacity(list.len + mem.page_size);
         const buf = list.items[list.len..];
         const buf_array = [_][]u8{buf};
-        const amt = try preadv(allocator, fd, buf_array, list.len);
+        const amt = try preadv(allocator, fd, &buf_array, list.len);
         list.len += amt;
         if (list.len > max_size) {
             return error.FileTooBig;
src-self-hosted/compilation.zig
@@ -148,13 +148,13 @@ pub const Compilation = struct {
     is_static: bool,
     linker_rdynamic: bool = false,
 
-    clang_argv: []const []const u8 = [_][]const u8{},
-    lib_dirs: []const []const u8 = [_][]const u8{},
-    rpath_list: []const []const u8 = [_][]const u8{},
-    assembly_files: []const []const u8 = [_][]const u8{},
+    clang_argv: []const []const u8 = &[_][]const u8{},
+    lib_dirs: []const []const u8 = &[_][]const u8{},
+    rpath_list: []const []const u8 = &[_][]const u8{},
+    assembly_files: []const []const u8 = &[_][]const u8{},
 
     /// paths that are explicitly provided by the user to link against
-    link_objects: []const []const u8 = [_][]const u8{},
+    link_objects: []const []const u8 = &[_][]const u8{},
 
     /// functions that have their own objects that we need to link
     /// it uses an optional pointer so that tombstone removals are possible
@@ -178,10 +178,10 @@ pub const Compilation = struct {
     verbose_llvm_ir: bool = false,
     verbose_link: bool = false,
 
-    darwin_frameworks: []const []const u8 = [_][]const u8{},
+    darwin_frameworks: []const []const u8 = &[_][]const u8{},
     darwin_version_min: DarwinVersionMin = .None,
 
-    test_filters: []const []const u8 = [_][]const u8{},
+    test_filters: []const []const u8 = &[_][]const u8{},
     test_name_prefix: ?[]const u8 = null,
 
     emit_file_type: Emit = .Binary,
@@ -1165,7 +1165,7 @@ pub const Compilation = struct {
         const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix);
         defer self.gpa().free(file_name);
 
-        const full_path = try std.fs.path.join(self.gpa(), [_][]const u8{ tmp_dir, file_name[0..] });
+        const full_path = try std.fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
         errdefer self.gpa().free(full_path);
 
         return Buffer.fromOwnedSlice(self.gpa(), full_path);
@@ -1186,7 +1186,7 @@ pub const Compilation = struct {
         const zig_dir_path = try getZigDir(self.gpa());
         defer self.gpa().free(zig_dir_path);
 
-        const tmp_dir = try std.fs.path.join(self.arena(), [_][]const u8{ zig_dir_path, comp_dir_name[0..] });
+        const tmp_dir = try std.fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] });
         try std.fs.makePath(self.gpa(), tmp_dir);
         return tmp_dir;
     }
@@ -1208,7 +1208,7 @@ pub const Compilation = struct {
         }
 
         var result: [12]u8 = undefined;
-        b64_fs_encoder.encode(result[0..], rand_bytes);
+        b64_fs_encoder.encode(result[0..], &rand_bytes);
         return result;
     }
 
src-self-hosted/link.zig
@@ -314,7 +314,7 @@ fn constructLinkerArgsElf(ctx: *Context) !void {
 }
 
 fn addPathJoin(ctx: *Context, dirname: []const u8, basename: []const u8) !void {
-    const full_path = try std.fs.path.join(&ctx.arena.allocator, [_][]const u8{ dirname, basename });
+    const full_path = try std.fs.path.join(&ctx.arena.allocator, &[_][]const u8{ dirname, basename });
     const full_path_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, full_path);
     try ctx.args.append(@ptrCast([*:0]const u8, full_path_with_null.ptr));
 }
src-self-hosted/main.zig
@@ -709,7 +709,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
             var it = dir.iterate();
             while (try it.next()) |entry| {
                 if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) {
-                    const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name });
+                    const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ file_path, entry.name });
                     @panic("TODO https://github.com/ziglang/zig/issues/3777");
                     // try group.call(fmtPath, fmt, full_path, check_mode);
                 }