From dffdb2844e0163f58507b1f4a51693f4086b7949 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 14 Sep 2020 18:06:19 -0700 Subject: [PATCH] track all TODO comments in BRANCH_TODO file Before merging, do this for every item in the file: * solve the issue, or * convert the task to a github issue and update the comment to link to the issue (and remove "TODO" text from the comment). Then delete the file. Related: #363 --- BRANCH_TODO | 51 +++++++++++++++++++++++++++ lib/std/child_process.zig | 4 +-- src-self-hosted/Compilation.zig | 8 ++--- src-self-hosted/glibc.zig | 9 +++-- src-self-hosted/libc_installation.zig | 2 +- src-self-hosted/main.zig | 2 +- 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 BRANCH_TODO diff --git a/BRANCH_TODO b/BRANCH_TODO new file mode 100644 index 000000000..2e9da59df --- /dev/null +++ b/BRANCH_TODO @@ -0,0 +1,51 @@ + * refactor 2 CObject fields to use CSourceFile + * integrate code model and have_frame_pointer to main() and c objects + * integrate target features into building C source files + * integrate target features into building assembly code + * handle .d files from c objects + * glibc .so files + * support rpaths in ELF linker code + * build & link against compiler-rt + * build & link againstn freestanding libc + * add CLI support for a way to pass extra flags to c source files + * implement the workaround for using LLVM to detect native CPU features + * self-host main.cpp + * capture lld stdout/stderr better + * musl + * mingw-w64 + * port the stage1 os.cpp code that raises the open fd limit + * use global zig-cache dir for crt files + * `zig translate-c` + * make sure zig cc works + - using it as a preprocessor (-E) + - @breakpoint(); // TODO the first arg is empty string right? skip past that. + - try building some software + * MachO LLD linking + * COFF LLD linking + * WASM LLD linking + * implement proper parsing of LLD stderr/stdout and exposing compile errors + * implement proper parsing of clang stderr/stdout and exposing compile errors + * implement proper compile errors for failing to build glibc crt files and shared libs + * skip LLD caching when bin directory is not in the cache (so we don't put `id.txt` into the cwd) + * self-host link.cpp and building libcs (#4313 and #4314). using the `zig cc` command will set a flag indicating a preference for the llvm backend, which will include linking with LLD. At least for now. If zig's self-hosted linker ever gets on par with the likes of ld and lld, we can make it always be used even for zig cc. + * improve the stage2 tests to support testing with LLVM extensions enabled + * multi-thread building C objects + * support cross compiling stage2 with `zig build` + * implement emit-h in stage2 + * implement -fno-emit-bin + * audit the base cache hash + * implement serialization/deserialization of incremental compilation metadata + * incremental compilation - implement detection of which source files changed + * improve the cache hash logic for c objects with respect to extra flags and file parameters + * LLVM codegen backend: put a sub-arch in the triple in some cases + * rework libc_installation.zig abstraction to use std.log instead of taking a stderr stream + * implement an LLVM backend for stage2 + * implement outputting dynamic libraries in self-hosted linker + * implement outputting static libraries (archive files) in self-hosted linker + * support linking against object files in self-hosted linker + * avoid invoking lld when it's just 1 object file (the `zig cc -c` case) + * `zig fmt --check` should output to stdout not stderr. + * main.zig: If there was an argsAllocZ we could avoid this allocation + * improve robustness of response file parsing + * there are a couple panic("TODO") in clang options parsing + * std.testing needs improvement to support exposing directory path for its tmp dir (look for "bogus") diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 9219b0508..82ed938f3 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -213,7 +213,7 @@ pub const ChildProcess = struct { const stdout_in = child.stdout.?.inStream(); const stderr_in = child.stderr.?.inStream(); - // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O). + // TODO https://github.com/ziglang/zig/issues/6343 const stdout = try stdout_in.readAllAlloc(args.allocator, args.max_output_bytes); errdefer args.allocator.free(stdout); const stderr = try stderr_in.readAllAlloc(args.allocator, args.max_output_bytes); @@ -485,7 +485,7 @@ pub const ChildProcess = struct { const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore); const nul_handle = if (any_ignore) - // "\Device\Null" or "\??\NUL" + // "\Device\Null" or "\??\NUL" windows.OpenFile(&[_]u16{ '\\', 'D', 'e', 'v', 'i', 'c', 'e', '\\', 'N', 'u', 'l', 'l' }, .{ .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, .share_access = windows.FILE_SHARE_READ, diff --git a/src-self-hosted/Compilation.zig b/src-self-hosted/Compilation.zig index 49747cecb..85db6495b 100644 --- a/src-self-hosted/Compilation.zig +++ b/src-self-hosted/Compilation.zig @@ -695,7 +695,6 @@ pub fn update(self: *Compilation) !void { defer tracy.end(); // For compiling C objects, we rely on the cache hash system to avoid duplicating work. - // TODO Look into caching this data in memory to improve performance. // Add a WorkItem for each C object. try self.work_queue.ensureUnusedCapacity(self.c_object_table.items().len); for (self.c_object_table.items()) |entry| { @@ -1052,8 +1051,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { switch (term) { .Exited => |code| { if (code != 0) { - // TODO make std.process.exit and std.ChildProcess exit code have the same type - // and forward it here. Currently it is u32 vs u8. + // TODO https://github.com/ziglang/zig/issues/6342 std.process.exit(1); } }, @@ -1069,7 +1067,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { const stdout_reader = child.stdout.?.reader(); const stderr_reader = child.stderr.?.reader(); - // TODO Need to poll to read these streams to prevent a deadlock (or rely on evented I/O). + // TODO https://github.com/ziglang/zig/issues/6343 const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32)); const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); @@ -1100,7 +1098,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest }); var o_dir = try comp.zig_cache_directory.handle.makeOpenPath(o_sub_path, .{}); defer o_dir.close(); - // TODO Add renameat capabilities to the std lib in a higher layer than the posix layer. + // TODO https://github.com/ziglang/zig/issues/6344 const tmp_basename = std.fs.path.basename(out_obj_path); try std.os.renameat(zig_cache_tmp_dir.fd, tmp_basename, o_dir.fd, o_basename); diff --git a/src-self-hosted/glibc.zig b/src-self-hosted/glibc.zig index 29d96bb37..80e66fa28 100644 --- a/src-self-hosted/glibc.zig +++ b/src-self-hosted/glibc.zig @@ -270,7 +270,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { "-g", "-Wa,--noexecstack", }); - return build_libc_object(comp, "crti.o", &[1]Compilation.CSourceFile{ + return build_crt_file(comp, "crti.o", &[1]Compilation.CSourceFile{ .{ .src_path = try start_asm_path(comp, arena, "crti.S"), .extra_flags = args.items, @@ -288,7 +288,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { "-g", "-Wa,--noexecstack", }); - return build_libc_object(comp, "crtn.o", &[1]Compilation.CSourceFile{ + return build_crt_file(comp, "crtn.o", &[1]Compilation.CSourceFile{ .{ .src_path = try start_asm_path(comp, arena, "crtn.S"), .extra_flags = args.items, @@ -339,7 +339,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { .extra_flags = args.items, }; }; - return build_libc_object(comp, "Scrt1.o", &[_]Compilation.CSourceFile{ start_os, abi_note_o }); + return build_crt_file(comp, "Scrt1.o", &[_]Compilation.CSourceFile{ start_os, abi_note_o }); }, .libc_nonshared_a => { return error.Unimplemented; // TODO @@ -585,7 +585,7 @@ fn lib_path(comp: *Compilation, arena: *Allocator, sub_path: []const u8) ![]cons return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path }); } -fn build_libc_object( +fn build_crt_file( comp: *Compilation, basename: []const u8, c_source_files: []const Compilation.CSourceFile, @@ -649,7 +649,6 @@ fn build_libc_object( else try comp.gpa.dupe(u8, basename); - // TODO obtain a lock on the artifact and put that in crt_files as well. comp.crt_files.putAssumeCapacityNoClobber(basename, .{ .full_object_path = artifact_path, .lock = sub_compilation.bin_file.toOwnedLock(), diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index 125f51406..eb59ef7e6 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -11,7 +11,7 @@ const is_gnu = Target.current.isGnu(); usingnamespace @import("windows_sdk.zig"); -// TODO Rework this abstraction to use std.log instead of taking a stderr stream. +// TODO https://github.com/ziglang/zig/issues/6345 /// See the render function implementation for documentation of the fields. pub const LibCInstallation = struct { diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index 918e92422..6ec2c4553 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -1615,7 +1615,7 @@ pub const info_zen = extern "c" fn ZigClang_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int; -/// TODO make it so the return value can be !noreturn +/// TODO https://github.com/ziglang/zig/issues/3257 fn punt_to_clang(arena: *Allocator, args: []const []const u8) error{OutOfMemory} { if (!build_options.have_llvm) fatal("`zig cc` and `zig c++` unavailable: compiler not built with LLVM extensions enabled", .{});