| author | |
| committer | |
| log | dffdb2844e0163f58507b1f4a51693f4086b7949 |
| tree | da3eb00ed7aab988b622aa2c6e2b3c07ec8ccfb4 |
| parent | 26798018b780846eb0613b2061835985bf0c58ea |
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: #3636 files changed, 62 insertions(+), 14 deletions(-)
BRANCH_TODO created+51| ... | @@ -0,0 +1,51 @@ | ||
| 1 | * refactor 2 CObject fields to use CSourceFile | ||
| 2 | * integrate code model and have_frame_pointer to main() and c objects | ||
| 3 | * integrate target features into building C source files | ||
| 4 | * integrate target features into building assembly code | ||
| 5 | * handle .d files from c objects | ||
| 6 | * glibc .so files | ||
| 7 | * support rpaths in ELF linker code | ||
| 8 | * build & link against compiler-rt | ||
| 9 | * build & link againstn freestanding libc | ||
| 10 | * add CLI support for a way to pass extra flags to c source files | ||
| 11 | * implement the workaround for using LLVM to detect native CPU features | ||
| 12 | * self-host main.cpp | ||
| 13 | * capture lld stdout/stderr better | ||
| 14 | * musl | ||
| 15 | * mingw-w64 | ||
| 16 | * port the stage1 os.cpp code that raises the open fd limit | ||
| 17 | * use global zig-cache dir for crt files | ||
| 18 | * `zig translate-c` | ||
| 19 | * make sure zig cc works | ||
| 20 | - using it as a preprocessor (-E) | ||
| 21 | - @breakpoint(); // TODO the first arg is empty string right? skip past that. | ||
| 22 | - try building some software | ||
| 23 | * MachO LLD linking | ||
| 24 | * COFF LLD linking | ||
| 25 | * WASM LLD linking | ||
| 26 | * implement proper parsing of LLD stderr/stdout and exposing compile errors | ||
| 27 | * implement proper parsing of clang stderr/stdout and exposing compile errors | ||
| 28 | * implement proper compile errors for failing to build glibc crt files and shared libs | ||
| 29 | * skip LLD caching when bin directory is not in the cache (so we don't put `id.txt` into the cwd) | ||
| 30 | * 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. | ||
| 31 | * improve the stage2 tests to support testing with LLVM extensions enabled | ||
| 32 | * multi-thread building C objects | ||
| 33 | * support cross compiling stage2 with `zig build` | ||
| 34 | * implement emit-h in stage2 | ||
| 35 | * implement -fno-emit-bin | ||
| 36 | * audit the base cache hash | ||
| 37 | * implement serialization/deserialization of incremental compilation metadata | ||
| 38 | * incremental compilation - implement detection of which source files changed | ||
| 39 | * improve the cache hash logic for c objects with respect to extra flags and file parameters | ||
| 40 | * LLVM codegen backend: put a sub-arch in the triple in some cases | ||
| 41 | * rework libc_installation.zig abstraction to use std.log instead of taking a stderr stream | ||
| 42 | * implement an LLVM backend for stage2 | ||
| 43 | * implement outputting dynamic libraries in self-hosted linker | ||
| 44 | * implement outputting static libraries (archive files) in self-hosted linker | ||
| 45 | * support linking against object files in self-hosted linker | ||
| 46 | * avoid invoking lld when it's just 1 object file (the `zig cc -c` case) | ||
| 47 | * `zig fmt --check` should output to stdout not stderr. | ||
| 48 | * main.zig: If there was an argsAllocZ we could avoid this allocation | ||
| 49 | * improve robustness of response file parsing | ||
| 50 | * there are a couple panic("TODO") in clang options parsing | ||
| 51 | * std.testing needs improvement to support exposing directory path for its tmp dir (look for "bogus") | ||
lib/std/child_process.zig+2-2| ... | @@ -213,7 +213,7 @@ pub const ChildProcess = struct { | ... | @@ -213,7 +213,7 @@ pub const ChildProcess = struct { |
| 213 | const stdout_in = child.stdout.?.inStream(); | 213 | const stdout_in = child.stdout.?.inStream(); |
| 214 | const stderr_in = child.stderr.?.inStream(); | 214 | const stderr_in = child.stderr.?.inStream(); |
| 215 | 215 | ||
| 216 | // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O). | 216 | // TODO https://github.com/ziglang/zig/issues/6343 |
| 217 | const stdout = try stdout_in.readAllAlloc(args.allocator, args.max_output_bytes); | 217 | const stdout = try stdout_in.readAllAlloc(args.allocator, args.max_output_bytes); |
| 218 | errdefer args.allocator.free(stdout); | 218 | errdefer args.allocator.free(stdout); |
| 219 | const stderr = try stderr_in.readAllAlloc(args.allocator, args.max_output_bytes); | 219 | const stderr = try stderr_in.readAllAlloc(args.allocator, args.max_output_bytes); |
| ... | @@ -485,7 +485,7 @@ pub const ChildProcess = struct { | ... | @@ -485,7 +485,7 @@ pub const ChildProcess = struct { |
| 485 | const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore); | 485 | const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore); |
| 486 | 486 | ||
| 487 | const nul_handle = if (any_ignore) | 487 | const nul_handle = if (any_ignore) |
| 488 | // "\Device\Null" or "\??\NUL" | 488 | // "\Device\Null" or "\??\NUL" |
| 489 | windows.OpenFile(&[_]u16{ '\\', 'D', 'e', 'v', 'i', 'c', 'e', '\\', 'N', 'u', 'l', 'l' }, .{ | 489 | windows.OpenFile(&[_]u16{ '\\', 'D', 'e', 'v', 'i', 'c', 'e', '\\', 'N', 'u', 'l', 'l' }, .{ |
| 490 | .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, | 490 | .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, |
| 491 | .share_access = windows.FILE_SHARE_READ, | 491 | .share_access = windows.FILE_SHARE_READ, |
src-self-hosted/Compilation.zig+3-5| ... | @@ -695,7 +695,6 @@ pub fn update(self: *Compilation) !void { | ... | @@ -695,7 +695,6 @@ pub fn update(self: *Compilation) !void { |
| 695 | defer tracy.end(); | 695 | defer tracy.end(); |
| 696 | 696 | ||
| 697 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. | 697 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. |
| 698 | // TODO Look into caching this data in memory to improve performance. | ||
| 699 | // Add a WorkItem for each C object. | 698 | // Add a WorkItem for each C object. |
| 700 | try self.work_queue.ensureUnusedCapacity(self.c_object_table.items().len); | 699 | try self.work_queue.ensureUnusedCapacity(self.c_object_table.items().len); |
| 701 | for (self.c_object_table.items()) |entry| { | 700 | for (self.c_object_table.items()) |entry| { |
| ... | @@ -1052,8 +1051,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { | ... | @@ -1052,8 +1051,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { |
| 1052 | switch (term) { | 1051 | switch (term) { |
| 1053 | .Exited => |code| { | 1052 | .Exited => |code| { |
| 1054 | if (code != 0) { | 1053 | if (code != 0) { |
| 1055 | // TODO make std.process.exit and std.ChildProcess exit code have the same type | 1054 | // TODO https://github.com/ziglang/zig/issues/6342 |
| 1056 | // and forward it here. Currently it is u32 vs u8. | ||
| 1057 | std.process.exit(1); | 1055 | std.process.exit(1); |
| 1058 | } | 1056 | } |
| 1059 | }, | 1057 | }, |
| ... | @@ -1069,7 +1067,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { | ... | @@ -1069,7 +1067,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { |
| 1069 | const stdout_reader = child.stdout.?.reader(); | 1067 | const stdout_reader = child.stdout.?.reader(); |
| 1070 | const stderr_reader = child.stderr.?.reader(); | 1068 | const stderr_reader = child.stderr.?.reader(); |
| 1071 | 1069 | ||
| 1072 | // TODO Need to poll to read these streams to prevent a deadlock (or rely on evented I/O). | 1070 | // TODO https://github.com/ziglang/zig/issues/6343 |
| 1073 | const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32)); | 1071 | const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32)); |
| 1074 | const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); | 1072 | const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024); |
| 1075 | 1073 | ||
| ... | @@ -1100,7 +1098,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { | ... | @@ -1100,7 +1098,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { |
| 1100 | const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest }); | 1098 | const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest }); |
| 1101 | var o_dir = try comp.zig_cache_directory.handle.makeOpenPath(o_sub_path, .{}); | 1099 | var o_dir = try comp.zig_cache_directory.handle.makeOpenPath(o_sub_path, .{}); |
| 1102 | defer o_dir.close(); | 1100 | defer o_dir.close(); |
| 1103 | // TODO Add renameat capabilities to the std lib in a higher layer than the posix layer. | 1101 | // TODO https://github.com/ziglang/zig/issues/6344 |
| 1104 | const tmp_basename = std.fs.path.basename(out_obj_path); | 1102 | const tmp_basename = std.fs.path.basename(out_obj_path); |
| 1105 | try std.os.renameat(zig_cache_tmp_dir.fd, tmp_basename, o_dir.fd, o_basename); | 1103 | try std.os.renameat(zig_cache_tmp_dir.fd, tmp_basename, o_dir.fd, o_basename); |
| 1106 | 1104 |
src-self-hosted/glibc.zig+4-5| ... | @@ -270,7 +270,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -270,7 +270,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 270 | "-g", | 270 | "-g", |
| 271 | "-Wa,--noexecstack", | 271 | "-Wa,--noexecstack", |
| 272 | }); | 272 | }); |
| 273 | return build_libc_object(comp, "crti.o", &[1]Compilation.CSourceFile{ | 273 | return build_crt_file(comp, "crti.o", &[1]Compilation.CSourceFile{ |
| 274 | .{ | 274 | .{ |
| 275 | .src_path = try start_asm_path(comp, arena, "crti.S"), | 275 | .src_path = try start_asm_path(comp, arena, "crti.S"), |
| 276 | .extra_flags = args.items, | 276 | .extra_flags = args.items, |
| ... | @@ -288,7 +288,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -288,7 +288,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 288 | "-g", | 288 | "-g", |
| 289 | "-Wa,--noexecstack", | 289 | "-Wa,--noexecstack", |
| 290 | }); | 290 | }); |
| 291 | return build_libc_object(comp, "crtn.o", &[1]Compilation.CSourceFile{ | 291 | return build_crt_file(comp, "crtn.o", &[1]Compilation.CSourceFile{ |
| 292 | .{ | 292 | .{ |
| 293 | .src_path = try start_asm_path(comp, arena, "crtn.S"), | 293 | .src_path = try start_asm_path(comp, arena, "crtn.S"), |
| 294 | .extra_flags = args.items, | 294 | .extra_flags = args.items, |
| ... | @@ -339,7 +339,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -339,7 +339,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 339 | .extra_flags = args.items, | 339 | .extra_flags = args.items, |
| 340 | }; | 340 | }; |
| 341 | }; | 341 | }; |
| 342 | return build_libc_object(comp, "Scrt1.o", &[_]Compilation.CSourceFile{ start_os, abi_note_o }); | 342 | return build_crt_file(comp, "Scrt1.o", &[_]Compilation.CSourceFile{ start_os, abi_note_o }); |
| 343 | }, | 343 | }, |
| 344 | .libc_nonshared_a => { | 344 | .libc_nonshared_a => { |
| 345 | return error.Unimplemented; // TODO | 345 | return error.Unimplemented; // TODO |
| ... | @@ -585,7 +585,7 @@ fn lib_path(comp: *Compilation, arena: *Allocator, sub_path: []const u8) ![]cons | ... | @@ -585,7 +585,7 @@ fn lib_path(comp: *Compilation, arena: *Allocator, sub_path: []const u8) ![]cons |
| 585 | return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path }); | 585 | return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path }); |
| 586 | } | 586 | } |
| 587 | 587 | ||
| 588 | fn build_libc_object( | 588 | fn build_crt_file( |
| 589 | comp: *Compilation, | 589 | comp: *Compilation, |
| 590 | basename: []const u8, | 590 | basename: []const u8, |
| 591 | c_source_files: []const Compilation.CSourceFile, | 591 | c_source_files: []const Compilation.CSourceFile, |
| ... | @@ -649,7 +649,6 @@ fn build_libc_object( | ... | @@ -649,7 +649,6 @@ fn build_libc_object( |
| 649 | else | 649 | else |
| 650 | try comp.gpa.dupe(u8, basename); | 650 | try comp.gpa.dupe(u8, basename); |
| 651 | 651 | ||
| 652 | // TODO obtain a lock on the artifact and put that in crt_files as well. | ||
| 653 | comp.crt_files.putAssumeCapacityNoClobber(basename, .{ | 652 | comp.crt_files.putAssumeCapacityNoClobber(basename, .{ |
| 654 | .full_object_path = artifact_path, | 653 | .full_object_path = artifact_path, |
| 655 | .lock = sub_compilation.bin_file.toOwnedLock(), | 654 | .lock = sub_compilation.bin_file.toOwnedLock(), |
src-self-hosted/libc_installation.zig+1-1| ... | @@ -11,7 +11,7 @@ const is_gnu = Target.current.isGnu(); | ... | @@ -11,7 +11,7 @@ const is_gnu = Target.current.isGnu(); |
| 11 | 11 | ||
| 12 | usingnamespace @import("windows_sdk.zig"); | 12 | usingnamespace @import("windows_sdk.zig"); |
| 13 | 13 | ||
| 14 | // TODO Rework this abstraction to use std.log instead of taking a stderr stream. | 14 | // TODO https://github.com/ziglang/zig/issues/6345 |
| 15 | 15 | ||
| 16 | /// See the render function implementation for documentation of the fields. | 16 | /// See the render function implementation for documentation of the fields. |
| 17 | pub const LibCInstallation = struct { | 17 | pub const LibCInstallation = struct { |
src-self-hosted/main.zig+1-1| ... | @@ -1615,7 +1615,7 @@ pub const info_zen = | ... | @@ -1615,7 +1615,7 @@ pub const info_zen = |
| 1615 | 1615 | ||
| 1616 | extern "c" fn ZigClang_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int; | 1616 | extern "c" fn ZigClang_main(argc: c_int, argv: [*:null]?[*:0]u8) c_int; |
| 1617 | 1617 | ||
| 1618 | /// TODO make it so the return value can be !noreturn | 1618 | /// TODO https://github.com/ziglang/zig/issues/3257 |
| 1619 | fn punt_to_clang(arena: *Allocator, args: []const []const u8) error{OutOfMemory} { | 1619 | fn punt_to_clang(arena: *Allocator, args: []const []const u8) error{OutOfMemory} { |
| 1620 | if (!build_options.have_llvm) | 1620 | if (!build_options.have_llvm) |
| 1621 | fatal("`zig cc` and `zig c++` unavailable: compiler not built with LLVM extensions enabled", .{}); | 1621 | fatal("`zig cc` and `zig c++` unavailable: compiler not built with LLVM extensions enabled", .{}); |