diff options
274 files changed, 10827 insertions, 2886 deletions
diff --git a/.gitattributes b/.gitattributes index 6cf47bc9ad..2983afbfc3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,4 @@ lib/libc/** linguist-vendored lib/libcxx/** linguist-vendored lib/libcxxabi/** linguist-vendored lib/libunwind/** linguist-vendored +lib/tsan/** linguist-vendored diff --git a/CMakeLists.txt b/CMakeLists.txt index a2bf856b9c..f279990e27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,12 @@ set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread") set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1") -set(ZIG_ENABLE_LOGGING off CACHE BOOL "enable logging") + +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set(ZIG_ENABLE_LOGGING ON CACHE BOOL "enable logging") +else() + set(ZIG_ENABLE_LOGGING OFF CACHE BOOL "enable logging") +endif() if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries") @@ -583,6 +588,11 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/link/MachO/reloc/aarch64.zig" "${CMAKE_SOURCE_DIR}/src/link/MachO/reloc/x86_64.zig" "${CMAKE_SOURCE_DIR}/src/link/Wasm.zig" + "${CMAKE_SOURCE_DIR}/src/link/tapi.zig" + "${CMAKE_SOURCE_DIR}/src/link/tapi/parse.zig" + "${CMAKE_SOURCE_DIR}/src/link/tapi/parse/test.zig" + "${CMAKE_SOURCE_DIR}/src/link/tapi/Tokenizer.zig" + "${CMAKE_SOURCE_DIR}/src/link/tapi/yaml.zig" "${CMAKE_SOURCE_DIR}/src/link/C/zig.h" "${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin" "${CMAKE_SOURCE_DIR}/src/liveness.zig" diff --git a/ci/azure/linux_script b/ci/azure/linux_script index 33c44c51e0..33ad349044 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -59,9 +59,9 @@ unset CXX make $JOBS install -# Look for formatting errors and AST errors. +# Look for non-conforming code formatting. # Formatting errors can be fixed by running `zig fmt` on the files printed here. -release/bin/zig fmt --check --ast-check .. +release/bin/zig fmt --check .. # Here we rebuild zig but this time using the Zig binary we just now produced to # build zig1.o rather than relying on the one built with stage0. See diff --git a/doc/docgen.zig b/doc/docgen.zig index 22d8d151c1..f58c94f15c 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -999,7 +999,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: .tilde, => try writeEscaped(out, src[token.loc.start..token.loc.end]), - .invalid, .invalid_ampersands, .invalid_periodasterisks => return parseError( + .invalid, .invalid_periodasterisks => return parseError( docgen_tokenizer, source_token, "syntax error", @@ -1017,7 +1017,6 @@ fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: To } fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8, do_code_tests: bool) !void { - var code_progress_index: usize = 0; var progress = Progress{}; const root_node = try progress.start("Generating docgen examples", toc.nodes.len); defer root_node.end(); @@ -1090,7 +1089,6 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any switch (code.id) { Code.Id.Exe => |expected_outcome| code_block: { - const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, exe_ext }); var build_args = std.ArrayList([]const u8).init(allocator); defer build_args.deinit(); try build_args.appendSlice(&[_][]const u8{ @@ -1361,19 +1359,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any }, Code.Id.Obj => |maybe_error_match| { const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext }); - const tmp_obj_file_name = try fs.path.join( - allocator, - &[_][]const u8{ tmp_dir_name, name_plus_obj_ext }, - ); var build_args = std.ArrayList([]const u8).init(allocator); defer build_args.deinit(); - const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{s}.h", .{code.name}); - const output_h_file_name = try fs.path.join( - allocator, - &[_][]const u8{ tmp_dir_name, name_plus_h_ext }, - ); - try build_args.appendSlice(&[_][]const u8{ zig_exe, "build-obj", diff --git a/doc/langref.html.in b/doc/langref.html.in index 4962183a77..b447a49ad4 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -258,7 +258,7 @@ pub fn main() !void { <p> The code sample begins by adding Zig's Standard Library to the build using the {#link|@import#} builtin function. The {#syntax#}@import("std"){#endsyntax#} function call creates a structure to represent the Standard Library. - The code then makes a {#link|top-level declaration|Global Variables#} of a + The code then {#link|declares|Container Level Variables#} a {#link|constant identifier|Assignment#}, named <code>std</code>, for easy access to <a href="https://github.com/ziglang/zig/wiki/FAQ#where-is-the-documentation-for-the-zig-standard-library">Zig's standard library</a>. </p> @@ -802,7 +802,7 @@ const hello_world_in_c = const x = 1234; fn foo() void { - // It works at global scope as well as inside functions. + // It works at file scope as well as inside functions. const y = 5678; // Once assigned, an identifier cannot be changed. @@ -872,18 +872,18 @@ test "init with undefined" { {#syntax#}var{#endsyntax#} when declaring a variable. This causes less work for both humans and computers to do when reading code, and creates more optimization opportunities. </p> - {#header_open|Global Variables#} + {#header_open|Container Level Variables#} <p> - Global variables are considered to be a top level declaration, which means that they are - order-independent and lazily analyzed. The initialization value of global variables is implicitly - {#link|comptime#}. If a global variable is {#syntax#}const{#endsyntax#} then its value is + Container level variables have static lifetime and are order-independent and lazily analyzed. + The initialization value of container level variables is implicitly + {#link|comptime#}. If a container level variable is {#syntax#}const{#endsyntax#} then its value is {#syntax#}comptime{#endsyntax#}-known, otherwise it is runtime-known. </p> - {#code_begin|test|global_variables#} + {#code_begin|test|container_level_variables#} var y: i32 = add(10, x); const x: i32 = add(12, 34); -test "global variables" { +test "container level variables" { try expect(x == 46); try expect(y == 56); } @@ -896,27 +896,51 @@ const std = @import("std"); const expect = std.testing.expect; {#code_end#} <p> - Global variables may be declared inside a {#link|struct#}, {#link|union#}, or {#link|enum#}: + Container level variables may be declared inside a {#link|struct#}, {#link|union#}, or {#link|enum#}: </p> - {#code_begin|test|namespaced_global#} + {#code_begin|test|namespaced_container_level_variable#} const std = @import("std"); const expect = std.testing.expect; -test "namespaced global variable" { +test "namespaced container level variable" { try expect(foo() == 1235); try expect(foo() == 1236); } +const S = struct { + var x: i32 = 1234; +}; + fn foo() i32 { - const S = struct { - var x: i32 = 1234; - }; S.x += 1; return S.x; } {#code_end#} + {#header_close#} + + {#header_open|Static Local Variables#} + <p> + It is also possible to have local variables with static lifetime by using containers inside functions. + </p> + {#code_begin|test|static_local_variable#} + const std = @import("std"); + const expect = std.testing.expect; + + test "static local variable" { + try expect(foo() == 1235); + try expect(foo() == 1236); + } + + fn foo() i32 { + const S = struct { + var x: i32 = 1234; + }; + S.x += 1; + return S.x; + } + {#code_end#} <p> - The {#syntax#}extern{#endsyntax#} keyword can be used to link against a variable that is exported + The {#syntax#}extern{#endsyntax#} keyword or {#link|@extern#} builtin function can be used to link against a variable that is exported from another object. The {#syntax#}export{#endsyntax#} keyword or {#link|@export#} builtin function can be used to make a variable available to other objects at link time. In both cases, the type of the variable must be C ABI compatible. @@ -941,14 +965,14 @@ test "thread local storage" { thread2.wait(); } -fn testTls(context: void) void { +fn testTls(_: void) void { assert(x == 1234); x += 1; assert(x == 1235); } {#code_end#} <p> - For {#link|Single Threaded Builds#}, all thread local variables are treated as {#link|Global Variables#}. + For {#link|Single Threaded Builds#}, all thread local variables are treated as regular {#link|Container Level Variables#}. </p> <p> Thread local variables may not be {#syntax#}const{#endsyntax#}. @@ -2467,7 +2491,7 @@ test "dot product" { try expect(Vec3.dot(v1, v2) == 0.0); } -// Structs can have global declarations. +// Structs can have declarations. // Structs can have 0 fields. const Empty = struct { pub const PI = 3.14; @@ -2478,6 +2502,8 @@ test "struct namespaced variable" { // you can still instantiate an empty struct const does_nothing = Empty {}; + + _ = does_nothing; } // struct field order is determined by the compiler for optimal performance. @@ -2986,7 +3012,7 @@ test "@typeInfo" { try expect(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "two")); } -// @tagName gives a []const u8 representation of an enum value: +// @tagName gives a [:0]const u8 representation of an enum value: test "@tagName" { try expect(mem.eql(u8, @tagName(Small.three), "three")); } @@ -3002,11 +3028,12 @@ const Foo = enum { a, b, c }; export fn entry(foo: Foo) void { } {#code_end#} <p> - For a C-ABI-compatible enum, use {#syntax#}extern enum{#endsyntax#}: + For a C-ABI-compatible enum, provide an explicit tag type to + the enum: </p> {#code_begin|obj#} -const Foo = extern enum { a, b, c }; -export fn entry(foo: Foo) void { } +const Foo = enum(c_int) { a, b, c }; +export fn entry(foo: Foo) void { _ = foo; } {#code_end#} {#header_close#} @@ -3233,7 +3260,7 @@ test "union method" { {#code_end#} <p> {#link|@tagName#} can be used to return a {#link|comptime#} - {#syntax#}[]const u8{#endsyntax#} value representing the field name: + {#syntax#}[:0]const u8{#endsyntax#} value representing the field name: </p> {#code_begin|test#} const std = @import("std"); @@ -3368,9 +3395,11 @@ test "inside test block" { test "separate scopes" { { const pi = 3.14; + _ = pi; } { var pi: bool = true; + _ = pi; } } {#code_end#} @@ -3408,7 +3437,7 @@ test "switch simple" { // Switching on arbitrary expressions is allowed as long as the // expression is known at compile-time. zz => zz, - comptime blk: { + blk: { const d: u32 = 5; const e: u32 = 100; break :blk d + e; @@ -3807,7 +3836,7 @@ test "for basics" { // To access the index of iteration, specify a second capture value. // This is zero-indexed. var sum2: i32 = 0; - for (items) |value, i| { + for (items) |_, i| { try expect(@TypeOf(i) == usize); sum2 += @intCast(i32, i); } @@ -3960,7 +3989,7 @@ test "if optional" { } const b: ?u32 = null; - if (b) |value| { + if (b) |_| { unreachable; } else { try expect(true); @@ -3997,11 +4026,13 @@ test "if error union" { if (a) |value| { try expect(value == 0); } else |err| { + _ = err; unreachable; } const b: anyerror!u32 = error.BadValue; if (b) |value| { + _ = value; unreachable; } else |err| { try expect(err == error.BadValue); @@ -4021,13 +4052,13 @@ test "if error union" { var c: anyerror!u32 = 3; if (c) |*value| { value.* = 9; - } else |err| { + } else |_| { unreachable; } if (c) |value| { try expect(value == 9); - } else |err| { + } else |_| { unreachable; } } @@ -4040,18 +4071,20 @@ test "if error union with optional" { if (a) |optional_value| { try expect(optional_value.? == 0); } else |err| { + _ = err; unreachable; } const b: anyerror!?u32 = null; if (b) |optional_value| { try expect(optional_value == null); - } else |err| { + } else |_| { unreachable; } const c: anyerror!?u32 = error.BadValue; if (c) |optional_value| { + _ = optional_value; unreachable; } else |err| { try expect(err == error.BadValue); @@ -4063,13 +4096,13 @@ test "if error union with optional" { if (optional_value.*) |*value| { value.* = 9; } - } else |err| { + } else |_| { unreachable; } if (d) |optional_value| { try expect(optional_value.? == 9); - } else |err| { + } else |_| { unreachable; } } @@ -4222,6 +4255,7 @@ test "type of unreachable" { {#code_begin|test#} fn foo(condition: bool, b: u32) void { const a = if (condition) b else return; + _ = a; @panic("do something with a"); } test "noreturn" { @@ -4550,7 +4584,7 @@ test "parse u64" { {#code_begin|syntax#} fn doAThing(str: []u8) void { const number = parseU64(str, 10) catch 13; - // ... + _ = number; // ... } {#code_end#} <p> @@ -4565,7 +4599,7 @@ fn doAThing(str: []u8) void { {#code_begin|syntax#} fn doAThing(str: []u8) !void { const number = parseU64(str, 10) catch |err| return err; - // ... + _ = number; // ... } {#code_end#} <p> @@ -4574,7 +4608,7 @@ fn doAThing(str: []u8) !void { {#code_begin|syntax#} fn doAThing(str: []u8) !void { const number = try parseU64(str, 10); - // ... + _ = number; // ... } {#code_end#} <p> @@ -4998,7 +5032,7 @@ extern fn malloc(size: size_t) ?*u8; fn doAThing() ?*Foo { const ptr = malloc(1234) orelse return null; - // ... + _ = ptr; // ... } {#code_end#} <p> @@ -5111,6 +5145,7 @@ test "optional pointers" { test "type coercion - variable declaration" { var a: u8 = 1; var b: u16 = a; + _ = b; } test "type coercion - function call" { @@ -5118,11 +5153,14 @@ test "type coercion - function call" { foo(a); } -fn foo(b: u16) void {} +fn foo(b: u16) void { + _ = b; +} test "type coercion - @as builtin" { var a: u8 = 1; var b = @as(u16, a); + _ = b; } {#code_end#} <p> @@ -5150,7 +5188,7 @@ test "type coercion - const qualification" { foo(b); } -fn foo(a: *const i32) void {} +fn foo(_: *const i32) void {} {#code_end#} <p> In addition, pointers coerce to const optional pointers: @@ -5400,7 +5438,7 @@ test "coercion between unions and enums" { test "coercion of zero bit types" { var x: void = {}; var y: *void = x; - //var z: void = y; // TODO + _ = y; } {#code_end#} {#header_close#} @@ -5684,7 +5722,7 @@ test "@intToPtr for pointer to zero bit type" { {#header_open|usingnamespace#} <p> - {#syntax#}usingnamespace{#endsyntax#} is a top level declaration that imports all the public declarations of + {#syntax#}usingnamespace{#endsyntax#} is a declaration that imports all the public declarations of the operand, which must be a {#link|struct#}, {#link|union#}, or {#link|enum#}, into the current scope: </p> {#code_begin|test|usingnamespace#} @@ -5695,6 +5733,19 @@ test "using std namespace" { } {#code_end#} <p> + {#syntax#}usingnamespace{#endsyntax#} can also be used in containers: + </p> + {#code_begin|test|usingnamespace_inside_struct#} +test "using namespace inside struct" { + const L = struct { + usingnamespace struct { + pub fn f() void {} + }; + }; + L.f(); +} + {#code_end#} + <p> Instead of the above pattern, it is generally recommended to explicitly alias individual declarations. However, {#syntax#}usingnamespace{#endsyntax#} has an important use case when organizing the public API of a file or package. For example, one might have <code>c.zig</code> with all of the @@ -6044,7 +6095,7 @@ test "fibonacci" { </p> <p> - In the global scope (outside of any function), all expressions are implicitly + At container level (outside of any function), all expressions are implicitly {#syntax#}comptime{#endsyntax#} expressions. This means that we can use functions to initialize complex static data. For example: </p> @@ -6462,7 +6513,7 @@ volatile ( {#header_open|Global Assembly#} <p> - When an assembly expression occurs in a top level {#link|comptime#} block, this is + When an assembly expression occurs in a container level {#link|comptime#} block, this is <strong>global assembly</strong>. </p> <p> @@ -6532,6 +6583,7 @@ var x: i32 = 1; test "suspend with no resume" { var frame = async func(); try expect(x == 2); + _ = frame; } fn func() void { @@ -6763,6 +6815,7 @@ fn amain() !void { var global_download_frame: anyframe = undefined; fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { + _ = url; // this is just an example, we don't actually do it! const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents"); errdefer allocator.free(result); suspend { @@ -6774,6 +6827,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { var global_file_frame: anyframe = undefined; fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { + _ = filename; // this is just an example, we don't actually do it! const result = try std.mem.dupe(allocator, u8, "this is the file contents"); errdefer allocator.free(result); suspend { @@ -6832,6 +6886,7 @@ fn amain() !void { } fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { + _ = url; // this is just an example, we don't actually do it! const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents"); errdefer allocator.free(result); std.debug.print("fetchUrl returning\n", .{}); @@ -6839,6 +6894,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { } fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { + _ = filename; // this is just an example, we don't actually do it! const result = try std.mem.dupe(allocator, u8, "this is the file contents"); errdefer allocator.free(result); std.debug.print("readFile returning\n", .{}); @@ -7447,7 +7503,7 @@ test "main" { {#see_also|@divFloor|@divExact#} {#header_close#} {#header_open|@embedFile#} - <pre>{#syntax#}@embedFile(comptime path: []const u8) *const [X:0]u8{#endsyntax#}</pre> + <pre>{#syntax#}@embedFile(comptime path: []const u8) *const [N:0]u8{#endsyntax#}</pre> <p> This function returns a compile time constant pointer to null-terminated, fixed-size array with length equal to the byte count of the file given by @@ -7475,7 +7531,7 @@ test "main" { {#header_close#} {#header_open|@errorName#} - <pre>{#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}</pre> + <pre>{#syntax#}@errorName(err: anyerror) [:0]const u8{#endsyntax#}</pre> <p> This function returns the string representation of an error. The string representation of {#syntax#}error.OutOfMem{#endsyntax#} is {#syntax#}"OutOfMem"{#endsyntax#}. @@ -7533,10 +7589,10 @@ test "main" { <code>declaration</code> must be one of two things: </p> <ul> - <li>An identifier ({#syntax#}x{#endsyntax#}) identifying a {#link|function|Functions#} or - {#link|global variable|Global Variables#}.</li> - <li>Field access ({#syntax#}x.y{#endsyntax#}) looking up a {#link|function|Functions#} or - {#link|global variable|Global Variables#}.</li> + <li>An identifier ({#syntax#}x{#endsyntax#}) identifying a {#link|function|Functions#} or a + {#link|variable|Container Level Variables#}.</li> + <li>Field access ({#syntax#}x.y{#endsyntax#}) looking up a {#link|function|Functions#} or a + {#link|variable|Container Level Variables#}.</li> </ul> <p> This builtin can be called from a {#link|comptime#} block to conditionally export symbols. @@ -8123,7 +8179,7 @@ pub const FloatMode = enum { {#header_close#} {#header_open|@setRuntimeSafety#} - <pre>{#syntax#}@setRuntimeSafety(safety_on: bool){#endsyntax#}</pre> + <pre>{#syntax#}@setRuntimeSafety(safety_on: bool) void{#endsyntax#}</pre> <p> Sets whether runtime safety checks are enabled for the scope that contains the function call. </p> @@ -8494,9 +8550,9 @@ fn doTheTest() !void { {#header_close#} {#header_open|@tagName#} - <pre>{#syntax#}@tagName(value: anytype) []const u8{#endsyntax#}</pre> + <pre>{#syntax#}@tagName(value: anytype) [:0]const u8{#endsyntax#}</pre> <p> - Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}. + Converts an enum value or union value to a string literal representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}. </p> {#header_close#} @@ -8529,7 +8585,7 @@ fn List(comptime T: type) type { } {#code_end#} <p> - When {#syntax#}@This(){#endsyntax#} is used at global scope, it returns a reference to the + When {#syntax#}@This(){#endsyntax#} is used at file scope, it returns a reference to the struct that corresponds to the current file. </p> {#header_close#} @@ -8547,6 +8603,7 @@ fn List(comptime T: type) type { test "integer cast panic" { var a: u16 = 0xabcd; var b: u8 = @intCast(u8, a); + _ = b; } {#code_end#} <p> @@ -8623,7 +8680,7 @@ test "integer truncation" { {#header_close#} {#header_open|@typeName#} - <pre>{#syntax#}@typeName(T: type) [N]u8{#endsyntax#}</pre> + <pre>{#syntax#}@typeName(T: type) *const [N:0]u8{#endsyntax#}</pre> <p> This function returns the string representation of a type, as an array. It is equivalent to a string literal of the type name. @@ -8744,7 +8801,7 @@ pub fn build(b: *Builder) void { {#header_open|Single Threaded Builds#} <p>Zig has a compile option <code>--single-threaded</code> which has the following effects:</p> <ul> - <li>All {#link|Thread Local Variables#} are treated as {#link|Global Variables#}.</li> + <li>All {#link|Thread Local Variables#} are treated as regular {#link|Container Level Variables#}.</li> <li>The overhead of {#link|Async Functions#} becomes equivalent to function call overhead.</li> <li>The {#syntax#}@import("builtin").single_threaded{#endsyntax#} becomes {#syntax#}true{#endsyntax#} and therefore various userland APIs which read this variable become more efficient. @@ -8802,6 +8859,7 @@ comptime { {#code_begin|exe_err#} pub fn main() void { var x = foo("hello"); + _ = x; } fn foo(x: []const u8) u8 { @@ -9070,6 +9128,7 @@ pub fn main() void { comptime { const optional_number: ?i32 = null; const number = optional_number.?; + _ = number; } {#code_end#} <p>At runtime:</p> @@ -9103,6 +9162,7 @@ pub fn main() void { {#code_begin|test_err|caught unexpected error 'UnableToReturnNumber'#} comptime { const number = getNumberOrFail() catch unreachable; + _ = number; } fn getNumberOrFail() !i32 { @@ -9150,6 +9210,7 @@ comptime { const err = error.AnError; const number = @errorToInt(err) + 10; const invalid_err = @intToError(number); + _ = invalid_err; } {#code_end#} <p>At runtime:</p> @@ -9160,7 +9221,7 @@ pub fn main() void { var err = error.AnError; var number = @errorToInt(err) + 500; var invalid_err = @intToError(number); - std.debug.print("value: {}\n", .{number}); + std.debug.print("value: {}\n", .{invalid_err}); } {#code_end#} {#header_close#} @@ -9175,6 +9236,7 @@ const Foo = enum { comptime { const a: u2 = 3; const b = @intToEnum(Foo, a); + _ = b; } {#code_end#} <p>At runtime:</p> @@ -9359,6 +9421,7 @@ comptime { pub fn main() void { var opt_ptr: ?*i32 = null; var ptr = @ptrCast(*i32, opt_ptr); + _ = ptr; } {#code_end#} {#header_close#} @@ -9486,7 +9549,9 @@ pub fn main() !void { This is why it is an error to pass a string literal to a mutable slice, like this: </p> {#code_begin|test_err|expected type '[]u8'#} -fn foo(s: []u8) void {} +fn foo(s: []u8) void { + _ = s; +} test "string literal to mutable slice" { foo("hello"); @@ -9494,7 +9559,9 @@ test "string literal to mutable slice" { {#code_end#} <p>However if you make the slice constant, then it works:</p> {#code_begin|test|strlit#} -fn foo(s: []const u8) void {} +fn foo(s: []const u8) void { + _ = s; +} test "string literal to constant slice" { foo("hello"); @@ -10439,7 +10506,7 @@ coding style. </p> {#header_close#} {#header_open|Examples#} - {#code_begin|syntax#} + <pre>{#syntax#} const namespace_name = @import("dir_name/file_name.zig"); const TypeName = @import("dir_name/TypeName.zig"); var global_var: i32 = undefined; @@ -10483,7 +10550,7 @@ const XmlParser = struct { // The initials BE (Big Endian) are just another word in Zig identifier names. fn readU32Be() u32 {} - {#code_end#} + {#endsyntax#}</pre> <p> See the Zig Standard Library for more examples. </p> diff --git a/lib/libc/darwin/libSystem.B.tbd b/lib/libc/darwin/libSystem.B.tbd new file mode 100644 index 0000000000..1b4e1184ec --- /dev/null +++ b/lib/libc/darwin/libSystem.B.tbd @@ -0,0 +1,3690 @@ +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: F86CC732-D5E4-30B5-AA7D-167DF5EC2708 + - target: x86_64-maccatalyst + value: F86CC732-D5E4-30B5-AA7D-167DF5EC2708 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: A17E8744-051E-356E-8619-66F2A6E89AD4 + - target: arm64e-maccatalyst + value: A17E8744-051E-356E-8619-66F2A6E89AD4 +install-name: '/usr/lib/libSystem.B.dylib' +current-version: 1292.60.1 +reexported-libraries: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + libraries: [ '/usr/lib/system/libcache.dylib', '/usr/lib/system/libcommonCrypto.dylib', + '/usr/lib/system/libcompiler_rt.dylib', '/usr/lib/system/libcopyfile.dylib', + '/usr/lib/system/libcorecrypto.dylib', '/usr/lib/system/libdispatch.dylib', + '/usr/lib/system/libdyld.dylib', '/usr/lib/system/libkeymgr.dylib', + '/usr/lib/system/liblaunch.dylib', '/usr/lib/system/libmacho.dylib', + '/usr/lib/system/libquarantine.dylib', '/usr/lib/system/libremovefile.dylib', + '/usr/lib/system/libsystem_asl.dylib', '/usr/lib/system/libsystem_blocks.dylib', + '/usr/lib/system/libsystem_c.dylib', '/usr/lib/system/libsystem_collections.dylib', + '/usr/lib/system/libsystem_configuration.dylib', '/usr/lib/system/libsystem_containermanager.dylib', + '/usr/lib/system/libsystem_coreservices.dylib', '/usr/lib/system/libsystem_darwin.dylib', + '/usr/lib/system/libsystem_dnssd.dylib', '/usr/lib/system/libsystem_featureflags.dylib', + '/usr/lib/system/libsystem_info.dylib', '/usr/lib/system/libsystem_kernel.dylib', + '/usr/lib/system/libsystem_m.dylib', '/usr/lib/system/libsystem_malloc.dylib', + '/usr/lib/system/libsystem_networkextension.dylib', '/usr/lib/system/libsystem_notify.dylib', + '/usr/lib/system/libsystem_platform.dylib', '/usr/lib/system/libsystem_product_info_filter.dylib', + '/usr/lib/system/libsystem_pthread.dylib', '/usr/lib/system/libsystem_sandbox.dylib', + '/usr/lib/system/libsystem_secinit.dylib', '/usr/lib/system/libsystem_symptoms.dylib', + '/usr/lib/system/libsystem_trace.dylib', '/usr/lib/system/libunwind.dylib', + '/usr/lib/system/libxpc.dylib' ] +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos ] + symbols: [ 'R8289209$_close', 'R8289209$_fork', 'R8289209$_fsync', 'R8289209$_getattrlist', + 'R8289209$_getrlimit', 'R8289209$_getxattr', 'R8289209$_open', + 'R8289209$_pthread_attr_destroy', 'R8289209$_pthread_attr_init', + 'R8289209$_pthread_attr_setdetachstate', 'R8289209$_pthread_create', + 'R8289209$_pthread_mutex_lock', 'R8289209$_pthread_mutex_unlock', + 'R8289209$_pthread_self', 'R8289209$_ptrace', 'R8289209$_read', + 'R8289209$_setattrlist', 'R8289209$_setrlimit', 'R8289209$_sigaction', + 'R8289209$_stat', 'R8289209$_sysctl', 'R8289209$_time', 'R8289209$_unlink', + 'R8289209$_write' ] + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___crashreporter_info__, _libSystem_atfork_child, _libSystem_atfork_parent, + _libSystem_atfork_prepare, _mach_init_routine ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 2F7F7303-DB23-359E-85CD-8B2F93223E2A + - target: x86_64-maccatalyst + value: 2F7F7303-DB23-359E-85CD-8B2F93223E2A + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: BF1D536B-540F-374E-BA7B-EB2429F334CD + - target: arm64e-maccatalyst + value: BF1D536B-540F-374E-BA7B-EB2429F334CD +install-name: '/usr/lib/system/libcache.dylib' +current-version: 83 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _cache_create, _cache_destroy, _cache_get, _cache_get_and_retain, + _cache_get_cost_hint, _cache_get_count_hint, _cache_get_info, + _cache_get_info_for_key, _cache_get_info_for_keys, _cache_get_minimum_values_hint, + _cache_get_name, _cache_hash_byte_string, _cache_invoke, _cache_key_hash_cb_cstring, + _cache_key_hash_cb_integer, _cache_key_is_equal_cb_cstring, + _cache_key_is_equal_cb_integer, _cache_print, _cache_print_stats, + _cache_release_cb_free, _cache_release_value, _cache_remove, + _cache_remove_all, _cache_remove_with_block, _cache_set_and_retain, + _cache_set_cost_hint, _cache_set_count_hint, _cache_set_minimum_values_hint, + _cache_set_name, _cache_simulate_memory_warning_event, _cache_value_make_nonpurgeable_cb, + _cache_value_make_purgeable_cb ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 1D0A75A5-DEC5-39C6-AB3D-E789B8866712 + - target: x86_64-maccatalyst + value: 1D0A75A5-DEC5-39C6-AB3D-E789B8866712 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: FEDF1785-B89A-3EFB-B95E-467645AC6113 + - target: arm64e-maccatalyst + value: FEDF1785-B89A-3EFB-B95E-467645AC6113 +install-name: '/usr/lib/system/libcommonCrypto.dylib' +current-version: 60178.40.2 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _CCAESCmac, _CCAESCmacCreate, _CCAESCmacDestroy, _CCAESCmacFinal, + _CCAESCmacOutputSizeFromContext, _CCAESCmacUpdate, _CCBigNumAdd, + _CCBigNumAddI, _CCBigNumBitCount, _CCBigNumByteCount, _CCBigNumClear, + _CCBigNumCompare, _CCBigNumCompareI, _CCBigNumCopy, _CCBigNumCreateRandom, + _CCBigNumDiv, _CCBigNumFree, _CCBigNumFromData, _CCBigNumFromDecimalString, + _CCBigNumFromHexString, _CCBigNumGetI, _CCBigNumIsNegative, + _CCBigNumIsPrime, _CCBigNumIsZero, _CCBigNumLeftShift, _CCBigNumMod, + _CCBigNumModExp, _CCBigNumModI, _CCBigNumMul, _CCBigNumMulI, + _CCBigNumMulMod, _CCBigNumRightShift, _CCBigNumSetI, _CCBigNumSetNegative, + _CCBigNumSub, _CCBigNumSubI, _CCBigNumToData, _CCBigNumToDecimalString, + _CCBigNumToHexString, _CCBigNumZeroLSBCount, _CCCKGContributorCommit, + _CCCKGContributorCreate, _CCCKGContributorDestroy, _CCCKGContributorFinish, + _CCCKGGetCommitmentSize, _CCCKGGetOpeningSize, _CCCKGGetShareSize, + _CCCKGOwnerCreate, _CCCKGOwnerDestroy, _CCCKGOwnerFinish, + _CCCKGOwnerGenerateShare, _CCCalibratePBKDF, _CCCreateBigNum, + _CCCrypt, _CCCryptorAddParameter, _CCCryptorChaCha20, _CCCryptorChaCha20Poly1305OneshotDecrypt, + _CCCryptorChaCha20Poly1305OneshotEncrypt, _CCCryptorCreate, + _CCCryptorCreateFromData, _CCCryptorCreateFromDataWithMode, + _CCCryptorCreateWithMode, _CCCryptorDecryptDataBlock, _CCCryptorEncryptDataBlock, + _CCCryptorFinal, _CCCryptorGCM, _CCCryptorGCMAddAAD, _CCCryptorGCMAddADD, + _CCCryptorGCMAddIV, _CCCryptorGCMDecrypt, _CCCryptorGCMEncrypt, + _CCCryptorGCMFinal, _CCCryptorGCMFinalize, _CCCryptorGCMOneshotDecrypt, + _CCCryptorGCMOneshotEncrypt, _CCCryptorGCMReset, _CCCryptorGCMSetIV, + _CCCryptorGCMaddAAD, _CCCryptorGetIV, _CCCryptorGetOutputLength, + _CCCryptorGetParameter, _CCCryptorRelease, _CCCryptorReset, + _CCCryptorReset_binary_compatibility, _CCCryptorUpdate, _CCDHComputeKey, + _CCDHCreate, _CCDHGenerateKey, _CCDHParametersCreateFromData, + _CCDHParametersCreateFromPKCS3, _CCDHParametersPKCS3Encode, + _CCDHParametersPKCS3EncodeLength, _CCDHParametersRelease, + _CCDHRelease, _CCDeriveKey, _CCDesCBCCksum, _CCDesIsWeakKey, + _CCDesSetOddParity, _CCDigest, _CCDigestBlockSize, _CCDigestCreate, + _CCDigestCreateByOID, _CCDigestDestroy, _CCDigestFinal, _CCDigestGetBlockSize, + _CCDigestGetBlockSizeFromRef, _CCDigestGetOutputSize, _CCDigestGetOutputSizeFromRef, + _CCDigestInit, _CCDigestOID, _CCDigestOIDLen, _CCDigestOutputSize, + _CCDigestReset, _CCDigestUpdate, _CCECCryptorBlind, _CCECCryptorBlindingKeysRelease, + _CCECCryptorComputeSharedSecret, _CCECCryptorCreateFromData, + _CCECCryptorExportKey, _CCECCryptorExportPublicKey, _CCECCryptorGenerateBlindingKeys, + _CCECCryptorGeneratePair, _CCECCryptorGetKeyComponents, _CCECCryptorGetPublicKeyFromPrivateKey, + _CCECCryptorH2C, _CCECCryptorImportKey, _CCECCryptorImportPublicKey, + _CCECCryptorRelease, _CCECCryptorSignHash, _CCECCryptorTwinDiversifyEntropySize, + _CCECCryptorTwinDiversifyKey, _CCECCryptorUnblind, _CCECCryptorUnwrapKey, + _CCECCryptorVerifyHash, _CCECCryptorWrapKey, _CCECGetKeySize, + _CCECGetKeyType, _CCHKDFExpand, _CCHKDFExtract, _CCHmac, _CCHmacClone, + _CCHmacCreate, _CCHmacDestroy, _CCHmacFinal, _CCHmacInit, + _CCHmacOneShot, _CCHmacOutputSize, _CCHmacOutputSizeFromRef, + _CCHmacUpdate, _CCKDFParametersCreateAnsiX963, _CCKDFParametersCreateCtrHmac, + _CCKDFParametersCreateCtrHmacFixed, _CCKDFParametersCreateHkdf, + _CCKDFParametersCreatePbkdf2, _CCKDFParametersDestroy, _CCKeyDerivationHMac, + _CCKeyDerivationPBKDF, _CCRSACryptorCreateFromData, _CCRSACryptorCreatePublicKeyFromPrivateKey, + _CCRSACryptorCrypt, _CCRSACryptorDecrypt, _CCRSACryptorEncrypt, + _CCRSACryptorExport, _CCRSACryptorGeneratePair, _CCRSACryptorGetPublicKeyFromPrivateKey, + _CCRSACryptorImport, _CCRSACryptorRelease, _CCRSACryptorSign, + _CCRSACryptorVerify, _CCRSAGetCRTComponents, _CCRSAGetCRTComponentsSizes, + _CCRSAGetKeyComponents, _CCRSAGetKeySize, _CCRSAGetKeyType, + _CCRandomCopyBytes, _CCRandomGenerateBytes, _CCRandomUniform, + _CCSymmetricKeyUnwrap, _CCSymmetricKeyWrap, _CCSymmetricUnwrappedSize, + _CCSymmetricWrappedSize, _CC_MD2, _CC_MD2_Final, _CC_MD2_Init, + _CC_MD2_Update, _CC_MD4, _CC_MD4_Final, _CC_MD4_Init, _CC_MD4_Update, + _CC_MD5, _CC_MD5_Final, _CC_MD5_Init, _CC_MD5_Update, _CC_SHA1, + _CC_SHA1_Final, _CC_SHA1_Init, _CC_SHA1_Update, _CC_SHA224, + _CC_SHA224_Final, _CC_SHA224_Init, _CC_SHA224_Update, _CC_SHA256, + _CC_SHA256_Final, _CC_SHA256_Init, _CC_SHA256_Update, _CC_SHA384, + _CC_SHA384_Final, _CC_SHA384_Init, _CC_SHA384_Update, _CC_SHA512, + _CC_SHA512_Final, _CC_SHA512_Init, _CC_SHA512_Update, _CCrfc3394_iv, + _CCrfc3394_ivLen, _CNCRC, _CNCRCDumpTable, _CNCRCFinal, _CNCRCInit, + _CNCRCRelease, _CNCRCUpdate, _CNCRCWeakTest, _CNEncode, _CNEncoderBlocksize, + _CNEncoderBlocksizeFromRef, _CNEncoderCreate, _CNEncoderCreateCustom, + _CNEncoderFinal, _CNEncoderGetOutputLength, _CNEncoderGetOutputLengthFromEncoding, + _CNEncoderRelease, _CNEncoderUpdate, _MD5Final, _ccDRBGGetRngState, + _ccDevRandomGetRngState, _kCCDHRFC2409Group2, _kCCDHRFC3526Group5, + _kCCRandomDefault, _kCCRandomDevRandom ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, arm64-macos, arm64e-macos ] +uuids: + - target: x86_64-macos + value: 0DB26EC8-B4CD-3268-B865-C2FC07E4D2AA + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 39A3467E-CBED-3C4A-B0BC-39C0093842E9 +install-name: '/usr/lib/system/libcompiler_rt.dylib' +current-version: 102.2 +parent-umbrella: + - targets: [ x86_64-macos, arm64-macos, arm64e-macos ] + umbrella: System +exports: + - targets: [ x86_64-macos ] + symbols: [ '$ld$hide$os10.4$___absvti2', '$ld$hide$os10.4$___addvti3', + '$ld$hide$os10.4$___ashlti3', '$ld$hide$os10.4$___ashrti3', + '$ld$hide$os10.4$___cmpti2', '$ld$hide$os10.4$___ctzti2', + '$ld$hide$os10.4$___ffsti2', '$ld$hide$os10.4$___fixunsxfti', + '$ld$hide$os10.4$___fixxfti', '$ld$hide$os10.4$___floattixf', + '$ld$hide$os10.4$___floatuntixf', '$ld$hide$os10.4$___lshrti3', + '$ld$hide$os10.4$___multi3', '$ld$hide$os10.4$___mulvti3', + '$ld$hide$os10.4$___negti2', '$ld$hide$os10.4$___negvti2', + '$ld$hide$os10.4$___parityti2', '$ld$hide$os10.4$___popcountti2', + '$ld$hide$os10.4$___subvti3', '$ld$hide$os10.4$___ucmpti2', + '$ld$hide$os10.5$___absvti2', '$ld$hide$os10.5$___addvti3', + '$ld$hide$os10.5$___ashlti3', '$ld$hide$os10.5$___ashrti3', + '$ld$hide$os10.5$___cmpti2', '$ld$hide$os10.5$___ctzti2', + '$ld$hide$os10.5$___ffsti2', '$ld$hide$os10.5$___fixunsxfti', + '$ld$hide$os10.5$___fixxfti', '$ld$hide$os10.5$___floattixf', + '$ld$hide$os10.5$___floatuntixf', '$ld$hide$os10.5$___lshrti3', + '$ld$hide$os10.5$___multi3', '$ld$hide$os10.5$___mulvti3', + '$ld$hide$os10.5$___negti2', '$ld$hide$os10.5$___negvti2', + '$ld$hide$os10.5$___parityti2', '$ld$hide$os10.5$___popcountti2', + '$ld$hide$os10.5$___subvti3', '$ld$hide$os10.5$___ucmpti2', + ___absvdi2, ___absvsi2, ___absvti2, ___addvdi3, ___addvsi3, + ___addvti3, ___ashldi3, ___ashlti3, ___ashrdi3, ___ashrti3, + ___clzdi2, ___clzsi2, ___cmpdi2, ___cmpti2, ___ctzdi2, ___ctzsi2, + ___ctzti2, ___divdc3, ___divdi3, ___divsc3, ___divxc3, ___ffsdi2, + ___ffsti2, ___fixdfdi, ___fixsfdi, ___fixunsdfdi, ___fixunsdfsi, + ___fixunssfdi, ___fixunssfsi, ___fixunsxfdi, ___fixunsxfsi, + ___fixunsxfti, ___fixxfdi, ___fixxfti, ___floatdidf, ___floatdisf, + ___floatdixf, ___floattixf, ___floatundidf, ___floatundisf, + ___floatundixf, ___floatuntixf, ___lshrdi3, ___lshrti3, ___moddi3, + ___muldi3, ___mulodi4, ___mulosi4, ___muloti4, ___multi3, + ___mulvdi3, ___mulvsi3, ___mulvti3, ___mulxc3, ___negdi2, + ___negti2, ___negvdi2, ___negvsi2, ___negvti2, ___paritydi2, + ___paritysi2, ___parityti2, ___popcountdi2, ___popcountsi2, + ___popcountti2, ___powixf2, ___subvdi3, ___subvsi3, ___subvti3, + ___ucmpdi2, ___ucmpti2, ___udivdi3, ___udivmoddi4, ___umoddi3 ] + - targets: [ x86_64-macos, arm64e-macos, arm64-macos ] + symbols: [ '$ld$hide$os10.10$___chkstk_darwin', '$ld$hide$os10.10$___extendhfsf2', + '$ld$hide$os10.10$___truncdfhf2', '$ld$hide$os10.10$___truncsfhf2', + '$ld$hide$os10.10$_atomic_flag_clear', '$ld$hide$os10.10$_atomic_flag_clear_explicit', + '$ld$hide$os10.10$_atomic_flag_test_and_set', '$ld$hide$os10.10$_atomic_flag_test_and_set_explicit', + '$ld$hide$os10.10$_atomic_signal_fence', '$ld$hide$os10.10$_atomic_thread_fence', + '$ld$hide$os10.11$___chkstk_darwin', '$ld$hide$os10.12$___chkstk_darwin', + '$ld$hide$os10.13$___chkstk_darwin', '$ld$hide$os10.14$___chkstk_darwin', + '$ld$hide$os10.4$___absvdi2', '$ld$hide$os10.4$___absvsi2', + '$ld$hide$os10.4$___addvdi3', '$ld$hide$os10.4$___addvsi3', + '$ld$hide$os10.4$___ashldi3', '$ld$hide$os10.4$___ashrdi3', + '$ld$hide$os10.4$___clear_cache', '$ld$hide$os10.4$___clzdi2', + '$ld$hide$os10.4$___clzsi2', '$ld$hide$os10.4$___clzti2', + '$ld$hide$os10.4$___cmpdi2', '$ld$hide$os10.4$___ctzdi2', + '$ld$hide$os10.4$___ctzsi2', '$ld$hide$os10.4$___divdc3', + '$ld$hide$os10.4$___divdi3', '$ld$hide$os10.4$___divsc3', + '$ld$hide$os10.4$___divti3', '$ld$hide$os10.4$___divxc3', + '$ld$hide$os10.4$___enable_execute_stack', '$ld$hide$os10.4$___ffsdi2', + '$ld$hide$os10.4$___fixdfdi', '$ld$hide$os10.4$___fixdfti', + '$ld$hide$os10.4$___fixsfdi', '$ld$hide$os10.4$___fixsfti', + '$ld$hide$os10.4$___fixunsdfdi', '$ld$hide$os10.4$___fixunsdfsi', + '$ld$hide$os10.4$___fixunsdfti', '$ld$hide$os10.4$___fixunssfdi', + '$ld$hide$os10.4$___fixunssfsi', '$ld$hide$os10.4$___fixunssfti', + '$ld$hide$os10.4$___fixunsxfdi', '$ld$hide$os10.4$___fixunsxfsi', + '$ld$hide$os10.4$___fixxfdi', '$ld$hide$os10.4$___floatdidf', + '$ld$hide$os10.4$___floatdisf', '$ld$hide$os10.4$___floatdixf', + '$ld$hide$os10.4$___floattidf', '$ld$hide$os10.4$___floattisf', + '$ld$hide$os10.4$___floatundidf', '$ld$hide$os10.4$___floatundisf', + '$ld$hide$os10.4$___floatundixf', '$ld$hide$os10.4$___floatuntidf', + '$ld$hide$os10.4$___floatuntisf', '$ld$hide$os10.4$___gcc_personality_v0', + '$ld$hide$os10.4$___lshrdi3', '$ld$hide$os10.4$___moddi3', + '$ld$hide$os10.4$___modti3', '$ld$hide$os10.4$___muldc3', + '$ld$hide$os10.4$___muldi3', '$ld$hide$os10.4$___mulsc3', + '$ld$hide$os10.4$___mulvdi3', '$ld$hide$os10.4$___mulvsi3', + '$ld$hide$os10.4$___mulxc3', '$ld$hide$os10.4$___negdi2', + '$ld$hide$os10.4$___negvdi2', '$ld$hide$os10.4$___negvsi2', + '$ld$hide$os10.4$___paritydi2', '$ld$hide$os10.4$___paritysi2', + '$ld$hide$os10.4$___popcountdi2', '$ld$hide$os10.4$___popcountsi2', + '$ld$hide$os10.4$___powidf2', '$ld$hide$os10.4$___powisf2', + '$ld$hide$os10.4$___powixf2', '$ld$hide$os10.4$___subvdi3', + '$ld$hide$os10.4$___subvsi3', '$ld$hide$os10.4$___ucmpdi2', + '$ld$hide$os10.4$___udivdi3', '$ld$hide$os10.4$___udivmoddi4', + '$ld$hide$os10.4$___udivmodti4', '$ld$hide$os10.4$___udivti3', + '$ld$hide$os10.4$___umoddi3', '$ld$hide$os10.4$___umodti3', + '$ld$hide$os10.5$___absvdi2', '$ld$hide$os10.5$___absvsi2', + '$ld$hide$os10.5$___addvdi3', '$ld$hide$os10.5$___addvsi3', + '$ld$hide$os10.5$___ashldi3', '$ld$hide$os10.5$___ashrdi3', + '$ld$hide$os10.5$___clear_cache', '$ld$hide$os10.5$___clzdi2', + '$ld$hide$os10.5$___clzsi2', '$ld$hide$os10.5$___clzti2', + '$ld$hide$os10.5$___cmpdi2', '$ld$hide$os10.5$___ctzdi2', + '$ld$hide$os10.5$___ctzsi2', '$ld$hide$os10.5$___divdc3', + '$ld$hide$os10.5$___divdi3', '$ld$hide$os10.5$___divsc3', + '$ld$hide$os10.5$___divti3', '$ld$hide$os10.5$___divxc3', + '$ld$hide$os10.5$___enable_execute_stack', '$ld$hide$os10.5$___ffsdi2', + '$ld$hide$os10.5$___fixdfdi', '$ld$hide$os10.5$___fixdfti', + '$ld$hide$os10.5$___fixsfdi', '$ld$hide$os10.5$___fixsfti', + '$ld$hide$os10.5$___fixunsdfdi', '$ld$hide$os10.5$___fixunsdfsi', + '$ld$hide$os10.5$___fixunsdfti', '$ld$hide$os10.5$___fixunssfdi', + '$ld$hide$os10.5$___fixunssfsi', '$ld$hide$os10.5$___fixunssfti', + '$ld$hide$os10.5$___fixunsxfdi', '$ld$hide$os10.5$___fixunsxfsi', + '$ld$hide$os10.5$___fixxfdi', '$ld$hide$os10.5$___floatdidf', + '$ld$hide$os10.5$___floatdisf', '$ld$hide$os10.5$___floatdixf', + '$ld$hide$os10.5$___floattidf', '$ld$hide$os10.5$___floattisf', + '$ld$hide$os10.5$___floatundidf', '$ld$hide$os10.5$___floatundisf', + '$ld$hide$os10.5$___floatundixf', '$ld$hide$os10.5$___floatuntidf', + '$ld$hide$os10.5$___floatuntisf', '$ld$hide$os10.5$___gcc_personality_v0', + '$ld$hide$os10.5$___lshrdi3', '$ld$hide$os10.5$___moddi3', + '$ld$hide$os10.5$___modti3', '$ld$hide$os10.5$___muldc3', + '$ld$hide$os10.5$___muldi3', '$ld$hide$os10.5$___mulsc3', + '$ld$hide$os10.5$___mulvdi3', '$ld$hide$os10.5$___mulvsi3', + '$ld$hide$os10.5$___mulxc3', '$ld$hide$os10.5$___negdi2', + '$ld$hide$os10.5$___negvdi2', '$ld$hide$os10.5$___negvsi2', + '$ld$hide$os10.5$___paritydi2', '$ld$hide$os10.5$___paritysi2', + '$ld$hide$os10.5$___popcountdi2', '$ld$hide$os10.5$___popcountsi2', + '$ld$hide$os10.5$___powidf2', '$ld$hide$os10.5$___powisf2', + '$ld$hide$os10.5$___powixf2', '$ld$hide$os10.5$___subvdi3', + '$ld$hide$os10.5$___subvsi3', '$ld$hide$os10.5$___ucmpdi2', + '$ld$hide$os10.5$___udivdi3', '$ld$hide$os10.5$___udivmoddi4', + '$ld$hide$os10.5$___udivmodti4', '$ld$hide$os10.5$___udivti3', + '$ld$hide$os10.5$___umoddi3', '$ld$hide$os10.5$___umodti3', + '$ld$hide$os10.6$___atomic_compare_exchange', '$ld$hide$os10.6$___atomic_compare_exchange_1', + '$ld$hide$os10.6$___atomic_compare_exchange_2', '$ld$hide$os10.6$___atomic_compare_exchange_4', + '$ld$hide$os10.6$___atomic_compare_exchange_8', '$ld$hide$os10.6$___atomic_exchange', + '$ld$hide$os10.6$___atomic_exchange_1', '$ld$hide$os10.6$___atomic_exchange_2', + '$ld$hide$os10.6$___atomic_exchange_4', '$ld$hide$os10.6$___atomic_exchange_8', + '$ld$hide$os10.6$___atomic_fetch_add_1', '$ld$hide$os10.6$___atomic_fetch_add_2', + '$ld$hide$os10.6$___atomic_fetch_add_4', '$ld$hide$os10.6$___atomic_fetch_add_8', + '$ld$hide$os10.6$___atomic_fetch_and_1', '$ld$hide$os10.6$___atomic_fetch_and_2', + '$ld$hide$os10.6$___atomic_fetch_and_4', '$ld$hide$os10.6$___atomic_fetch_and_8', + '$ld$hide$os10.6$___atomic_fetch_or_1', '$ld$hide$os10.6$___atomic_fetch_or_2', + '$ld$hide$os10.6$___atomic_fetch_or_4', '$ld$hide$os10.6$___atomic_fetch_or_8', + '$ld$hide$os10.6$___atomic_fetch_sub_1', '$ld$hide$os10.6$___atomic_fetch_sub_2', + '$ld$hide$os10.6$___atomic_fetch_sub_4', '$ld$hide$os10.6$___atomic_fetch_sub_8', + '$ld$hide$os10.6$___atomic_fetch_xor_1', '$ld$hide$os10.6$___atomic_fetch_xor_2', + '$ld$hide$os10.6$___atomic_fetch_xor_4', '$ld$hide$os10.6$___atomic_fetch_xor_8', + '$ld$hide$os10.6$___atomic_load', '$ld$hide$os10.6$___atomic_load_1', + '$ld$hide$os10.6$___atomic_load_2', '$ld$hide$os10.6$___atomic_load_4', + '$ld$hide$os10.6$___atomic_load_8', '$ld$hide$os10.6$___atomic_store', + '$ld$hide$os10.6$___atomic_store_1', '$ld$hide$os10.6$___atomic_store_2', + '$ld$hide$os10.6$___atomic_store_4', '$ld$hide$os10.6$___atomic_store_8', + '$ld$hide$os10.6$___chkstk_darwin', '$ld$hide$os10.6$___extendhfsf2', + '$ld$hide$os10.6$___truncdfhf2', '$ld$hide$os10.6$___truncsfhf2', + '$ld$hide$os10.6$_atomic_flag_clear', '$ld$hide$os10.6$_atomic_flag_clear_explicit', + '$ld$hide$os10.6$_atomic_flag_test_and_set', '$ld$hide$os10.6$_atomic_flag_test_and_set_explicit', + '$ld$hide$os10.6$_atomic_signal_fence', '$ld$hide$os10.6$_atomic_thread_fence', + '$ld$hide$os10.7$___atomic_compare_exchange', '$ld$hide$os10.7$___atomic_compare_exchange_1', + '$ld$hide$os10.7$___atomic_compare_exchange_2', '$ld$hide$os10.7$___atomic_compare_exchange_4', + '$ld$hide$os10.7$___atomic_compare_exchange_8', '$ld$hide$os10.7$___atomic_exchange', + '$ld$hide$os10.7$___atomic_exchange_1', '$ld$hide$os10.7$___atomic_exchange_2', + '$ld$hide$os10.7$___atomic_exchange_4', '$ld$hide$os10.7$___atomic_exchange_8', + '$ld$hide$os10.7$___atomic_fetch_add_1', '$ld$hide$os10.7$___atomic_fetch_add_2', + '$ld$hide$os10.7$___atomic_fetch_add_4', '$ld$hide$os10.7$___atomic_fetch_add_8', + '$ld$hide$os10.7$___atomic_fetch_and_1', '$ld$hide$os10.7$___atomic_fetch_and_2', + '$ld$hide$os10.7$___atomic_fetch_and_4', '$ld$hide$os10.7$___atomic_fetch_and_8', + '$ld$hide$os10.7$___atomic_fetch_or_1', '$ld$hide$os10.7$___atomic_fetch_or_2', + '$ld$hide$os10.7$___atomic_fetch_or_4', '$ld$hide$os10.7$___atomic_fetch_or_8', + '$ld$hide$os10.7$___atomic_fetch_sub_1', '$ld$hide$os10.7$___atomic_fetch_sub_2', + '$ld$hide$os10.7$___atomic_fetch_sub_4', '$ld$hide$os10.7$___atomic_fetch_sub_8', + '$ld$hide$os10.7$___atomic_fetch_xor_1', '$ld$hide$os10.7$___atomic_fetch_xor_2', + '$ld$hide$os10.7$___atomic_fetch_xor_4', '$ld$hide$os10.7$___atomic_fetch_xor_8', + '$ld$hide$os10.7$___atomic_load', '$ld$hide$os10.7$___atomic_load_1', + '$ld$hide$os10.7$___atomic_load_2', '$ld$hide$os10.7$___atomic_load_4', + '$ld$hide$os10.7$___atomic_load_8', '$ld$hide$os10.7$___atomic_store', + '$ld$hide$os10.7$___atomic_store_1', '$ld$hide$os10.7$___atomic_store_2', + '$ld$hide$os10.7$___atomic_store_4', '$ld$hide$os10.7$___atomic_store_8', + '$ld$hide$os10.7$___chkstk_darwin', '$ld$hide$os10.7$___extendhfsf2', + '$ld$hide$os10.7$___truncdfhf2', '$ld$hide$os10.7$___truncsfhf2', + '$ld$hide$os10.7$_atomic_flag_clear', '$ld$hide$os10.7$_atomic_flag_clear_explicit', + '$ld$hide$os10.7$_atomic_flag_test_and_set', '$ld$hide$os10.7$_atomic_flag_test_and_set_explicit', + '$ld$hide$os10.7$_atomic_signal_fence', '$ld$hide$os10.7$_atomic_thread_fence', + '$ld$hide$os10.8$___atomic_compare_exchange', '$ld$hide$os10.8$___atomic_compare_exchange_1', + '$ld$hide$os10.8$___atomic_compare_exchange_2', '$ld$hide$os10.8$___atomic_compare_exchange_4', + '$ld$hide$os10.8$___atomic_compare_exchange_8', '$ld$hide$os10.8$___atomic_exchange', + '$ld$hide$os10.8$___atomic_exchange_1', '$ld$hide$os10.8$___atomic_exchange_2', + '$ld$hide$os10.8$___atomic_exchange_4', '$ld$hide$os10.8$___atomic_exchange_8', + '$ld$hide$os10.8$___atomic_fetch_add_1', '$ld$hide$os10.8$___atomic_fetch_add_2', + '$ld$hide$os10.8$___atomic_fetch_add_4', '$ld$hide$os10.8$___atomic_fetch_add_8', + '$ld$hide$os10.8$___atomic_fetch_and_1', '$ld$hide$os10.8$___atomic_fetch_and_2', + '$ld$hide$os10.8$___atomic_fetch_and_4', '$ld$hide$os10.8$___atomic_fetch_and_8', + '$ld$hide$os10.8$___atomic_fetch_or_1', '$ld$hide$os10.8$___atomic_fetch_or_2', + '$ld$hide$os10.8$___atomic_fetch_or_4', '$ld$hide$os10.8$___atomic_fetch_or_8', + '$ld$hide$os10.8$___atomic_fetch_sub_1', '$ld$hide$os10.8$___atomic_fetch_sub_2', + '$ld$hide$os10.8$___atomic_fetch_sub_4', '$ld$hide$os10.8$___atomic_fetch_sub_8', + '$ld$hide$os10.8$___atomic_fetch_xor_1', '$ld$hide$os10.8$___atomic_fetch_xor_2', + '$ld$hide$os10.8$___atomic_fetch_xor_4', '$ld$hide$os10.8$___atomic_fetch_xor_8', + '$ld$hide$os10.8$___atomic_load', '$ld$hide$os10.8$___atomic_load_1', + '$ld$hide$os10.8$___atomic_load_2', '$ld$hide$os10.8$___atomic_load_4', + '$ld$hide$os10.8$___atomic_load_8', '$ld$hide$os10.8$___atomic_store', + '$ld$hide$os10.8$___atomic_store_1', '$ld$hide$os10.8$___atomic_store_2', + '$ld$hide$os10.8$___atomic_store_4', '$ld$hide$os10.8$___atomic_store_8', + '$ld$hide$os10.8$___chkstk_darwin', '$ld$hide$os10.8$___extendhfsf2', + '$ld$hide$os10.8$___truncdfhf2', '$ld$hide$os10.8$___truncsfhf2', + '$ld$hide$os10.8$_atomic_flag_clear', '$ld$hide$os10.8$_atomic_flag_clear_explicit', + '$ld$hide$os10.8$_atomic_flag_test_and_set', '$ld$hide$os10.8$_atomic_flag_test_and_set_explicit', + '$ld$hide$os10.8$_atomic_signal_fence', '$ld$hide$os10.8$_atomic_thread_fence', + '$ld$hide$os10.9$___chkstk_darwin', '$ld$hide$os10.9$___extendhfsf2', + '$ld$hide$os10.9$___truncdfhf2', '$ld$hide$os10.9$___truncsfhf2', + '$ld$hide$os10.9$_atomic_flag_clear', '$ld$hide$os10.9$_atomic_flag_clear_explicit', + '$ld$hide$os10.9$_atomic_flag_test_and_set', '$ld$hide$os10.9$_atomic_flag_test_and_set_explicit', + '$ld$hide$os10.9$_atomic_signal_fence', '$ld$hide$os10.9$_atomic_thread_fence', + ___atomic_compare_exchange, ___atomic_compare_exchange_1, + ___atomic_compare_exchange_2, ___atomic_compare_exchange_4, + ___atomic_compare_exchange_8, ___atomic_exchange, ___atomic_exchange_1, + ___atomic_exchange_2, ___atomic_exchange_4, ___atomic_exchange_8, + ___atomic_fetch_add_1, ___atomic_fetch_add_2, ___atomic_fetch_add_4, + ___atomic_fetch_add_8, ___atomic_fetch_and_1, ___atomic_fetch_and_2, + ___atomic_fetch_and_4, ___atomic_fetch_and_8, ___atomic_fetch_or_1, + ___atomic_fetch_or_2, ___atomic_fetch_or_4, ___atomic_fetch_or_8, + ___atomic_fetch_sub_1, ___atomic_fetch_sub_2, ___atomic_fetch_sub_4, + ___atomic_fetch_sub_8, ___atomic_fetch_xor_1, ___atomic_fetch_xor_2, + ___atomic_fetch_xor_4, ___atomic_fetch_xor_8, ___atomic_load, + ___atomic_load_1, ___atomic_load_2, ___atomic_load_4, ___atomic_load_8, + ___atomic_store, ___atomic_store_1, ___atomic_store_2, ___atomic_store_4, + ___atomic_store_8, ___chkstk_darwin, ___clear_cache, ___clzti2, + ___divti3, ___enable_execute_stack, ___extendhfsf2, ___fixdfti, + ___fixsfti, ___fixunsdfti, ___fixunssfti, ___floattidf, ___floattisf, + ___floatuntidf, ___floatuntisf, ___gcc_personality_v0, ___gnu_f2h_ieee, + ___gnu_h2f_ieee, ___modti3, ___muldc3, ___mulsc3, ___powidf2, + ___powisf2, ___truncdfhf2, ___truncsfhf2, ___udivmodti4, ___udivti3, + ___umodti3, _atomic_flag_clear, _atomic_flag_clear_explicit, + _atomic_flag_test_and_set, _atomic_flag_test_and_set_explicit, + _atomic_signal_fence, _atomic_thread_fence ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 89483CD4-DA46-3AF2-AE78-FC37CED05ACC + - target: x86_64-maccatalyst + value: 89483CD4-DA46-3AF2-AE78-FC37CED05ACC + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 8AE5EFE8-BBA5-380B-9165-D350CD7EA3CE + - target: arm64e-maccatalyst + value: 8AE5EFE8-BBA5-380B-9165-D350CD7EA3CE +install-name: '/usr/lib/system/libcopyfile.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _copyfile, _copyfile_state_alloc, _copyfile_state_free, _copyfile_state_get, + _copyfile_state_set, _fcopyfile, _xattr_flags_from_name, _xattr_intent_with_flags, + _xattr_name_with_flags, _xattr_name_without_flags, _xattr_preserve_for_intent ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 92F0211E-506E-3760-A3C2-808BF3905C07 + - target: x86_64-maccatalyst + value: 92F0211E-506E-3760-A3C2-808BF3905C07 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: D6B8B5AA-56DF-3E47-A778-007A7AA81372 + - target: arm64e-maccatalyst + value: D6B8B5AA-56DF-3E47-A778-007A7AA81372 +install-name: '/usr/lib/system/libcorecrypto.dylib' +current-version: 1000.60.19 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +allowable-clients: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + clients: [ cc_fips_test, corecrypto_test ] +exports: + - targets: [ x86_64-macos, x86_64-maccatalyst ] + symbols: [ _ccaes_intel_cbc_decrypt_aesni_mode, _ccaes_intel_cbc_decrypt_opt_mode, + _ccaes_intel_cbc_encrypt_aesni_mode, _ccaes_intel_cbc_encrypt_opt_mode, + _ccaes_intel_ecb_decrypt_aesni_mode, _ccaes_intel_ecb_decrypt_opt_mode, + _ccaes_intel_ecb_encrypt_aesni_mode, _ccaes_intel_ecb_encrypt_opt_mode, + _ccaes_intel_xts_decrypt_aesni_mode, _ccaes_intel_xts_decrypt_opt_mode, + _ccaes_intel_xts_encrypt_aesni_mode, _ccaes_intel_xts_encrypt_opt_mode, + _ccsha1_vng_intel_SupplementalSSE3_di, _ccsha224_vng_intel_SupplementalSSE3_di, + _ccsha256_vng_intel_SupplementalSSE3_di ] + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _CCEC_FAULT_CANARY, _CCRSA_PKCS1_FAULT_CANARY, _CCRSA_PSS_FAULT_CANARY, + _cc_abort, _cc_atfork_child, _cc_atfork_parent, _cc_atfork_prepare, + _cc_clear, _cc_cmp_safe, _cc_muxp, _ccaes_cbc_decrypt_mode, + _ccaes_cbc_encrypt_mode, _ccaes_ccm_decrypt_mode, _ccaes_ccm_encrypt_mode, + _ccaes_cfb8_decrypt_mode, _ccaes_cfb8_encrypt_mode, _ccaes_cfb_decrypt_mode, + _ccaes_cfb_encrypt_mode, _ccaes_ctr_crypt_mode, _ccaes_ecb_decrypt_mode, + _ccaes_ecb_encrypt_mode, _ccaes_gcm_decrypt_mode, _ccaes_gcm_encrypt_mode, + _ccaes_gladman_cbc_decrypt_mode, _ccaes_gladman_cbc_encrypt_mode, + _ccaes_ltc_ecb_decrypt_mode, _ccaes_ltc_ecb_encrypt_mode, + _ccaes_ofb_crypt_mode, _ccaes_siv_decrypt_mode, _ccaes_siv_encrypt_mode, + _ccaes_siv_hmac_sha256_decrypt_mode, _ccaes_siv_hmac_sha256_encrypt_mode, + _ccaes_unwind, _ccaes_xts_decrypt_mode, _ccaes_xts_encrypt_mode, + _ccansikdf_x963, _ccapsic_client_check_intersect_response, + _ccapsic_client_generate_match_response, _ccapsic_client_init, + _ccapsic_client_state_sizeof, _ccapsic_server_determine_intersection, + _ccapsic_server_encode_element, _ccapsic_server_init, _ccapsic_server_state_sizeof, + _ccblowfish_cbc_decrypt_mode, _ccblowfish_cbc_encrypt_mode, + _ccblowfish_cfb8_decrypt_mode, _ccblowfish_cfb8_encrypt_mode, + _ccblowfish_cfb_decrypt_mode, _ccblowfish_cfb_encrypt_mode, + _ccblowfish_ctr_crypt_mode, _ccblowfish_ecb_decrypt_mode, + _ccblowfish_ecb_encrypt_mode, _ccblowfish_ofb_crypt_mode, + _cccast_cbc_decrypt_mode, _cccast_cbc_encrypt_mode, _cccast_cfb8_decrypt_mode, + _cccast_cfb8_encrypt_mode, _cccast_cfb_decrypt_mode, _cccast_cfb_encrypt_mode, + _cccast_ctr_crypt_mode, _cccast_ecb_decrypt_mode, _cccast_ecb_encrypt_mode, + _cccast_ofb_crypt_mode, _cccbc_one_shot, _ccchacha20, _ccchacha20_final, + _ccchacha20_init, _ccchacha20_reset, _ccchacha20_setcounter, + _ccchacha20_setnonce, _ccchacha20_update, _ccchacha20poly1305_aad, + _ccchacha20poly1305_decrypt, _ccchacha20poly1305_decrypt_oneshot, + _ccchacha20poly1305_encrypt, _ccchacha20poly1305_encrypt_oneshot, + _ccchacha20poly1305_finalize, _ccchacha20poly1305_incnonce, + _ccchacha20poly1305_info, _ccchacha20poly1305_init, _ccchacha20poly1305_reset, + _ccchacha20poly1305_setnonce, _ccchacha20poly1305_verify, + _ccckg_contributor_commit, _ccckg_contributor_finish, _ccckg_init, + _ccckg_owner_finish, _ccckg_owner_generate_share, _ccckg_sizeof_commitment, + _ccckg_sizeof_ctx, _ccckg_sizeof_opening, _ccckg_sizeof_share, + _cccmac_final_generate, _cccmac_final_verify, _cccmac_init, + _cccmac_one_shot_generate, _cccmac_one_shot_verify, _cccmac_update, + _cccurve25519, _ccder_decode_bitstring, _ccder_decode_constructed_tl, + _ccder_decode_constructed_tl_strict, _ccder_decode_dhparam_n, + _ccder_decode_dhparams, _ccder_decode_eckey, _ccder_decode_len, + _ccder_decode_len_strict, _ccder_decode_oid, _ccder_decode_rsa_priv, + _ccder_decode_rsa_priv_n, _ccder_decode_rsa_pub, _ccder_decode_rsa_pub_n, + _ccder_decode_rsa_pub_x509, _ccder_decode_rsa_pub_x509_n, + _ccder_decode_seqii, _ccder_decode_seqii_strict, _ccder_decode_sequence_tl, + _ccder_decode_sequence_tl_strict, _ccder_decode_tag, _ccder_decode_tl, + _ccder_decode_tl_strict, _ccder_decode_uint, _ccder_decode_uint64, + _ccder_decode_uint_n, _ccder_decode_uint_strict, _ccder_encode_body, + _ccder_encode_body_nocopy, _ccder_encode_constructed_tl, _ccder_encode_dhparams, + _ccder_encode_dhparams_size, _ccder_encode_eckey, _ccder_encode_eckey_size, + _ccder_encode_implicit_integer, _ccder_encode_implicit_octet_string, + _ccder_encode_implicit_raw_octet_string, _ccder_encode_implicit_uint64, + _ccder_encode_integer, _ccder_encode_len, _ccder_encode_octet_string, + _ccder_encode_oid, _ccder_encode_raw_octet_string, _ccder_encode_rsa_priv, + _ccder_encode_rsa_priv_size, _ccder_encode_rsa_pub, _ccder_encode_rsa_pub_size, + _ccder_encode_tag, _ccder_encode_tl, _ccder_encode_uint64, + _ccder_sizeof, _ccder_sizeof_implicit_integer, _ccder_sizeof_implicit_octet_string, + _ccder_sizeof_implicit_raw_octet_string, _ccder_sizeof_implicit_uint64, + _ccder_sizeof_integer, _ccder_sizeof_len, _ccder_sizeof_octet_string, + _ccder_sizeof_oid, _ccder_sizeof_raw_octet_string, _ccder_sizeof_tag, + _ccder_sizeof_uint64, _ccdes3_cbc_decrypt_mode, _ccdes3_cbc_encrypt_mode, + _ccdes3_cfb8_decrypt_mode, _ccdes3_cfb8_encrypt_mode, _ccdes3_cfb_decrypt_mode, + _ccdes3_cfb_encrypt_mode, _ccdes3_ctr_crypt_mode, _ccdes3_ecb_decrypt_mode, + _ccdes3_ecb_encrypt_mode, _ccdes3_ltc_ecb_decrypt_mode, _ccdes3_ltc_ecb_encrypt_mode, + _ccdes3_ofb_crypt_mode, _ccdes_cbc_cksum, _ccdes_cbc_decrypt_mode, + _ccdes_cbc_encrypt_mode, _ccdes_cfb8_decrypt_mode, _ccdes_cfb8_encrypt_mode, + _ccdes_cfb_decrypt_mode, _ccdes_cfb_encrypt_mode, _ccdes_ctr_crypt_mode, + _ccdes_ecb_decrypt_mode, _ccdes_ecb_encrypt_mode, _ccdes_key_is_weak, + _ccdes_key_set_odd_parity, _ccdes_ofb_crypt_mode, _ccdh_compute_key, + _ccdh_compute_shared_secret, _ccdh_export_pub, _ccdh_generate_key, + _ccdh_gp_apple768, _ccdh_gp_rfc2409group02, _ccdh_gp_rfc3526group05, + _ccdh_gp_rfc3526group14, _ccdh_gp_rfc3526group15, _ccdh_gp_rfc3526group16, + _ccdh_gp_rfc3526group17, _ccdh_gp_rfc3526group18, _ccdh_gp_rfc5114_MODP_1024_160, + _ccdh_gp_rfc5114_MODP_2048_224, _ccdh_gp_rfc5114_MODP_2048_256, + _ccdh_import_full, _ccdh_import_priv, _ccdh_import_pub, _ccdh_init_gp, + _ccdh_init_gp_from_bytes, _ccdh_init_gp_with_order, _ccdh_lookup_gp, + _ccdigest, _ccdigest_init, _ccdigest_oid_lookup, _ccdigest_update, + _ccdrbg_factory_nistctr, _ccdrbg_factory_nisthmac, _ccec_blind, + _ccec_compact_export, _ccec_compact_export_pub, _ccec_compact_generate_key, + _ccec_compact_import_priv, _ccec_compact_import_priv_size, + _ccec_compact_import_pub, _ccec_compact_import_pub_size, _ccec_compact_transform_key, + _ccec_compressed_x962_export_pub, _ccec_compressed_x962_export_pub_size, + _ccec_compressed_x962_import_pub, _ccec_compute_key, _ccec_cp_192, + _ccec_cp_224, _ccec_cp_256, _ccec_cp_384, _ccec_cp_521, _ccec_curve_for_length_lookup, + _ccec_der_export_diversified_pub, _ccec_der_export_diversified_pub_size, + _ccec_der_export_priv, _ccec_der_export_priv_size, _ccec_der_import_diversified_pub, + _ccec_der_import_priv, _ccec_der_import_priv_keytype, _ccec_diversify_min_entropy_len, + _ccec_diversify_priv_twin, _ccec_diversify_pub, _ccec_diversify_pub_twin, + _ccec_export_pub, _ccec_extract_rs, _ccec_generate_blinding_keys, + _ccec_generate_key, _ccec_generate_key_deterministic, _ccec_generate_key_fips, + _ccec_generate_key_internal_fips, _ccec_generate_key_legacy, + _ccec_get_cp, _ccec_get_fullkey_components, _ccec_get_pubkey_components, + _ccec_import_pub, _ccec_keysize_is_supported, _ccec_make_priv, + _ccec_make_pub, _ccec_pairwise_consistency_check, _ccec_print_full_key, + _ccec_print_public_key, _ccec_raw_import_priv_only, _ccec_raw_import_pub, + _ccec_rfc6637_dh_curve_p256, _ccec_rfc6637_dh_curve_p521, + _ccec_rfc6637_unwrap_key, _ccec_rfc6637_unwrap_sha256_kek_aes128, + _ccec_rfc6637_unwrap_sha512_kek_aes256, _ccec_rfc6637_wrap_key, + _ccec_rfc6637_wrap_key_diversified, _ccec_rfc6637_wrap_key_size, + _ccec_rfc6637_wrap_sha256_kek_aes128, _ccec_rfc6637_wrap_sha512_kek_aes256, + _ccec_sign, _ccec_sign_composite, _ccec_sign_composite_msg, + _ccec_sign_msg, _ccec_signature_r_s_size, _ccec_unblind, _ccec_validate_pub, + _ccec_verify, _ccec_verify_composite, _ccec_verify_composite_digest, + _ccec_verify_composite_msg, _ccec_verify_digest, _ccec_verify_msg, + _ccec_x963_export, _ccec_x963_import_priv, _ccec_x963_import_priv_size, + _ccec_x963_import_pub, _ccec_x963_import_pub_size, _ccecdh_compute_shared_secret, + _ccecdh_generate_key, _ccecies_decrypt_gcm, _ccecies_decrypt_gcm_composite, + _ccecies_decrypt_gcm_from_shared_secret, _ccecies_decrypt_gcm_plaintext_size, + _ccecies_decrypt_gcm_plaintext_size_cp, _ccecies_decrypt_gcm_setup, + _ccecies_encrypt_gcm, _ccecies_encrypt_gcm_ciphertext_size, + _ccecies_encrypt_gcm_composite, _ccecies_encrypt_gcm_from_shared_secret, + _ccecies_encrypt_gcm_setup, _ccecies_import_eph_pub, _ccecies_pub_key_size, + _ccecies_pub_key_size_cp, _cced25519_make_key_pair, _cced25519_make_pub, + _cced25519_sign, _cced25519_verify, _ccgcm_inc_iv, _ccgcm_init_with_iv, + _ccgcm_one_shot, _ccgcm_one_shot_legacy, _ccgcm_set_iv_legacy, + _cch2c, _cch2c_name, _cch2c_p256_sha256_sae_compat_info, _cch2c_p256_sha256_sswu_ro_info, + _cch2c_p384_sha384_sae_compat_info, _cch2c_p384_sha512_sswu_ro_info, + _cch2c_p521_sha512_sswu_ro_info, _cchkdf, _cchkdf_expand, + _cchkdf_extract, _cchmac, _cchmac_final, _cchmac_init, _cchmac_update, + _cchpke_initiator_encrypt, _cchpke_initiator_seal, _cchpke_initiator_setup, + _cchpke_kem_generate_key_pair, _cchpke_params_sizeof_aead_key, + _cchpke_params_sizeof_aead_nonce, _cchpke_params_sizeof_aead_tag, + _cchpke_params_sizeof_kdf_hash, _cchpke_params_sizeof_kem_enc, + _cchpke_params_sizeof_kem_pk, _cchpke_params_sizeof_kem_pk_marshalled, + _cchpke_params_sizeof_kem_sk, _cchpke_params_sizeof_kem_zz, + _cchpke_params_x25519_AESGCM128_HKDF_SHA256, _cchpke_responder_decrypt, + _cchpke_responder_open, _cchpke_responder_setup, _ccmd2_ltc_di, + _ccmd4_ltc_di, _ccmd5_di, _ccmd5_ltc_di, _ccmgf, _ccmode_factory_cbc_decrypt, + _ccmode_factory_cbc_encrypt, _ccmode_factory_ccm_decrypt, + _ccmode_factory_ccm_encrypt, _ccmode_factory_cfb8_decrypt, + _ccmode_factory_cfb8_encrypt, _ccmode_factory_cfb_decrypt, + _ccmode_factory_cfb_encrypt, _ccmode_factory_ctr_crypt, _ccmode_factory_gcm_decrypt, + _ccmode_factory_gcm_encrypt, _ccmode_factory_ofb_crypt, _ccmode_factory_omac_decrypt, + _ccmode_factory_omac_encrypt, _ccmode_factory_siv_decrypt, + _ccmode_factory_siv_encrypt, _ccmode_factory_xts_decrypt, + _ccmode_factory_xts_encrypt, _ccn_add, _ccn_add1, _ccn_addmul1, + _ccn_bitlen, _ccn_cmp, _ccn_cmpn, _ccn_div_euclid, _ccn_lprint, + _ccn_mul, _ccn_mul1, _ccn_n, _ccn_print, _ccn_random_bits, + _ccn_read_uint, _ccn_set, _ccn_shift_right, _ccn_sub, _ccn_sub1, + _ccn_write_int, _ccn_write_int_size, _ccn_write_uint, _ccn_write_uint_padded_ct, + _ccn_write_uint_size, _ccn_zero_multi, _ccnistkdf_ctr_cmac, + _ccnistkdf_ctr_cmac_fixed, _ccnistkdf_ctr_hmac, _ccnistkdf_ctr_hmac_fixed, + _ccnistkdf_fb_hmac, _ccnistkdf_fb_hmac_fixed, _ccpad_cts1_decrypt, + _ccpad_cts1_encrypt, _ccpad_cts2_decrypt, _ccpad_cts2_encrypt, + _ccpad_cts3_decrypt, _ccpad_cts3_encrypt, _ccpad_pkcs7_decode, + _ccpad_pkcs7_decrypt, _ccpad_pkcs7_ecb_decrypt, _ccpad_pkcs7_ecb_encrypt, + _ccpad_pkcs7_encrypt, _ccpad_xts_decrypt, _ccpad_xts_encrypt, + _ccpbkdf2_hmac, _ccpoly1305, _ccpoly1305_final, _ccpoly1305_init, + _ccpoly1305_update, _ccrc2_cbc_decrypt_mode, _ccrc2_cbc_encrypt_mode, + _ccrc2_cfb8_decrypt_mode, _ccrc2_cfb8_encrypt_mode, _ccrc2_cfb_decrypt_mode, + _ccrc2_cfb_encrypt_mode, _ccrc2_ctr_crypt_mode, _ccrc2_ecb_decrypt_mode, + _ccrc2_ecb_encrypt_mode, _ccrc2_ofb_crypt_mode, _ccrc4, _ccrc4_eay, + _ccrmd160_ltc_di, _ccrng, _ccrng_drbg_done, _ccrng_drbg_init, + _ccrng_drbg_init_withdrbg, _ccrng_drbg_reseed, _ccrng_ecfips_test_init, + _ccrng_pbkdf2_prng_init, _ccrng_rsafips_test_init, _ccrng_rsafips_test_set_next, + _ccrng_sequence_init, _ccrng_system_done, _ccrng_system_init, + _ccrng_test_done, _ccrng_test_init, _ccrng_uniform, _ccrsa_decrypt_eme_pkcs1v15, + _ccrsa_decrypt_eme_pkcs1v15_blinded, _ccrsa_decrypt_oaep, + _ccrsa_decrypt_oaep_blinded, _ccrsa_dump_full_key, _ccrsa_dump_public_key, + _ccrsa_eme_pkcs1v15_decode, _ccrsa_eme_pkcs1v15_encode, _ccrsa_emsa_pkcs1v15_encode, + _ccrsa_emsa_pkcs1v15_verify, _ccrsa_emsa_pss_decode, _ccrsa_emsa_pss_encode, + _ccrsa_encrypt_eme_pkcs1v15, _ccrsa_encrypt_oaep, _ccrsa_export_pub, + _ccrsa_generate_fips186_key, _ccrsa_generate_key, _ccrsa_get_fullkey_components, + _ccrsa_get_pubkey_components, _ccrsa_import_pub, _ccrsa_init_pub, + _ccrsa_make_priv, _ccrsa_make_pub, _ccrsa_oaep_decode_parameter, + _ccrsa_oaep_encode_parameter, _ccrsa_priv_crypt, _ccrsa_priv_crypt_blinded, + _ccrsa_pub_crypt, _ccrsa_pubkeylength, _ccrsa_recover_priv, + _ccrsa_sign_pkcs1v15, _ccrsa_sign_pkcs1v15_msg, _ccrsa_sign_pss, + _ccrsa_sign_pss_msg, _ccrsa_verify_pkcs1v15, _ccrsa_verify_pkcs1v15_allowshortsigs, + _ccrsa_verify_pkcs1v15_digest, _ccrsa_verify_pkcs1v15_msg, + _ccrsa_verify_pss, _ccrsa_verify_pss_digest, _ccrsa_verify_pss_msg, + _ccscrypt, _ccscrypt_storage_size, _ccsha1_di, _ccsha1_eay_di, + _ccsha1_ltc_di, _ccsha224_di, _ccsha224_ltc_di, _ccsha256_di, + _ccsha256_ltc_di, _ccsha384_di, _ccsha384_ltc_di, _ccsha512_256_di, + _ccsha512_256_ltc_di, _ccsha512_di, _ccsha512_ltc_di, _ccsiv_hmac_aad, + _ccsiv_hmac_ciphertext_size, _ccsiv_hmac_crypt, _ccsiv_hmac_init, + _ccsiv_hmac_one_shot, _ccsiv_hmac_plaintext_size, _ccsiv_hmac_reset, + _ccsiv_hmac_set_nonce, _ccspake_cp_256, _ccspake_cp_384, _ccspake_cp_521, + _ccspake_generate_L, _ccspake_kex_generate, _ccspake_kex_process, + _ccspake_mac_compute, _ccspake_mac_hkdf_cmac_aes128_sha256, + _ccspake_mac_hkdf_hmac_sha256, _ccspake_mac_hkdf_hmac_sha512, + _ccspake_mac_verify_and_get_session_key, _ccspake_prover_init, + _ccspake_sizeof_ctx, _ccspake_sizeof_point, _ccspake_sizeof_w, + _ccspake_verifier_init, _ccsrp_client_process_challenge, _ccsrp_client_start_authentication, + _ccsrp_client_verify_session, _ccsrp_generate_salt_and_verification, + _ccsrp_generate_verifier, _ccsrp_gp_rfc5054_1024, _ccsrp_gp_rfc5054_2048, + _ccsrp_gp_rfc5054_3072, _ccsrp_gp_rfc5054_4096, _ccsrp_gp_rfc5054_8192, + _ccsrp_server_compute_session, _ccsrp_server_generate_public_key, + _ccsrp_server_start_authentication, _ccsrp_server_verify_session, + _ccsrp_test_calculations, _ccss_shamir_parameters_init, _ccss_shamir_parameters_maximum_secret_length, + _ccss_shamir_share_bag_add_share, _ccss_shamir_share_bag_init, + _ccss_shamir_share_bag_recover_secret, _ccss_shamir_share_export, + _ccss_shamir_share_generator_generate_share, _ccss_shamir_share_generator_init, + _ccss_shamir_share_import, _ccss_shamir_share_init, _ccss_shamir_share_sizeof_y, + _ccvrf_derive_public_key, _ccvrf_factory_irtfdraft03, _ccvrf_factory_irtfdraft03_default, + _ccvrf_proof_to_hash, _ccvrf_prove, _ccvrf_sizeof_hash, _ccvrf_sizeof_proof, + _ccvrf_sizeof_public_key, _ccvrf_sizeof_secret_key, _ccvrf_verify, + _ccwrap_auth_decrypt, _ccwrap_auth_decrypt_withiv, _ccwrap_auth_encrypt, + _ccwrap_auth_encrypt_withiv, _ccwrap_unwrapped_size, _ccwrap_wrapped_size, + _ccxts_one_shot, _ccz_add, _ccz_addi, _ccz_bit, _ccz_bitlen, + _ccz_cmp, _ccz_cmpi, _ccz_divmod, _ccz_expmod, _ccz_free, + _ccz_init, _ccz_is_negative, _ccz_is_one, _ccz_is_prime, _ccz_is_zero, + _ccz_lsl, _ccz_lsr, _ccz_mod, _ccz_mul, _ccz_muli, _ccz_mulmod, + _ccz_neg, _ccz_random_bits, _ccz_read_radix, _ccz_read_uint, + _ccz_set, _ccz_set_bit, _ccz_seti, _ccz_size, _ccz_sub, _ccz_subi, + _ccz_trailing_zeros, _ccz_write_int, _ccz_write_int_size, + _ccz_write_radix, _ccz_write_radix_size, _ccz_write_uint, + _ccz_write_uint_size, _ccz_zero, _cczp_init, _cczp_init_with_recip, + _cczp_power, _csss_shamir_share_bag_can_recover_secret, _fipspost_post, + _fipspost_trace_vtable ] + - targets: [ arm64e-macos, arm64e-maccatalyst, arm64-macos, arm64-maccatalyst ] + symbols: [ _ccaes_arm_cbc_decrypt_mode, _ccaes_arm_cbc_encrypt_mode, + _ccaes_arm_cfb_decrypt_mode, _ccaes_arm_cfb_encrypt_mode, + _ccaes_arm_ecb_decrypt_mode, _ccaes_arm_ecb_encrypt_mode, + _ccaes_arm_ofb_crypt_mode, _ccaes_arm_xts_decrypt_mode, _ccaes_arm_xts_encrypt_mode, + _ccsha1_vng_arm_di, _ccsha224_vng_arm_di, _ccsha256_vng_arm64neon_di, + _ccsha256_vng_arm_di, _ccsha384_vng_arm_di, _ccsha512_256_vng_arm_di, + _ccsha512_vng_arm_di ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: CEF1460B-1362-381A-AE69-6BCE2D8C215B + - target: x86_64-maccatalyst + value: CEF1460B-1362-381A-AE69-6BCE2D8C215B + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 68CAA910-6621-32A1-95AE-40594BA75013 + - target: arm64e-maccatalyst + value: 68CAA910-6621-32A1-95AE-40594BA75013 +install-name: '/usr/lib/system/libdispatch.dylib' +current-version: 1271.40.12 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ '$ld$hide$os10.12$_dispatch_assert_queue', '$ld$hide$os10.12$_dispatch_assert_queue_not', + '$ld$hide$os10.12$_dispatch_queue_create_with_target', __dispatch_begin_NSAutoReleasePool, + __dispatch_bug, __dispatch_data_destructor_free, __dispatch_data_destructor_munmap, + __dispatch_data_destructor_none, __dispatch_data_destructor_vm_deallocate, + __dispatch_data_empty, __dispatch_data_format_type_base32, + __dispatch_data_format_type_base32hex, __dispatch_data_format_type_base64, + __dispatch_data_format_type_none, __dispatch_data_format_type_utf16be, + __dispatch_data_format_type_utf16le, __dispatch_data_format_type_utf8, + __dispatch_data_format_type_utf_any, __dispatch_end_NSAutoReleasePool, + __dispatch_get_main_queue_handle_4CF, __dispatch_get_main_queue_port_4CF, + __dispatch_iocntl, __dispatch_is_fork_of_multithreaded_parent, + __dispatch_is_multithreaded, __dispatch_log, __dispatch_mach_hooks_install_default, + __dispatch_main_q, __dispatch_main_queue_callback_4CF, __dispatch_poll_for_events_4launchd, + __dispatch_prohibit_transition_to_multithreaded, __dispatch_pthread_root_queue_create_with_observer_hooks_4IOHID, + __dispatch_queue_attr_concurrent, __dispatch_queue_is_exclusively_owned_by_current_thread_4IOHID, + __dispatch_runloop_root_queue_create_4CF, __dispatch_runloop_root_queue_get_port_4CF, + __dispatch_runloop_root_queue_perform_4CF, __dispatch_runloop_root_queue_wakeup_4CF, + __dispatch_source_set_runloop_timer_4CF, __dispatch_source_type_data_add, + __dispatch_source_type_data_or, __dispatch_source_type_data_replace, + __dispatch_source_type_interval, __dispatch_source_type_mach_recv, + __dispatch_source_type_mach_send, __dispatch_source_type_memorypressure, + __dispatch_source_type_memorystatus, __dispatch_source_type_nw_channel, + __dispatch_source_type_proc, __dispatch_source_type_read, + __dispatch_source_type_signal, __dispatch_source_type_sock, + __dispatch_source_type_timer, __dispatch_source_type_vfs, + __dispatch_source_type_vm, __dispatch_source_type_vnode, __dispatch_source_type_write, + __dispatch_source_will_reenable_kevent_4NW, __dispatch_wait_for_enqueuer, + __dispatch_workloop_set_observer_hooks_4IOHID, __dispatch_workloop_should_yield_4NW, + __firehose_spi_version, __os_object_alloc, __os_object_alloc_realized, + __os_object_dealloc, __os_object_release, __os_object_release_internal, + __os_object_release_internal_n, __os_object_release_without_xref_dispose, + __os_object_retain, __os_object_retain_internal, __os_object_retain_internal_n, + __os_object_retain_with_resurrect, _dispatch_activate, _dispatch_after, + _dispatch_after_f, _dispatch_allocator_layout, _dispatch_apply, + _dispatch_apply_f, _dispatch_assert_queue, '_dispatch_assert_queue$V2', + _dispatch_assert_queue_barrier, _dispatch_assert_queue_not, + '_dispatch_assert_queue_not$V2', _dispatch_async, _dispatch_async_and_wait, + _dispatch_async_and_wait_f, _dispatch_async_enforce_qos_class_f, + _dispatch_async_f, _dispatch_atfork_child, _dispatch_atfork_parent, + _dispatch_atfork_prepare, _dispatch_barrier_async, _dispatch_barrier_async_and_wait, + _dispatch_barrier_async_and_wait_f, _dispatch_barrier_async_f, + _dispatch_barrier_sync, _dispatch_barrier_sync_f, _dispatch_benchmark, + _dispatch_benchmark_f, _dispatch_block_cancel, _dispatch_block_create, + _dispatch_block_create_with_qos_class, _dispatch_block_create_with_voucher, + _dispatch_block_create_with_voucher_and_qos_class, _dispatch_block_notify, + _dispatch_block_perform, _dispatch_block_testcancel, _dispatch_block_wait, + _dispatch_channel_async, _dispatch_channel_async_f, _dispatch_channel_cancel, + _dispatch_channel_create, _dispatch_channel_drain, _dispatch_channel_drain_f, + _dispatch_channel_enqueue, _dispatch_channel_foreach_work_item_peek, + _dispatch_channel_foreach_work_item_peek_f, _dispatch_channel_testcancel, + _dispatch_channel_wakeup, _dispatch_data_apply, _dispatch_data_apply_f, + _dispatch_data_copy_region, _dispatch_data_create, _dispatch_data_create_alloc, + _dispatch_data_create_concat, _dispatch_data_create_f, _dispatch_data_create_map, + _dispatch_data_create_subrange, _dispatch_data_create_with_transform, + _dispatch_data_get_flattened_bytes_4libxpc, _dispatch_data_get_size, + _dispatch_data_make_memory_entry, _dispatch_debug, _dispatch_debugv, + _dispatch_get_context, _dispatch_get_current_queue, _dispatch_get_global_queue, + _dispatch_get_specific, _dispatch_group_async, _dispatch_group_async_f, + _dispatch_group_create, _dispatch_group_enter, _dispatch_group_leave, + _dispatch_group_notify, _dispatch_group_notify_f, _dispatch_group_wait, + _dispatch_io_barrier, _dispatch_io_barrier_f, _dispatch_io_close, + _dispatch_io_create, _dispatch_io_create_f, _dispatch_io_create_with_io, + _dispatch_io_create_with_io_f, _dispatch_io_create_with_path, + _dispatch_io_create_with_path_f, _dispatch_io_get_descriptor, + _dispatch_io_read, _dispatch_io_read_f, _dispatch_io_set_high_water, + _dispatch_io_set_interval, _dispatch_io_set_low_water, _dispatch_io_write, + _dispatch_io_write_f, _dispatch_mach_can_handoff_4libxpc, + _dispatch_mach_cancel, _dispatch_mach_connect, _dispatch_mach_create, + _dispatch_mach_create_4libxpc, _dispatch_mach_create_f, _dispatch_mach_get_checkin_port, + _dispatch_mach_handoff_reply, _dispatch_mach_handoff_reply_f, + _dispatch_mach_hooks_install_4libxpc, _dispatch_mach_mig_demux, + _dispatch_mach_mig_demux_get_context, _dispatch_mach_msg_create, + _dispatch_mach_msg_get_context, _dispatch_mach_msg_get_filter_policy_id, + _dispatch_mach_msg_get_msg, _dispatch_mach_notify_no_senders, + _dispatch_mach_receive_barrier, _dispatch_mach_receive_barrier_f, + _dispatch_mach_reconnect, _dispatch_mach_request_no_senders, + _dispatch_mach_send, _dispatch_mach_send_and_wait_for_reply, + _dispatch_mach_send_barrier, _dispatch_mach_send_barrier_f, + _dispatch_mach_send_with_result, _dispatch_mach_send_with_result_and_async_reply_4libxpc, + _dispatch_mach_send_with_result_and_wait_for_reply, _dispatch_mach_set_flags, + _dispatch_main, _dispatch_mig_server, _dispatch_once, _dispatch_once_f, + _dispatch_pthread_root_queue_copy_current, _dispatch_pthread_root_queue_create, + _dispatch_queue_attr_make_initially_inactive, _dispatch_queue_attr_make_with_autorelease_frequency, + _dispatch_queue_attr_make_with_overcommit, _dispatch_queue_attr_make_with_qos_class, + _dispatch_queue_create, _dispatch_queue_create_with_accounting_override_voucher, + _dispatch_queue_create_with_target, '_dispatch_queue_create_with_target$V2', + _dispatch_queue_get_label, _dispatch_queue_get_qos_class, + _dispatch_queue_get_specific, _dispatch_queue_offsets, _dispatch_queue_set_label_nocopy, + _dispatch_queue_set_specific, _dispatch_queue_set_width, _dispatch_read, + _dispatch_read_f, _dispatch_release, _dispatch_resume, _dispatch_retain, + _dispatch_semaphore_create, _dispatch_semaphore_signal, _dispatch_semaphore_wait, + _dispatch_set_context, _dispatch_set_finalizer_f, _dispatch_set_qos_class, + _dispatch_set_qos_class_fallback, _dispatch_set_qos_class_floor, + _dispatch_set_target_queue, _dispatch_source_cancel, _dispatch_source_cancel_and_wait, + _dispatch_source_create, _dispatch_source_get_data, _dispatch_source_get_extended_data, + _dispatch_source_get_handle, _dispatch_source_get_mask, _dispatch_source_merge_data, + _dispatch_source_set_cancel_handler, _dispatch_source_set_cancel_handler_f, + _dispatch_source_set_event_handler, _dispatch_source_set_event_handler_f, + _dispatch_source_set_mandatory_cancel_handler, _dispatch_source_set_mandatory_cancel_handler_f, + _dispatch_source_set_registration_handler, _dispatch_source_set_registration_handler_f, + _dispatch_source_set_timer, _dispatch_source_testcancel, _dispatch_suspend, + _dispatch_sync, _dispatch_sync_f, _dispatch_time, _dispatch_time_to_nsecs, + _dispatch_tsd_indexes, _dispatch_walltime, _dispatch_workloop_copy_current, + _dispatch_workloop_create, _dispatch_workloop_create_inactive, + _dispatch_workloop_is_current, _dispatch_workloop_set_autorelease_frequency, + _dispatch_workloop_set_cpupercent, _dispatch_workloop_set_os_workgroup, + _dispatch_workloop_set_qos_class, _dispatch_workloop_set_qos_class_floor, + _dispatch_workloop_set_scheduler_priority, _dispatch_write, + _dispatch_write_f, _libdispatch_init, _mach_voucher_persona_for_originator, + _mach_voucher_persona_self, _os_eventlink_activate, _os_eventlink_associate, + _os_eventlink_cancel, _os_eventlink_create, _os_eventlink_create_remote_with_eventlink, + _os_eventlink_create_with_port, _os_eventlink_disassociate, + _os_eventlink_extract_remote_port, _os_eventlink_signal, _os_eventlink_signal_and_wait, + _os_eventlink_signal_and_wait_until, _os_eventlink_wait, _os_eventlink_wait_until, + _os_release, _os_retain, _os_workgroup_attr_set_flags, _os_workgroup_attr_set_interval_type, + _os_workgroup_cancel, _os_workgroup_copy_port, _os_workgroup_create, + _os_workgroup_create_with_port, _os_workgroup_create_with_workgroup, + _os_workgroup_get_working_arena, _os_workgroup_interval_copy_current_4AudioToolbox, + _os_workgroup_interval_create, _os_workgroup_interval_finish, + _os_workgroup_interval_start, _os_workgroup_interval_update, + _os_workgroup_join, _os_workgroup_join_self, _os_workgroup_leave, + _os_workgroup_leave_self, _os_workgroup_max_parallel_threads, + _os_workgroup_parallel_create, _os_workgroup_set_working_arena, + _os_workgroup_testcancel, _voucher_activity_create_with_data, + _voucher_activity_create_with_location, _voucher_activity_flush, + _voucher_activity_get_logging_preferences, _voucher_activity_get_metadata_buffer, + _voucher_activity_id_allocate, _voucher_activity_initialize_4libtrace, + _voucher_activity_should_send_strings, _voucher_activity_trace, + _voucher_activity_trace_v, _voucher_activity_trace_v_2, _voucher_adopt, + _voucher_copy, _voucher_copy_with_persona_mach_voucher, _voucher_copy_without_importance, + _voucher_create_with_mach_msg, _voucher_decrement_importance_count4CF, + _voucher_get_activity_id, _voucher_get_activity_id_and_creator, + _voucher_get_current_persona, _voucher_get_current_persona_originator_info, + _voucher_get_current_persona_proximate_info, _voucher_kvoucher_debug, + _voucher_replace_default_voucher ] + objc-classes: [ OS_dispatch_channel, OS_dispatch_data, OS_dispatch_disk, OS_dispatch_group, + OS_dispatch_io, OS_dispatch_mach, OS_dispatch_mach_msg, OS_dispatch_object, + OS_dispatch_operation, OS_dispatch_queue, OS_dispatch_queue_attr, + OS_dispatch_queue_concurrent, OS_dispatch_queue_global, OS_dispatch_queue_main, + OS_dispatch_queue_serial, OS_dispatch_semaphore, OS_dispatch_source, + OS_dispatch_workloop, OS_object, OS_os_eventlink, OS_os_workgroup, + OS_os_workgroup_interval, OS_os_workgroup_parallel, OS_voucher ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 2F8A14F5-7CB8-3EDD-85EA-7FA960BBC04E + - target: x86_64-maccatalyst + value: 2F8A14F5-7CB8-3EDD-85EA-7FA960BBC04E + - target: arm64-macos + value: 4CF2A2F5-4D7D-3067-BF36-60FCD3CC0E0C + - target: arm64-maccatalyst + value: 4CF2A2F5-4D7D-3067-BF36-60FCD3CC0E0C + - target: arm64e-macos + value: 87B502C5-584E-381A-8C99-6105402B8A6E + - target: arm64e-maccatalyst + value: 87B502C5-584E-381A-8C99-6105402B8A6E +install-name: '/usr/lib/system/libdyld.dylib' +current-version: 832.7.1 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ arm64-macos, x86_64-macos, arm64e-macos, x86_64-maccatalyst, + arm64-maccatalyst, arm64e-maccatalyst ] + symbols: [ _NSAddImage, _NSAddLibrary, _NSAddLibraryWithSearching, _NSAddressOfSymbol, + _NSCreateObjectFileImageFromFile, _NSCreateObjectFileImageFromMemory, + _NSDestroyObjectFileImage, _NSGetSectionDataInObjectFileImage, + _NSInstallLinkEditErrorHandlers, _NSIsSymbolDefinedInObjectFileImage, + _NSIsSymbolNameDefined, _NSIsSymbolNameDefinedInImage, _NSIsSymbolNameDefinedWithHint, + _NSLibraryNameForModule, _NSLinkEditError, _NSLinkModule, + _NSLookupAndBindSymbol, _NSLookupAndBindSymbolWithHint, _NSLookupSymbolInImage, + _NSLookupSymbolInModule, _NSModuleForSymbol, _NSNameOfModule, + _NSNameOfSymbol, _NSSymbolDefinitionCountInObjectFileImage, + _NSSymbolDefinitionNameInObjectFileImage, _NSSymbolReferenceCountInObjectFileImage, + _NSSymbolReferenceNameInObjectFileImage, _NSUnLinkModule, + _NSVersionOfLinkTimeLibrary, _NSVersionOfRunTimeLibrary, _NXArgc, + _NXArgv, __NSGetExecutablePath, __ZN5dyld316compatFuncLookupEPKcPPv, + __ZN5dyld318entryVectorForDyldE, ___progname, __dyld_all_twolevel_modules_prebound, + __dyld_atfork_parent, __dyld_atfork_prepare, __dyld_bind_fully_image_containing_address, + __dyld_find_unwind_sections, __dyld_for_each_objc_class, __dyld_for_each_objc_protocol, + __dyld_fork_child, __dyld_get_image_header, __dyld_get_image_header_containing_address, + __dyld_get_image_name, __dyld_get_image_slide, __dyld_get_image_uuid, + __dyld_get_image_vmaddr_slide, __dyld_get_objc_selector, __dyld_get_prog_image_header, + __dyld_get_shared_cache_range, __dyld_get_shared_cache_uuid, + __dyld_has_fix_for_radar, __dyld_image_containing_address, + __dyld_image_count, __dyld_images_for_addresses, __dyld_initializer, + __dyld_is_memory_immutable, __dyld_is_objc_constant, __dyld_launch_mode, + __dyld_launched_prebound, __dyld_lookup_and_bind, __dyld_lookup_and_bind_fully, + __dyld_lookup_and_bind_with_hint, __dyld_missing_symbol_abort, + __dyld_objc_notify_register, __dyld_present, __dyld_process_info_create, + __dyld_process_info_for_each_aot_image, __dyld_process_info_for_each_image, + __dyld_process_info_for_each_segment, __dyld_process_info_get_aot_cache, + __dyld_process_info_get_cache, __dyld_process_info_get_platform, + __dyld_process_info_get_state, __dyld_process_info_notify, + __dyld_process_info_notify_main, __dyld_process_info_notify_release, + __dyld_process_info_notify_retain, __dyld_process_info_release, + __dyld_process_info_retain, __dyld_register_driverkit_main, + __dyld_register_for_bulk_image_loads, __dyld_register_for_image_loads, + __dyld_register_func_for_add_image, __dyld_register_func_for_remove_image, + __dyld_shared_cache_contains_path, __dyld_shared_cache_is_locally_built, + __dyld_shared_cache_optimized, __dyld_shared_cache_real_path, + __tlv_atexit, __tlv_bootstrap, __tlv_exit, _dladdr, _dlclose, + _dlerror, _dlopen, _dlopen_audited, _dlopen_from, _dlopen_preflight, + _dlsym, _dyldVersionNumber, _dyldVersionString, _dyld_dynamic_interpose, + _dyld_get_active_platform, _dyld_get_base_platform, _dyld_get_image_versions, + _dyld_get_min_os_version, _dyld_get_program_min_os_version, + _dyld_get_program_sdk_version, _dyld_get_sdk_version, _dyld_has_inserted_or_interposing_libraries, + _dyld_image_header_containing_address, _dyld_image_path_containing_address, + _dyld_is_simulator_platform, _dyld_minos_at_least, _dyld_need_closure, + _dyld_process_is_restricted, _dyld_program_minos_at_least, + _dyld_program_sdk_at_least, _dyld_sdk_at_least, _dyld_shared_cache_file_path, + _dyld_shared_cache_find_iterate_text, _dyld_shared_cache_iterate_text, + _dyld_shared_cache_some_image_overridden, _environ, dyld_stub_binder ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 2C7B58B0-BE54-3A50-B399-AA49C19083A9 + - target: x86_64-maccatalyst + value: 2C7B58B0-BE54-3A50-B399-AA49C19083A9 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 3EF55D83-6DD4-376B-8C0B-5B12CD0D3D94 + - target: arm64e-maccatalyst + value: 3EF55D83-6DD4-376B-8C0B-5B12CD0D3D94 +install-name: '/usr/lib/system/libkeymgr.dylib' +current-version: 31 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___keymgr_dwarf2_register_sections, ___keymgr_initializer, + __keymgr_get_and_lock_processwide_ptr, __keymgr_get_and_lock_processwide_ptr_2, + __keymgr_get_lock_count_processwide_ptr, __keymgr_get_lockmode_processwide_ptr, + __keymgr_set_and_unlock_processwide_ptr, __keymgr_set_lockmode_processwide_ptr, + __keymgr_unlock_processwide_ptr, _keymgrVersionNumber, _keymgrVersionString ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 05A7EFDD-4111-3E4D-B668-239B69DE3D0F + - target: x86_64-maccatalyst + value: 05A7EFDD-4111-3E4D-B668-239B69DE3D0F + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: A42FB952-AEBC-335F-8336-751E963F09F4 + - target: arm64e-maccatalyst + value: A42FB952-AEBC-335F-8336-751E963F09F4 +install-name: '/usr/lib/system/liblaunch.dylib' +current-version: 2038.40.38 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +reexports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ __spawn_via_launchd, __vproc_get_last_exit_status, __vproc_grab_subset, + __vproc_kickstart_by_label, __vproc_log, __vproc_log_error, + __vproc_logv, __vproc_pid_is_managed, __vproc_post_fork_ping, + __vproc_send_signal_by_label, __vproc_set_global_on_demand, + __vproc_standby_begin, __vproc_standby_count, __vproc_standby_end, + __vproc_standby_timeout, __vproc_transaction_begin, __vproc_transaction_count, + __vproc_transaction_count_for_pid, __vproc_transaction_end, + __vproc_transaction_set_clean_callback, __vproc_transaction_try_exit, + __vproc_transactions_enable, __vprocmgr_detach_from_console, + __vprocmgr_getsocket, __vprocmgr_init, __vprocmgr_log_drain, + __vprocmgr_log_forward, __vprocmgr_move_subset_to_user, __vprocmgr_switch_to_session, + _bootstrap_check_in, _bootstrap_check_in2, _bootstrap_check_in3, + _bootstrap_create_server, _bootstrap_create_service, _bootstrap_get_root, + _bootstrap_info, _bootstrap_init, _bootstrap_look_up, _bootstrap_look_up2, + _bootstrap_look_up3, _bootstrap_look_up_per_user, _bootstrap_lookup_children, + _bootstrap_parent, _bootstrap_register, _bootstrap_register2, + _bootstrap_status, _bootstrap_strerror, _bootstrap_subset, + _bootstrap_unprivileged, _create_and_switch_to_per_session_launchd, + _launch_data_alloc, _launch_data_array_get_count, _launch_data_array_get_index, + _launch_data_array_set_index, _launch_data_copy, _launch_data_dict_get_count, + _launch_data_dict_insert, _launch_data_dict_iterate, _launch_data_dict_lookup, + _launch_data_dict_remove, _launch_data_free, _launch_data_get_bool, + _launch_data_get_errno, _launch_data_get_fd, _launch_data_get_integer, + _launch_data_get_machport, _launch_data_get_opaque, _launch_data_get_opaque_size, + _launch_data_get_real, _launch_data_get_string, _launch_data_get_type, + _launch_data_new_bool, _launch_data_new_errno, _launch_data_new_fd, + _launch_data_new_integer, _launch_data_new_machport, _launch_data_new_opaque, + _launch_data_new_real, _launch_data_new_string, _launch_data_pack, + _launch_data_set_bool, _launch_data_set_errno, _launch_data_set_fd, + _launch_data_set_integer, _launch_data_set_machport, _launch_data_set_opaque, + _launch_data_set_real, _launch_data_set_string, _launch_data_unpack, + _launch_get_fd, _launch_msg, _launch_socket_service_check_in, + _launch_wait, _launchd_close, _launchd_fdopen, _launchd_getfd, + _launchd_msg_recv, _launchd_msg_send, _load_launchd_jobs_at_loginwindow_prompt, + _mpm_uncork_fork, _mpm_wait, _reboot2, _vproc_release, _vproc_retain, + _vproc_standby_begin, _vproc_standby_end, _vproc_swap_complex, + _vproc_swap_integer, _vproc_swap_string, _vproc_transaction_begin, + _vproc_transaction_end, _vprocmgr_lookup_vproc ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64e-macos ] +uuids: + - target: x86_64-macos + value: 28AE1649-22ED-3C4D-A232-29D37F821C39 + - target: x86_64-maccatalyst + value: 28AE1649-22ED-3C4D-A232-29D37F821C39 + - target: arm64-macos + value: C3C1B373-AB10-3216-95BA-998C43146888 + - target: arm64-maccatalyst + value: C3C1B373-AB10-3216-95BA-998C43146888 + - target: arm64e-macos + value: 29AD4E0E-F6A4-313F-AFA3-825CA94917BD + - target: arm64e-maccatalyst + value: 29AD4E0E-F6A4-313F-AFA3-825CA94917BD +install-name: '/usr/lib/system/libmacho.dylib' +current-version: 973.4 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64e-macos ] + umbrella: System +exports: + - targets: [ arm64-macos, x86_64-macos, arm64e-macos, x86_64-maccatalyst ] + symbols: [ _NXCombineCpuSubtypes, _NXFindBestFatArch, _NXFindBestFatArch_64, + _NXFreeArchInfo, _NXGetAllArchInfos, _NXGetArchInfoFromCpuType, + _NXGetArchInfoFromName, _NXGetLocalArchInfo, _get_edata, _get_end, + _get_etext, _getsectbyname, _getsectbynamefromheader, _getsectbynamefromheader_64, + _getsectbynamefromheaderwithswap, _getsectbynamefromheaderwithswap_64, + _getsectdata, _getsectdatafromFramework, _getsectdatafromheader, + _getsectdatafromheader_64, _getsectiondata, _getsegbyname, + _getsegmentdata, _slot_name, _swap_build_tool_version, _swap_build_version_command, + _swap_dyld_info_command, _swap_dylib_command, _swap_dylib_module, + _swap_dylib_module_64, _swap_dylib_reference, _swap_dylib_table_of_contents, + _swap_dylinker_command, _swap_dysymtab_command, _swap_encryption_command, + _swap_encryption_command_64, _swap_entry_point_command, _swap_fat_arch, + _swap_fat_arch_64, _swap_fat_header, _swap_fileset_entry_command, + _swap_fvmfile_command, _swap_fvmlib_command, _swap_hppa_fp_thread_state, + _swap_hppa_frame_thread_state, _swap_hppa_integer_thread_state, + _swap_i386_exception_state, _swap_i386_float_state, _swap_i386_thread_state, + _swap_i860_thread_state_regs, _swap_ident_command, _swap_indirect_symbols, + _swap_linkedit_data_command, _swap_linker_option_command, + _swap_load_command, _swap_m68k_thread_state_68882, _swap_m68k_thread_state_regs, + _swap_m68k_thread_state_user_reg, _swap_m88110_thread_state_impl_t, + _swap_m88k_thread_state_grf_t, _swap_m88k_thread_state_user_t, + _swap_m88k_thread_state_xrf_t, _swap_mach_header, _swap_mach_header_64, + _swap_nlist, _swap_nlist_64, _swap_note_command, _swap_ppc_exception_state_t, + _swap_ppc_float_state_t, _swap_ppc_thread_state_t, _swap_prebind_cksum_command, + _swap_prebound_dylib_command, _swap_ranlib, _swap_ranlib_64, + _swap_relocation_info, _swap_routines_command, _swap_routines_command_64, + _swap_rpath_command, _swap_section, _swap_section_64, _swap_segment_command, + _swap_segment_command_64, _swap_source_version_command, _swap_sparc_thread_state_fpu, + _swap_sparc_thread_state_regs, _swap_sub_client_command, _swap_sub_framework_command, + _swap_sub_library_command, _swap_sub_umbrella_command, _swap_symseg_command, + _swap_symtab_command, _swap_thread_command, _swap_twolevel_hint, + _swap_twolevel_hints_command, _swap_uuid_command, _swap_version_min_command, + _swap_x86_debug_state, _swap_x86_debug_state32, _swap_x86_debug_state64, + _swap_x86_exception_state, _swap_x86_exception_state64, _swap_x86_float_state, + _swap_x86_float_state64, _swap_x86_state_hdr, _swap_x86_thread_state, + _swap_x86_thread_state64 ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 19D42B9D-3336-3543-AF75-6E605EA31599 + - target: x86_64-maccatalyst + value: 19D42B9D-3336-3543-AF75-6E605EA31599 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: C55DCBDE-51FF-3D90-AF78-9BE9F8FC8DD6 + - target: arm64e-maccatalyst + value: C55DCBDE-51FF-3D90-AF78-9BE9F8FC8DD6 +install-name: '/usr/lib/system/libquarantine.dylib' +current-version: 119.40.2 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___esp_check, ___esp_check_ns, ___esp_enabled, ___esp_notify, + ___esp_notify_ns, ___libquarantineVersionNumber, ___libquarantineVersionString, + ___qtn_syscall_quarantine_getinfo_fd, ___qtn_syscall_quarantine_getinfo_mount_point, + ___qtn_syscall_quarantine_getinfo_path, ___qtn_syscall_quarantine_getprocinfo, + ___qtn_syscall_quarantine_setinfo_fd, ___qtn_syscall_quarantine_setinfo_mount_point, + ___qtn_syscall_quarantine_setinfo_path, ___qtn_syscall_quarantine_setprocinfo, + ___qtn_syscall_responsibility_get, ___qtn_syscall_responsibility_get2, + ___qtn_syscall_responsibility_get3, ___qtn_syscall_responsibility_set, + ___qtn_syscall_responsibility_set_audittoken_for_caller, ___qtn_syscall_responsibility_set_audittoken_for_self, + ___qtn_syscall_responsibility_set_caller_for_caller, ___qtn_syscall_responsibility_set_hosted_path, + __qtn_error, __qtn_file_alloc, __qtn_file_apply_to_fd, __qtn_file_apply_to_mount_point, + __qtn_file_apply_to_path, __qtn_file_clone, __qtn_file_free, + __qtn_file_get_flags, __qtn_file_get_identifier, __qtn_file_get_metadata, + __qtn_file_get_metadata_size, __qtn_file_get_timestamp, __qtn_file_init, + __qtn_file_init_with_data, __qtn_file_init_with_fd, __qtn_file_init_with_mount_point, + __qtn_file_init_with_path, __qtn_file_set_flags, __qtn_file_set_identifier, + __qtn_file_set_metadata, __qtn_file_set_timestamp, __qtn_file_to_data, + __qtn_label_name, __qtn_proc_alloc, __qtn_proc_apply_to_self, + __qtn_proc_clone, __qtn_proc_free, __qtn_proc_get_flags, __qtn_proc_get_identifier, + __qtn_proc_get_metadata, __qtn_proc_get_metadata_size, __qtn_proc_get_path_exclusion_pattern, + __qtn_proc_init, __qtn_proc_init_with_data, __qtn_proc_init_with_self, + __qtn_proc_set_flags, __qtn_proc_set_identifier, __qtn_proc_set_metadata, + __qtn_proc_set_path_exclusion_pattern, __qtn_proc_to_data, + __qtn_xattr_name, _qtn_proc_init_with_pid, _responsibility_get_attribution_for_audittoken, + _responsibility_get_pid_responsible_for_pid, _responsibility_get_responsible_audit_token_for_audit_token, + _responsibility_get_responsible_for_pid, _responsibility_get_uniqueid_responsible_for_pid, + _responsibility_identity_get_binary_entitlement_data, _responsibility_identity_get_binary_is_platform, + _responsibility_identity_get_binary_offset, _responsibility_identity_get_binary_path, + _responsibility_identity_get_binary_signing_id, _responsibility_identity_get_binary_team_id, + _responsibility_identity_get_hosted_path, _responsibility_identity_get_persistent_identifier, + _responsibility_identity_get_user_uuid, _responsibility_identity_release, + _responsibility_init, _responsibility_set_audittoken_responsible_for_caller, + _responsibility_set_audittoken_responsible_for_self, _responsibility_set_caller_responsible_for_self, + _responsibility_set_hosted_path, _responsibility_set_pid_responsible_for_pid, + _responsibility_spawnattrs_getdisclaim, _responsibility_spawnattrs_setdisclaim ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 750012C2-7097-33C3-B796-2766E6CDE8C1 + - target: x86_64-maccatalyst + value: 750012C2-7097-33C3-B796-2766E6CDE8C1 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 8FAF9121-D546-3319-B366-1C50BAF59FE8 + - target: arm64e-maccatalyst + value: 8FAF9121-D546-3319-B366-1C50BAF59FE8 +install-name: '/usr/lib/system/libremovefile.dylib' +current-version: 49.40.3 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___removefile_init_random, ___removefile_random_char, ___removefile_randomize_buffer, + ___removefile_rename_unlink, ___removefile_sunlink, ___removefile_tree_walker, + _removefile, _removefile_cancel, _removefile_state_alloc, + _removefile_state_free, _removefile_state_get, _removefile_state_set, + _removefileat ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 940C5BB9-4928-3A63-97F2-132797C8B7E5 + - target: x86_64-maccatalyst + value: 940C5BB9-4928-3A63-97F2-132797C8B7E5 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: B25E1954-9781-3238-8B1C-0CF44B5FA684 + - target: arm64e-maccatalyst + value: B25E1954-9781-3238-8B1C-0CF44B5FA684 +install-name: '/usr/lib/system/libsystem_asl.dylib' +current-version: 385 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ _ASL_LEVEL_TO_STRING, __asl_evaluate_send, __asl_fork_child, + __asl_lib_log, __asl_log_args_to_xpc, __asl_msg_dump, __asl_mt_shim_fork_child, + __asl_mt_shim_send_message, __asl_server_cancel_direct_watch, + __asl_server_control_query, __asl_server_create_aux_link, + __asl_server_match, __asl_server_message, __asl_server_query_2, + __asl_server_register_direct_watch, _asl_add_log_file, _asl_add_output, + _asl_add_output_file, _asl_append, _asl_base_msg, _asl_client_add_output_file, + _asl_client_get_control, _asl_client_kvdict, _asl_client_match, + _asl_client_open, _asl_client_open_from_file, _asl_client_release, + _asl_client_remove_output_file, _asl_client_retain, _asl_client_search, + _asl_client_send, _asl_client_set_control, _asl_client_set_filter, + _asl_client_set_output_file_filter, _asl_close, _asl_close_auxiliary_file, + _asl_core_check_access, _asl_core_decode_buffer, _asl_core_encode_buffer, + _asl_core_error, _asl_core_get_service_port, _asl_core_htonq, + _asl_core_level_to_string, _asl_core_new_msg_id, _asl_core_ntohq, + _asl_core_parse_time, _asl_core_str_match, _asl_core_str_match_c_time, + _asl_core_str_match_char, _asl_core_str_to_size, _asl_core_str_to_time, + _asl_core_str_to_uint32, _asl_core_string_hash, _asl_core_time_to_str, + _asl_count, _asl_create_auxiliary_file, _asl_fetch_key_val_op, + _asl_file_close, _asl_file_compact, _asl_file_ctime, _asl_file_fetch, + _asl_file_fetch_next, _asl_file_fetch_previous, _asl_file_filter, + _asl_file_filter_level, _asl_file_list_add, _asl_file_list_close, + _asl_file_list_match, _asl_file_list_match_end, _asl_file_list_match_next, + _asl_file_list_match_start, _asl_file_match, _asl_file_open_read, + _asl_file_open_write, _asl_file_read_set_position, _asl_file_release, + _asl_file_retain, _asl_file_save, _asl_file_size, _asl_filesystem_path, + _asl_format, _asl_format_message, _asl_free, _asl_get, _asl_get_filter, + _asl_get_index, _asl_get_local_control, _asl_get_type, _asl_get_value_for_key, + _asl_key, _asl_legacy1_close, _asl_legacy1_fetch, _asl_legacy1_match, + _asl_legacy1_open, _asl_list_from_string, _asl_log, _asl_log_auxiliary_location, + _asl_log_descriptor, _asl_log_message, _asl_match, _asl_msg_cmp, + _asl_msg_cmp_list, _asl_msg_copy, _asl_msg_count, _asl_msg_fetch, + _asl_msg_from_string, _asl_msg_get_val_for_key, _asl_msg_key, + _asl_msg_list_append, _asl_msg_list_count, _asl_msg_list_from_string, + _asl_msg_list_get_index, _asl_msg_list_insert, _asl_msg_list_match, + _asl_msg_list_new, _asl_msg_list_new_count, _asl_msg_list_next, + _asl_msg_list_prepend, _asl_msg_list_prev, _asl_msg_list_release, + _asl_msg_list_remove_index, _asl_msg_list_reset_iteration, + _asl_msg_list_retain, _asl_msg_list_search, _asl_msg_list_to_asl_string, + _asl_msg_list_to_string, _asl_msg_lookup, _asl_msg_merge, + _asl_msg_new, _asl_msg_release, _asl_msg_retain, _asl_msg_set_key_val, + _asl_msg_set_key_val_op, _asl_msg_to_string, _asl_msg_type, + _asl_msg_unset, _asl_msg_unset_index, _asl_new, _asl_next, + _asl_object_append, _asl_object_count, _asl_object_get_key_val_op_at_index, + _asl_object_get_object_at_index, _asl_object_get_val_op_for_key, + _asl_object_match, _asl_object_next, _asl_object_prepend, + _asl_object_prev, _asl_object_remove_object_at_index, _asl_object_search, + _asl_object_set_iteration_index, _asl_object_set_key_val_op, + _asl_object_unset_key, _asl_open, _asl_open_from_file, _asl_open_path, + _asl_parse_time, _asl_prepend, _asl_prev, _asl_release, _asl_remote_notify_name, + _asl_remove_log_file, _asl_remove_output, _asl_remove_output_file, + _asl_reset_iteration, _asl_retain, _asl_search, _asl_send, + _asl_set, _asl_set_filter, _asl_set_key_val_op, _asl_set_local_control, + _asl_set_output_file_filter, _asl_set_query, _asl_store_close, + _asl_store_location, _asl_store_match, _asl_store_match_next, + _asl_store_match_start, _asl_store_match_timeout, _asl_store_max_file_size, + _asl_store_open_aux, _asl_store_open_read, _asl_store_open_write, + _asl_store_release, _asl_store_retain, _asl_store_save, _asl_store_set_flags, + _asl_store_statistics, _asl_store_sweep_file_cache, _asl_string_allocated_size, + _asl_string_append, _asl_string_append_asl_key, _asl_string_append_asl_msg, + _asl_string_append_char_no_encoding, _asl_string_append_no_encoding, + _asl_string_append_no_encoding_len, _asl_string_append_op, + _asl_string_append_xml_tag, _asl_string_bytes, _asl_string_length, + _asl_string_new, _asl_string_release, _asl_string_release_return_bytes, + _asl_string_retain, _asl_syslog_faciliy_name_to_num, _asl_syslog_faciliy_num_to_name, + _asl_trigger_aslmanager, _asl_unset, _asl_unset_key, _asl_vlog, + _aslresponse_free, _aslresponse_next, _closelog, _openlog, + _setlogmask, _syslog, '_syslog$DARWIN_EXTSN', _vsyslog ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 9CF131C6-16FB-3DD0-B046-9E0B6AB99935 + - target: x86_64-maccatalyst + value: 9CF131C6-16FB-3DD0-B046-9E0B6AB99935 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: D3998C8A-7A1C-3962-822C-91DFC11ACBF7 + - target: arm64e-maccatalyst + value: D3998C8A-7A1C-3962-822C-91DFC11ACBF7 +install-name: '/usr/lib/system/libsystem_blocks.dylib' +current-version: 78 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _Block_size, __Block_copy, __Block_extended_layout, __Block_has_signature, + __Block_isDeallocating, __Block_layout, __Block_object_assign, + __Block_object_dispose, __Block_release, __Block_signature, + __Block_tryRetain, __Block_use_RR2, __Block_use_stret, __NSConcreteAutoBlock, + __NSConcreteFinalizingBlock, __NSConcreteGlobalBlock, __NSConcreteMallocBlock, + __NSConcreteStackBlock, __NSConcreteWeakBlockVariable ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 06D9F593-C815-385D-957F-2B5BCC223A8A + - target: x86_64-maccatalyst + value: 06D9F593-C815-385D-957F-2B5BCC223A8A + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 4A324485-84D9-318F-8267-70FF10504289 + - target: arm64e-maccatalyst + value: 4A324485-84D9-318F-8267-70FF10504289 +install-name: '/usr/lib/system/libsystem_c.dylib' +current-version: 1439.40.11 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos ] + symbols: [ '___opendir2$INODE64', ___strtopx, '__readdir_unlocked$INODE64', + '__seekdir$INODE64', '_alphasort$INODE64', '_daemon$1050', + '_fdopendir$INODE64', _fstatx64_np, '_fstatx_np$INODE64', + '_fts_children$INODE64', '_fts_close$INODE64', '_fts_open$INODE64', + '_fts_open_b$INODE64', '_fts_read$INODE64', '_fts_set$INODE64', + '_ftw$INODE64', '_getmntinfo$INODE64', _getmntinfo64, '_getmntinfo_r_np$INODE64', + '_glob$INODE64', '_glob_b$INODE64', _lstatx64_np, '_lstatx_np$INODE64', + '_nftw$INODE64', '_opendir$INODE64', '_readdir$INODE64', '_readdir_r$INODE64', + '_rewinddir$INODE64', '_scandir$INODE64', '_scandir_b$INODE64', + '_seekdir$INODE64', _statx64_np, '_statx_np$INODE64', '_telldir$INODE64', + mcount ] + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ '$ld$weak$os10.11$_basename_r', '$ld$weak$os10.11$_clock_getres', + '$ld$weak$os10.11$_clock_gettime', '$ld$weak$os10.11$_clock_settime', + '$ld$weak$os10.11$_dirname_r', '$ld$weak$os10.11$_getentropy', + '$ld$weak$os10.11$_mkostemp', '$ld$weak$os10.11$_mkostemps', + '$ld$weak$os10.11$_timingsafe_bcmp', '$ld$weak$os10.12$_utimensat', + __CurrentRuneLocale, __DefaultRuneLocale, __Exit, __NSGetArgc, + __NSGetArgv, __NSGetEnviron, __NSGetMachExecuteHeader, __NSGetProgname, + __PathLocale, __Read_RuneMagi, ___Balloc_D2A, ___Bfree_D2A, + ___ULtod_D2A, ____mb_cur_max, ____mb_cur_max_l, ____runetype, + ____runetype_l, ____tolower, ____tolower_l, ____toupper, ____toupper_l, + ___add_ovflpage, ___addel, ___any_on_D2A, ___assert_rtn, ___b2d_D2A, + ___big_delete, ___big_insert, ___big_keydata, ___big_return, + ___big_split, ___bigtens_D2A, ___bt_close, ___bt_cmp, ___bt_defcmp, + ___bt_defpfx, ___bt_delete, ___bt_dleaf, ___bt_fd, ___bt_free, + ___bt_get, ___bt_new, ___bt_open, ___bt_pgin, ___bt_pgout, + ___bt_put, ___bt_ret, ___bt_search, ___bt_seq, ___bt_setcur, + ___bt_split, ___bt_sync, ___buf_free, ___call_hash, ___cleanup, + ___cmp_D2A, ___collate_equiv_match, ___collate_load_error, + ___collate_lookup, ___collate_lookup_l, ___copybits_D2A, ___cxa_atexit, + ___cxa_finalize, ___cxa_finalize_ranges, ___cxa_thread_atexit, + ___d2b_D2A, ___dbpanic, ___decrement_D2A, ___default_hash, + ___default_utx, ___delpair, ___diff_D2A, ___dtoa, ___expand_table, + ___fflush, ___fgetwc, ___find_bigpair, ___find_last_page, + ___fix_locale_grouping_str, ___fread, ___free_ovflpage, ___freedtoa, + ___gdtoa, ___gdtoa_locks, ___get_buf, ___get_page, ___gethex_D2A, + ___getonlyClocaleconv, ___hash_open, ___hdtoa, ___hexdig_D2A, + ___hexdig_init_D2A, ___hexnan_D2A, ___hi0bits_D2A, ___hldtoa, + ___i2b_D2A, ___ibitmap, ___increment_D2A, ___isctype, ___istype, + ___istype_l, ___ldtoa, ___libc_init, ___lo0bits_D2A, ___log2, + ___lshift_D2A, ___maskrune, ___maskrune_l, ___match_D2A, ___mb_cur_max, + ___mb_sb_limit, ___memccpy_chk, ___memcpy_chk, ___memmove_chk, + ___memset_chk, ___mult_D2A, ___multadd_D2A, ___nrv_alloc_D2A, + ___opendir2, ___ovfl_delete, ___ovfl_get, ___ovfl_put, ___pow5mult_D2A, + ___put_page, ___quorem_D2A, ___ratio_D2A, ___rec_close, ___rec_delete, + ___rec_dleaf, ___rec_fd, ___rec_fmap, ___rec_fpipe, ___rec_get, + ___rec_iput, ___rec_open, ___rec_put, ___rec_ret, ___rec_search, + ___rec_seq, ___rec_sync, ___rec_vmap, ___rec_vpipe, ___reclaim_buf, + ___rshift_D2A, ___rv_alloc_D2A, ___s2b_D2A, ___sF, ___sclose, + ___sdidinit, ___set_ones_D2A, ___setonlyClocaleconv, ___sflags, + ___sflush, ___sfp, ___sfvwrite, ___sglue, ___sinit, ___slbexpand, + ___smakebuf, ___snprintf_chk, ___snprintf_object_size_chk, + ___split_page, ___sprintf_chk, ___sprintf_object_size_chk, + ___sread, ___srefill, ___srget, ___sseek, ___stack_chk_fail, + ___stack_chk_guard, ___stderrp, ___stdinp, ___stdoutp, ___stpcpy_chk, + ___stpncpy_chk, ___strcat_chk, ___strcp_D2A, ___strcpy_chk, + ___strlcat_chk, ___strlcpy_chk, ___strncat_chk, ___strncpy_chk, + ___strtodg, ___strtopdd, ___sum_D2A, ___svfscanf, ___swbuf, + ___swhatbuf, ___swrite, ___swsetup, ___tens_D2A, ___tinytens_D2A, + ___tolower, ___tolower_l, ___toupper, ___toupper_l, ___trailz_D2A, + ___ulp_D2A, ___ungetc, ___ungetwc, ___vsnprintf_chk, ___vsprintf_chk, + ___wcwidth, ___wcwidth_l, __allocenvstate, __atexit_receipt, + __c_locale, __cleanup, __closeutx, __copyenv, __cthread_init_routine, + __deallocenvstate, __endutxent, __flockfile_debug_stub, __fseeko, + __ftello, __fwalk, __getenvp, __getutxent, __getutxid, __getutxline, + __inet_aton_check, __init_clock_port, __int_to_time, __libc_fork_child, + __libc_initializer, __long_to_time, __mkpath_np, __mktemp, + __openutx, __os_assert_log, __os_assert_log_ctx, __os_assumes_log, + __os_assumes_log_ctx, __os_avoid_tail_call, __os_crash, __os_crash_callback, + __os_crash_fmt, __os_debug_log, __os_debug_log_error_str, + __putenvp, __pututxline, __rand48_add, __rand48_mult, __rand48_seed, + __readdir_unlocked, __reclaim_telldir, __seekdir, __setenvp, + __setutxent, __sigaction_nobind, __sigintr, __signal_nobind, + __sigvec_nobind, __sread, __sseek, __subsystem_init, __swrite, + __time32_to_time, __time64_to_time, __time_to_int, __time_to_long, + __time_to_time32, __time_to_time64, __unsetenvp, __utmpxname, + _a64l, _abort, _abort_report_np, _abs, _acl_add_flag_np, _acl_add_perm, + _acl_calc_mask, _acl_clear_flags_np, _acl_clear_perms, _acl_copy_entry, + _acl_copy_ext, _acl_copy_ext_native, _acl_copy_int, _acl_copy_int_native, + _acl_create_entry, _acl_create_entry_np, _acl_delete_def_file, + _acl_delete_entry, _acl_delete_fd_np, _acl_delete_file_np, + _acl_delete_flag_np, _acl_delete_link_np, _acl_delete_perm, + _acl_dup, _acl_free, _acl_from_text, _acl_get_entry, _acl_get_fd, + _acl_get_fd_np, _acl_get_file, _acl_get_flag_np, _acl_get_flagset_np, + _acl_get_link_np, _acl_get_perm_np, _acl_get_permset, _acl_get_permset_mask_np, + _acl_get_qualifier, _acl_get_tag_type, _acl_init, _acl_maximal_permset_mask_np, + _acl_set_fd, _acl_set_fd_np, _acl_set_file, _acl_set_flagset_np, + _acl_set_link_np, _acl_set_permset, _acl_set_permset_mask_np, + _acl_set_qualifier, _acl_set_tag_type, _acl_size, _acl_to_text, + _acl_valid, _acl_valid_fd_np, _acl_valid_file_np, _acl_valid_link, + _addr2ascii, _alarm, _alphasort, _arc4random, _arc4random_addrandom, + _arc4random_buf, _arc4random_stir, _arc4random_uniform, _ascii2addr, + _asctime, _asctime_r, _asprintf, _asprintf_l, _asxprintf, + _asxprintf_exec, _atexit, _atexit_b, _atof, _atof_l, _atoi, + _atoi_l, _atol, _atol_l, _atoll, _atoll_l, _backtrace, _backtrace_from_fp, + _backtrace_image_offsets, _backtrace_symbols, _backtrace_symbols_fd, + _basename, _basename_r, _bcopy, _brk, _bsd_signal, _bsearch, + _bsearch_b, _btowc, _btowc_l, _catclose, _catgets, _catopen, + _cfgetispeed, _cfgetospeed, _cfmakeraw, _cfsetispeed, _cfsetospeed, + _cfsetspeed, _cgetcap, _cgetclose, _cgetent, _cgetfirst, _cgetmatch, + _cgetnext, _cgetnum, _cgetset, _cgetstr, _cgetustr, _chmodx_np, + _clearerr, _clearerr_unlocked, _clock, _clock_getres, _clock_gettime, + _clock_gettime_nsec_np, _clock_port, _clock_sem, _clock_settime, + _closedir, _compat_mode, _confstr, _copy_printf_domain, _creat, + '_creat$NOCANCEL', _crypt, _ctermid, _ctermid_r, _ctime, _ctime_r, + _daemon, _daylight, _dbm_clearerr, _dbm_close, _dbm_delete, + _dbm_dirfno, _dbm_error, _dbm_fetch, _dbm_firstkey, _dbm_nextkey, + _dbm_open, _dbm_store, _dbopen, _devname, _devname_r, _difftime, + _digittoint, _digittoint_l, _dirfd, _dirname, _dirname_r, + _div, _dprintf, _dprintf_l, _drand48, _duplocale, _dxprintf, + _dxprintf_exec, _ecvt, _encrypt, _endttyent, _endusershell, + _endutxent, _endutxent_wtmp, _erand48, _err, _err_set_exit, + _err_set_exit_b, _err_set_file, _errc, _errx, _execl, _execle, + _execlp, _execv, _execvP, _execvp, _exit, _f_prealloc, _fchmodx_np, + _fclose, _fcvt, _fdopen, '_fdopen$DARWIN_EXTSN', _fdopendir, + _feof, _feof_unlocked, _ferror, _ferror_unlocked, _fflagstostr, + _fflush, _fgetc, _fgetln, _fgetpos, _fgetrune, _fgets, _fgetwc, + _fgetwc_l, _fgetwln, _fgetwln_l, _fgetws, _fgetws_l, _fileno, + _fileno_unlocked, _filesec_dup, _filesec_free, _filesec_get_property, + _filesec_init, _filesec_query_property, _filesec_set_property, + _filesec_unset_property, _flockfile, _fmemopen, _fmtcheck, + _fmtmsg, _fnmatch, _fopen, '_fopen$DARWIN_EXTSN', _fork, _forkpty, + _fparseln, _fprintf, _fprintf_l, _fpurge, _fputc, _fputrune, + _fputs, _fputwc, _fputwc_l, _fputws, _fputws_l, _fread, _free_printf_comp, + _free_printf_domain, _freelocale, _freopen, _fscanf, _fscanf_l, + _fseek, _fseeko, _fsetpos, _fstatvfs, _fstatx_np, _fsync_volume_np, + _ftell, _ftello, _ftime, _ftok, _ftrylockfile, _fts_children, + _fts_close, _fts_open, _fts_open_b, _fts_read, _fts_set, _ftw, + _fungetrune, _funlockfile, _funopen, _fwide, _fwprintf, _fwprintf_l, + _fwrite, _fwscanf, _fwscanf_l, _fxprintf, _fxprintf_exec, + _gcvt, _getbsize, _getc, _getc_unlocked, _getchar, _getchar_unlocked, + _getcwd, _getdate, _getdate_err, _getdelim, _getdiskbyname, + _getenv, '_getgroups$DARWIN_EXTSN', _gethostid, _gethostname, + _getipv4sourcefilter, _getlastlogx, _getlastlogxbyname, _getline, + _getloadavg, _getlogin, _getlogin_r, _getmntinfo, _getmntinfo_r_np, + _getmode, _getopt, _getopt_long, _getopt_long_only, _getpagesize, + _getpass, _getpeereid, _getprogname, _gets, _getsourcefilter, + _getsubopt, _gettimeofday, _getttyent, _getttynam, _getusershell, + _getutmp, _getutmpx, _getutxent, _getutxent_wtmp, _getutxid, + _getutxline, _getvfsbyname, _getw, _getwc, _getwc_l, _getwchar, + _getwchar_l, _getwd, _glob, _glob_b, _globfree, _gmtime, _gmtime_r, + _grantpt, _hash_create, _hash_destroy, _hash_purge, _hash_search, + _hash_stats, _hash_traverse, _hcreate, _hdestroy, _heapsort, + _heapsort_b, _hsearch, _imaxabs, _imaxdiv, _inet_addr, _inet_aton, + _inet_lnaof, _inet_makeaddr, _inet_net_ntop, _inet_net_pton, + _inet_neta, _inet_netof, _inet_network, _inet_nsap_addr, _inet_nsap_ntoa, + _inet_ntoa, _inet_ntop, _inet_ntop4, _inet_ntop6, _inet_pton, + _initstate, _insque, _isalnum, _isalnum_l, _isalpha, _isalpha_l, + _isascii, _isatty, _isblank, _isblank_l, _iscntrl, _iscntrl_l, + _isdigit, _isdigit_l, _isgraph, _isgraph_l, _ishexnumber, + _ishexnumber_l, _isideogram, _isideogram_l, _islower, _islower_l, + _isnumber, _isnumber_l, _isphonogram, _isphonogram_l, _isprint, + _isprint_l, _ispunct, _ispunct_l, _isrune, _isrune_l, _isspace, + _isspace_l, _isspecial, _isspecial_l, _isupper, _isupper_l, + _iswalnum, _iswalnum_l, _iswalpha, _iswalpha_l, _iswascii, + _iswblank, _iswblank_l, _iswcntrl, _iswcntrl_l, _iswctype, + _iswctype_l, _iswdigit, _iswdigit_l, _iswgraph, _iswgraph_l, + _iswhexnumber, _iswhexnumber_l, _iswideogram, _iswideogram_l, + _iswlower, _iswlower_l, _iswnumber, _iswnumber_l, _iswphonogram, + _iswphonogram_l, _iswprint, _iswprint_l, _iswpunct, _iswpunct_l, + _iswrune, _iswrune_l, _iswspace, _iswspace_l, _iswspecial, + _iswspecial_l, _iswupper, _iswupper_l, _iswxdigit, _iswxdigit_l, + _isxdigit, _isxdigit_l, _jrand48, _kOSThermalNotificationPressureLevelName, + _killpg, _l64a, _labs, _lchflags, _lchmod, _lcong48, _ldiv, + _lfind, _link_addr, _link_ntoa, _llabs, _lldiv, _localeconv, + _localeconv_l, _localtime, _localtime_r, _lockf, '_lockf$NOCANCEL', + _login, _login_tty, _logout, _logwtmp, _lrand48, _lsearch, + _lstatx_np, _lutimes, _mblen, _mblen_l, _mbmb, _mbrlen, _mbrlen_l, + _mbrrune, _mbrtowc, _mbrtowc_l, _mbrune, _mbsinit, _mbsinit_l, + _mbsnrtowcs, _mbsnrtowcs_l, _mbsrtowcs, _mbsrtowcs_l, _mbstowcs, + _mbstowcs_l, _mbtowc, _mbtowc_l, _memmem, _memset_s, _mergesort, + _mergesort_b, _mkdirx_np, _mkdtemp, _mkdtempat_np, _mkfifox_np, + _mkostemp, _mkostemps, _mkostempsat_np, _mkpath_np, _mkpathat_np, + _mkstemp, _mkstemp_dprotected_np, _mkstemps, _mkstempsat_np, + _mktemp, _mktime, _monaddition, _moncontrol, _moncount, _moninit, + _monitor, _monoutput, _monreset, _monstartup, _mpool_close, + _mpool_filter, _mpool_get, _mpool_new, _mpool_open, _mpool_put, + _mpool_sync, _mrand48, _nanosleep, '_nanosleep$NOCANCEL', + _new_printf_comp, _new_printf_domain, _newlocale, _nextwctype, + _nextwctype_l, _nftw, _nice, _nl_langinfo, _nl_langinfo_l, + _nrand48, _nvis, _off32, _off64, _offtime, _open_memstream, + _open_with_subsystem, _open_wmemstream, _opendev, _opendir, + _openpty, _openx_np, _optarg, _opterr, _optind, _optopt, _optreset, + _pause, '_pause$NOCANCEL', _pclose, _perror, _popen, '_popen$DARWIN_EXTSN', + _posix2time, _posix_openpt, _posix_spawnp, _printf, _printf_l, + _psignal, _psort, _psort_b, _psort_r, _ptsname, _ptsname_r, + _putc, _putc_unlocked, _putchar, _putchar_unlocked, _putenv, + _puts, _pututxline, _putw, _putwc, _putwc_l, _putwchar, _putwchar_l, + _qsort, _qsort_b, _qsort_r, _querylocale, _radixsort, _raise, + _rand, _rand_r, _random, _rb_tree_count, _rb_tree_find_node, + _rb_tree_find_node_geq, _rb_tree_find_node_leq, _rb_tree_init, + _rb_tree_insert_node, _rb_tree_iterate, _rb_tree_remove_node, + _readdir, _readdir_r, _readpassphrase, _reallocf, _realpath, + '_realpath$DARWIN_EXTSN', _recv, '_recv$NOCANCEL', _regcomp, + _regcomp_l, _regerror, _regexec, _regfree, _register_printf_domain_function, + _register_printf_domain_render_std, _regncomp, _regncomp_l, + _regnexec, _regwcomp, _regwcomp_l, _regwexec, _regwncomp, + _regwncomp_l, _regwnexec, _remove, _remque, _rewind, _rewinddir, + _rindex, _rpmatch, _sbrk, _scandir, _scandir_b, _scanf, _scanf_l, + _seed48, _seekdir, _send, '_send$NOCANCEL', _setbuf, _setbuffer, + _setenv, _sethostid, _sethostname, _setinvalidrune, _setipv4sourcefilter, + _setkey, _setlinebuf, _setlocale, _setlogin, _setmode, _setpgrp, + _setprogname, _setrgid, _setruid, _setrunelocale, _setsourcefilter, + _setstate, _settimeofday, _setttyent, _setusershell, _setutxent, + _setutxent_wtmp, _setvbuf, _sigaction, _sigaddset, _sigaltstack, + _sigblock, _sigdelset, _sigemptyset, _sigfillset, _sighold, + _sigignore, _siginterrupt, _sigismember, _signal, _sigpause, + '_sigpause$NOCANCEL', _sigrelse, _sigset, _sigsetmask, _sigvec, + _skip, _sl_add, _sl_find, _sl_free, _sl_init, _sleep, '_sleep$NOCANCEL', + _snprintf, _snprintf_l, _snvis, _sockatmark, _sprintf, _sprintf_l, + _sradixsort, _srand, _srand48, _sranddev, _srandom, _srandomdev, + _sscanf, _sscanf_l, _stat_with_subsystem, _statvfs, _statx_np, + _stpcpy, _stpncpy, _strcasecmp, _strcasecmp_l, _strcasestr, + _strcasestr_l, _strcat, _strcoll, _strcoll_l, _strcspn, _strdup, + _strenvisx, _strerror, _strerror_r, _strfmon, _strfmon_l, + _strftime, _strftime_l, _strmode, _strncasecmp, _strncasecmp_l, + _strncat, _strndup, _strnstr, _strnunvis, _strnunvisx, _strnvis, + _strnvisx, _strpbrk, _strptime, _strptime_l, _strrchr, _strsenvisx, + _strsep, _strsignal, _strsignal_r, _strsnvis, _strsnvisx, + _strspn, _strsvis, _strsvisx, _strtod, _strtod_l, _strtof, + _strtof_l, _strtofflags, _strtoimax, _strtoimax_l, _strtok, + _strtok_r, _strtol, _strtol_l, _strtold, _strtold_l, _strtoll, + _strtoll_l, _strtonum, _strtoq, _strtoq_l, _strtoul, _strtoul_l, + _strtoull, _strtoull_l, _strtoumax, _strtoumax_l, _strtouq, + _strtouq_l, _strunvis, _strunvisx, _strvis, _strvisx, _strxfrm, + _strxfrm_l, _suboptarg, _svis, _swab, _swprintf, _swprintf_l, + _swscanf, _swscanf_l, _sxprintf, _sxprintf_exec, _sync_volume_np, + _sys_errlist, _sys_nerr, _sys_siglist, _sys_signame, _sysconf, + _sysctl, _sysctlbyname, _sysctlnametomib, _system, '_system$NOCANCEL', + _tcdrain, '_tcdrain$NOCANCEL', _tcflow, _tcflush, _tcgetattr, + _tcgetpgrp, _tcgetsid, _tcsendbreak, _tcsetattr, _tcsetpgrp, + _tdelete, _telldir, _tempnam, _tfind, _thread_stack_pcs, _time, + _time2posix, _timegm, _timelocal, _timeoff, _times, _timespec_get, + _timezone, _timingsafe_bcmp, _tmpfile, _tmpnam, _toascii, + _tolower, _tolower_l, _toupper, _toupper_l, _towctrans, _towctrans_l, + _towlower, _towlower_l, _towupper, _towupper_l, _tre_ast_new_catenation, + _tre_ast_new_iter, _tre_ast_new_literal, _tre_ast_new_node, + _tre_ast_new_union, _tre_compile, _tre_fill_pmatch, _tre_free, + _tre_mem_alloc_impl, _tre_mem_destroy, _tre_mem_new_impl, + _tre_parse, _tre_stack_destroy, _tre_stack_new, _tre_stack_num_objects, + _tre_tnfa_run_backtrack, _tre_tnfa_run_parallel, _tsearch, + _ttyname, _ttyname_r, _ttyslot, _twalk, _tzname, _tzset, _tzsetwall, + _ualarm, _ulimit, _umaskx_np, _uname, _ungetc, _ungetwc, _ungetwc_l, + _unlockpt, _unsetenv, _unvis, _uselocale, _usleep, '_usleep$NOCANCEL', + _utime, _utmpxname, _uuid_clear, _uuid_compare, _uuid_copy, + _uuid_generate, _uuid_generate_random, _uuid_generate_time, + _uuid_is_null, _uuid_pack, _uuid_parse, _uuid_unpack, _uuid_unparse, + _uuid_unparse_lower, _uuid_unparse_upper, _vasprintf, _vasprintf_l, + _vasxprintf, _vasxprintf_exec, _vdprintf, _vdprintf_l, _vdxprintf, + _vdxprintf_exec, _verr, _verrc, _verrx, _vfprintf, _vfprintf_l, + _vfscanf, _vfscanf_l, _vfwprintf, _vfwprintf_l, _vfwscanf, + _vfwscanf_l, _vfxprintf, _vfxprintf_exec, _vis, _vprintf, + _vprintf_l, _vscanf, _vscanf_l, _vsnprintf, _vsnprintf_l, + _vsprintf, _vsprintf_l, _vsscanf, _vsscanf_l, _vswprintf, + _vswprintf_l, _vswscanf, _vswscanf_l, _vsxprintf, _vsxprintf_exec, + _vwarn, _vwarnc, _vwarnx, _vwprintf, _vwprintf_l, _vwscanf, + _vwscanf_l, _vxprintf, _vxprintf_exec, _wait, '_wait$NOCANCEL', + _wait3, _waitpid, '_waitpid$NOCANCEL', _warn, _warnc, _warnx, + _wcpcpy, _wcpncpy, _wcrtomb, _wcrtomb_l, _wcscasecmp, _wcscasecmp_l, + _wcscat, _wcschr, _wcscmp, _wcscoll, _wcscoll_l, _wcscpy, + _wcscspn, _wcsdup, _wcsftime, _wcsftime_l, _wcslcat, _wcslcpy, + _wcslen, _wcsncasecmp, _wcsncasecmp_l, _wcsncat, _wcsncmp, + _wcsncpy, _wcsnlen, _wcsnrtombs, _wcsnrtombs_l, _wcspbrk, + _wcsrchr, _wcsrtombs, _wcsrtombs_l, _wcsspn, _wcsstr, _wcstod, + _wcstod_l, _wcstof, _wcstof_l, _wcstoimax, _wcstoimax_l, _wcstok, + _wcstol, _wcstol_l, _wcstold, _wcstold_l, _wcstoll, _wcstoll_l, + _wcstombs, _wcstombs_l, _wcstoul, _wcstoul_l, _wcstoull, _wcstoull_l, + _wcstoumax, _wcstoumax_l, _wcswidth, _wcswidth_l, _wcsxfrm, + _wcsxfrm_l, _wctob, _wctob_l, _wctomb, _wctomb_l, _wctrans, + _wctrans_l, _wctype, _wctype_l, _wcwidth, _wcwidth_l, _wmemchr, + _wmemcmp, _wmemcpy, _wmemmove, _wmemset, _wordexp, _wordfree, + _wprintf, _wprintf_l, _wscanf, _wscanf_l, _wtmpxname, _xprintf, + _xprintf_exec ] +reexports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ _bcmp, _bzero, _index, _memccpy, _memchr, _memcmp, _memcpy, + _memmove, _memset, _memset_pattern16, _memset_pattern4, _memset_pattern8, + _strchr, _strcmp, _strcpy, _strlcat, _strlcpy, _strlen, _strncmp, + _strncpy, _strnlen, _strstr ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: D40D8097-0ABF-3645-B065-168F43ACFF4C + - target: x86_64-maccatalyst + value: D40D8097-0ABF-3645-B065-168F43ACFF4C + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 5EEC397D-2CAA-39D1-8B82-6370E633FDC9 + - target: arm64e-maccatalyst + value: 5EEC397D-2CAA-39D1-8B82-6370E633FDC9 +install-name: '/usr/lib/system/libsystem_collections.dylib' +current-version: 1439.40.11 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _os_map_128_clear, _os_map_128_count, _os_map_128_delete, + _os_map_128_destroy, _os_map_128_find, _os_map_128_foreach, + _os_map_128_init, _os_map_128_insert, _os_map_32_clear, _os_map_32_count, + _os_map_32_delete, _os_map_32_destroy, _os_map_32_find, _os_map_32_foreach, + _os_map_32_init, _os_map_32_insert, _os_map_64_clear, _os_map_64_count, + _os_map_64_delete, _os_map_64_destroy, _os_map_64_find, _os_map_64_foreach, + _os_map_64_init, _os_map_64_insert, _os_map_str_clear, _os_map_str_count, + _os_map_str_delete, _os_map_str_destroy, _os_map_str_entry, + _os_map_str_find, _os_map_str_foreach, _os_map_str_init, _os_map_str_insert ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: C57B346B-0A03-3F87-BCAC-87B702FA0719 + - target: x86_64-maccatalyst + value: C57B346B-0A03-3F87-BCAC-87B702FA0719 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 5D4DB975-F8DC-3B07-8F2B-4054CCA4B9B6 + - target: arm64e-maccatalyst + value: 5D4DB975-F8DC-3B07-8F2B-4054CCA4B9B6 +install-name: '/usr/lib/system/libsystem_configuration.dylib' +current-version: 1109.60.2 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ __dns_configuration_ack, __libSC_info_fork_child, __libSC_info_fork_parent, + __libSC_info_fork_prepare, __nwi_config_agent_copy_data, __nwi_state_ack, + __nwi_state_force_refresh, _config_agent_copy_dns_information, + _config_agent_copy_proxy_information, _config_agent_free_dns_information, + _config_agent_free_proxy_information, _config_agent_get_dns_nameservers, + _config_agent_get_dns_searchdomains, _config_agent_update_proxy_information, + _dns_configuration_copy, _dns_configuration_free, _dns_configuration_notify_key, + _is_config_agent_type_dns, _is_config_agent_type_proxy, _nwi_ifstate_compare_rank, + _nwi_ifstate_get_dns_signature, _nwi_ifstate_get_flags, _nwi_ifstate_get_generation, + _nwi_ifstate_get_ifname, _nwi_ifstate_get_next, _nwi_ifstate_get_reachability_flags, + _nwi_ifstate_get_signature, _nwi_ifstate_get_vpn_server, _nwi_state_copy, + _nwi_state_get_first_ifstate, _nwi_state_get_generation, _nwi_state_get_ifstate, + _nwi_state_get_interface_names, _nwi_state_get_notify_key, + _nwi_state_get_reachability_flags, _nwi_state_release ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 4ED09A19-04CC-3464-9EFB-F674932020B5 + - target: x86_64-maccatalyst + value: 4ED09A19-04CC-3464-9EFB-F674932020B5 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 165B6DCF-6B92-3EC9-84D3-98FBFAB26EA1 + - target: arm64e-maccatalyst + value: 165B6DCF-6B92-3EC9-84D3-98FBFAB26EA1 +install-name: '/usr/lib/system/libsystem_containermanager.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _CONTAINER_CURRENT_MOBILE_UID, _CONTAINER_INSTALLATION_UID, + _CONTAINER_NOTIFY_CLEANUP_COMPLETE, _CONTAINER_NOTIFY_REBOOT_CLEANUP_COMPLETE, + _CONTAINER_NOTIFY_USER_INVALIDATED, _CONTAINER_SYSTEM_UID, + __container_init, _container_acquire_sandbox_extension, _container_bundle_copy_data_container, + _container_bundle_copy_data_container_path, _container_client_create_from_audit_token, + _container_copy_code_signing_info_for_identifier, _container_copy_from_path, + _container_copy_info, _container_copy_info_value_for_key, + _container_copy_object, _container_copy_path, _container_copy_persona_unique_strings, + _container_create_or_lookup, _container_create_or_lookup_app_group_path_by_app_group_identifier, + _container_create_or_lookup_app_group_paths, _container_create_or_lookup_app_group_paths_for_current_user, + _container_create_or_lookup_app_group_paths_for_platform, + _container_create_or_lookup_app_group_paths_from_entitlements, + _container_create_or_lookup_for_current_user, _container_create_or_lookup_for_platform, + _container_create_or_lookup_group_container_paths_for_current_user, + _container_create_or_lookup_path, _container_create_or_lookup_path_for_current_user, + _container_create_or_lookup_path_for_platform, _container_create_or_lookup_system_group_paths, + _container_create_or_lookup_user_managed_assets_path, _container_create_or_lookup_user_managed_assets_relative_path, + _container_delete, _container_delete_all_container_content, + _container_delete_all_data_container_content, _container_delete_all_data_container_content_for_current_user, + _container_delete_array_of_containers, _container_delete_user_managed_assets, + _container_delete_with_class_and_identifier_for_current_user, + _container_delete_with_uid_class_and_identifier, _container_disk_usage, + _container_error_is_fatal, _container_flush_container_cache, + _container_flush_persona_cache, _container_free_array_of_containers, + _container_free_client, _container_free_object, _container_get_all_with_class, + _container_get_all_with_class_for_current_user, _container_get_class, + _container_get_error_description, _container_get_identifier, + _container_get_persona_unique_string, _container_get_unique_path_component, + _container_group_container_identifiers_for_current_user, _container_invalidate_code_signing_cache, + _container_is_transient, _container_perform_data_migration, + _container_perform_data_migration_for_current_user, _container_perform_with_client_context, + _container_process_restored_container, _container_recreate_structure, + _container_regenerate_uuid, _container_repair_user_data, _container_replace, + _container_set_code_signing_info_for_identifier, _container_set_data_protection_for_current_user, + _container_set_info_value, _container_stage_shared_system_content, + _container_subdirectories_for_class, _container_system_group_path_for_identifier, + _container_system_path_for_identifier, _container_user_managed_assets_path, + _container_user_managed_assets_relative_path ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: A2D875B9-8BA8-33AD-BE92-ADAB915A8D5B + - target: x86_64-maccatalyst + value: A2D875B9-8BA8-33AD-BE92-ADAB915A8D5B + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 1F4E0C2D-9A82-3E3F-B546-1F23A3B180B5 + - target: arm64e-maccatalyst + value: 1F4E0C2D-9A82-3E3F-B546-1F23A3B180B5 +install-name: '/usr/lib/system/libsystem_coreservices.dylib' +current-version: 127 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _NSGetNextSearchPathEnumeration, _NSStartSearchPathEnumeration, + _NSStartSearchPathEnumerationPrivate, ___user_local_dirname, + ___user_relative_dirname, __append_relative_path_component, + __dirhelper, __dirhelper_relative, __get_user_dir_suffix, + __libcoreservices_fork_child, __set_user_dir_suffix, _sysdir_get_next_search_path_enumeration, + _sysdir_start_search_path_enumeration, _sysdir_start_search_path_enumeration_private ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: BD269412-C9D0-32EE-B42B-B09A187A9B95 + - target: x86_64-maccatalyst + value: BD269412-C9D0-32EE-B42B-B09A187A9B95 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 1DEB48CE-5F39-3BBC-8D13-00C7636F7FE5 + - target: arm64e-maccatalyst + value: 1DEB48CE-5F39-3BBC-8D13-00C7636F7FE5 +install-name: '/usr/lib/system/libsystem_darwin.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___libdarwin_init, ___os_temporary_resource_shortage, _claimfd_np, + _close_drop_np, _close_drop_optional_np, _crfprintf_np, _dirstat_np, + _dirstatat_np, _dup_np, _err_np, _errc_np, _fcheck_np, _memdup2_np, + _memdup_np, _os_assert_mach, _os_assert_mach_port_status, + _os_boot_mode_query, _os_crash_get_reporter_port_array, _os_crash_port_array_deallocate, + _os_crash_set_reporter_port, _os_crash_spawnattr_set_reporter_port, + _os_flagset_copy_string, _os_localtime_file, _os_mach_msg_copy_description, + _os_mach_msg_get_audit_trailer, _os_mach_msg_get_context_trailer, + _os_mach_msg_get_trailer, _os_mach_msg_trailer_copy_description, + _os_mach_port_copy_description, _os_parse_boot_arg_int, _os_parse_boot_arg_string, + _os_simple_hash, _os_simple_hash_string, _os_simple_hash_string_with_seed, + _os_simple_hash_with_seed, _os_subcommand_fprintf, _os_subcommand_main, + _os_subcommand_vfprintf, _os_variant_allows_internal_security_policies, + _os_variant_check, _os_variant_copy_description, _os_variant_has_factory_content, + _os_variant_has_internal_content, _os_variant_has_internal_diagnostics, + _os_variant_has_internal_ui, _os_variant_init_4launchd, _os_variant_is_basesystem, + _os_variant_is_darwinos, _os_variant_is_recovery, _os_variant_uses_ephemeral_storage, + _realpath_np, _strerror_np, _strexit_np, _symerror_np, _symexit_np, + _sysctl_get_data_np, _sysctlbyname_get_data_np, _sysexit_np, + _vcrfprintf_np, _verr_np, _verrc_np, _vwarn_np, _vwfprintf_np, + _warn_np, _wfprintf_np, _xferfd_np, _zsnprintf_np ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 81EFC44D-450E-3AA3-AC8F-D7EF68F464B4 + - target: x86_64-maccatalyst + value: 81EFC44D-450E-3AA3-AC8F-D7EF68F464B4 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: E498E2D5-BD16-3458-AF9C-B4EE888935CB + - target: arm64e-maccatalyst + value: E498E2D5-BD16-3458-AF9C-B4EE888935CB +install-name: '/usr/lib/system/libsystem_dnssd.dylib' +current-version: 1310.60.4 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _DNSServiceAddRecord, _DNSServiceBrowse, _DNSServiceBrowserCreate, + _DNSServiceConstructFullName, _DNSServiceCreateConnection, + _DNSServiceCreateDelegateConnection, _DNSServiceDiscoveryDeallocate, + _DNSServiceDiscoveryMachPort, _DNSServiceDiscovery_handleReply, + _DNSServiceEnumerateDomains, _DNSServiceGetAddrInfo, _DNSServiceGetPID, + _DNSServiceGetProperty, _DNSServiceNATPortMappingCreate, _DNSServiceProcessResult, + _DNSServiceQueryRecord, _DNSServiceReconfirmRecord, _DNSServiceRefDeallocate, + _DNSServiceRefSockFD, _DNSServiceRegister, _DNSServiceRegisterRecord, + _DNSServiceRemoveRecord, _DNSServiceResolve, _DNSServiceResolverResolve, + _DNSServiceSetDefaultDomainForUser, _DNSServiceSetDispatchQueue, + _DNSServiceSetResolverDefaults, _DNSServiceSleepKeepalive, + _DNSServiceSleepKeepalive_sockaddr, _DNSServiceUpdateRecord, + _PeerConnectionRelease, _TXTRecordContainsKey, _TXTRecordCreate, + _TXTRecordDeallocate, _TXTRecordGetBytesPtr, _TXTRecordGetCount, + _TXTRecordGetItemAtIndex, _TXTRecordGetLength, _TXTRecordGetValuePtr, + _TXTRecordRemoveValue, _TXTRecordSetValue ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 7B4EBDDB-244E-3F78-8895-566FE22288F3 + - target: x86_64-maccatalyst + value: 7B4EBDDB-244E-3F78-8895-566FE22288F3 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 790541FA-8846-39B1-B87F-BCB1C87A6A27 + - target: arm64e-maccatalyst + value: 790541FA-8846-39B1-B87F-BCB1C87A6A27 +install-name: '/usr/lib/system/libsystem_featureflags.dylib' +current-version: 28.60.1 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ __os_feature_enabled_impl, __os_feature_enabled_simple_impl ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 0979757C-5F0D-3F5A-9E0E-EBF234B310AF + - target: x86_64-maccatalyst + value: 0979757C-5F0D-3F5A-9E0E-EBF234B310AF + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: CFE4640F-4E04-3DC5-80F6-79E0BF7F4FAF + - target: arm64e-maccatalyst + value: CFE4640F-4E04-3DC5-80F6-79E0BF7F4FAF +install-name: '/usr/lib/system/libsystem_info.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _LI_get_thread_item, _LI_get_thread_list, _LI_ils_create, + _LI_set_thread_item, _LI_set_thread_list, ___dn_skipname, + __authenticate, __ds_running, __gai_nat64_can_v4_address_be_synthesized, + __gai_serv_to_port, __gai_simple, __getaddrinfo_interface_async_call, + __getlong, __getnameinfo_interface_async_call, __getshort, + __null_auth, __res, __seterr_reply, __si_disable_opendirectory, + __yp_dobind, _alias_endent, _alias_getbyname, _alias_getent, + _alias_setent, _authnone_create, _authunix_create, _authunix_create_default, + _bindresvport, _bindresvport_sa, _bootparams_endent, _bootparams_getbyname, + _bootparams_getent, _bootparams_setent, _clnt_broadcast, _clnt_create, + _clnt_pcreateerror, _clnt_perrno, _clnt_perror, _clnt_spcreateerror, + _clnt_sperrno, _clnt_sperror, _clntraw_create, _clnttcp_create, + _clntudp_bufcreate, _clntudp_create, _configuration_profile_copy_property_list, + _configuration_profile_create_notification_key, _dn_expand, + _endfsent, _endgrent, _endhostent, _endnetent, _endnetgrent, + _endprotoent, _endpwent, _endrpcent, _endservent, _ether_aton, + _ether_hostton, _ether_line, _ether_ntoa, _ether_ntohost, + _freeaddrinfo, _freehostent, _freeifaddrs, _freeifmaddrs, + _gL1CacheEnabled, _gai_strerror, _getaddrinfo, _getaddrinfo_async_cancel, + _getaddrinfo_async_handle_reply, _getaddrinfo_async_receive, + _getaddrinfo_async_send, _getaddrinfo_async_start, _getdomainname, + _getfsent, _getfsfile, _getfsspec, _getgrent, _getgrgid, _getgrgid_r, + _getgrnam, _getgrnam_r, _getgroupcount, _getgrouplist, _getgrouplist_2, + _getgruuid, _getgruuid_r, _gethostbyaddr, _gethostbyaddr_async_cancel, + _gethostbyaddr_async_handleReply, _gethostbyaddr_async_start, + _gethostbyname, _gethostbyname2, _gethostbyname_async_cancel, + _gethostbyname_async_handleReply, _gethostbyname_async_start, + _gethostent, _getifaddrs, _getifmaddrs, _getipnodebyaddr, + _getipnodebyname, _getnameinfo, _getnameinfo_async_cancel, + _getnameinfo_async_handle_reply, _getnameinfo_async_send, + _getnameinfo_async_start, _getnetbyaddr, _getnetbyname, _getnetent, + _getnetgrent, _getprotobyname, _getprotobynumber, _getprotoent, + _getpwent, _getpwnam, _getpwnam_r, _getpwuid, _getpwuid_r, + _getpwuuid, _getpwuuid_r, _getrpcbyname, _getrpcbynumber, + _getrpcent, _getrpcport, _getservbyname, _getservbyport, _getservent, + _group_from_gid, _h_errno, _herror, _hstrerror, _htonl, _htons, + _if_freenameindex, _if_indextoname, _if_nameindex, _if_nametoindex, + _in6addr_any, _in6addr_linklocal_allnodes, _in6addr_linklocal_allrouters, + _in6addr_linklocal_allv2routers, _in6addr_loopback, _in6addr_nodelocal_allnodes, + _inet6_opt_append, _inet6_opt_find, _inet6_opt_finish, _inet6_opt_get_val, + _inet6_opt_init, _inet6_opt_next, _inet6_opt_set_val, _inet6_option_alloc, + _inet6_option_append, _inet6_option_find, _inet6_option_init, + _inet6_option_next, _inet6_option_space, _inet6_rth_add, _inet6_rth_getaddr, + _inet6_rth_init, _inet6_rth_reverse, _inet6_rth_segments, + _inet6_rth_space, _inet6_rthdr_add, _inet6_rthdr_getaddr, + _inet6_rthdr_getflags, _inet6_rthdr_init, _inet6_rthdr_lasthop, + _inet6_rthdr_segments, _inet6_rthdr_space, _initgroups, _innetgr, + _iruserok, _iruserok_sa, _kvarray_free, _kvbuf_add_dict, _kvbuf_add_key, + _kvbuf_add_val, _kvbuf_add_val_len, _kvbuf_append_kvbuf, _kvbuf_decode, + _kvbuf_free, _kvbuf_get_len, _kvbuf_init, _kvbuf_init_zone, + _kvbuf_make_nonpurgeable, _kvbuf_make_purgeable, _kvbuf_new, + _kvbuf_new_zone, _kvbuf_next_dict, _kvbuf_next_key, _kvbuf_next_val, + _kvbuf_next_val_len, _kvbuf_query, _kvbuf_query_key_int, _kvbuf_query_key_uint, + _kvbuf_query_key_val, _kvbuf_reset, _mbr_check_membership, + _mbr_check_membership_by_id, _mbr_check_membership_ext, _mbr_check_membership_refresh, + _mbr_check_service_membership, _mbr_gid_to_uuid, _mbr_group_name_to_uuid, + _mbr_identifier_to_uuid, _mbr_identifier_translate, _mbr_reset_cache, + _mbr_set_identifier_ttl, _mbr_sid_to_string, _mbr_sid_to_uuid, + _mbr_string_to_sid, _mbr_string_to_uuid, _mbr_uid_to_uuid, + _mbr_user_name_to_uuid, _mbr_uuid_to_id, _mbr_uuid_to_sid, + _mbr_uuid_to_sid_type, _mbr_uuid_to_string, _ntohl, _ntohs, + _pmap_getmaps, _pmap_getport, _pmap_rmtcall, _pmap_set, _pmap_unset, + _prdb_end, _prdb_get, _prdb_getbyname, _prdb_set, _rcmd, _rcmd_af, + _res_init, _res_query, _res_search, _rpc_createerr, _rresvport, + _rresvport_af, _ruserok, _setdomainname, _setfsent, _setgrent, + _setgroupent, _sethostent, _setnetent, _setnetgrent, _setpassent, + _setprotoent, _setpwent, _setrpcent, _setservent, _si_addrinfo, + _si_addrinfo_list, _si_addrinfo_list_from_hostent, _si_addrinfo_v4, + _si_addrinfo_v4_mapped, _si_addrinfo_v6, _si_alias_all, _si_alias_byname, + _si_async_call, _si_async_cancel, _si_async_handle_reply, + _si_destination_compare, _si_destination_compare_no_dependencies, + _si_fs_all, _si_fs_byfile, _si_fs_byspec, _si_group_all, _si_group_bygid, + _si_group_byname, _si_group_byuuid, _si_grouplist, _si_host_all, + _si_host_byaddr, _si_host_byname, _si_in_netgroup, _si_ipnode_byname, + _si_item_call, _si_item_is_valid, _si_item_match, _si_item_release, + _si_item_retain, _si_list_add, _si_list_call, _si_list_concat, + _si_list_next, _si_list_release, _si_list_reset, _si_list_retain, + _si_mac_all, _si_mac_bymac, _si_mac_byname, _si_module_name, + _si_module_release, _si_module_retain, _si_module_vers, _si_module_with_name, + _si_nameinfo, _si_netgroup_byname, _si_network_all, _si_network_byaddr, + _si_network_byname, _si_protocol_all, _si_protocol_byname, + _si_protocol_bynumber, _si_rpc_all, _si_rpc_byname, _si_rpc_bynumber, + _si_search, _si_search_module_set_flags, _si_service_all, + _si_service_byname, _si_service_byport, _si_set_nat64_v4_requires_synthesis, + _si_set_nat64_v4_synthesize, _si_srv_byname, _si_standardize_mac_address, + _si_user_all, _si_user_byname, _si_user_byuid, _si_user_byuuid, + _si_wants_addrinfo, _svc_fdset, _svc_getreq, _svc_getreqset, + _svc_register, _svc_run, _svc_sendreply, _svc_unregister, + _svcerr_auth, _svcerr_decode, _svcerr_noproc, _svcerr_noprog, + _svcerr_progvers, _svcerr_systemerr, _svcerr_weakauth, _svcfd_create, + _svcraw_create, _svctcp_create, _svcudp_bufcreate, _svcudp_create, + _user_from_uid, _xdr_array, _xdr_authunix_parms, _xdr_bool, + _xdr_bytes, _xdr_callhdr, _xdr_callmsg, _xdr_char, _xdr_des_block, + _xdr_domainname, _xdr_double, _xdr_enum, _xdr_float, _xdr_free, + _xdr_hyper, _xdr_int, _xdr_int16_t, _xdr_int32_t, _xdr_int64_t, + _xdr_keydat, _xdr_long, _xdr_longlong_t, _xdr_mapname, _xdr_netobj, + _xdr_opaque, _xdr_peername, _xdr_pmap, _xdr_pmaplist, _xdr_pointer, + _xdr_reference, _xdr_replymsg, _xdr_rmtcall_args, _xdr_rmtcallres, + _xdr_short, _xdr_string, _xdr_u_char, _xdr_u_hyper, _xdr_u_int, + _xdr_u_int16_t, _xdr_u_int32_t, _xdr_u_int64_t, _xdr_u_long, + _xdr_u_longlong_t, _xdr_u_short, _xdr_union, _xdr_valdat, + _xdr_vector, _xdr_void, _xdr_wrapstring, _xdr_x_passwd, _xdr_ypbind_binding, + _xdr_ypbind_resp, _xdr_ypbind_resptype, _xdr_ypbind_setdom, + _xdr_ypmaplist, _xdr_yppasswd, _xdr_ypreq_key, _xdr_ypreq_nokey, + _xdr_ypresp_all, _xdr_ypresp_all_seq, _xdr_ypresp_key_val, + _xdr_ypresp_maplist, _xdr_ypresp_master, _xdr_ypresp_order, + _xdr_ypresp_val, _xdr_ypstat, _xdrmem_create, _xdrrec_create, + _xdrrec_endofrecord, _xdrrec_eof, _xdrrec_skiprecord, _xdrstdio_create, + _xprt_register, _xprt_unregister, _yp_all, _yp_bind, _yp_first, + _yp_get_default_domain, _yp_maplist, _yp_master, _yp_match, + _yp_next, _yp_order, _yp_unbind, _yperr_string, _ypprot_err ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: C7D4E6AF-4446-3435-8F2C-0F5CCBEF61E9 + - target: x86_64-maccatalyst + value: C7D4E6AF-4446-3435-8F2C-0F5CCBEF61E9 + - target: arm64-macos + value: 7795E4F6-7356-31DD-A256-30483E74DD61 + - target: arm64-maccatalyst + value: 7795E4F6-7356-31DD-A256-30483E74DD61 + - target: arm64e-macos + value: C860F076-F332-3A67-A7D9-FEDF89124762 + - target: arm64e-maccatalyst + value: C860F076-F332-3A67-A7D9-FEDF89124762 +install-name: '/usr/lib/system/libsystem_kernel.dylib' +current-version: 7195.60.74 +parent-umbrella: + - targets: [ i386-macos, i386-maccatalyst, x86_64-macos, x86_64-maccatalyst, + arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos ] + symbols: [ '_fstat$INODE64', '_fstatat$INODE64', '_fstatfs$INODE64', + '_getfsstat$INODE64', _i386_get_ldt, _i386_set_ldt, '_lstat$INODE64', + '_pselect$1050', '_select$1050', '_stat$INODE64', '_statfs$INODE64' ] + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64-maccatalyst, arm64-macos, + arm64e-maccatalyst, arm64e-macos ] + symbols: [ _NDR_record, _____old_semwait_signal_nocancel, _____sigwait_nocancel, + ____kernelVersionNumber, ____kernelVersionString, ___abort_with_payload, + ___accept, ___accept_nocancel, ___access_extended, ___aio_suspend_nocancel, + ___bind, ___bsdthread_create, ___bsdthread_ctl, ___bsdthread_register, + ___bsdthread_terminate, ___carbon_delete, ___channel_get_info, + ___channel_get_opt, ___channel_open, ___channel_set_opt, ___channel_sync, + ___chmod, ___chmod_extended, ___close_nocancel, ___coalition, + ___coalition_info, ___coalition_ledger, ___commpage_gettimeofday, + ___connect, ___connect_nocancel, ___copyfile, ___csrctl, ___darwin_check_fd_set_overflow, + ___delete, ___disable_threadsignal, ___error, ___exit, ___fchmod, + ___fchmod_extended, ___fcntl, ___fcntl_nocancel, ___fork, + ___fs_snapshot, ___fstat64_extended, ___fstat_extended, ___fsync_nocancel, + ___get_remove_counter, ___getattrlist, ___getdirentries64, + ___gethostuuid, ___getlogin, ___getpeername, ___getpid, ___getrlimit, + ___getsgroups, ___getsockname, ___gettid, ___gettimeofday, + ___getwgroups, ___guarded_open_dprotected_np, ___guarded_open_np, + ___identitysvc, ___inc_remove_counter, ___initgroups, ___ioctl, + ___iopolicysys, ___kdebug_trace, ___kdebug_trace64, ___kdebug_trace_string, + ___kdebug_typefilter, ___kill, ___kqueue_workloop_ctl, ___lchown, + ___libkernel_init, ___libkernel_init_late, ___libkernel_platform_init, + ___libkernel_voucher_init, ___listen, ___log_data, ___lseek, + ___lstat64_extended, ___lstat_extended, ___mac_execve, ___mac_get_fd, + ___mac_get_file, ___mac_get_link, ___mac_get_mount, ___mac_get_pid, + ___mac_get_proc, ___mac_getfsstat, ___mac_mount, ___mac_set_fd, + ___mac_set_file, ___mac_set_link, ___mac_set_proc, ___mac_syscall, + ___mach_bridge_remote_time, ___mach_eventlink_signal, ___mach_eventlink_signal_wait_until, + ___mach_eventlink_wait_until, ___memorystatus_available_memory, + ___microstackshot, ___mkdir_extended, ___mkfifo_extended, + ___mmap, ___mprotect, ___msgctl, ___msgrcv_nocancel, ___msgsnd_nocancel, + ___msgsys, ___msync, ___msync_nocancel, ___munmap, ___nexus_create, + ___nexus_deregister, ___nexus_destroy, ___nexus_get_opt, ___nexus_open, + ___nexus_register, ___nexus_set_opt, ___old_semwait_signal, + ___open, ___open_dprotected_np, ___open_extended, ___open_nocancel, + ___openat, ___openat_nocancel, ___os_nexus_flow_add, ___os_nexus_flow_del, + ___os_nexus_ifattach, ___os_nexus_ifdetach, ___persona, ___pipe, + ___poll_nocancel, ___posix_spawn, ___pread_nocancel, ___preadv_nocancel, + ___proc_info, ___proc_info_extended_id, ___process_policy, + ___pselect, ___pselect_nocancel, ___psynch_cvbroad, ___psynch_cvclrprepost, + ___psynch_cvsignal, ___psynch_cvwait, ___psynch_mutexdrop, + ___psynch_mutexwait, ___psynch_rw_downgrade, ___psynch_rw_longrdlock, + ___psynch_rw_rdlock, ___psynch_rw_unlock, ___psynch_rw_unlock2, + ___psynch_rw_upgrade, ___psynch_rw_wrlock, ___psynch_rw_yieldwrlock, + ___pthread_canceled, ___pthread_chdir, ___pthread_fchdir, + ___pthread_kill, ___pthread_markcancel, ___pthread_sigmask, + ___ptrace, ___pwrite_nocancel, ___pwritev_nocancel, ___read_nocancel, + ___readv_nocancel, ___reboot, ___recvfrom, ___recvfrom_nocancel, + ___recvmsg, ___recvmsg_nocancel, ___rename, ___renameat, ___renameatx_np, + ___rmdir, ___sandbox_me, ___sandbox_mm, ___sandbox_ms, ___sandbox_msp, + ___select, ___select_nocancel, ___sem_open, ___sem_wait_nocancel, + ___semctl, ___semsys, ___semwait_signal, ___semwait_signal_nocancel, + ___sendmsg, ___sendmsg_nocancel, ___sendto, ___sendto_nocancel, + ___setattrlist, ___setlogin, ___setpriority, ___setregid, + ___setreuid, ___setrlimit, ___setsgroups, ___settid, ___settid_with_pid, + ___settimeofday, ___setwgroups, ___sfi_ctl, ___sfi_pidctl, + ___shared_region_check_np, ___shared_region_map_and_slide_2_np, + ___shared_region_map_and_slide_np, ___shm_open, ___shmctl, + ___shmsys, ___sigaction, ___sigaltstack, ___sigreturn, ___sigsuspend, + ___sigsuspend_nocancel, ___sigwait, ___socketpair, ___stack_snapshot_with_config, + ___stat64_extended, ___stat_extended, ___syscall, ___syscall_logger, + ___sysctl, ___sysctlbyname, ___telemetry, ___terminate_with_payload, + ___thread_selfid, ___thread_selfusage, ___ulock_wait, ___ulock_wait2, + ___ulock_wake, ___umask_extended, ___unlink, ___unlinkat, + ___vfork, ___wait4, ___wait4_nocancel, ___waitid_nocancel, + ___work_interval_ctl, ___workq_kernreturn, ___workq_open, + ___write_nocancel, ___writev_nocancel, __cpu_capabilities, + __cpu_has_altivec, __exit, __get_cpu_capabilities, __getprivatesystemidentifier, + __host_page_size, __init_cpu_capabilities, __kernelrpc_host_create_mach_voucher, + __kernelrpc_mach_port_allocate, __kernelrpc_mach_port_allocate_full, + __kernelrpc_mach_port_allocate_name, __kernelrpc_mach_port_allocate_qos, + __kernelrpc_mach_port_allocate_trap, __kernelrpc_mach_port_construct, + __kernelrpc_mach_port_construct_trap, __kernelrpc_mach_port_deallocate, + __kernelrpc_mach_port_deallocate_trap, __kernelrpc_mach_port_destroy, + __kernelrpc_mach_port_destruct, __kernelrpc_mach_port_destruct_trap, + __kernelrpc_mach_port_dnrequest_info, __kernelrpc_mach_port_extract_member, + __kernelrpc_mach_port_extract_member_trap, __kernelrpc_mach_port_extract_right, + __kernelrpc_mach_port_get_attributes, __kernelrpc_mach_port_get_attributes_trap, + __kernelrpc_mach_port_get_context, __kernelrpc_mach_port_get_refs, + __kernelrpc_mach_port_get_set_status, __kernelrpc_mach_port_get_srights, + __kernelrpc_mach_port_guard, __kernelrpc_mach_port_guard_trap, + __kernelrpc_mach_port_guard_with_flags, __kernelrpc_mach_port_insert_member, + __kernelrpc_mach_port_insert_member_trap, __kernelrpc_mach_port_insert_right, + __kernelrpc_mach_port_insert_right_trap, __kernelrpc_mach_port_kernel_object, + __kernelrpc_mach_port_kobject, __kernelrpc_mach_port_kobject_description, + __kernelrpc_mach_port_mod_refs, __kernelrpc_mach_port_mod_refs_trap, + __kernelrpc_mach_port_move_member, __kernelrpc_mach_port_move_member_trap, + __kernelrpc_mach_port_names, __kernelrpc_mach_port_peek, __kernelrpc_mach_port_rename, + __kernelrpc_mach_port_request_notification, __kernelrpc_mach_port_request_notification_trap, + __kernelrpc_mach_port_set_attributes, __kernelrpc_mach_port_set_context, + __kernelrpc_mach_port_set_mscount, __kernelrpc_mach_port_set_seqno, + __kernelrpc_mach_port_space_basic_info, __kernelrpc_mach_port_space_info, + __kernelrpc_mach_port_special_reply_port_reset_link, __kernelrpc_mach_port_swap_guard, + __kernelrpc_mach_port_type, __kernelrpc_mach_port_type_trap, + __kernelrpc_mach_port_unguard, __kernelrpc_mach_port_unguard_trap, + __kernelrpc_mach_vm_allocate, __kernelrpc_mach_vm_allocate_trap, + __kernelrpc_mach_vm_deallocate, __kernelrpc_mach_vm_deallocate_trap, + __kernelrpc_mach_vm_map, __kernelrpc_mach_vm_map_trap, __kernelrpc_mach_vm_protect, + __kernelrpc_mach_vm_protect_trap, __kernelrpc_mach_vm_purgable_control, + __kernelrpc_mach_vm_purgable_control_trap, __kernelrpc_mach_vm_read, + __kernelrpc_mach_vm_remap, __kernelrpc_mach_voucher_extract_attr_recipe, + __kernelrpc_task_set_port_space, __kernelrpc_thread_policy, + __kernelrpc_thread_policy_set, __kernelrpc_thread_set_policy, + __kernelrpc_vm_map, __kernelrpc_vm_purgable_control, __kernelrpc_vm_read, + __kernelrpc_vm_remap, __mach_errors, __mach_fork_child, __mach_snprintf, + __mach_vsnprintf, __os_alloc_once_table, __os_xbs_chrooted, + __register_gethostuuid_callback, __thread_set_tsd_base, _abort_with_payload, + _abort_with_reason, _accept, '_accept$NOCANCEL', _access, + _accessx_np, _acct, _act_get_state, _act_set_state, _adjtime, + _aio_cancel, _aio_error, _aio_fsync, _aio_read, _aio_return, + _aio_suspend, '_aio_suspend$NOCANCEL', _aio_write, _audit, + _audit_session_join, _audit_session_port, _audit_session_self, + _auditctl, _auditon, _bind, _bootstrap_port, _cerror, _cerror_nocancel, + _change_fdguard_np, _chdir, _chflags, _chmod, _chown, _chroot, + _clock_alarm, _clock_alarm_reply, _clock_get_attributes, _clock_get_time, + _clock_set_attributes, _clock_set_time, _clock_sleep, _clock_sleep_trap, + _clonefile, _clonefileat, _close, '_close$NOCANCEL', _coalition_create, + _coalition_info_resource_usage, _coalition_info_set_efficiency, + _coalition_info_set_name, _coalition_ledger_set_logical_writes_limit, + _coalition_reap, _coalition_terminate, _connect, '_connect$NOCANCEL', + _connectx, _csops, _csops_audittoken, _csr_check, _csr_get_active_config, + _debug_control_port_for_pid, _denap_boost_assertion_token, + _disconnectx, _dup, _dup2, _errno, _etap_trace_thread, _exc_server, + _exc_server_routine, _exception_raise, _exception_raise_state, + _exception_raise_state_identity, _exchangedata, _execve, _faccessat, + _fchdir, _fchflags, _fchmod, _fchmodat, _fchown, _fchownat, + _fclonefileat, _fcntl, '_fcntl$NOCANCEL', _fdatasync, _ffsctl, + _fgetattrlist, _fgetxattr, _fhopen, _fileport_makefd, _fileport_makeport, + _flistxattr, _flock, _fmount, _fpathconf, _fremovexattr, _fs_snapshot_create, + _fs_snapshot_delete, _fs_snapshot_list, _fs_snapshot_mount, + _fs_snapshot_rename, _fs_snapshot_revert, _fs_snapshot_root, + _fsctl, _fsetattrlist, _fsetxattr, _fsgetpath, _fsgetpath_ext, + _fstat, _fstat64, _fstatat, _fstatat64, _fstatfs, _fstatfs64, + _fsync, '_fsync$NOCANCEL', _ftruncate, _futimens, _futimes, + _getattrlist, _getattrlistat, _getattrlistbulk, _getaudit, + _getaudit_addr, _getauid, _getdirentries, _getdirentriesattr, + _getdtablesize, _getegid, _getentropy, _geteuid, _getfh, _getfsstat, + _getfsstat64, _getgid, _getgroups, _gethostuuid, _getiopolicy_np, + _getitimer, _getpeername, _getpgid, _getpgrp, _getpid, _getppid, + _getpriority, _getrlimit, _getrusage, _getsgroups_np, _getsid, + _getsockname, _getsockopt, _getuid, _getwgroups_np, _getxattr, + _grab_pgo_data, _guarded_close_np, _guarded_kqueue_np, _guarded_open_dprotected_np, + _guarded_open_np, _guarded_pwrite_np, _guarded_write_np, _guarded_writev_np, + _host_check_multiuser_mode, _host_create_mach_voucher, _host_create_mach_voucher_trap, + _host_default_memory_manager, _host_get_UNDServer, _host_get_atm_diagnostic_flag, + _host_get_boot_info, _host_get_clock_control, _host_get_clock_service, + _host_get_exception_ports, _host_get_io_master, _host_get_multiuser_config_flags, + _host_get_special_port, _host_info, _host_kernel_version, + _host_lockgroup_info, _host_page_size, _host_priv_statistics, + _host_processor_info, _host_processor_set_priv, _host_processor_sets, + _host_processors, _host_reboot, _host_register_mach_voucher_attr_manager, + _host_register_well_known_mach_voucher_attr_manager, _host_request_notification, + _host_security_create_task_token, _host_security_set_task_token, + _host_self, _host_self_trap, _host_set_UNDServer, _host_set_atm_diagnostic_flag, + _host_set_exception_ports, _host_set_multiuser_config_flags, + _host_set_special_port, _host_statistics, _host_statistics64, + _host_swap_exception_ports, _host_virtual_physical_table_info, + _important_boost_assertion_token, _internal_catch_exc_subsystem, + _ioctl, _issetugid, _kas_info, _kdebug_is_enabled, _kdebug_signpost, + _kdebug_signpost_end, _kdebug_signpost_start, _kdebug_trace, + _kdebug_trace_string, _kdebug_typefilter, _kdebug_using_continuous_time, + _kevent, _kevent64, _kevent_id, _kevent_qos, _kext_request, + _kill, _kmod_control, _kmod_create, _kmod_destroy, _kmod_get_info, + _kpersona_alloc, _kpersona_dealloc, _kpersona_find, _kpersona_find_by_type, + _kpersona_get, _kpersona_getpath, _kpersona_info, _kpersona_palloc, + _kpersona_pidinfo, _kqueue, _lchown, _ledger, _link, _linkat, + _lio_listio, _listen, _listxattr, _lock_acquire, _lock_handoff, + _lock_handoff_accept, _lock_make_stable, _lock_release, _lock_set_create, + _lock_set_destroy, _lock_try, _log_data_as_kernel, _lseek, + _lstat, _lstat64, _mach_absolute_time, _mach_approximate_time, + _mach_boottime_usec, _mach_continuous_approximate_time, _mach_continuous_time, + _mach_error, _mach_error_full_diag, _mach_error_string, _mach_error_type, + _mach_eventlink_associate, _mach_eventlink_create, _mach_eventlink_destroy, + _mach_eventlink_disassociate, _mach_eventlink_signal, _mach_eventlink_signal_wait_until, + _mach_eventlink_wait_until, _mach_generate_activity_id, _mach_get_times, + _mach_host_self, _mach_host_special_port_description, _mach_host_special_port_for_id, + _mach_init, _mach_make_memory_entry, _mach_make_memory_entry_64, + _mach_memory_entry_access_tracking, _mach_memory_entry_ownership, + _mach_memory_entry_purgable_control, _mach_memory_info, _mach_memory_object_memory_entry, + _mach_memory_object_memory_entry_64, _mach_msg, _mach_msg_destroy, + _mach_msg_overwrite, _mach_msg_overwrite_trap, _mach_msg_priority_encode, + _mach_msg_priority_is_pthread_priority, _mach_msg_priority_overide_qos, + _mach_msg_priority_qos, _mach_msg_priority_relpri, _mach_msg_receive, + _mach_msg_send, _mach_msg_server, _mach_msg_server_importance, + _mach_msg_server_once, _mach_msg_trap, _mach_notify_dead_name, + _mach_notify_no_senders, _mach_notify_port_deleted, _mach_notify_port_destroyed, + _mach_notify_send_once, _mach_port_allocate, _mach_port_allocate_full, + _mach_port_allocate_name, _mach_port_allocate_qos, _mach_port_construct, + _mach_port_deallocate, _mach_port_destroy, _mach_port_destruct, + _mach_port_dnrequest_info, _mach_port_extract_member, _mach_port_extract_right, + _mach_port_get_attributes, _mach_port_get_context, _mach_port_get_refs, + _mach_port_get_set_status, _mach_port_get_srights, _mach_port_guard, + _mach_port_guard_with_flags, _mach_port_insert_member, _mach_port_insert_right, + _mach_port_kernel_object, _mach_port_kobject, _mach_port_kobject_description, + _mach_port_mod_refs, _mach_port_move_member, _mach_port_names, + _mach_port_peek, _mach_port_rename, _mach_port_request_notification, + _mach_port_set_attributes, _mach_port_set_context, _mach_port_set_mscount, + _mach_port_set_seqno, _mach_port_space_basic_info, _mach_port_space_info, + _mach_port_swap_guard, _mach_port_type, _mach_port_unguard, + _mach_ports_lookup, _mach_ports_register, _mach_reply_port, + _mach_right_recv_construct, _mach_right_recv_destruct, _mach_right_send_create, + _mach_right_send_once_consume, _mach_right_send_once_create, + _mach_right_send_release, _mach_right_send_retain, _mach_sync_ipc_link_monitoring_start, + _mach_sync_ipc_link_monitoring_stop, _mach_task_self, _mach_task_self_, + _mach_task_special_port_description, _mach_task_special_port_for_id, + _mach_thread_self, _mach_timebase_info, _mach_timebase_info_trap, + _mach_vm_allocate, _mach_vm_behavior_set, _mach_vm_copy, _mach_vm_deallocate, + _mach_vm_inherit, _mach_vm_machine_attribute, _mach_vm_map, + _mach_vm_msync, _mach_vm_page_info, _mach_vm_page_query, _mach_vm_page_range_query, + _mach_vm_protect, _mach_vm_purgable_control, _mach_vm_read, + _mach_vm_read_list, _mach_vm_read_overwrite, _mach_vm_region, + _mach_vm_region_recurse, _mach_vm_remap, _mach_vm_wire, _mach_vm_write, + _mach_voucher_attr_command, _mach_voucher_deallocate, _mach_voucher_debug_info, + _mach_voucher_extract_all_attr_recipes, _mach_voucher_extract_attr_content, + _mach_voucher_extract_attr_recipe, _mach_voucher_extract_attr_recipe_trap, + _mach_wait_until, _mach_zone_force_gc, _mach_zone_get_btlog_records, + _mach_zone_get_zlog_zones, _mach_zone_info, _mach_zone_info_for_largest_zone, + _mach_zone_info_for_zone, _macx_backing_store_recovery, _macx_backing_store_suspend, + _macx_swapoff, _macx_swapon, _macx_triggers, _madvise, _memorystatus_control, + _memorystatus_get_level, _mig_allocate, _mig_dealloc_reply_port, + _mig_dealloc_special_reply_port, _mig_deallocate, _mig_get_reply_port, + _mig_get_special_reply_port, _mig_put_reply_port, _mig_reply_setup, + _mig_strncpy, _mig_strncpy_zerofill, _mincore, _minherit, + _mk_timer_arm, _mk_timer_arm_leeway, _mk_timer_cancel, _mk_timer_create, + _mk_timer_destroy, _mkdir, _mkdirat, _mkfifo, _mknod, _mlock, + _mlockall, _mmap, _mount, _mprotect, _mremap_encrypted, _msg_receive, + _msg_rpc, _msg_send, _msgctl, _msgget, _msgrcv, '_msgrcv$NOCANCEL', + _msgsnd, '_msgsnd$NOCANCEL', _msgsys, _msync, '_msync$NOCANCEL', + _munlock, _munlockall, _munmap, _necp_client_action, _necp_match_policy, + _necp_open, _necp_session_action, _necp_session_open, _net_qos_guideline, + _netagent_trigger, _netname_check_in, _netname_check_out, + _netname_look_up, _netname_version, _nfsclnt, _nfssvc, _non_boost_assertion_token, + _normal_boost_assertion_token, _ntp_adjtime, _ntp_gettime, + _open, '_open$NOCANCEL', _open_dprotected_np, _openat, '_openat$NOCANCEL', + _openbyid_np, _os_buflet_get_data_address, _os_buflet_get_data_length, + _os_buflet_get_data_limit, _os_buflet_get_data_offset, _os_buflet_get_object_address, + _os_buflet_get_object_limit, _os_buflet_set_data_length, _os_buflet_set_data_offset, + _os_channel_advance_slot, _os_channel_attr_clone, _os_channel_attr_create, + _os_channel_attr_destroy, _os_channel_attr_get, _os_channel_attr_get_key, + _os_channel_attr_set, _os_channel_attr_set_key, _os_channel_available_slot_count, + _os_channel_buflet_alloc, _os_channel_buflet_free, _os_channel_configure_interface_advisory, + _os_channel_create, _os_channel_create_extended, _os_channel_destroy, + _os_channel_event_free, _os_channel_event_get_event_data, + _os_channel_event_get_next_event, _os_channel_flow_admissible, + _os_channel_get_advisory_region, _os_channel_get_fd, _os_channel_get_interface_advisory, + _os_channel_get_next_event_handle, _os_channel_get_next_slot, + _os_channel_get_stats_region, _os_channel_is_defunct, _os_channel_packet_alloc, + _os_channel_packet_free, _os_channel_packet_pool_purge, _os_channel_pending, + _os_channel_read_attr, _os_channel_read_nexus_extension_info, + _os_channel_ring_id, _os_channel_ring_notify_time, _os_channel_ring_sync_time, + _os_channel_rx_ring, _os_channel_set_slot_properties, _os_channel_slot_attach_packet, + _os_channel_slot_detach_packet, _os_channel_slot_get_packet, + _os_channel_sync, _os_channel_tx_ring, _os_channel_write_attr, + _os_copy_and_inet_checksum, _os_cpu_copy_in_cksum, _os_cpu_in_cksum, + _os_cpu_in_cksum_mbuf, _os_fault_with_payload, _os_inet_checksum, + _os_nexus_attr_clone, _os_nexus_attr_create, _os_nexus_attr_destroy, + _os_nexus_attr_get, _os_nexus_attr_set, _os_nexus_controller_alloc_provider_instance, + _os_nexus_controller_bind_provider_instance, _os_nexus_controller_create, + _os_nexus_controller_deregister_provider, _os_nexus_controller_destroy, + _os_nexus_controller_free_provider_instance, _os_nexus_controller_get_fd, + _os_nexus_controller_read_provider_attr, _os_nexus_controller_register_provider, + _os_nexus_controller_unbind_provider_instance, _os_packet_add_buflet, + _os_packet_clear_flow_uuid, _os_packet_decrement_use_count, + _os_packet_finalize, _os_packet_get_aggregation_type, _os_packet_get_buflet_count, + _os_packet_get_compression_generation_count, _os_packet_get_data_length, + _os_packet_get_expire_time, _os_packet_get_flow_uuid, _os_packet_get_group_end, + _os_packet_get_group_start, _os_packet_get_headroom, _os_packet_get_inet_checksum, + _os_packet_get_link_broadcast, _os_packet_get_link_ethfcs, + _os_packet_get_link_header_length, _os_packet_get_link_multicast, + _os_packet_get_next_buflet, _os_packet_get_packetid, _os_packet_get_segment_count, + _os_packet_get_service_class, _os_packet_get_token, _os_packet_get_traffic_class, + _os_packet_get_transport_retransmit, _os_packet_get_transport_traffic_background, + _os_packet_get_transport_traffic_realtime, _os_packet_get_truncated, + _os_packet_get_vlan_id, _os_packet_get_vlan_priority, _os_packet_get_vlan_tag, + _os_packet_increment_use_count, _os_packet_set_compression_generation_count, + _os_packet_set_expire_time, _os_packet_set_flow_uuid, _os_packet_set_group_end, + _os_packet_set_group_start, _os_packet_set_headroom, _os_packet_set_inet_checksum, + _os_packet_set_link_broadcast, _os_packet_set_link_ethfcs, + _os_packet_set_link_header_length, _os_packet_set_link_multicast, + _os_packet_set_packetid, _os_packet_set_service_class, _os_packet_set_token, + _os_packet_set_traffic_class, _os_packet_set_transport_last_packet, + _os_packet_set_transport_retransmit, _os_packet_set_transport_traffic_background, + _os_packet_set_transport_traffic_realtime, _os_packet_set_vlan_tag, + _os_proc_available_memory, _panic, _panic_init, _pathconf, + _peeloff, _pid_for_task, _pid_hibernate, _pid_resume, _pid_shutdown_networking, + _pid_shutdown_sockets, _pid_suspend, _pipe, _pivot_root, _pkt_subtype_assert_fail, + _pkt_type_assert_fail, _poll, '_poll$NOCANCEL', _port_obj_init, + _port_obj_table, _port_obj_table_size, _posix_madvise, _posix_spawn, + _posix_spawn_file_actions_add_fileportdup2_np, _posix_spawn_file_actions_addchdir_np, + _posix_spawn_file_actions_addclose, _posix_spawn_file_actions_adddup2, + _posix_spawn_file_actions_addfchdir_np, _posix_spawn_file_actions_addinherit_np, + _posix_spawn_file_actions_addopen, _posix_spawn_file_actions_destroy, + _posix_spawn_file_actions_init, _posix_spawnattr_destroy, + _posix_spawnattr_disable_ptr_auth_a_keys_np, _posix_spawnattr_get_darwin_role_np, + _posix_spawnattr_get_qos_clamp_np, _posix_spawnattr_getarchpref_np, + _posix_spawnattr_getbinpref_np, _posix_spawnattr_getcpumonitor, + _posix_spawnattr_getflags, _posix_spawnattr_getmacpolicyinfo_np, + _posix_spawnattr_getpcontrol_np, _posix_spawnattr_getpgroup, + _posix_spawnattr_getprocesstype_np, _posix_spawnattr_getsigdefault, + _posix_spawnattr_getsigmask, _posix_spawnattr_init, _posix_spawnattr_set_csm_np, + _posix_spawnattr_set_darwin_role_np, _posix_spawnattr_set_gid_np, + _posix_spawnattr_set_groups_np, _posix_spawnattr_set_importancewatch_port_np, + _posix_spawnattr_set_jetsam_ttr_np, _posix_spawnattr_set_login_np, + _posix_spawnattr_set_max_addr_np, _posix_spawnattr_set_persona_gid_np, + _posix_spawnattr_set_persona_groups_np, _posix_spawnattr_set_persona_np, + _posix_spawnattr_set_persona_uid_np, _posix_spawnattr_set_platform_np, + _posix_spawnattr_set_ptrauth_task_port_np, _posix_spawnattr_set_qos_clamp_np, + _posix_spawnattr_set_registered_ports_np, _posix_spawnattr_set_subsystem_root_path_np, + _posix_spawnattr_set_threadlimit_ext, _posix_spawnattr_set_uid_np, + _posix_spawnattr_setarchpref_np, _posix_spawnattr_setauditsessionport_np, + _posix_spawnattr_setbinpref_np, _posix_spawnattr_setcoalition_np, + _posix_spawnattr_setcpumonitor, _posix_spawnattr_setcpumonitor_default, + _posix_spawnattr_setexceptionports_np, _posix_spawnattr_setflags, + _posix_spawnattr_setjetsam_ext, _posix_spawnattr_setmacpolicyinfo_np, + _posix_spawnattr_setnosmt_np, _posix_spawnattr_setpcontrol_np, + _posix_spawnattr_setpgroup, _posix_spawnattr_setprocesstype_np, + _posix_spawnattr_setsigdefault, _posix_spawnattr_setsigmask, + _posix_spawnattr_setspecialport_np, _posix_spawnattr_setsuidcredport_np, + _pread, '_pread$NOCANCEL', _preadv, '_preadv$NOCANCEL', _proc_clear_cpulimits, + _proc_clear_delayidlesleep, _proc_clear_dirty, _proc_clear_vmpressure, + _proc_denap_assertion_begin_with_msg, _proc_denap_assertion_complete, + _proc_disable_apptype, _proc_disable_cpumon, _proc_disable_wakemon, + _proc_donate_importance_boost, _proc_enable_apptype, _proc_get_cpumon_params, + _proc_get_dirty, _proc_get_wakemon_params, _proc_importance_assertion_begin_with_msg, + _proc_importance_assertion_complete, _proc_kmsgbuf, _proc_libversion, + _proc_list_dynkqueueids, _proc_list_uptrs, _proc_listallpids, + _proc_listchildpids, _proc_listcoalitions, _proc_listpgrppids, + _proc_listpids, _proc_listpidspath, _proc_name, _proc_pid_rusage, + _proc_piddynkqueueinfo, _proc_pidfdinfo, _proc_pidfileportinfo, + _proc_pidinfo, _proc_pidoriginatorinfo, _proc_pidpath, _proc_pidpath_audittoken, + _proc_regionfilename, _proc_reset_footprint_interval, _proc_resume_cpumon, + _proc_rlimit_control, _proc_set_cpumon_defaults, _proc_set_cpumon_params, + _proc_set_cpumon_params_fatal, _proc_set_csm, _proc_set_delayidlesleep, + _proc_set_dirty, _proc_set_no_smt, _proc_set_owner_vmpressure, + _proc_set_wakemon_defaults, _proc_set_wakemon_params, _proc_setcpu_percentage, + _proc_setpcontrol, _proc_setthread_cpupercent, _proc_setthread_csm, + _proc_setthread_no_smt, _proc_suppress, _proc_terminate, _proc_trace_log, + _proc_track_dirty, _proc_udata_info, _proc_uuid_policy, _processor_assign, + _processor_control, _processor_exit, _processor_get_assignment, + _processor_info, _processor_set_create, _processor_set_default, + _processor_set_destroy, _processor_set_info, _processor_set_max_priority, + _processor_set_policy_control, _processor_set_policy_disable, + _processor_set_policy_enable, _processor_set_stack_usage, + _processor_set_statistics, _processor_set_tasks, _processor_set_tasks_with_flavor, + _processor_set_threads, _processor_start, _pselect, '_pselect$DARWIN_EXTSN', + '_pselect$DARWIN_EXTSN$NOCANCEL', '_pselect$NOCANCEL', _pthread_getugid_np, + _pthread_setugid_np, _ptrace, _pwrite, '_pwrite$NOCANCEL', + _pwritev, '_pwritev$NOCANCEL', _quota, _quotactl, _read, '_read$NOCANCEL', + _readlink, _readlinkat, _readv, '_readv$NOCANCEL', _reboot, + _reboot_np, _recvfrom, '_recvfrom$NOCANCEL', _recvmsg, '_recvmsg$NOCANCEL', + _recvmsg_x, _removexattr, _rename, _rename_ext, _renameat, + _renameatx_np, _renamex_np, _revoke, _rmdir, _searchfs, _select, + '_select$DARWIN_EXTSN', '_select$DARWIN_EXTSN$NOCANCEL', '_select$NOCANCEL', + _sem_close, _sem_destroy, _sem_getvalue, _sem_init, _sem_open, + _sem_post, _sem_trywait, _sem_unlink, _sem_wait, '_sem_wait$NOCANCEL', + _semaphore_create, _semaphore_destroy, _semaphore_signal, + _semaphore_signal_all, _semaphore_signal_all_trap, _semaphore_signal_thread, + _semaphore_signal_thread_trap, _semaphore_signal_trap, _semaphore_timedwait, + _semaphore_timedwait_signal, _semaphore_timedwait_signal_trap, + _semaphore_timedwait_trap, _semaphore_wait, _semaphore_wait_signal, + _semaphore_wait_signal_trap, _semaphore_wait_trap, _semctl, + _semget, _semop, _semsys, _sendfile, _sendmsg, '_sendmsg$NOCANCEL', + _sendmsg_x, _sendto, '_sendto$NOCANCEL', _setattrlist, _setattrlistat, + _setaudit, _setaudit_addr, _setauid, _setegid, _seteuid, _setgid, + _setgroups, _setiopolicy_np, _setitimer, _setpgid, _setpriority, + _setprivexec, _setquota, _setregid, _setreuid, _setrlimit, + _setsgroups_np, _setsid, _setsockopt, _setuid, _setwgroups_np, + _setxattr, _sfi_get_class_offtime, _sfi_process_get_flags, + _sfi_process_set_flags, _sfi_set_class_offtime, _shm_open, + _shm_unlink, _shmat, _shmctl, _shmdt, _shmget, _shmsys, _shutdown, + _sigpending, _sigprocmask, _sigsuspend, '_sigsuspend$NOCANCEL', + _socket, _socket_delegate, _socketpair, _stackshot_capture_with_config, + _stackshot_config_create, _stackshot_config_dealloc, _stackshot_config_dealloc_buffer, + _stackshot_config_get_stackshot_buffer, _stackshot_config_get_stackshot_size, + _stackshot_config_set_delta_timestamp, _stackshot_config_set_flags, + _stackshot_config_set_pagetable_mask, _stackshot_config_set_pid, + _stackshot_config_set_size_hint, _stat, _stat64, _statfs, + _statfs64, _swapon, _swtch, _swtch_pri, _symlink, _symlinkat, + _sync, _syscall, _syscall_thread_switch, _system_get_sfi_window, + _system_override, _system_set_sfi_window, _system_version_compat_mode, + _task_assign, _task_assign_default, _task_create, _task_create_suid_cred, + _task_for_pid, _task_generate_corpse, _task_get_assignment, + _task_get_dyld_image_infos, _task_get_emulation_vector, _task_get_exc_guard_behavior, + _task_get_exception_ports, _task_get_mach_voucher, _task_get_special_port, + _task_get_state, _task_info, _task_inspect, _task_inspect_for_pid, + _task_map_corpse_info, _task_map_corpse_info_64, _task_name_for_pid, + _task_policy, _task_policy_get, _task_policy_set, _task_purgable_info, + _task_read_for_pid, _task_register_dyld_get_process_state, + _task_register_dyld_image_infos, _task_register_dyld_set_dyld_state, + _task_register_dyld_shared_cache_image_info, _task_restartable_ranges_register, + _task_restartable_ranges_synchronize, _task_resume, _task_resume2, + _task_sample, _task_self_, _task_self_trap, _task_set_emulation, + _task_set_emulation_vector, _task_set_exc_guard_behavior, + _task_set_exception_ports, _task_set_info, _task_set_mach_voucher, + _task_set_phys_footprint_limit, _task_set_policy, _task_set_port_space, + _task_set_ras_pc, _task_set_special_port, _task_set_state, + _task_suspend, _task_suspend2, _task_swap_exception_ports, + _task_swap_mach_voucher, _task_terminate, _task_threads, _task_unregister_dyld_image_infos, + _task_zone_info, _terminate_with_payload, _terminate_with_reason, + _thread_abort, _thread_abort_safely, _thread_assign, _thread_assign_default, + _thread_convert_thread_state, _thread_create, _thread_create_running, + _thread_depress_abort, _thread_destruct_special_reply_port, + _thread_get_assignment, _thread_get_exception_ports, _thread_get_mach_voucher, + _thread_get_register_pointer_values, _thread_get_special_port, + _thread_get_special_reply_port, _thread_get_state, _thread_info, + _thread_policy, _thread_policy_get, _thread_policy_set, _thread_resume, + _thread_sample, _thread_self_trap, _thread_selfcounts, _thread_set_exception_ports, + _thread_set_mach_voucher, _thread_set_policy, _thread_set_special_port, + _thread_set_state, _thread_suspend, _thread_swap_exception_ports, + _thread_swap_mach_voucher, _thread_switch, _thread_terminate, + _thread_wire, _truncate, _umask, _undelete, _unlink, _unlinkat, + _unmount, _usrctl, _utimensat, _utimes, _vfork, _vfs_purge, + _vm_allocate, _vm_allocate_cpm, _vm_behavior_set, _vm_copy, + _vm_deallocate, _vm_inherit, _vm_kernel_page_mask, _vm_kernel_page_shift, + _vm_kernel_page_size, _vm_machine_attribute, _vm_map, _vm_map_page_query, + _vm_msync, _vm_page_mask, _vm_page_shift, _vm_page_size, _vm_pressure_monitor, + _vm_protect, _vm_purgable_control, _vm_read, _vm_read_list, + _vm_read_overwrite, _vm_region_64, _vm_region_recurse_64, + _vm_remap, _vm_wire, _vm_write, _voucher_mach_msg_adopt, _voucher_mach_msg_clear, + _voucher_mach_msg_revert, _voucher_mach_msg_set, _vprintf_stderr_func, + _wait4, _waitid, '_waitid$NOCANCEL', _work_interval_copy_port, + _work_interval_create, _work_interval_destroy, _work_interval_get_flags_from_port, + _work_interval_instance_alloc, _work_interval_instance_clear, + _work_interval_instance_finish, _work_interval_instance_free, + _work_interval_instance_get_complexity, _work_interval_instance_get_deadline, + _work_interval_instance_get_finish, _work_interval_instance_get_id, + _work_interval_instance_get_start, _work_interval_instance_set_complexity, + _work_interval_instance_set_deadline, _work_interval_instance_set_finish, + _work_interval_instance_set_start, _work_interval_instance_start, + _work_interval_instance_update, _work_interval_join, _work_interval_join_port, + _work_interval_leave, _work_interval_notify, _work_interval_notify_simple, + _write, '_write$NOCANCEL', _writev, '_writev$NOCANCEL' ] + - targets: [ arm64-maccatalyst, arm64-macos, arm64e-maccatalyst, arm64e-macos ] + symbols: [ ___fstat, ___fstatat, ___fstatfs, ___getfsstat, ___lstat, + ___stat, ___statfs, __current_pid, _mach_absolute_time_kernel, + _mach_continuous_time_kernel ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, x86_64h-macos, x86_64h-maccatalyst, + arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 0F98499E-662F-36EC-AB58-91A8D5A0FB74 + - target: x86_64-maccatalyst + value: 0F98499E-662F-36EC-AB58-91A8D5A0FB74 + - target: x86_64h-macos + value: 79820D9E-0FF1-3F20-AF4F-F87EE20CE8C9 + - target: x86_64h-maccatalyst + value: 79820D9E-0FF1-3F20-AF4F-F87EE20CE8C9 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 129930A8-F06B-3AD4-BA84-21549591F87A + - target: arm64e-maccatalyst + value: 129930A8-F06B-3AD4-BA84-21549591F87A +install-name: '/usr/lib/system/libsystem_m.dylib' +current-version: 3186.40.2 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, x86_64h-macos, x86_64h-maccatalyst, + arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, x86_64h-macos, x86_64-maccatalyst, x86_64h-maccatalyst ] + symbols: [ __FE_DFL_DISABLE_SSE_DENORMS_ENV, ___cos_d4, ___cos_f8, ___fpclassify, + ___inf, ___inff, ___infl, ___isfinite, ___isinf, ___isnan, + ___isnormal, ___nan, ___signbit, ___sin_d4, ___sin_f8, __simd_acos_d4, + __simd_acos_d8, __simd_acos_f16, __simd_acos_f8, __simd_acosh_d4, + __simd_acosh_d8, __simd_acosh_f16, __simd_acosh_f8, __simd_asin_d4, + __simd_asin_d8, __simd_asin_f16, __simd_asin_f8, __simd_asinh_d4, + __simd_asinh_d8, __simd_asinh_f16, __simd_asinh_f8, __simd_atan2_d4, + __simd_atan2_d8, __simd_atan2_f16, __simd_atan2_f8, __simd_atan_d4, + __simd_atan_d8, __simd_atan_f16, __simd_atan_f8, __simd_atanh_d4, + __simd_atanh_d8, __simd_atanh_f16, __simd_atanh_f8, __simd_cbrt_d4, + __simd_cbrt_d8, __simd_cbrt_f16, __simd_cbrt_f8, __simd_cos_d4, + __simd_cos_d8, __simd_cos_f16, __simd_cos_f8, __simd_cosh_d4, + __simd_cosh_d8, __simd_cosh_f16, __simd_cosh_f8, __simd_cospi_d4, + __simd_cospi_d8, __simd_cospi_f16, __simd_cospi_f8, __simd_erf_d4, + __simd_erf_d8, __simd_erf_f16, __simd_erf_f8, __simd_erfc_d4, + __simd_erfc_d8, __simd_erfc_f16, __simd_erfc_f8, __simd_exp10_d4, + __simd_exp10_d8, __simd_exp10_f16, __simd_exp10_f8, __simd_exp2_d4, + __simd_exp2_d8, __simd_exp2_f16, __simd_exp2_f8, __simd_exp_d4, + __simd_exp_d8, __simd_exp_f16, __simd_exp_f8, __simd_expm1_d4, + __simd_expm1_d8, __simd_expm1_f16, __simd_expm1_f8, __simd_fmod_d4, + __simd_fmod_d8, __simd_fmod_f16, __simd_fmod_f8, __simd_hypot_d4, + __simd_hypot_d8, __simd_hypot_f16, __simd_hypot_f8, __simd_log10_d4, + __simd_log10_d8, __simd_log10_f16, __simd_log10_f8, __simd_log1p_d4, + __simd_log1p_d8, __simd_log1p_f16, __simd_log1p_f8, __simd_log2_d4, + __simd_log2_d8, __simd_log2_f16, __simd_log2_f8, __simd_log_d4, + __simd_log_d8, __simd_log_f16, __simd_log_f8, __simd_nextafter_d4, + __simd_nextafter_d8, __simd_nextafter_f16, __simd_nextafter_f8, + __simd_pow_d4, __simd_pow_d8, __simd_pow_f16, __simd_pow_f8, + __simd_remainder_d4, __simd_remainder_d8, __simd_remainder_f16, + __simd_remainder_f8, __simd_round_d4, __simd_round_d8, __simd_round_f16, + __simd_round_f8, __simd_sin_d4, __simd_sin_d8, __simd_sin_f16, + __simd_sin_f8, __simd_sinh_d4, __simd_sinh_d8, __simd_sinh_f16, + __simd_sinh_f8, __simd_sinpi_d4, __simd_sinpi_d8, __simd_sinpi_f16, + __simd_sinpi_f8, __simd_tan_d4, __simd_tan_d8, __simd_tan_f16, + __simd_tan_f8, __simd_tanh_d4, __simd_tanh_d8, __simd_tanh_f16, + __simd_tanh_f8, __simd_tanpi_d4, __simd_tanpi_d8, __simd_tanpi_f16, + __simd_tanpi_f8, __simd_tgamma_d4, __simd_tgamma_d8, __simd_tgamma_f16, + __simd_tgamma_f8, '_acos$fenv_access_off', '_acosf$fenv_access_off', + '_acosh$fenv_access_off', '_acoshf$fenv_access_off', '_acoshl$fenv_access_off', + '_acosl$fenv_access_off', '_asin$fenv_access_off', '_asinf$fenv_access_off', + '_asinh$fenv_access_off', '_asinhf$fenv_access_off', '_asinhl$fenv_access_off', + '_asinl$fenv_access_off', '_atan$fenv_access_off', '_atan2$fenv_access_off', + '_atan2f$fenv_access_off', '_atan2l$fenv_access_off', '_atanf$fenv_access_off', + '_atanh$fenv_access_off', '_atanhf$fenv_access_off', '_atanhl$fenv_access_off', + '_atanl$fenv_access_off', '_cabs$fenv_access_off', '_cabsf$fenv_access_off', + '_cabsl$fenv_access_off', '_cacos$fenv_access_off', '_cacosf$fenv_access_off', + '_cacosh$fenv_access_off', '_cacoshf$fenv_access_off', '_cacoshl$fenv_access_off', + '_cacosl$fenv_access_off', '_carg$fenv_access_off', '_cargf$fenv_access_off', + '_cargl$fenv_access_off', '_casin$fenv_access_off', '_casinf$fenv_access_off', + '_casinh$fenv_access_off', '_casinhf$fenv_access_off', '_casinhl$fenv_access_off', + '_casinl$fenv_access_off', '_catan$fenv_access_off', '_catanf$fenv_access_off', + '_catanh$fenv_access_off', '_catanhf$fenv_access_off', '_catanhl$fenv_access_off', + '_catanl$fenv_access_off', '_cbrt$fenv_access_off', '_cbrtf$fenv_access_off', + '_cbrtl$fenv_access_off', '_ccos$fenv_access_off', '_ccosf$fenv_access_off', + '_ccosh$fenv_access_off', '_ccoshf$fenv_access_off', '_ccoshl$fenv_access_off', + '_ccosl$fenv_access_off', '_ceil$fenv_access_off', '_ceilf$fenv_access_off', + '_ceill$fenv_access_off', '_cexp$fenv_access_off', '_cexpf$fenv_access_off', + '_cexpl$fenv_access_off', '_cimag$fenv_access_off', '_cimagf$fenv_access_off', + '_cimagl$fenv_access_off', '_clog$fenv_access_off', '_clogf$fenv_access_off', + '_clogl$fenv_access_off', '_conj$fenv_access_off', '_conjf$fenv_access_off', + '_conjl$fenv_access_off', '_copysign$fenv_access_off', '_copysignf$fenv_access_off', + '_copysignl$fenv_access_off', '_cos$fenv_access_off', '_cosf$fenv_access_off', + '_cosh$fenv_access_off', '_coshf$fenv_access_off', '_coshl$fenv_access_off', + '_cosl$fenv_access_off', '_cpow$fenv_access_off', '_cpowf$fenv_access_off', + '_cpowl$fenv_access_off', '_cproj$fenv_access_off', '_cprojf$fenv_access_off', + '_cprojl$fenv_access_off', '_creal$fenv_access_off', '_crealf$fenv_access_off', + '_creall$fenv_access_off', '_csin$fenv_access_off', '_csinf$fenv_access_off', + '_csinh$fenv_access_off', '_csinhf$fenv_access_off', '_csinhl$fenv_access_off', + '_csinl$fenv_access_off', '_csqrt$fenv_access_off', '_csqrtf$fenv_access_off', + '_csqrtl$fenv_access_off', '_ctan$fenv_access_off', '_ctanf$fenv_access_off', + '_ctanh$fenv_access_off', '_ctanhf$fenv_access_off', '_ctanhl$fenv_access_off', + '_ctanl$fenv_access_off', _drem, '_erf$fenv_access_off', '_erfc$fenv_access_off', + '_erfcf$fenv_access_off', '_erfcl$fenv_access_off', '_erff$fenv_access_off', + '_erfl$fenv_access_off', '_exp$fenv_access_off', '_exp2$fenv_access_off', + '_exp2f$fenv_access_off', '_exp2l$fenv_access_off', '_expf$fenv_access_off', + '_expl$fenv_access_off', '_expm1$fenv_access_off', '_expm1f$fenv_access_off', + '_expm1l$fenv_access_off', '_fabs$fenv_access_off', '_fabsf$fenv_access_off', + '_fabsl$fenv_access_off', '_fdim$fenv_access_off', '_fdimf$fenv_access_off', + '_fdiml$fenv_access_off', _fegetexcept, _fesetexcept, _finite, + '_floor$fenv_access_off', '_floorf$fenv_access_off', '_floorl$fenv_access_off', + '_fma$fenv_access_off', '_fmaf$fenv_access_off', '_fmal$fenv_access_off', + '_fmax$fenv_access_off', '_fmaxf$fenv_access_off', '_fmaxl$fenv_access_off', + '_fmin$fenv_access_off', '_fminf$fenv_access_off', '_fminl$fenv_access_off', + '_fmod$fenv_access_off', '_fmodf$fenv_access_off', '_fmodl$fenv_access_off', + '_frexp$fenv_access_off', '_frexpf$fenv_access_off', '_frexpl$fenv_access_off', + _gamma, '_gamma$fenv_access_off', '_hypot$fenv_access_off', + '_hypotf$fenv_access_off', '_hypotl$fenv_access_off', '_ilogb$fenv_access_off', + '_ilogbf$fenv_access_off', '_ilogbl$fenv_access_off', '_ldexp$fenv_access_off', + '_ldexpf$fenv_access_off', '_ldexpl$fenv_access_off', '_lgamma$fenv_access_off', + '_lgamma_r$fenv_access_off', '_lgammaf$fenv_access_off', '_lgammaf_r$fenv_access_off', + '_lgammal$fenv_access_off', '_lgammal_r$fenv_access_off', + '_llrint$fenv_access_off', '_llrintf$fenv_access_off', '_llrintl$fenv_access_off', + '_llround$fenv_access_off', '_llroundf$fenv_access_off', '_llroundl$fenv_access_off', + '_log$fenv_access_off', '_log10$fenv_access_off', '_log10f$fenv_access_off', + '_log10l$fenv_access_off', '_log1p$fenv_access_off', '_log1pf$fenv_access_off', + '_log1pl$fenv_access_off', '_log2$fenv_access_off', '_log2f$fenv_access_off', + '_log2l$fenv_access_off', '_logb$fenv_access_off', '_logbf$fenv_access_off', + '_logbl$fenv_access_off', '_logf$fenv_access_off', '_logl$fenv_access_off', + '_lrint$fenv_access_off', '_lrintf$fenv_access_off', '_lrintl$fenv_access_off', + '_lround$fenv_access_off', '_lroundf$fenv_access_off', '_lroundl$fenv_access_off', + _matherr, '_modf$fenv_access_off', '_modff$fenv_access_off', + '_modfl$fenv_access_off', '_nearbyint$fenv_access_off', '_nearbyintf$fenv_access_off', + '_nearbyintl$fenv_access_off', '_nextafter$fenv_access_off', + _nextafterd, '_nextafterf$fenv_access_off', '_nextafterl$fenv_access_off', + '_nexttoward$fenv_access_off', '_nexttowardf$fenv_access_off', + '_nexttowardl$fenv_access_off', '_pow$fenv_access_off', '_powf$fenv_access_off', + '_powl$fenv_access_off', '_remainder$fenv_access_off', '_remainderf$fenv_access_off', + '_remainderl$fenv_access_off', '_remquo$fenv_access_off', + '_remquof$fenv_access_off', '_remquol$fenv_access_off', '_rint$fenv_access_off', + '_rintf$fenv_access_off', '_rintl$fenv_access_off', _rinttol, + '_round$fenv_access_off', '_roundf$fenv_access_off', '_roundl$fenv_access_off', + _roundtol, '_scalbln$fenv_access_off', '_scalblnf$fenv_access_off', + '_scalblnl$fenv_access_off', '_scalbn$fenv_access_off', '_scalbnf$fenv_access_off', + '_scalbnl$fenv_access_off', _significand, '_sin$fenv_access_off', + '_sinf$fenv_access_off', '_sinh$fenv_access_off', '_sinhf$fenv_access_off', + '_sinhl$fenv_access_off', '_sinl$fenv_access_off', '_sqrt$fenv_access_off', + '_sqrtf$fenv_access_off', '_sqrtl$fenv_access_off', '_tan$fenv_access_off', + '_tanf$fenv_access_off', '_tanh$fenv_access_off', '_tanhf$fenv_access_off', + '_tanhl$fenv_access_off', '_tanl$fenv_access_off', '_tgamma$fenv_access_off', + '_tgammaf$fenv_access_off', '_tgammal$fenv_access_off', '_trunc$fenv_access_off', + '_truncf$fenv_access_off', '_truncl$fenv_access_off' ] + - targets: [ x86_64-macos, arm64e-macos, x86_64h-macos, x86_64-maccatalyst, + x86_64h-maccatalyst, arm64e-maccatalyst, arm64-macos, arm64-maccatalyst ] + symbols: [ __FE_DFL_ENV, ___Libm_version, ___cos_d2, ___cos_f4, ___cospi, + ___cospif, ___exp10, ___exp10f, ___fegetfltrounds, ___fpclassifyd, + ___fpclassifyf, ___fpclassifyl, ___inline_isfinited, ___inline_isfinitef, + ___inline_isfinitel, ___inline_isinfd, ___inline_isinff, ___inline_isinfl, + ___inline_isnand, ___inline_isnanf, ___inline_isnanl, ___inline_isnormald, + ___inline_isnormalf, ___inline_isnormall, ___inline_signbitd, + ___inline_signbitf, ___inline_signbitl, ___invert_d2, ___invert_d3, + ___invert_d4, ___invert_f2, ___invert_f3, ___invert_f4, ___isfinited, + ___isfinitef, ___isfinitel, ___isinfd, ___isinff, ___isinfl, + ___isnand, ___isnanf, ___isnanl, ___isnormald, ___isnormalf, + ___isnormall, ___math_errhandling, ___signbitd, ___signbitf, + ___signbitl, ___sin_d2, ___sin_f4, ___sincos, ___sincos_stret, + ___sincosf, ___sincosf_stret, ___sincospi, ___sincospi_stret, + ___sincospif, ___sincospif_stret, ___sinpi, ___sinpif, ___tanpi, + ___tanpif, __simd_acos_d2, __simd_acos_f4, __simd_acosh_d2, + __simd_acosh_f4, __simd_asin_d2, __simd_asin_f4, __simd_asinh_d2, + __simd_asinh_f4, __simd_atan2_d2, __simd_atan2_f4, __simd_atan_d2, + __simd_atan_f4, __simd_atanh_d2, __simd_atanh_f4, __simd_cbrt_d2, + __simd_cbrt_f4, __simd_cos_d2, __simd_cos_f4, __simd_cosh_d2, + __simd_cosh_f4, __simd_cospi_d2, __simd_cospi_f4, __simd_erf_d2, + __simd_erf_f4, __simd_erfc_d2, __simd_erfc_f4, __simd_exp10_d2, + __simd_exp10_f4, __simd_exp2_d2, __simd_exp2_f4, __simd_exp_d2, + __simd_exp_f4, __simd_expm1_d2, __simd_expm1_f4, __simd_fma_d2, + __simd_fma_f4, __simd_fmod_d2, __simd_fmod_f4, __simd_hypot_d2, + __simd_hypot_f4, __simd_incircle_pd2, __simd_incircle_pf2, + __simd_insphere_pd3, __simd_insphere_pf3, __simd_log10_d2, + __simd_log10_f4, __simd_log1p_d2, __simd_log1p_f4, __simd_log2_d2, + __simd_log2_f4, __simd_log_d2, __simd_log_f4, __simd_nextafter_d2, + __simd_nextafter_f4, __simd_orient_pd2, __simd_orient_pd3, + __simd_orient_pf2, __simd_orient_pf3, __simd_orient_vd2, __simd_orient_vd3, + __simd_orient_vf2, __simd_orient_vf3, __simd_pow_d2, __simd_pow_f4, + __simd_remainder_d2, __simd_remainder_f4, __simd_round_d2, + __simd_round_f4, __simd_sin_d2, __simd_sin_f4, __simd_sinh_d2, + __simd_sinh_f4, __simd_sinpi_d2, __simd_sinpi_f4, __simd_tan_d2, + __simd_tan_f4, __simd_tanh_d2, __simd_tanh_f4, __simd_tanpi_d2, + __simd_tanpi_f4, __simd_tgamma_d2, __simd_tgamma_f4, _acos, + _acosf, _acosh, _acoshf, _acoshl, _acosl, _asin, _asinf, _asinh, + _asinhf, _asinhl, _asinl, _atan, _atan2, _atan2f, _atan2l, + _atanf, _atanh, _atanhf, _atanhl, _atanl, _cabs, _cabsf, _cabsl, + _cacos, _cacosf, _cacosh, _cacoshf, _cacoshl, _cacosl, _carg, + _cargf, _cargl, _casin, _casinf, _casinh, _casinhf, _casinhl, + _casinl, _catan, _catanf, _catanh, _catanhf, _catanhl, _catanl, + _cbrt, _cbrtf, _cbrtl, _ccos, _ccosf, _ccosh, _ccoshf, _ccoshl, + _ccosl, _ceil, _ceilf, _ceill, _cexp, _cexpf, _cexpl, _cimag, + _cimagf, _cimagl, _clog, _clogf, _clogl, _conj, _conjf, _conjl, + _copysign, _copysignf, _copysignl, _cos, _cosf, _cosh, _coshf, + _coshl, _cosl, _cpow, _cpowf, _cpowl, _cproj, _cprojf, _cprojl, + _creal, _crealf, _creall, _csin, _csinf, _csinh, _csinhf, + _csinhl, _csinl, _csqrt, _csqrtf, _csqrtl, _ctan, _ctanf, + _ctanh, _ctanhf, _ctanhl, _ctanl, _erf, _erfc, _erfcf, _erfcl, + _erff, _erfl, _exp, _exp2, _exp2f, _exp2l, _expf, _expl, _expm1, + _expm1f, _expm1l, _fabs, _fabsf, _fabsl, _fdim, _fdimf, _fdiml, + _feclearexcept, _fegetenv, _fegetexceptflag, _fegetround, + _feholdexcept, _feraiseexcept, _fesetenv, _fesetexceptflag, + _fesetround, _fetestexcept, _feupdateenv, _floor, _floorf, + _floorl, _fma, _fmaf, _fmal, _fmax, _fmaxf, _fmaxl, _fmin, + _fminf, _fminl, _fmod, _fmodf, _fmodl, _frexp, _frexpf, _frexpl, + _hypot, _hypotf, _hypotl, _ilogb, _ilogbf, _ilogbl, _isinf, + _isnan, _j0, _j1, _jn, _ldexp, _ldexpf, _ldexpl, _lgamma, + _lgamma_r, _lgammaf, _lgammaf_r, _lgammal, _lgammal_r, _llrint, + _llrintf, _llrintl, _llround, _llroundf, _llroundl, _log, + _log10, _log10f, _log10l, _log1p, _log1pf, _log1pl, _log2, + _log2f, _log2l, _logb, _logbf, _logbl, _logf, _logl, _lrint, + _lrintf, _lrintl, _lround, _lroundf, _lroundl, _matrix_identity_double2x2, + _matrix_identity_double3x3, _matrix_identity_double4x4, _matrix_identity_float2x2, + _matrix_identity_float3x3, _matrix_identity_float4x4, _modf, + _modff, _modfl, _nan, _nanf, _nanl, _nearbyint, _nearbyintf, + _nearbyintl, _nextafter, _nextafterf, _nextafterl, _nexttoward, + _nexttowardf, _nexttowardl, _pow, _powf, _powl, _remainder, + _remainderf, _remainderl, _remquo, _remquof, _remquol, _rint, + _rintf, _rintl, _round, _roundf, _roundl, _scalb, _scalbln, + _scalblnf, _scalblnl, _scalbn, _scalbnf, _scalbnl, _signgam, + _sin, _sinf, _sinh, _sinhf, _sinhl, _sinl, _sqrt, _sqrtf, + _sqrtl, _tan, _tanf, _tanh, _tanhf, _tanhl, _tanl, _tgamma, + _tgammaf, _tgammal, _trunc, _truncf, _truncl, _y0, _y1, _yn ] + - targets: [ arm64e-macos, arm64e-maccatalyst, arm64-macos, arm64-maccatalyst ] + symbols: [ __FE_DFL_DISABLE_DENORMS_ENV ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 2EF43B96-90FB-3C50-B73E-035238504E33 + - target: x86_64-maccatalyst + value: 2EF43B96-90FB-3C50-B73E-035238504E33 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: E47334AF-7E46-3FAE-B71C-9D9B4F1DF1DE + - target: arm64e-maccatalyst + value: E47334AF-7E46-3FAE-B71C-9D9B4F1DF1DE +install-name: '/usr/lib/system/libsystem_malloc.dylib' +current-version: 317.40.8 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ ___mach_stack_logging_copy_uniquing_table, ___mach_stack_logging_enumerate_records, + ___mach_stack_logging_frames_for_uniqued_stack, ___mach_stack_logging_get_frames, + ___mach_stack_logging_get_frames_for_stackid, ___mach_stack_logging_set_file_path, + ___mach_stack_logging_shared_memory_address, ___mach_stack_logging_stackid_for_vm_region, + ___mach_stack_logging_start_reading, ___mach_stack_logging_stop_reading, + ___mach_stack_logging_uniquing_table_copy_from_serialized, + ___mach_stack_logging_uniquing_table_read_stack, ___mach_stack_logging_uniquing_table_release, + ___mach_stack_logging_uniquing_table_retain, ___mach_stack_logging_uniquing_table_serialize, + ___mach_stack_logging_uniquing_table_sizeof, ___malloc_init, + ___stack_logging_early_finished, __malloc_fork_child, __malloc_fork_parent, + __malloc_fork_prepare, __malloc_no_asl_log, __os_cpu_number_override, + _aligned_alloc, _calloc, _free, _mag_set_thread_index, _malloc, + _malloc_check_counter, _malloc_check_each, _malloc_check_start, + _malloc_claimed_address, _malloc_create_legacy_default_zone, + _malloc_create_zone, _malloc_debug, _malloc_default_purgeable_zone, + _malloc_default_zone, _malloc_destroy_zone, _malloc_engaged_nano, + _malloc_enter_process_memory_limit_warn_mode, _malloc_error, + _malloc_freezedry, _malloc_get_all_zones, _malloc_get_zone_name, + _malloc_good_size, _malloc_jumpstart, _malloc_logger, _malloc_make_nonpurgeable, + _malloc_make_purgeable, _malloc_memory_event_handler, _malloc_num_zones, + _malloc_num_zones_allocated, _malloc_printf, _malloc_register_stack_logger, + _malloc_set_zone_name, _malloc_singlethreaded, _malloc_size, + _malloc_zone_batch_free, _malloc_zone_batch_malloc, _malloc_zone_calloc, + _malloc_zone_check, _malloc_zone_claimed_address, _malloc_zone_disable_discharge_checking, + _malloc_zone_discharge, _malloc_zone_enable_discharge_checking, + _malloc_zone_enumerate_discharged_pointers, _malloc_zone_free, + _malloc_zone_from_ptr, _malloc_zone_log, _malloc_zone_malloc, + _malloc_zone_memalign, _malloc_zone_pressure_relief, _malloc_zone_print, + _malloc_zone_print_ptr_info, _malloc_zone_realloc, _malloc_zone_register, + _malloc_zone_statistics, _malloc_zone_unregister, _malloc_zone_valloc, + _malloc_zones, _mstats, _pgm_diagnose_fault_from_crash_reporter, + _posix_memalign, _realloc, '_reallocarray$DARWIN_EXTSN', '_reallocarrayf$DARWIN_EXTSN', + _scalable_zone_info, _scalable_zone_statistics, _set_malloc_singlethreaded, + _stack_logging_enable_logging, _szone_check_counter, _szone_check_modulo, + _szone_check_start, _tiny_print_region_free_list, _turn_off_stack_logging, + _turn_on_stack_logging, _valloc, _vfree, _zeroify_scalable_zone ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: F476B1CB-3561-30C5-A78E-44E99B1720A3 + - target: x86_64-maccatalyst + value: F476B1CB-3561-30C5-A78E-44E99B1720A3 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 399ACCA2-77CA-3A30-9930-1382F8DBBAD3 + - target: arm64e-maccatalyst + value: 399ACCA2-77CA-3A30-9930-1382F8DBBAD3 +install-name: '/usr/lib/system/libsystem_networkextension.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _NEHelperCacheAddRedirectedAddress, _NEHelperCacheClearRedirectedAddresses, + _NEHelperCacheClearUUIDs, _NEHelperCacheCopyAppUUIDMapping, + _NEHelperCacheCopyAppUUIDMappingExtended, _NEHelperCacheCopyAppUUIDMappingForUIDExtended, + _NEHelperCacheCopySigningIdentifierMapping, _NEHelperCacheSetDomainDictionaries, + _NEHelperCacheSetRoutes, _NEHelperCopyAggregatePathRules, + _NEHelperCopyAppInfo, _NEHelperCopyCurrentNetworkAsync, _NEHelperCopyCurrentNetworkInfo, + _NEHelperCopyPerAppDomains, _NEHelperCopyPreferredBundleID, + _NEHelperCopyResponse, _NEHelperCopyResponseAndCancel, _NEHelperGetIKESocket, + _NEHelperGetIKESocketWithResult, _NEHelperGetKernelControlSocket, + _NEHelperGetKernelControlSocketExtended, _NEHelperGetNECPSessionFD, + _NEHelperGetPFKeySocket, _NEHelperHandleConfigurationsChangedBySC, + _NEHelperInit, _NEHelperInterfaceRemoveAddress, _NEHelperInterfaceSetAddress, + _NEHelperInterfaceSetMTU, _NEHelperInterfaceSetOption, _NEHelperSendRequest, + _NEHelperSettingsSetArray, _NEHelperSettingsSetBool, _NEHelperSettingsSetNumber, + _NEHelperVPNConfigurationExists, _NEHelperVPNSetEnabled, _g_ne_read_uuid_cache, + _g_ne_uuid_cache_hit, _ne_copy_cached_bundle_identifier_for_uuid, + _ne_copy_cached_preferred_bundle_for_bundle_identifier, _ne_copy_cached_uuids_for_bundle_identifier, + _ne_copy_signature_info_for_pid, _ne_copy_signing_identifier_for_pid, + _ne_copy_uuid_cache, _ne_force_reset_uuid_cache, _ne_get_configuration_generation, + _ne_is_sockaddr_valid, _ne_log_large_obj, _ne_log_obj, _ne_print_backtrace, + _ne_session_add_necp_drop_dest_from_path, _ne_session_address_matches_subnets, + _ne_session_agent_get_advisory, _ne_session_agent_get_advisory_interface_index, + _ne_session_always_on_vpn_configs_present, _ne_session_always_on_vpn_configs_present_at_boot, + _ne_session_app_vpn_configs_present, _ne_session_cancel, _ne_session_content_filter_configs_present, + _ne_session_copy_app_data_from_flow_divert_socket, _ne_session_copy_app_data_from_flow_divert_token, + _ne_session_copy_policy_match, _ne_session_copy_security_session_info, + _ne_session_copy_socket_attributes, _ne_session_create, _ne_session_disable_restrictions, + _ne_session_dns_proxy_configs_present, _ne_session_dns_settings_configs_present, + _ne_session_establish_ipc, _ne_session_fallback_advisory, + _ne_session_fallback_default, _ne_session_get_config_id_from_network_agent, + _ne_session_get_configuration_id, _ne_session_get_info, _ne_session_get_info2, + _ne_session_get_status, _ne_session_info_type_to_string, _ne_session_initialize_necp_drop_all, + _ne_session_is_always_on_vpn_enabled, _ne_session_is_safeboot, + _ne_session_local_communication_configs_present, _ne_session_local_communication_send_info, + _ne_session_manager_get_pid, _ne_session_manager_has_active_sessions, + _ne_session_manager_is_running, _ne_session_on_demand_configs_present, + _ne_session_path_controller_configs_present, _ne_session_policy_copy_flow_divert_token, + _ne_session_policy_copy_flow_divert_token_with_key, _ne_session_policy_match_get_filter_unit, + _ne_session_policy_match_get_flow_divert_unit, _ne_session_policy_match_get_scoped_interface_index, + _ne_session_policy_match_get_service, _ne_session_policy_match_get_service_action, + _ne_session_policy_match_get_service_type, _ne_session_policy_match_is_drop, + _ne_session_policy_match_is_flow_divert, _ne_session_policy_match_service_is_registered, + _ne_session_release, _ne_session_retain, _ne_session_send_barrier, + _ne_session_service_get_dns_service_id, _ne_session_service_get_dns_service_id_for_interface, + _ne_session_service_matches_address, _ne_session_service_matches_address_for_interface, + _ne_session_set_event_handler, _ne_session_set_socket_attributes, + _ne_session_should_disable_nexus, _ne_session_start, _ne_session_start_on_behalf_of, + _ne_session_start_with_options, _ne_session_status_to_string, + _ne_session_stop, _ne_session_stop_all_with_plugin_type, _ne_session_stop_reason_to_string, + _ne_session_type_to_string, _ne_session_use_as_system_vpn, + _ne_session_vpn_include_all_networks_configs_present, _nehelper_copy_connection, + _nehelper_queue, _nelog_is_debug_logging_enabled, _nelog_is_extra_vpn_logging_enabled, + _nelog_is_info_logging_enabled ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 98D74EEF-60D9-3665-B877-7BE1558BA83E + - target: x86_64-maccatalyst + value: 98D74EEF-60D9-3665-B877-7BE1558BA83E + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: C8ADD6C0-5150-359F-8A38-AEAA3351AA5C + - target: arm64e-maccatalyst + value: C8ADD6C0-5150-359F-8A38-AEAA3351AA5C +install-name: '/usr/lib/system/libsystem_notify.dylib' +current-version: 279.40.4 +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ __notify_fork_child, _notify_cancel, _notify_check, _notify_dump_status, + _notify_get_event, _notify_get_state, _notify_is_valid_token, + _notify_monitor_file, _notify_peek, _notify_post, _notify_register_check, + _notify_register_dispatch, _notify_register_file_descriptor, + _notify_register_mach_port, _notify_register_plain, _notify_register_signal, + _notify_resume, _notify_resume_pid, _notify_set_options, _notify_set_state, + _notify_simple_post, _notify_suspend, _notify_suspend_pid ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 3F7F6461-7B5C-3197-ACD7-C8A0CFCC6F55 + - target: x86_64-maccatalyst + value: 3F7F6461-7B5C-3197-ACD7-C8A0CFCC6F55 + - target: arm64-macos + value: BE741EB0-93DC-3787-A097-82EF092CD45C + - target: arm64-maccatalyst + value: BE741EB0-93DC-3787-A097-82EF092CD45C + - target: arm64e-macos + value: 089E074F-F575-3853-B081-B3B0A23FDA61 + - target: arm64e-maccatalyst + value: 089E074F-F575-3853-B081-B3B0A23FDA61 +install-name: '/usr/lib/system/libsystem_platform.dylib' +current-version: 254.60.1 +parent-umbrella: + - targets: [ i386-macos, i386-maccatalyst, x86_64-macos, x86_64-maccatalyst, + arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos ] + symbols: [ '_OSAtomicFifoDequeue$VARIANT$PFZ', '_OSAtomicFifoDequeue$VARIANT$UnfairLock', + '_OSAtomicFifoEnqueue$VARIANT$PFZ', '_OSAtomicFifoEnqueue$VARIANT$UnfairLock', + __sigtramp, _bzero_sse_np, _longjmperror, _memmove_sse_np, + _memset_pattern16_sse_np, _memset_pattern4_sse_np, _memset_pattern8_sse_np, + _memset_sse_np ] + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64-maccatalyst, arm64-macos, + arm64e-maccatalyst, arm64e-macos ] + symbols: [ _OSAtomicAdd32, _OSAtomicAdd32Barrier, _OSAtomicAdd64, _OSAtomicAdd64Barrier, + _OSAtomicAnd32, _OSAtomicAnd32Barrier, _OSAtomicAnd32Orig, + _OSAtomicAnd32OrigBarrier, _OSAtomicCompareAndSwap32, _OSAtomicCompareAndSwap32Barrier, + _OSAtomicCompareAndSwap64, _OSAtomicCompareAndSwap64Barrier, + _OSAtomicCompareAndSwapInt, _OSAtomicCompareAndSwapIntBarrier, + _OSAtomicCompareAndSwapLong, _OSAtomicCompareAndSwapLongBarrier, + _OSAtomicCompareAndSwapPtr, _OSAtomicCompareAndSwapPtrBarrier, + _OSAtomicDecrement32, _OSAtomicDecrement32Barrier, _OSAtomicDecrement64, + _OSAtomicDecrement64Barrier, _OSAtomicDequeue, _OSAtomicEnqueue, + _OSAtomicFifoDequeue, _OSAtomicFifoEnqueue, _OSAtomicIncrement32, + _OSAtomicIncrement32Barrier, _OSAtomicIncrement64, _OSAtomicIncrement64Barrier, + _OSAtomicOr32, _OSAtomicOr32Barrier, _OSAtomicOr32Orig, _OSAtomicOr32OrigBarrier, + _OSAtomicTestAndClear, _OSAtomicTestAndClearBarrier, _OSAtomicTestAndSet, + _OSAtomicTestAndSetBarrier, _OSAtomicXor32, _OSAtomicXor32Barrier, + _OSAtomicXor32Orig, _OSAtomicXor32OrigBarrier, _OSMemoryBarrier, + _OSSpinLockLock, _OSSpinLockTry, _OSSpinLockUnlock, __OSSpinLockLockSlow, + ___bzero, ___libplatform_init, ___os_once_reset, ___platform_sigaction, + __longjmp, __os_alloc_once, __os_lock_type_eliding, __os_lock_type_handoff, + __os_lock_type_nospin, __os_lock_type_spin, __os_lock_type_transactional, + __os_lock_type_unfair, __os_nospin_lock_lock, __os_nospin_lock_trylock, + __os_nospin_lock_unlock, __os_once, __os_semaphore_create, + __os_semaphore_dispose, __os_semaphore_signal, __os_semaphore_wait, + __platform_bzero, __platform_memccpy, __platform_memchr, __platform_memcmp, + __platform_memmove, __platform_memset, __platform_memset_pattern16, + __platform_memset_pattern4, __platform_memset_pattern8, __platform_strchr, + __platform_strcmp, __platform_strcpy, __platform_strlcat, + __platform_strlcpy, __platform_strlen, __platform_strncmp, + __platform_strncpy, __platform_strnlen, __platform_strstr, + __setjmp, __simple_asl_log, __simple_asl_log_prog, __simple_asl_msg_new, + __simple_asl_msg_set, __simple_asl_send, __simple_dprintf, + __simple_esappend, __simple_esprintf, __simple_getenv, __simple_put, + __simple_putline, __simple_salloc, __simple_sappend, __simple_sfree, + __simple_sprintf, __simple_sresize, __simple_string, __simple_vdprintf, + __simple_vesprintf, __simple_vsprintf, __spin_lock, __spin_lock_try, + __spin_unlock, _ffs, _ffsl, _ffsll, _fls, _flsl, _flsll, _getcontext, + _longjmp, _makecontext, _os_lock_lock, _os_lock_trylock, _os_lock_unlock, + _os_unfair_lock_assert_not_owner, _os_unfair_lock_assert_owner, + _os_unfair_lock_lock, _os_unfair_lock_lock_no_tsd, _os_unfair_lock_lock_with_options, + _os_unfair_lock_trylock, _os_unfair_lock_unlock, _os_unfair_lock_unlock_no_tsd, + _os_unfair_recursive_lock_lock_with_options, _os_unfair_recursive_lock_owned, + _os_unfair_recursive_lock_trylock, _os_unfair_recursive_lock_tryunlock4objc, + _os_unfair_recursive_lock_unlock, _os_unfair_recursive_lock_unlock_forked_child, + _platform_task_attach, _platform_task_copy_next_thread, _platform_task_detach, + _platform_task_is_64_bit, _platform_task_perform, _platform_task_resume_threads, + _platform_task_suspend_threads, _platform_task_update_threads, + _platform_thread_abort_safely, _platform_thread_get_pthread, + _platform_thread_get_state, _platform_thread_get_unique_id, + _platform_thread_info, _platform_thread_perform, _platform_thread_release, + _platform_thread_resume, _platform_thread_set_state, _platform_thread_suspend, + _setcontext, _setjmp, _siglongjmp, _sigsetjmp, _spin_lock, + _spin_lock_try, _spin_unlock, _swapcontext, _sys_cache_control, + _sys_dcache_flush, _sys_icache_invalidate ] + - targets: [ arm64-maccatalyst, arm64-macos, arm64e-maccatalyst, arm64e-macos ] + symbols: [ __ctx_done ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 7CCAF1A8-F570-341E-B275-0C80B092F8E0 + - target: x86_64-maccatalyst + value: 7CCAF1A8-F570-341E-B275-0C80B092F8E0 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: BF4F283D-1B0C-3A5A-8DAC-CFB3096CEDB4 + - target: arm64e-maccatalyst + value: BF4F283D-1B0C-3A5A-8DAC-CFB3096CEDB4 +install-name: '/usr/lib/system/libsystem_product_info_filter.dylib' +current-version: 8.40.1 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 8DD3A0BC-2C92-31E3-BBAB-CE923A4342E4 + - target: x86_64-maccatalyst + value: 8DD3A0BC-2C92-31E3-BBAB-CE923A4342E4 + - target: arm64-macos + value: 7EDAEC3F-03BB-3E2D-8DBD-6F86979C566F + - target: arm64-maccatalyst + value: 7EDAEC3F-03BB-3E2D-8DBD-6F86979C566F + - target: arm64e-macos + value: EDB716F3-BF94-3941-B7DA-D6C91094C645 + - target: arm64e-maccatalyst + value: EDB716F3-BF94-3941-B7DA-D6C91094C645 +install-name: '/usr/lib/system/libsystem_pthread.dylib' +current-version: 454.60.1 +parent-umbrella: + - targets: [ i386-macos, x86_64-macos, x86_64-maccatalyst, arm64-macos, + arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + symbols: [ __pthread_is_threaded, _cthread_yield ] + - targets: [ arm64-macos, x86_64-macos, arm64e-macos, x86_64-maccatalyst, + arm64-maccatalyst, arm64e-maccatalyst ] + symbols: [ ____chkstk_darwin, ___is_threaded, ___pthread_init, ___pthread_workqueue_setkill, + ___unix_conforming, __pthread_atfork_child, __pthread_atfork_child_handlers, + __pthread_atfork_parent, __pthread_atfork_parent_handlers, + __pthread_atfork_prepare, __pthread_atfork_prepare_handlers, + __pthread_clear_qos_tsd, __pthread_exit_if_canceled, __pthread_fork_child, + __pthread_fork_child_postinit, __pthread_fork_parent, __pthread_fork_prepare, + __pthread_mutex_enable_legacy_mode, __pthread_override_qos_class_end_direct, + __pthread_override_qos_class_start_direct, __pthread_qos_class_decode, + __pthread_qos_class_encode, __pthread_qos_class_encode_workqueue, + __pthread_qos_override_end_direct, __pthread_qos_override_start_direct, + __pthread_self, __pthread_set_properties_self, __pthread_set_self, + __pthread_setspecific_static, __pthread_start, __pthread_workloop_create, + __pthread_workloop_destroy, __pthread_workqueue_addthreads, + __pthread_workqueue_asynchronous_override_add, __pthread_workqueue_asynchronous_override_reset_all_self, + __pthread_workqueue_asynchronous_override_reset_self, __pthread_workqueue_init, + __pthread_workqueue_init_with_kevent, __pthread_workqueue_init_with_workloop, + __pthread_workqueue_override_reset, __pthread_workqueue_override_start_direct, + __pthread_workqueue_override_start_direct_check_owner, __pthread_workqueue_set_event_manager_priority, + __pthread_workqueue_should_narrow, __pthread_workqueue_supported, + __pthread_wqthread, _posix_spawnattr_get_qos_class_np, _posix_spawnattr_set_qos_class_np, + _pthread_atfork, _pthread_attr_destroy, _pthread_attr_get_qos_class_np, + _pthread_attr_getdetachstate, _pthread_attr_getguardsize, + _pthread_attr_getinheritsched, _pthread_attr_getschedparam, + _pthread_attr_getschedpolicy, _pthread_attr_getscope, _pthread_attr_getstack, + _pthread_attr_getstackaddr, _pthread_attr_getstacksize, _pthread_attr_init, + _pthread_attr_set_qos_class_np, _pthread_attr_setcpupercent_np, + _pthread_attr_setdetachstate, _pthread_attr_setguardsize, + _pthread_attr_setinheritsched, _pthread_attr_setschedparam, + _pthread_attr_setschedpolicy, _pthread_attr_setscope, _pthread_attr_setstack, + _pthread_attr_setstackaddr, _pthread_attr_setstacksize, _pthread_cancel, + _pthread_chdir_np, _pthread_cond_broadcast, _pthread_cond_destroy, + _pthread_cond_init, _pthread_cond_signal, _pthread_cond_signal_thread_np, + _pthread_cond_timedwait, '_pthread_cond_timedwait$NOCANCEL', + _pthread_cond_timedwait_relative_np, _pthread_cond_wait, '_pthread_cond_wait$NOCANCEL', + _pthread_condattr_destroy, _pthread_condattr_getpshared, _pthread_condattr_init, + _pthread_condattr_setpshared, _pthread_cpu_number_np, _pthread_create, + _pthread_create_from_mach_thread, _pthread_create_suspended_np, + _pthread_current_stack_contains_np, _pthread_dependency_fulfill_np, + _pthread_dependency_init_np, _pthread_dependency_wait_np, + _pthread_detach, _pthread_equal, _pthread_exit, _pthread_fchdir_np, + _pthread_from_mach_thread_np, _pthread_get_qos_class_np, _pthread_get_stackaddr_np, + _pthread_get_stacksize_np, _pthread_getconcurrency, _pthread_getname_np, + _pthread_getschedparam, _pthread_getspecific, _pthread_introspection_getspecific_np, + _pthread_introspection_hook_install, _pthread_introspection_setspecific_np, + _pthread_is_threaded_np, _pthread_jit_write_protect_np, _pthread_jit_write_protect_supported_np, + _pthread_join, '_pthread_join$NOCANCEL', _pthread_key_create, + _pthread_key_delete, _pthread_key_init_np, _pthread_kill, + _pthread_layout_offsets, _pthread_mach_thread_np, _pthread_main_np, + _pthread_main_thread_np, _pthread_mutex_destroy, _pthread_mutex_getprioceiling, + _pthread_mutex_init, _pthread_mutex_lock, _pthread_mutex_setprioceiling, + _pthread_mutex_trylock, _pthread_mutex_unlock, _pthread_mutexattr_destroy, + _pthread_mutexattr_getpolicy_np, _pthread_mutexattr_getprioceiling, + _pthread_mutexattr_getprotocol, _pthread_mutexattr_getpshared, + _pthread_mutexattr_gettype, _pthread_mutexattr_init, _pthread_mutexattr_setpolicy_np, + _pthread_mutexattr_setprioceiling, _pthread_mutexattr_setprotocol, + _pthread_mutexattr_setpshared, _pthread_mutexattr_settype, + _pthread_once, _pthread_override_qos_class_end_np, _pthread_override_qos_class_start_np, + _pthread_prefer_alternate_amx_self, _pthread_qos_max_parallelism, + _pthread_rwlock_destroy, _pthread_rwlock_init, _pthread_rwlock_rdlock, + _pthread_rwlock_tryrdlock, _pthread_rwlock_trywrlock, _pthread_rwlock_unlock, + _pthread_rwlock_wrlock, _pthread_rwlockattr_destroy, _pthread_rwlockattr_getpshared, + _pthread_rwlockattr_init, _pthread_rwlockattr_setpshared, + _pthread_self, _pthread_self_is_exiting_np, _pthread_set_fixedpriority_self, + _pthread_set_qos_class_np, _pthread_set_qos_class_self_np, + _pthread_set_timeshare_self, _pthread_setcancelstate, _pthread_setcanceltype, + _pthread_setconcurrency, _pthread_setname_np, _pthread_setschedparam, + _pthread_setspecific, _pthread_sigmask, _pthread_stack_frame_decode_np, + _pthread_testcancel, _pthread_threadid_np, _pthread_time_constraint_max_parallelism, + _pthread_workqueue_addthreads_np, _pthread_workqueue_setdispatch_np, + _pthread_workqueue_setdispatchoffset_np, _pthread_workqueue_setup, + _pthread_yield_np, _qos_class_main, _qos_class_self, _sched_get_priority_max, + _sched_get_priority_min, _sched_yield, _sigwait, '_sigwait$NOCANCEL', + _start_wqthread, _thread_chkstk_darwin, _thread_start ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 8CE27199-D633-31D2-AB08-56380A1DA9FB + - target: x86_64-maccatalyst + value: 8CE27199-D633-31D2-AB08-56380A1DA9FB + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 0EE4CE47-4715-3EE3-93CA-F4863FE29A5C + - target: arm64e-maccatalyst + value: 0EE4CE47-4715-3EE3-93CA-F4863FE29A5C +install-name: '/usr/lib/system/libsystem_sandbox.dylib' +current-version: 1441.60.4 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ _APP_SANDBOX_IOKIT_CLIENT, _APP_SANDBOX_MACH, _APP_SANDBOX_READ, + _APP_SANDBOX_READ_WRITE, _IOS_SANDBOX_APPLICATION_GROUP, _IOS_SANDBOX_CONTAINER, + _SANDBOX_CHECK_ALLOW_APPROVAL, _SANDBOX_CHECK_CANONICAL, _SANDBOX_CHECK_NOFOLLOW, + _SANDBOX_CHECK_NO_APPROVAL, _SANDBOX_CHECK_NO_REPORT, _SANDBOX_EXTENSION_CANONICAL, + _SANDBOX_EXTENSION_DEFAULT, _SANDBOX_EXTENSION_MACL_LEARNING, + _SANDBOX_EXTENSION_MAGIC, _SANDBOX_EXTENSION_NOFOLLOW, _SANDBOX_EXTENSION_NO_REPORT, + _SANDBOX_EXTENSION_NO_STORAGE_CLASS, _SANDBOX_EXTENSION_PREFIXMATCH, + _SANDBOX_EXTENSION_UNRESOLVED, _SANDBOX_EXTENSION_USER_INTENT, + __amkrtemp, __sandbox_in_a_container, _gpu_bundle_find_trusted, + _gpu_bundle_is_path_trusted, _kSBXProfileNoInternet, _kSBXProfileNoNetwork, + _kSBXProfileNoWrite, _kSBXProfileNoWriteExceptTemporary, _kSBXProfilePureComputation, + _rootless_allows_task_for_pid, _rootless_apply, _rootless_apply_internal, + _rootless_apply_relative, _rootless_check_datavault_flag, + _rootless_check_restricted_flag, _rootless_check_trusted, + _rootless_check_trusted_class, _rootless_check_trusted_fd, + _rootless_convert_to_datavault, _rootless_manifest_free, _rootless_manifest_parse, + _rootless_mkdir_datavault, _rootless_mkdir_nounlink, _rootless_mkdir_restricted, + _rootless_preflight, _rootless_protected_volume, _rootless_register_trusted_storage_class, + _rootless_restricted_environment, _rootless_suspend, _rootless_trusted_by_self_token, + _rootless_verify_trusted_by_self_token, _sandbox_builtin_query, + _sandbox_check, _sandbox_check_bulk, _sandbox_check_by_audit_token, + _sandbox_check_by_reference, _sandbox_check_by_uniqueid, _sandbox_check_message_filter_integer, + _sandbox_check_message_filter_string, _sandbox_consume_extension, + _sandbox_consume_fs_extension, _sandbox_consume_mach_extension, + _sandbox_container_path_for_audit_token, _sandbox_container_path_for_pid, + _sandbox_enable_root_translation, _sandbox_extension_consume, + _sandbox_extension_issue_file, _sandbox_extension_issue_file_to_process, + _sandbox_extension_issue_file_to_process_by_pid, _sandbox_extension_issue_file_to_self, + _sandbox_extension_issue_generic, _sandbox_extension_issue_generic_to_process, + _sandbox_extension_issue_generic_to_process_by_pid, _sandbox_extension_issue_iokit_registry_entry_class, + _sandbox_extension_issue_iokit_registry_entry_class_to_process, + _sandbox_extension_issue_iokit_registry_entry_class_to_process_by_pid, + _sandbox_extension_issue_iokit_user_client_class, _sandbox_extension_issue_mach, + _sandbox_extension_issue_mach_to_process, _sandbox_extension_issue_mach_to_process_by_pid, + _sandbox_extension_issue_posix_ipc, _sandbox_extension_reap, + _sandbox_extension_release, _sandbox_extension_release_file, + _sandbox_extension_update_file, _sandbox_free_error, _sandbox_init, + _sandbox_init_from_pid, _sandbox_init_with_extensions, _sandbox_init_with_parameters, + _sandbox_issue_extension, _sandbox_issue_fs_extension, _sandbox_issue_fs_rw_extension, + _sandbox_issue_mach_extension, _sandbox_message_filter_query, + _sandbox_message_filter_release, _sandbox_note, _sandbox_passthrough_access, + _sandbox_proc_getcontainer, _sandbox_proc_getprofilename, + _sandbox_query_approval_policy_for_path, _sandbox_query_user_intent_for_process_with_audit_token, + _sandbox_reference_release, _sandbox_reference_retain_by_audit_token, + _sandbox_release_fs_extension, _sandbox_requests_integrity_protection_for_preference_domain, + _sandbox_set_container_path_for_application_group, _sandbox_set_container_path_for_application_group_with_persona, + _sandbox_set_container_path_for_signing_id, _sandbox_set_container_path_for_signing_id_with_persona, + _sandbox_spawnattrs_getcontainer, _sandbox_spawnattrs_getprofilename, + _sandbox_spawnattrs_init, _sandbox_spawnattrs_setcontainer, + _sandbox_spawnattrs_setprofilename, _sandbox_suspend, _sandbox_unsuspend ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 99B5FD99-1A8B-37C1-BD70-04990FA33B1C + - target: x86_64-maccatalyst + value: 99B5FD99-1A8B-37C1-BD70-04990FA33B1C + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 04EF7D20-ABBD-3DB1-B990-278887044735 + - target: arm64e-maccatalyst + value: 04EF7D20-ABBD-3DB1-B990-278887044735 +install-name: '/usr/lib/system/libsystem_secinit.dylib' +current-version: 87.60.1 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ __libsecinit_initializer, _libsecinit_delete_all_data_container_content_for_current_user, + _libsecinit_fileoperation_save, _libsecinit_fileoperation_set_attributes, + _libsecinit_fileoperation_symlink ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 88F35AAC-746F-3176-81DF-49CE3D285636 + - target: x86_64-maccatalyst + value: 88F35AAC-746F-3176-81DF-49CE3D285636 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: CF9E7636-168A-36DD-95F0-6CA76B91D3DC + - target: arm64e-maccatalyst + value: CF9E7636-168A-36DD-95F0-6CA76B91D3DC +install-name: '/usr/lib/system/libsystem_symptoms.dylib' +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-macos, arm64e-macos, x86_64-maccatalyst, arm64e-maccatalyst, + arm64-macos, arm64-maccatalyst ] + symbols: [ __symptoms_daemon_fallback_initial_disposition, __symptoms_daemon_fallback_subseq_disposition, + __symptoms_is_daemon_fallback_blacklisted, _symptom_framework_init, + _symptom_framework_set_version, _symptom_new, _symptom_send, + _symptom_send_immediate, _symptom_set_additional_qualifier, + _symptom_set_qualifier ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 48C14376-626E-3C81-B0F5-7416E64580C7 + - target: x86_64-maccatalyst + value: 48C14376-626E-3C81-B0F5-7416E64580C7 + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: D67123A1-A8BC-329C-BC76-830E95EBA1B3 + - target: arm64e-maccatalyst + value: D67123A1-A8BC-329C-BC76-830E95EBA1B3 +install-name: '/usr/lib/system/libsystem_trace.dylib' +current-version: 1277.50.1 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ __libtrace_fork_child, __libtrace_init, __os_activity_create, + __os_activity_current, __os_activity_initiate, __os_activity_initiate_f, + __os_activity_label_useraction, __os_activity_none, __os_activity_set_breadcrumb, + __os_activity_start, __os_activity_stream_entry_encode, __os_log_create, + __os_log_debug, __os_log_debug_impl, __os_log_default, __os_log_disabled, + __os_log_error, __os_log_error_impl, __os_log_fault, __os_log_fault_impl, + __os_log_impl, __os_log_internal, __os_log_pack_fill, __os_log_pack_size, + __os_log_preferences_compute, __os_log_preferences_load, __os_log_release, + __os_log_set_nscf_formatter, __os_signpost_emit_impl, __os_signpost_emit_unreliably_impl, + __os_signpost_emit_unreliably_with_name_impl, __os_signpost_emit_with_name_impl, + __os_signpost_pack_fill, __os_signpost_pack_send, __os_state_request_for_pidlist, + __os_trace_atm_diagnostic_config, __os_trace_basesystem_storage_available, + __os_trace_calloc, __os_trace_commpage_compute, __os_trace_fdscandir_b, + __os_trace_get_boot_uuid, __os_trace_get_image_info, __os_trace_get_mode_for_pid, + __os_trace_get_times_now, __os_trace_getxattr_at, __os_trace_intprefsdir_path, + __os_trace_is_development_build, __os_trace_log_simple, __os_trace_macho_for_each_slice, + __os_trace_malloc, __os_trace_memdup, __os_trace_mmap, __os_trace_mmap_at, + __os_trace_mmap_offset, __os_trace_mode_match_4tests, __os_trace_prefs_latest_version_4tests, + __os_trace_prefsdir_path, __os_trace_read_file_at, __os_trace_read_plist_at, + __os_trace_realloc, __os_trace_scandir_free_namelist, __os_trace_set_diagnostic_flags, + __os_trace_set_mode_for_pid, __os_trace_strdup, __os_trace_sysprefsdir_path, + __os_trace_update_with_datavolume_4launchd, __os_trace_with_buffer, + __os_trace_write, __os_trace_writev, __os_trace_zalloc, _os_activity_apply, + _os_activity_apply_f, _os_activity_diagnostic_for_pid, _os_activity_end, + _os_activity_for_task_thread, _os_activity_for_thread, _os_activity_get_active, + _os_activity_get_identifier, _os_activity_iterate_activities, + _os_activity_iterate_breadcrumbs, _os_activity_iterate_messages, + _os_activity_iterate_processes, _os_activity_messages_for_thread, + _os_activity_scope_enter, _os_activity_scope_leave, _os_log_backtrace_copy_description, + _os_log_backtrace_copy_serialized_buffer, _os_log_backtrace_create_from_buffer, + _os_log_backtrace_create_from_current, _os_log_backtrace_create_from_pcs, + _os_log_backtrace_create_from_return_address, _os_log_backtrace_destroy, + _os_log_backtrace_get_frames, _os_log_backtrace_get_length, + _os_log_backtrace_print_to_blob, _os_log_backtrace_serialize_to_blob, + _os_log_create, _os_log_errors_count, _os_log_fault_default_callback, + _os_log_faults_count, _os_log_fmt_compose, _os_log_fmt_convert_trace, + _os_log_fmt_extract_pubdata, _os_log_fmt_get_plugin, _os_log_get_type, + _os_log_is_debug_enabled, _os_log_is_enabled, _os_log_pack_compose, + _os_log_pack_send, _os_log_pack_send_and_compose, _os_log_set_client_type, + _os_log_set_enabled, _os_log_set_fault_callback, _os_log_shim_enabled, + _os_log_shim_legacy_logging_enabled, _os_log_shim_with_CFString, + _os_log_type_enabled, _os_log_with_args, _os_signpost_enabled, + _os_signpost_id_generate, _os_signpost_id_make_with_pointer, + _os_signpost_set_introspection_hook_4Perf, _os_state_add_handler, + _os_state_remove_handler, _os_trace_debug_enabled, _os_trace_get_code, + _os_trace_get_mode, _os_trace_get_type, _os_trace_info_enabled, + _os_trace_set_mode ] + objc-classes: [ OS_os_log ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: C5792A9C-DF0F-3821-BC14-238A78462E8A + - target: x86_64-maccatalyst + value: C5792A9C-DF0F-3821-BC14-238A78462E8A + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: 21A28401-C508-38BE-A7CF-C2A56AB3C311 + - target: arm64e-maccatalyst + value: 21A28401-C508-38BE-A7CF-C2A56AB3C311 +install-name: '/usr/lib/system/libunwind.dylib' +current-version: 200.10 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos ] + symbols: [ '$ld$hide$os10.4$__Unwind_Backtrace', '$ld$hide$os10.4$__Unwind_DeleteException', + '$ld$hide$os10.4$__Unwind_FindEnclosingFunction', '$ld$hide$os10.4$__Unwind_Find_FDE', + '$ld$hide$os10.4$__Unwind_ForcedUnwind', '$ld$hide$os10.4$__Unwind_GetCFA', + '$ld$hide$os10.4$__Unwind_GetDataRelBase', '$ld$hide$os10.4$__Unwind_GetGR', + '$ld$hide$os10.4$__Unwind_GetIP', '$ld$hide$os10.4$__Unwind_GetIPInfo', + '$ld$hide$os10.4$__Unwind_GetLanguageSpecificData', '$ld$hide$os10.4$__Unwind_GetRegionStart', + '$ld$hide$os10.4$__Unwind_GetTextRelBase', '$ld$hide$os10.4$__Unwind_RaiseException', + '$ld$hide$os10.4$__Unwind_Resume', '$ld$hide$os10.4$__Unwind_Resume_or_Rethrow', + '$ld$hide$os10.4$__Unwind_SetGR', '$ld$hide$os10.4$__Unwind_SetIP', + '$ld$hide$os10.4$___deregister_frame', '$ld$hide$os10.4$___deregister_frame_info', + '$ld$hide$os10.4$___deregister_frame_info_bases', '$ld$hide$os10.4$___register_frame', + '$ld$hide$os10.4$___register_frame_info', '$ld$hide$os10.4$___register_frame_info_bases', + '$ld$hide$os10.4$___register_frame_info_table', '$ld$hide$os10.4$___register_frame_info_table_bases', + '$ld$hide$os10.4$___register_frame_table', '$ld$hide$os10.5$__Unwind_Backtrace', + '$ld$hide$os10.5$__Unwind_DeleteException', '$ld$hide$os10.5$__Unwind_FindEnclosingFunction', + '$ld$hide$os10.5$__Unwind_Find_FDE', '$ld$hide$os10.5$__Unwind_ForcedUnwind', + '$ld$hide$os10.5$__Unwind_GetCFA', '$ld$hide$os10.5$__Unwind_GetDataRelBase', + '$ld$hide$os10.5$__Unwind_GetGR', '$ld$hide$os10.5$__Unwind_GetIP', + '$ld$hide$os10.5$__Unwind_GetIPInfo', '$ld$hide$os10.5$__Unwind_GetLanguageSpecificData', + '$ld$hide$os10.5$__Unwind_GetRegionStart', '$ld$hide$os10.5$__Unwind_GetTextRelBase', + '$ld$hide$os10.5$__Unwind_RaiseException', '$ld$hide$os10.5$__Unwind_Resume', + '$ld$hide$os10.5$__Unwind_Resume_or_Rethrow', '$ld$hide$os10.5$__Unwind_SetGR', + '$ld$hide$os10.5$__Unwind_SetIP', '$ld$hide$os10.5$___deregister_frame', + '$ld$hide$os10.5$___deregister_frame_info', '$ld$hide$os10.5$___deregister_frame_info_bases', + '$ld$hide$os10.5$___register_frame', '$ld$hide$os10.5$___register_frame_info', + '$ld$hide$os10.5$___register_frame_info_bases', '$ld$hide$os10.5$___register_frame_info_table', + '$ld$hide$os10.5$___register_frame_info_table_bases', '$ld$hide$os10.5$___register_frame_table', + '$ld$hide$os10.6$___deregister_frame_info', '$ld$hide$os10.6$___deregister_frame_info_bases', + '$ld$hide$os10.6$___register_frame_info', '$ld$hide$os10.6$___register_frame_info_bases', + '$ld$hide$os10.6$___register_frame_info_table', '$ld$hide$os10.6$___register_frame_info_table_bases', + '$ld$hide$os10.6$___register_frame_table', ___deregister_frame_info, + ___deregister_frame_info_bases, ___register_frame_info, ___register_frame_info_bases, + ___register_frame_info_table, ___register_frame_info_table_bases, + ___register_frame_table ] + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ __Unwind_Backtrace, __Unwind_DeleteException, __Unwind_FindEnclosingFunction, + __Unwind_Find_FDE, __Unwind_ForcedUnwind, __Unwind_GetCFA, + __Unwind_GetDataRelBase, __Unwind_GetGR, __Unwind_GetIP, __Unwind_GetIPInfo, + __Unwind_GetLanguageSpecificData, __Unwind_GetRegionStart, + __Unwind_GetTextRelBase, __Unwind_RaiseException, __Unwind_Resume, + __Unwind_Resume_or_Rethrow, __Unwind_SetGR, __Unwind_SetIP, + ___deregister_frame, ___register_frame, ___unw_add_dynamic_fde, + ___unw_remove_dynamic_fde, _unw_get_fpreg, _unw_get_proc_info, + _unw_get_proc_name, _unw_get_reg, _unw_getcontext, _unw_init_local, + _unw_is_fpreg, _unw_is_signal_frame, _unw_iterate_dwarf_unwind_cache, + _unw_local_addr_space, _unw_regname, _unw_resume, _unw_set_fpreg, + _unw_set_reg, _unw_step ] +--- !tapi-tbd +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: 003A027D-9CE3-3794-A319-88495844662D + - target: x86_64-maccatalyst + value: 003A027D-9CE3-3794-A319-88495844662D + - target: arm64-macos + value: 00000000-0000-0000-0000-000000000000 + - target: arm64-maccatalyst + value: 00000000-0000-0000-0000-000000000000 + - target: arm64e-macos + value: D87D7BAA-9E73-3A84-8247-3456B703C302 + - target: arm64e-maccatalyst + value: D87D7BAA-9E73-3A84-8247-3456B703C302 +install-name: '/usr/lib/system/libxpc.dylib' +current-version: 2038.40.38 +parent-umbrella: + - targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] + umbrella: System +exports: + - targets: [ x86_64-maccatalyst, x86_64-macos, arm64e-maccatalyst, arm64e-macos, + arm64-macos, arm64-maccatalyst ] + symbols: [ _XPC_ACTIVITY_ALLOW_BATTERY, _XPC_ACTIVITY_APP_REFRESH, _XPC_ACTIVITY_CHECK_IN, + _XPC_ACTIVITY_COMMUNICATES_WITH_PAIRED_DEVICE, _XPC_ACTIVITY_CPU_INTENSIVE, + _XPC_ACTIVITY_DELAY, _XPC_ACTIVITY_DESIRED_MOTION_STATE, _XPC_ACTIVITY_DISK_INTENSIVE, + _XPC_ACTIVITY_DO_IT_LATER, _XPC_ACTIVITY_DUET_ACTIVITY_SCHEDULER_DATA, + _XPC_ACTIVITY_DUET_ATTRIBUTE_COST, _XPC_ACTIVITY_DUET_ATTRIBUTE_NAME, + _XPC_ACTIVITY_DUET_ATTRIBUTE_VALUE, _XPC_ACTIVITY_DUET_RELATED_APPLICATIONS, + _XPC_ACTIVITY_EXCLUSIVE, _XPC_ACTIVITY_EXPECTED_DURATION, + _XPC_ACTIVITY_GRACE_PERIOD, _XPC_ACTIVITY_GROUP_CONCURRENCY_LIMIT, + _XPC_ACTIVITY_GROUP_NAME, _XPC_ACTIVITY_INTERVAL, _XPC_ACTIVITY_INTERVAL_15_MIN, + _XPC_ACTIVITY_INTERVAL_1_DAY, _XPC_ACTIVITY_INTERVAL_1_HOUR, + _XPC_ACTIVITY_INTERVAL_1_MIN, _XPC_ACTIVITY_INTERVAL_30_MIN, + _XPC_ACTIVITY_INTERVAL_4_HOURS, _XPC_ACTIVITY_INTERVAL_5_MIN, + _XPC_ACTIVITY_INTERVAL_7_DAYS, _XPC_ACTIVITY_INTERVAL_8_HOURS, + _XPC_ACTIVITY_MAY_REBOOT_DEVICE, _XPC_ACTIVITY_MEMORY_INTENSIVE, + _XPC_ACTIVITY_MOTION_STATE_AUTOMOTIVE, _XPC_ACTIVITY_MOTION_STATE_AUTOMOTIVE_MOVING, + _XPC_ACTIVITY_MOTION_STATE_AUTOMOTIVE_STATIONARY, _XPC_ACTIVITY_MOTION_STATE_CYCLING, + _XPC_ACTIVITY_MOTION_STATE_RUNNING, _XPC_ACTIVITY_MOTION_STATE_STATIONARY, + _XPC_ACTIVITY_MOTION_STATE_WALKING, _XPC_ACTIVITY_NETWORK_TRANSFER_BIDIRECTIONAL, + _XPC_ACTIVITY_NETWORK_TRANSFER_DIRECTION, _XPC_ACTIVITY_NETWORK_TRANSFER_DIRECTION_DOWNLOAD, + _XPC_ACTIVITY_NETWORK_TRANSFER_DIRECTION_UPLOAD, _XPC_ACTIVITY_NETWORK_TRANSFER_ENDPOINT, + _XPC_ACTIVITY_NETWORK_TRANSFER_PARAMETERS, _XPC_ACTIVITY_NETWORK_TRANSFER_SIZE, + _XPC_ACTIVITY_POST_INSTALL, _XPC_ACTIVITY_POWER_NAP, _XPC_ACTIVITY_PRIORITY, + _XPC_ACTIVITY_PRIORITY_MAINTENANCE, _XPC_ACTIVITY_PRIORITY_UTILITY, + _XPC_ACTIVITY_RANDOM_INITIAL_DELAY, _XPC_ACTIVITY_REPEATING, + _XPC_ACTIVITY_REPLY_ENDPOINT, _XPC_ACTIVITY_REQUIRES_BUDDY_COMPLETE, + _XPC_ACTIVITY_REQUIRES_CLASS_A, _XPC_ACTIVITY_REQUIRES_CLASS_B, + _XPC_ACTIVITY_REQUIRES_CLASS_C, _XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL, + _XPC_ACTIVITY_REQUIRE_HDD_SPINNING, _XPC_ACTIVITY_REQUIRE_INEXPENSIVE_NETWORK_CONNECTIVITY, + _XPC_ACTIVITY_REQUIRE_NETWORK_CONNECTIVITY, _XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP, + _XPC_ACTIVITY_REQUIRE_SIGNIFICANT_USER_INACTIVITY, _XPC_ACTIVITY_RUN_WHEN_APP_FOREGROUNDED, + _XPC_ACTIVITY_SEQUENCE_NUMBER, _XPC_ACTIVITY_SHOULD_WAKE_DEVICE, + _XPC_ACTIVITY_USER_REQUESTED_BACKUP_TASK, _XPC_ACTIVITY_USES_DUET_POWER_BUDGETING, + _XPC_COALITION_INFO_KEY_BUNDLE_IDENTIFIER, _XPC_COALITION_INFO_KEY_CID, + _XPC_COALITION_INFO_KEY_NAME, _XPC_COALITION_INFO_KEY_RESOURCE_USAGE_BLOB, + __availability_version_check, __launch_job_routine, __launch_job_routine_async, + __launch_msg2, __launch_service_stats_copy_4ppse_impl, __libxpc_initializer, + __spawn_via_launchd, __system_ios_support_version_copy_string_sysctl, + __system_version_copy_string_plist, __system_version_copy_string_sysctl, + __system_version_fallback, __system_version_parse_string, + __vproc_get_last_exit_status, __vproc_grab_subset, __vproc_kickstart_by_label, + __vproc_log, __vproc_log_error, __vproc_logv, __vproc_pid_is_managed, + __vproc_post_fork_ping, __vproc_send_signal_by_label, __vproc_set_global_on_demand, + __vproc_standby_begin, __vproc_standby_count, __vproc_standby_end, + __vproc_standby_timeout, __vproc_transaction_begin, __vproc_transaction_count, + __vproc_transaction_count_for_pid, __vproc_transaction_end, + __vproc_transaction_set_clean_callback, __vproc_transaction_try_exit, + __vproc_transactions_enable, __vprocmgr_detach_from_console, + __vprocmgr_getsocket, __vprocmgr_init, __vprocmgr_log_drain, + __vprocmgr_log_forward, __vprocmgr_move_subset_to_user, __vprocmgr_switch_to_session, + __xpc_bool_create_distinct, __xpc_bool_false, __xpc_bool_set_value, + __xpc_bool_true, __xpc_connection_set_event_handler_f, __xpc_data_set_value, + __xpc_dictionary_create_reply_with_port, __xpc_dictionary_extract_mach_send, + __xpc_dictionary_extract_reply_msg_id, __xpc_dictionary_extract_reply_port, + __xpc_dictionary_get_reply_msg_id, __xpc_dictionary_set_remote_connection, + __xpc_dictionary_set_reply_msg_id, __xpc_double_set_value, + __xpc_error_connection_interrupted, __xpc_error_connection_invalid, + __xpc_error_key_description, __xpc_error_termination_imminent, + __xpc_event_key_name, __xpc_event_key_stream_name, __xpc_fd_get_port, + __xpc_int64_set_value, __xpc_payload_create_from_mach_msg, + __xpc_pipe_handle_mig, __xpc_runtime_get_entitlements_data, + __xpc_runtime_get_self_entitlements, __xpc_runtime_is_app_sandboxed, + __xpc_service_last_xref_cancel, __xpc_service_routine, __xpc_shmem_get_mach_port, + __xpc_spawnattr_binprefs_pack, __xpc_spawnattr_binprefs_size, + __xpc_spawnattr_binprefs_unpack, __xpc_spawnattr_pack_string, + __xpc_spawnattr_pack_string_fragment, __xpc_spawnattr_unpack_string, + __xpc_spawnattr_unpack_strings, __xpc_string_set_value, __xpc_type_activity, + __xpc_type_array, __xpc_type_base, __xpc_type_bool, __xpc_type_bundle, + __xpc_type_connection, __xpc_type_data, __xpc_type_date, __xpc_type_dictionary, + __xpc_type_double, __xpc_type_endpoint, __xpc_type_error, + __xpc_type_fd, __xpc_type_file_transfer, __xpc_type_int64, + __xpc_type_mach_recv, __xpc_type_mach_send, __xpc_type_null, + __xpc_type_pipe, __xpc_type_pointer, __xpc_type_serializer, + __xpc_type_service, __xpc_type_service_instance, __xpc_type_shmem, + __xpc_type_string, __xpc_type_uint64, __xpc_type_uuid, __xpc_vtables, + _bootstrap_check_in, _bootstrap_check_in2, _bootstrap_check_in3, + _bootstrap_create_server, _bootstrap_create_service, _bootstrap_get_root, + _bootstrap_info, _bootstrap_init, _bootstrap_look_up, _bootstrap_look_up2, + _bootstrap_look_up3, _bootstrap_look_up_per_user, _bootstrap_lookup_children, + _bootstrap_parent, _bootstrap_register, _bootstrap_register2, + _bootstrap_status, _bootstrap_strerror, _bootstrap_subset, + _bootstrap_unprivileged, _create_and_switch_to_per_session_launchd, + _launch_activate_socket, _launch_add_external_service, _launch_bootout_user_service_4coresim, + _launch_copy_busy_extension_instances, _launch_copy_endpoints_properties_for_pid, + _launch_copy_extension_properties, _launch_copy_extension_properties_for_pid, + _launch_copy_properties_for_pid_4assertiond, _launch_create_persona, + _launch_data_alloc, _launch_data_array_get_count, _launch_data_array_get_index, + _launch_data_array_set_index, _launch_data_copy, _launch_data_dict_get_count, + _launch_data_dict_insert, _launch_data_dict_iterate, _launch_data_dict_lookup, + _launch_data_dict_remove, _launch_data_free, _launch_data_get_bool, + _launch_data_get_errno, _launch_data_get_fd, _launch_data_get_integer, + _launch_data_get_machport, _launch_data_get_opaque, _launch_data_get_opaque_size, + _launch_data_get_real, _launch_data_get_string, _launch_data_get_type, + _launch_data_new_bool, _launch_data_new_errno, _launch_data_new_fd, + _launch_data_new_integer, _launch_data_new_machport, _launch_data_new_opaque, + _launch_data_new_real, _launch_data_new_string, _launch_data_pack, + _launch_data_set_bool, _launch_data_set_errno, _launch_data_set_fd, + _launch_data_set_integer, _launch_data_set_machport, _launch_data_set_opaque, + _launch_data_set_real, _launch_data_set_string, _launch_data_unpack, + _launch_destroy_persona, _launch_disable_directory, _launch_enable_directory, + _launch_extension_check_in_live_4UIKit, _launch_extension_property_bundle_id, + _launch_extension_property_host_bundle_id, _launch_extension_property_host_pid, + _launch_extension_property_path, _launch_extension_property_pid, + _launch_extension_property_version, _launch_extension_property_xpc_bundle, + _launch_get_fd, _launch_get_service_enabled, _launch_get_system_service_enabled, + _launch_msg, _launch_path_for_user_service_4coresim, _launch_perfcheck_property_endpoint_active, + _launch_perfcheck_property_endpoint_event, _launch_perfcheck_property_endpoint_name, + _launch_perfcheck_property_endpoint_needs_activation, _launch_perfcheck_property_endpoints, + _launch_remove_external_service, _launch_service_instance_create, + _launch_service_instance_remove, _launch_service_stats_disable_4ppse, + _launch_service_stats_enable_4ppse, _launch_service_stats_is_enabled_4ppse, + _launch_set_service_enabled, _launch_set_system_service_enabled, + _launch_socket_service_check_in, _launch_version_for_user_service_4coresim, + _launch_wait, _launchd_close, _launchd_fdopen, _launchd_getfd, + _launchd_msg_recv, _launchd_msg_send, _load_launchd_jobs_at_loginwindow_prompt, + _mpm_uncork_fork, _mpm_wait, _os_system_version_get_current_version, + _os_system_version_get_ios_support_version, _os_system_version_sim_get_current_host_version, + _os_transaction_copy_description, _os_transaction_create, + _os_transaction_get_timestamp, _os_transaction_needs_more_time, + _place_hold_on_real_loginwindow, _reboot2, _reboot3, _vproc_release, + _vproc_retain, _vproc_standby_begin, _vproc_standby_end, _vproc_swap_complex, + _vproc_swap_integer, _vproc_swap_string, _vproc_transaction_begin, + _vproc_transaction_end, _vprocmgr_lookup_vproc, _xpc_activity_add_eligibility_changed_handler, + _xpc_activity_copy_criteria, _xpc_activity_copy_dispatch_queue, + _xpc_activity_copy_identifier, _xpc_activity_debug, _xpc_activity_defer_until_network_change, + _xpc_activity_defer_until_percentage, _xpc_activity_get_percentage, + _xpc_activity_get_state, _xpc_activity_list, _xpc_activity_register, + _xpc_activity_remove_eligibility_changed_handler, _xpc_activity_run, + _xpc_activity_set_completion_status, _xpc_activity_set_criteria, + _xpc_activity_set_network_threshold, _xpc_activity_set_state, + _xpc_activity_should_defer, _xpc_activity_unregister, _xpc_add_bundle, + _xpc_add_bundles_for_domain, _xpc_array_append_value, _xpc_array_apply, + _xpc_array_apply_f, _xpc_array_copy_mach_send, _xpc_array_create, + _xpc_array_create_connection, _xpc_array_create_empty, _xpc_array_dup_fd, + _xpc_array_get_array, _xpc_array_get_bool, _xpc_array_get_count, + _xpc_array_get_data, _xpc_array_get_date, _xpc_array_get_dictionary, + _xpc_array_get_double, _xpc_array_get_int64, _xpc_array_get_pointer, + _xpc_array_get_string, _xpc_array_get_uint64, _xpc_array_get_uuid, + _xpc_array_get_value, _xpc_array_set_bool, _xpc_array_set_connection, + _xpc_array_set_data, _xpc_array_set_date, _xpc_array_set_double, + _xpc_array_set_fd, _xpc_array_set_int64, _xpc_array_set_mach_send, + _xpc_array_set_pointer, _xpc_array_set_string, _xpc_array_set_uint64, + _xpc_array_set_uuid, _xpc_array_set_value, _xpc_atfork_child, + _xpc_atfork_parent, _xpc_atfork_prepare, _xpc_binprefs_add, + _xpc_binprefs_alloc, _xpc_binprefs_copy, _xpc_binprefs_copy_description, + _xpc_binprefs_count, _xpc_binprefs_cpu_subtype, _xpc_binprefs_cpu_type, + _xpc_binprefs_equal, _xpc_binprefs_init, _xpc_binprefs_is_noop, + _xpc_binprefs_set_psattr, _xpc_bool_create, _xpc_bool_get_value, + _xpc_bundle_copy_info_dictionary, _xpc_bundle_copy_resource_path, + _xpc_bundle_copy_services, _xpc_bundle_create, _xpc_bundle_create_from_origin, + _xpc_bundle_create_main, _xpc_bundle_get_error, _xpc_bundle_get_executable_path, + _xpc_bundle_get_info_dictionary, _xpc_bundle_get_path, _xpc_bundle_get_property, + _xpc_bundle_get_xpcservice_dictionary, _xpc_bundle_populate, + _xpc_bundle_resolve, _xpc_bundle_resolve_on_queue, _xpc_bundle_resolve_sync, + _xpc_coalition_copy_info, _xpc_coalition_history_pipe_async, + _xpc_connection_activate, _xpc_connection_cancel, _xpc_connection_copy_bundle_id, + _xpc_connection_copy_entitlement_value, _xpc_connection_create, + _xpc_connection_create_from_endpoint, _xpc_connection_create_listener, + _xpc_connection_create_mach_service, _xpc_connection_enable_sim2host_4sim, + _xpc_connection_enable_termination_imminent_event, _xpc_connection_get_asid, + _xpc_connection_get_audit_token, _xpc_connection_get_bs_type, + _xpc_connection_get_context, _xpc_connection_get_egid, _xpc_connection_get_euid, + _xpc_connection_get_instance, _xpc_connection_get_name, _xpc_connection_get_peer_instance, + _xpc_connection_get_pid, _xpc_connection_is_extension, _xpc_connection_kill, + _xpc_connection_resume, _xpc_connection_send_barrier, _xpc_connection_send_message, + _xpc_connection_send_message_with_reply, _xpc_connection_send_message_with_reply_sync, + _xpc_connection_send_notification, _xpc_connection_set_bootstrap, + _xpc_connection_set_bs_type, _xpc_connection_set_context, + _xpc_connection_set_event_channel, _xpc_connection_set_event_handler, + _xpc_connection_set_finalizer_f, _xpc_connection_set_instance, + _xpc_connection_set_instance_binpref, _xpc_connection_set_legacy, + _xpc_connection_set_non_launching, _xpc_connection_set_oneshot_instance, + _xpc_connection_set_privileged, _xpc_connection_set_qos_class_fallback, + _xpc_connection_set_qos_class_floor, _xpc_connection_set_target_queue, + _xpc_connection_set_target_uid, _xpc_connection_suspend, _xpc_copy, + _xpc_copy_bootstrap, _xpc_copy_clean_description, _xpc_copy_code_signing_identity_for_token, + _xpc_copy_debug_description, _xpc_copy_description, _xpc_copy_domain, + _xpc_copy_entitlement_for_self, _xpc_copy_entitlement_for_token, + _xpc_copy_entitlements_data_for_token, _xpc_copy_entitlements_for_pid, + _xpc_copy_entitlements_for_self, _xpc_copy_event, _xpc_copy_event_entitlements, + _xpc_copy_short_description, _xpc_create_from_plist, _xpc_create_from_plist_descriptor, + _xpc_create_from_serialization, _xpc_create_from_serialization_with_ool, + _xpc_create_reply_with_format, _xpc_create_reply_with_format_and_arguments, + _xpc_create_with_format, _xpc_create_with_format_and_arguments, + _xpc_data_create, _xpc_data_create_with_dispatch_data, _xpc_data_get_bytes, + _xpc_data_get_bytes_ptr, _xpc_data_get_inline_max, _xpc_data_get_length, + _xpc_date_create, _xpc_date_create_absolute, _xpc_date_create_from_current, + _xpc_date_get_value, _xpc_date_get_value_absolute, _xpc_date_is_int64_range, + _xpc_dictionary_apply, _xpc_dictionary_apply_f, _xpc_dictionary_copy_basic_description, + _xpc_dictionary_copy_mach_send, _xpc_dictionary_create, _xpc_dictionary_create_connection, + _xpc_dictionary_create_empty, _xpc_dictionary_create_reply, + _xpc_dictionary_dup_fd, _xpc_dictionary_expects_reply, _xpc_dictionary_extract_mach_recv, + _xpc_dictionary_get_array, _xpc_dictionary_get_audit_token, + _xpc_dictionary_get_bool, _xpc_dictionary_get_connection, + _xpc_dictionary_get_count, _xpc_dictionary_get_data, _xpc_dictionary_get_date, + _xpc_dictionary_get_dictionary, _xpc_dictionary_get_double, + _xpc_dictionary_get_int64, _xpc_dictionary_get_pointer, _xpc_dictionary_get_remote_connection, + _xpc_dictionary_get_string, _xpc_dictionary_get_uint64, _xpc_dictionary_get_uuid, + _xpc_dictionary_get_value, _xpc_dictionary_handoff_reply, + _xpc_dictionary_handoff_reply_f, _xpc_dictionary_send_reply, + _xpc_dictionary_set_bool, _xpc_dictionary_set_connection, + _xpc_dictionary_set_data, _xpc_dictionary_set_date, _xpc_dictionary_set_double, + _xpc_dictionary_set_fd, _xpc_dictionary_set_int64, _xpc_dictionary_set_mach_recv, + _xpc_dictionary_set_mach_send, _xpc_dictionary_set_pointer, + _xpc_dictionary_set_string, _xpc_dictionary_set_uint64, _xpc_dictionary_set_uuid, + _xpc_dictionary_set_value, _xpc_double_create, _xpc_double_get_value, + _xpc_endpoint_compare, _xpc_endpoint_copy_listener_port_4sim, + _xpc_endpoint_create, _xpc_endpoint_create_bs_named, _xpc_endpoint_create_mach_port_4sim, + _xpc_equal, _xpc_event_publisher_activate, _xpc_event_publisher_create, + _xpc_event_publisher_fire, _xpc_event_publisher_fire_noboost, + _xpc_event_publisher_fire_with_reply, _xpc_event_publisher_fire_with_reply_sync, + _xpc_event_publisher_get_subscriber_asid, _xpc_event_publisher_set_error_handler, + _xpc_event_publisher_set_handler, _xpc_event_publisher_set_initial_load_completed_handler_4remoted, + _xpc_event_publisher_set_subscriber_keepalive, _xpc_event_stream_check_in, + _xpc_event_stream_check_in2, _xpc_exit_reason_get_label, _xpc_extension_type_init, + _xpc_fd_create, _xpc_fd_dup, _xpc_file_transfer_cancel, _xpc_file_transfer_copy_io, + _xpc_file_transfer_create_with_fd, _xpc_file_transfer_create_with_path, + _xpc_file_transfer_get_size, _xpc_file_transfer_get_transfer_id, + _xpc_file_transfer_send_finished, _xpc_file_transfer_set_transport_writing_callbacks, + _xpc_file_transfer_write_finished, _xpc_file_transfer_write_to_fd, + _xpc_file_transfer_write_to_path, _xpc_generate_audit_token, + _xpc_get_attachment_endpoint, _xpc_get_class4NSXPC, _xpc_get_event_name, + _xpc_get_instance, _xpc_get_type, _xpc_handle_service, _xpc_handle_subservice, + _xpc_hash, _xpc_impersonate_user, _xpc_init_services, _xpc_inspect_copy_description, + _xpc_inspect_copy_description_local, _xpc_inspect_copy_short_description, + _xpc_inspect_copy_short_description_local, _xpc_install_remote_hooks, + _xpc_int64_create, _xpc_int64_get_value, _xpc_is_kind_of_xpc_object4NSXPC, + _xpc_mach_recv_create, _xpc_mach_recv_extract_right, _xpc_mach_send_copy_right, + _xpc_mach_send_create, _xpc_mach_send_create_with_disposition, + _xpc_mach_send_get_right, _xpc_main, _xpc_make_serialization, + _xpc_make_serialization_with_ool, _xpc_null_create, _xpc_pipe_create, + _xpc_pipe_create_from_port, _xpc_pipe_invalidate, _xpc_pipe_receive, + _xpc_pipe_routine, _xpc_pipe_routine_async, _xpc_pipe_routine_forward, + _xpc_pipe_routine_reply, _xpc_pipe_routine_with_flags, _xpc_pipe_simpleroutine, + _xpc_pipe_try_receive, _xpc_pointer_create, _xpc_pointer_get_value, + _xpc_receive_mach_msg, _xpc_receive_remote_msg, _xpc_release, + _xpc_retain, _xpc_service_attach, _xpc_service_create, _xpc_service_create_from_specifier, + _xpc_service_get_rendezvous_token, _xpc_service_instance_dup2, + _xpc_service_instance_get_context, _xpc_service_instance_get_host_pid, + _xpc_service_instance_get_pid, _xpc_service_instance_get_type, + _xpc_service_instance_is_configurable, _xpc_service_instance_run, + _xpc_service_instance_set_binpref, _xpc_service_instance_set_context, + _xpc_service_instance_set_cwd, _xpc_service_instance_set_endpoint, + _xpc_service_instance_set_environment, _xpc_service_instance_set_finalizer_f, + _xpc_service_instance_set_jetsam_properties, _xpc_service_instance_set_path, + _xpc_service_instance_set_start_suspended, _xpc_service_kickstart, + _xpc_service_set_attach_handler, _xpc_set_event, _xpc_set_event_state, + _xpc_set_event_stream_handler, _xpc_set_event_with_flags, + _xpc_set_idle_handler, _xpc_shmem_create, _xpc_shmem_create_readonly, + _xpc_shmem_get_length, _xpc_shmem_map, _xpc_strerror, _xpc_string_create, + _xpc_string_create_no_copy, _xpc_string_create_with_format, + _xpc_string_create_with_format_and_arguments, _xpc_string_get_length, + _xpc_string_get_string_ptr, _xpc_test_symbols_exported, _xpc_track_activity, + _xpc_transaction_begin, _xpc_transaction_end, _xpc_transaction_exit_clean, + _xpc_transaction_interrupt_clean_exit, _xpc_transactions_enable, + _xpc_type_get_name, _xpc_uint64_create, _xpc_uint64_get_value, + _xpc_uuid_create, _xpc_uuid_get_bytes ] + objc-classes: [ OS_xpc_object ] +... diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index 059f6e73a7..9afb93348a 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -22,6 +22,10 @@ const Progress = @This(); /// not print on update() terminal: ?std.fs.File = undefined, +/// Is this a windows API terminal (note: this is not the same as being run on windows +/// because other terminals exist like MSYS/git-bash) +is_windows_terminal: bool = false, + /// Whether the terminal supports ANSI escape codes. supports_ansi_escape_codes: bool = false, @@ -143,6 +147,7 @@ pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) !* self.terminal = stderr; self.supports_ansi_escape_codes = true; } else if (std.builtin.os.tag == .windows and stderr.isTty()) { + self.is_windows_terminal = true; self.terminal = stderr; } else if (std.builtin.os.tag != .windows) { // we are in a "dumb" terminal like in acme or writing to a file @@ -192,8 +197,9 @@ const DECRC = "\x1b8"; // supported by some terminals (eg. Terminal.app). fn refreshWithHeldLock(self: *Progress) void { - const is_dumb = !self.supports_ansi_escape_codes and !(std.builtin.os.tag == .windows); + const is_dumb = !self.supports_ansi_escape_codes and !self.is_windows_terminal; if (is_dumb and self.dont_print_on_dumb) return; + const file = self.terminal orelse return; var end: usize = 0; @@ -206,6 +212,8 @@ fn refreshWithHeldLock(self: *Progress) void { std.mem.copy(u8, self.output_buffer[end..], seq_before); end += seq_before.len; } else if (std.builtin.os.tag == .windows) winapi: { + std.debug.assert(self.is_windows_terminal); + var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) unreachable; @@ -282,19 +290,21 @@ fn refreshWithHeldLock(self: *Progress) void { const seq_after = DECRC; std.mem.copy(u8, self.output_buffer[end..], seq_after); end += seq_after.len; - } else if (std.builtin.os.tag != .windows) { + } else if (!self.is_windows_terminal) { self.output_buffer[end] = '\n'; end += 1; } - _ = file.write(self.output_buffer[0..end]) catch |e| { + _ = file.write(self.output_buffer[0..end]) catch { // Stop trying to write to this file once it errors. self.terminal = null; }; if (std.builtin.os.tag == .windows) { - if (windows.kernel32.SetConsoleCursorPosition(file.handle, saved_cursor_pos) != windows.TRUE) - unreachable; + if (self.is_windows_terminal) { + const res = windows.kernel32.SetConsoleCursorPosition(file.handle, saved_cursor_pos); + std.debug.assert(res == windows.TRUE); + } } self.prev_refresh_timestamp = self.timer.read(); @@ -318,7 +328,7 @@ fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: any end.* = self.output_buffer.len; }, } - const bytes_needed_for_esc_codes_at_end = if (std.builtin.os.tag == .windows) 0 else 11; + const bytes_needed_for_esc_codes_at_end: u8 = if (self.is_windows_terminal) 0 else 11; const max_end = self.output_buffer.len - bytes_needed_for_esc_codes_at_end; if (end.* > max_end) { const suffix = "... "; diff --git a/lib/std/SemanticVersion.zig b/lib/std/SemanticVersion.zig index 8e748184a8..e029952509 100644 --- a/lib/std/SemanticVersion.zig +++ b/lib/std/SemanticVersion.zig @@ -162,6 +162,7 @@ pub fn format( options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); @@ -259,7 +260,7 @@ test "SemanticVersion format" { // Invalid version string that may overflow. const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12"; - if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |err| {} + if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {} } test "SemanticVersion precedence" { diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 76a865cf10..06fe2a84dc 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -518,8 +518,8 @@ pub fn cpuCount() CpuCountError!usize { }, .haiku => { var count: u32 = undefined; - var system_info: os.system_info = undefined; - const rc = os.system.get_system_info(&system_info); + // var system_info: os.system_info = undefined; + // const rc = os.system.get_system_info(&system_info); count = system_info.cpu_count; return @intCast(usize, count); }, diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index d88a6de31e..8485f84aa4 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -40,12 +40,18 @@ else pub const SingleThreadedCondition = struct { pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void { + _ = cond; + _ = mutex; unreachable; // deadlock detected } - pub fn signal(cond: *SingleThreadedCondition) void {} + pub fn signal(cond: *SingleThreadedCondition) void { + _ = cond; + } - pub fn broadcast(cond: *SingleThreadedCondition) void {} + pub fn broadcast(cond: *SingleThreadedCondition) void { + _ = cond; + } }; pub const WindowsCondition = struct { diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig index 0a6a1d568e..6f869e0d89 100644 --- a/lib/std/Thread/StaticResetEvent.zig +++ b/lib/std/Thread/StaticResetEvent.zig @@ -105,6 +105,7 @@ pub const DebugEvent = struct { } pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult { + _ = timeout; switch (ev.state) { .unset => return .timed_out, .set => return .event_set, @@ -174,7 +175,10 @@ pub const AtomicEvent = struct { }; pub const SpinFutex = struct { - fn wake(waiters: *u32, wake_count: u32) void {} + fn wake(waiters: *u32, wake_count: u32) void { + _ = waiters; + _ = wake_count; + } fn wait(waiters: *u32, timeout: ?u64) !void { var timer: time.Timer = undefined; @@ -193,6 +197,7 @@ pub const AtomicEvent = struct { pub const LinuxFutex = struct { fn wake(waiters: *u32, wake_count: u32) void { + _ = wake_count; const waiting = std.math.maxInt(i32); // wake_count const ptr = @ptrCast(*const i32, waiters); const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting); diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 1ddbfce20c..9bcecab47e 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type { pub const StringContext = struct { pub fn hash(self: @This(), s: []const u8) u32 { + _ = self; return hashString(s); } pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { + _ = self; return eqlString(a, b); } }; @@ -1324,17 +1326,17 @@ pub fn ArrayHashMapUnmanaged( } fn removeFromIndexByIndexGeneric(self: *Self, entry_index: usize, ctx: ByIndexContext, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { const slot = self.getSlotByIndex(entry_index, ctx, header, I, indexes); - self.removeSlot(slot, header, I, indexes); + removeSlot(slot, header, I, indexes); } fn removeFromIndexByKey(self: *Self, key: anytype, ctx: anytype, header: *IndexHeader, comptime I: type, indexes: []Index(I)) ?usize { const slot = self.getSlotByKey(key, ctx, header, I, indexes) orelse return null; const removed_entry_index = indexes[slot].entry_index; - self.removeSlot(slot, header, I, indexes); + removeSlot(slot, header, I, indexes); return removed_entry_index; } - fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { + fn removeSlot(removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { const start_index = removed_slot +% 1; const end_index = start_index +% indexes.len; @@ -1619,13 +1621,13 @@ pub fn ArrayHashMapUnmanaged( if (self.index_header) |header| { p("\n", .{}); switch (header.capacityIndexType()) { - .u8 => self.dumpIndex(header, u8), - .u16 => self.dumpIndex(header, u16), - .u32 => self.dumpIndex(header, u32), + .u8 => dumpIndex(header, u8), + .u16 => dumpIndex(header, u16), + .u32 => dumpIndex(header, u32), } } } - fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void { + fn dumpIndex(header: *IndexHeader, comptime I: type) void { const p = std.debug.print; p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() }); const indexes = header.indexes(I); @@ -1918,7 +1920,7 @@ test "iterator hash map" { try testing.expect(count == 3); try testing.expect(it.next() == null); - for (buffer) |v, i| { + for (buffer) |_, i| { try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); } @@ -1930,7 +1932,7 @@ test "iterator hash map" { if (count >= 2) break; } - for (buffer[0..2]) |v, i| { + for (buffer[0..2]) |_, i| { try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); } @@ -2154,6 +2156,7 @@ test "compile everything" { pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; return getAutoHashFn(usize, void)({}, @ptrToInt(key)); } }.hash; @@ -2162,6 +2165,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return a == b; } }.eql; @@ -2177,6 +2181,7 @@ pub fn AutoContext(comptime K: type) type { pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; if (comptime trait.hasUniqueRepresentation(K)) { return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key))); } else { @@ -2191,6 +2196,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return meta.eql(a, b); } }.eql; @@ -2217,6 +2223,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool { pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; var hasher = Wyhash.init(0); std.hash.autoHashStrat(&hasher, key, strategy); return @truncate(u32, hasher.final()); diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index d137bc7552..80fb1ae297 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" { test "Atomic.storeUnchecked" { inline for (atomicIntTypes()) |Int| { + _ = Int; var x = Atomic(usize).init(5); x.storeUnchecked(10); try testing.expectEqual(x.loadUnchecked(), 10); @@ -250,6 +251,7 @@ test "Atomic.load" { test "Atomic.store" { inline for (atomicIntTypes()) |Int| { inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| { + _ = Int; var x = Atomic(usize).init(5); x.store(10, ordering); try testing.expectEqual(x.load(.SeqCst), 10); diff --git a/lib/std/base64.zig b/lib/std/base64.zig index 1f37f07a28..4b01455112 100644 --- a/lib/std/base64.zig +++ b/lib/std/base64.zig @@ -112,9 +112,6 @@ pub const Base64Encoder = struct { const out_len = encoder.calcSize(source.len); assert(dest.len >= out_len); - const nibbles = source.len / 3; - const leftover = source.len - 3 * nibbles; - var acc: u12 = 0; var acc_len: u4 = 0; var out_idx: usize = 0; @@ -223,7 +220,6 @@ pub const Base64Decoder = struct { if (decoder.pad_char) |pad_char| { const padding_len = acc_len / 2; var padding_chars: usize = 0; - var i: usize = 0; for (leftover) |c| { if (c != pad_char) { return if (c == Base64Decoder.invalid_char) error.InvalidCharacter else error.InvalidPadding; @@ -302,7 +298,6 @@ pub const Base64DecoderWithIgnore = struct { var leftover = source[leftover_idx.?..]; if (decoder.pad_char) |pad_char| { var padding_chars: usize = 0; - var i: usize = 0; for (leftover) |c| { if (decoder_with_ignore.char_is_ignored[c]) continue; if (c != pad_char) { diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index 7187b564d2..f7339bfdcf 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type { /// Returns the number of bits in this bit set pub inline fn capacity(self: Self) usize { + _ = self; return bit_length; } @@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { /// Returns the number of bits in this bit set pub inline fn capacity(self: Self) usize { + _ = self; return bit_length; } @@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { /// Flips every bit in the bit set. pub fn toggleAll(self: *Self) void { - for (self.masks) |*mask, i| { + for (self.masks) |*mask| { mask.* = ~mask.*; } @@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct { if (bit_length == 0) return; const num_masks = numMasks(self.bit_length); - for (self.masks[0..num_masks]) |*mask, i| { + for (self.masks[0..num_masks]) |*mask| { mask.* = ~mask.*; } diff --git a/lib/std/build.zig b/lib/std/build.zig index 96af4a3071..36a71d5061 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -57,6 +57,7 @@ pub const Builder = struct { exe_dir: []const u8, h_dir: []const u8, install_path: []const u8, + sysroot: ?[]const u8 = null, search_prefixes: ArrayList([]const u8), libc_file: ?[]const u8 = null, installed_files: ArrayList(InstalledFile), @@ -390,6 +391,7 @@ pub const Builder = struct { } pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind { + _ = self; return .{ .versioned = .{ .major = major, @@ -543,7 +545,7 @@ pub const Builder = struct { return null; }, .scalar => |s| { - const n = std.fmt.parseFloat(T, s) catch |err| { + const n = std.fmt.parseFloat(T, s) catch { warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) }); self.markInvalidUserInput(); return null; @@ -2700,6 +2702,10 @@ pub const LibExeObjStep = struct { } } + if (builder.sysroot) |sysroot| { + try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot }); + } + for (builder.search_prefixes.items) |search_prefix| { try zig_args.append("-L"); try zig_args.append(try fs.path.join(builder.allocator, &[_][]const u8{ @@ -3129,7 +3135,9 @@ pub const Step = struct { self.dependencies.append(other) catch unreachable; } - fn makeNoOp(self: *Step) anyerror!void {} + fn makeNoOp(self: *Step) anyerror!void { + _ = self; + } pub fn cast(step: *Step, comptime T: type) ?*T { if (step.id == T.base_id) { diff --git a/lib/std/build/InstallRawStep.zig b/lib/std/build/InstallRawStep.zig index f1d9608951..743b25f3cd 100644 --- a/lib/std/build/InstallRawStep.zig +++ b/lib/std/build/InstallRawStep.zig @@ -139,6 +139,7 @@ const BinaryElfOutput = struct { } fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool { + _ = context; if (left.physicalAddress < right.physicalAddress) { return true; } @@ -149,6 +150,7 @@ const BinaryElfOutput = struct { } fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool { + _ = context; return left.binaryOffset < right.binaryOffset; } }; diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 4d9350bbdd..615df9b9af 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -65,6 +65,8 @@ pub const StackTrace = struct { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const debug_info = std.debug.getSelfDebugInfo() catch |err| { @@ -521,6 +523,7 @@ pub const Version = struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; if (fmt.len == 0) { if (self.patch == 0) { if (self.minor == 0) { diff --git a/lib/std/c/tokenizer.zig b/lib/std/c/tokenizer.zig index 0d4c646c39..f8709e12be 100644 --- a/lib/std/c/tokenizer.zig +++ b/lib/std/c/tokenizer.zig @@ -351,7 +351,6 @@ pub const Tokenizer = struct { pp_directive: bool = false, pub fn next(self: *Tokenizer) Token { - const start_index = self.index; var result = Token{ .id = .Eof, .start = self.index, @@ -1380,12 +1379,12 @@ test "operators" { test "keywords" { try expectTokens( - \\auto break case char const continue default do - \\double else enum extern float for goto if int - \\long register return short signed sizeof static - \\struct switch typedef union unsigned void volatile - \\while _Bool _Complex _Imaginary inline restrict _Alignas - \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local + \\auto break case char const continue default do + \\double else enum extern float for goto if int + \\long register return short signed sizeof static + \\struct switch typedef union unsigned void volatile + \\while _Bool _Complex _Imaginary inline restrict _Alignas + \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local \\ , &[_]Token.Id{ .Keyword_auto, diff --git a/lib/std/coff.zig b/lib/std/coff.zig index 22ba7468fc..8b00a24297 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -98,6 +98,7 @@ pub const CoffError = error{ InvalidPEHeader, InvalidMachine, MissingCoffSection, + MissingStringTable, }; // Official documentation of the format: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format @@ -162,20 +163,47 @@ pub const Coff = struct { try self.loadOptionalHeader(); } + fn readStringFromTable(self: *Coff, offset: usize, buf: []u8) ![]const u8 { + if (self.coff_header.pointer_to_symbol_table == 0) { + // No symbol table therefore no string table + return error.MissingStringTable; + } + // The string table is at the end of the symbol table and symbols are 18 bytes long + const string_table_offset = self.coff_header.pointer_to_symbol_table + (self.coff_header.number_of_symbols * 18) + offset; + const in = self.in_file.reader(); + const old_pos = try self.in_file.getPos(); + + try self.in_file.seekTo(string_table_offset); + defer { + self.in_file.seekTo(old_pos) catch unreachable; + } + + const str = try in.readUntilDelimiterOrEof(buf, 0); + return str orelse ""; + } + fn loadOptionalHeader(self: *Coff) !void { const in = self.in_file.reader(); + const opt_header_pos = try self.in_file.getPos(); + self.pe_header.magic = try in.readIntLittle(u16); - // For now we're only interested in finding the reference to the .pdb, - // so we'll skip most of this header, which size is different in 32 - // 64 bits by the way. - var skip_size: u16 = undefined; + // All we care about is the image base value and PDB info + // The header structure is different for 32 or 64 bit + var num_rva_pos: u64 = undefined; if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 18 * @sizeOf(u32); + num_rva_pos = opt_header_pos + 92; + + try self.in_file.seekTo(opt_header_pos + 28); + const image_base32 = try in.readIntLittle(u32); + self.pe_header.image_base = image_base32; } else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { - skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 12 * @sizeOf(u32) + 5 * @sizeOf(u64); + num_rva_pos = opt_header_pos + 108; + + try self.in_file.seekTo(opt_header_pos + 24); + self.pe_header.image_base = try in.readIntLittle(u64); } else return error.InvalidPEMagic; - try self.in_file.seekBy(skip_size); + try self.in_file.seekTo(num_rva_pos); const number_of_rva_and_sizes = try in.readIntLittle(u32); if (number_of_rva_and_sizes != IMAGE_NUMBEROF_DIRECTORY_ENTRIES) @@ -258,11 +286,23 @@ pub const Coff = struct { const in = self.in_file.reader(); - var name: [8]u8 = undefined; + var name: [32]u8 = undefined; var i: u16 = 0; while (i < self.coff_header.number_of_sections) : (i += 1) { - try in.readNoEof(name[0..]); + try in.readNoEof(name[0..8]); + + if (name[0] == '/') { + // This is a long name and stored in the string table + const offset_len = mem.indexOfScalar(u8, name[1..], 0) orelse 7; + + const str_offset = try std.fmt.parseInt(u32, name[1 .. offset_len + 1], 10); + const str = try self.readStringFromTable(str_offset, &name); + std.mem.set(u8, name[str.len..], 0); + } else { + std.mem.set(u8, name[8..], 0); + } + try self.sections.append(Section{ .header = SectionHeader{ .name = name, @@ -288,6 +328,22 @@ pub const Coff = struct { } return null; } + + // Return an owned slice full of the section data + pub fn getSectionData(self: *Coff, comptime name: []const u8, allocator: *mem.Allocator) ![]u8 { + const sec = for (self.sections.items) |*sec| { + if (mem.eql(u8, sec.header.name[0..name.len], name)) { + break sec; + } + } else { + return error.MissingCoffSection; + }; + const in = self.in_file.reader(); + try self.in_file.seekTo(sec.header.pointer_to_raw_data); + const out_buff = try allocator.alloc(u8, sec.header.misc.virtual_size); + try in.readNoEof(out_buff); + return out_buff; + } }; const CoffHeader = struct { @@ -308,6 +364,7 @@ const OptionalHeader = struct { magic: u16, data_directory: [IMAGE_NUMBEROF_DIRECTORY_ENTRIES]DataDirectory, + image_base: u64, }; const DebugDirectoryEntry = packed struct { @@ -331,7 +388,7 @@ const SectionHeader = struct { virtual_size: u32, }; - name: [8]u8, + name: [32]u8, misc: Misc, virtual_address: u32, size_of_raw_data: u32, diff --git a/lib/std/compress/gzip.zig b/lib/std/compress/gzip.zig index 387b64f59a..6f17601949 100644 --- a/lib/std/compress/gzip.zig +++ b/lib/std/compress/gzip.zig @@ -62,6 +62,8 @@ pub fn GzipStream(comptime ReaderType: type) type { const XFL = header[8]; // Operating system where the compression took place const OS = header[9]; + _ = XFL; + _ = OS; if (FLG & FEXTRA != 0) { // Skip the extra data, we could read and expose it to the user diff --git a/lib/std/compress/zlib.zig b/lib/std/compress/zlib.zig index 0ee154bf22..909bae4090 100644 --- a/lib/std/compress/zlib.zig +++ b/lib/std/compress/zlib.zig @@ -35,6 +35,7 @@ pub fn ZlibStream(comptime ReaderType: type) type { const CM = @truncate(u4, header[0]); const CINFO = @truncate(u4, header[0] >> 4); const FCHECK = @truncate(u5, header[1]); + _ = FCHECK; const FDICT = @truncate(u1, header[1] >> 5); if ((@as(u16, header[0]) << 8 | header[1]) % 31 != 0) diff --git a/lib/std/comptime_string_map.zig b/lib/std/comptime_string_map.zig index 0bf86167f9..7da24545ec 100644 --- a/lib/std/comptime_string_map.zig +++ b/lib/std/comptime_string_map.zig @@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type { var sorted_kvs: [kvs.len]KV = undefined; const lenAsc = (struct { fn lenAsc(context: void, a: KV, b: KV) bool { + _ = context; return a.key.len < b.key.len; } }).lenAsc; diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index b6321e8d8c..4940f0dee6 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -346,7 +346,7 @@ test "ed25519 test vectors" { .expected = error.IdentityElement, // 11 - small-order A }, }; - for (entries) |entry, i| { + for (entries) |entry| { var msg: [entry.msg_hex.len / 2]u8 = undefined; _ = try fmt.hexToBytes(&msg, entry.msg_hex); var public_key: [32]u8 = undefined; diff --git a/lib/std/crypto/25519/scalar.zig b/lib/std/crypto/25519/scalar.zig index 46ab2017ca..bea054234e 100644 --- a/lib/std/crypto/25519/scalar.zig +++ b/lib/std/crypto/25519/scalar.zig @@ -330,13 +330,10 @@ pub const Scalar = struct { const carry9 = z02 >> 56; const c01 = carry9; const carry10 = (z12 + c01) >> 56; - const t21 = @truncate(u64, z12 + c01) & 0xffffffffffffff; const c11 = carry10; const carry11 = (z22 + c11) >> 56; - const t22 = @truncate(u64, z22 + c11) & 0xffffffffffffff; const c21 = carry11; const carry12 = (z32 + c21) >> 56; - const t23 = @truncate(u64, z32 + c21) & 0xffffffffffffff; const c31 = carry12; const carry13 = (z42 + c31) >> 56; const t24 = @truncate(u64, z42 + c31) & 0xffffffffffffff; @@ -605,13 +602,10 @@ const ScalarDouble = struct { const carry0 = z01 >> 56; const c00 = carry0; const carry1 = (z11 + c00) >> 56; - const t100 = @as(u64, @truncate(u64, z11 + c00)) & 0xffffffffffffff; const c10 = carry1; const carry2 = (z21 + c10) >> 56; - const t101 = @as(u64, @truncate(u64, z21 + c10)) & 0xffffffffffffff; const c20 = carry2; const carry3 = (z31 + c20) >> 56; - const t102 = @as(u64, @truncate(u64, z31 + c20)) & 0xffffffffffffff; const c30 = carry3; const carry4 = (z41 + c30) >> 56; const t103 = @as(u64, @truncate(u64, z41 + c30)) & 0xffffffffffffff; diff --git a/lib/std/crypto/aes/soft.zig b/lib/std/crypto/aes/soft.zig index 5eda9557ee..0d8a566793 100644 --- a/lib/std/crypto/aes/soft.zig +++ b/lib/std/crypto/aes/soft.zig @@ -49,8 +49,6 @@ pub const Block = struct { /// Encrypt a block with a round key. pub inline fn encrypt(block: Block, round_key: Block) Block { - const src = &block.repr; - const s0 = block.repr[0]; const s1 = block.repr[1]; const s2 = block.repr[2]; @@ -66,8 +64,6 @@ pub const Block = struct { /// Encrypt a block with the last round key. pub inline fn encryptLast(block: Block, round_key: Block) Block { - const src = &block.repr; - const t0 = block.repr[0]; const t1 = block.repr[1]; const t2 = block.repr[2]; @@ -88,8 +84,6 @@ pub const Block = struct { /// Decrypt a block with a round key. pub inline fn decrypt(block: Block, round_key: Block) Block { - const src = &block.repr; - const s0 = block.repr[0]; const s1 = block.repr[1]; const s2 = block.repr[2]; @@ -105,8 +99,6 @@ pub const Block = struct { /// Decrypt a block with the last round key. pub inline fn decryptLast(block: Block, round_key: Block) Block { - const src = &block.repr; - const t0 = block.repr[0]; const t1 = block.repr[1]; const t2 = block.repr[2]; diff --git a/lib/std/crypto/aes_gcm.zig b/lib/std/crypto/aes_gcm.zig index cc2a423f70..492a1a5223 100644 --- a/lib/std/crypto/aes_gcm.zig +++ b/lib/std/crypto/aes_gcm.zig @@ -114,7 +114,6 @@ test "Aes256Gcm - Empty message and no associated data" { const ad = ""; const m = ""; var c: [m.len]u8 = undefined; - var m2: [m.len]u8 = undefined; var tag: [Aes256Gcm.tag_length]u8 = undefined; Aes256Gcm.encrypt(&c, &tag, m, ad, nonce, key); diff --git a/lib/std/crypto/aes_ocb.zig b/lib/std/crypto/aes_ocb.zig index 48548f942f..6aaa7fc8cb 100644 --- a/lib/std/crypto/aes_ocb.zig +++ b/lib/std/crypto/aes_ocb.zig @@ -271,7 +271,6 @@ test "AesOcb test vector 1" { var c: [0]u8 = undefined; Aes128Ocb.encrypt(&c, &tag, "", "", nonce, k); - var expected_c: [c.len]u8 = undefined; var expected_tag: [tag.len]u8 = undefined; _ = try hexToBytes(&expected_tag, "785407BFFFC8AD9EDCC5520AC9111EE6"); diff --git a/lib/std/crypto/bcrypt.zig b/lib/std/crypto/bcrypt.zig index c1ad239e90..07c2142a97 100644 --- a/lib/std/crypto/bcrypt.zig +++ b/lib/std/crypto/bcrypt.zig @@ -48,7 +48,6 @@ const State = struct { fn expand0(state: *State, key: []const u8) void { var i: usize = 0; var j: usize = 0; - var t: u32 = undefined; while (i < state.subkeys.len) : (i += 1) { state.subkeys[i] ^= toWord(key, &j); } @@ -75,7 +74,6 @@ const State = struct { fn expand(state: *State, data: []const u8, key: []const u8) void { var i: usize = 0; var j: usize = 0; - var t: u32 = undefined; while (i < state.subkeys.len) : (i += 1) { state.subkeys[i] ^= toWord(key, &j); } diff --git a/lib/std/crypto/blake3.zig b/lib/std/crypto/blake3.zig index c4ef40de3d..75aba06da0 100644 --- a/lib/std/crypto/blake3.zig +++ b/lib/std/crypto/blake3.zig @@ -394,6 +394,7 @@ pub const Blake3 = struct { /// Construct a new `Blake3` for the key derivation function. The context /// string should be hardcoded, globally unique, and application-specific. pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 { + _ = options; var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT); context_hasher.update(context); var context_key: [KEY_LEN]u8 = undefined; diff --git a/lib/std/crypto/chacha20.zig b/lib/std/crypto/chacha20.zig index b89a35cbd4..592116ddd4 100644 --- a/lib/std/crypto/chacha20.zig +++ b/lib/std/crypto/chacha20.zig @@ -444,7 +444,6 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type { if (comptime @sizeOf(usize) > 4) { // A big block is giant: 256 GiB, but we can avoid this limitation var remaining_blocks: u32 = @intCast(u32, (in.len / big_block)); - var i: u32 = 0; while (remaining_blocks > 0) : (remaining_blocks -= 1) { ChaChaImpl(rounds_nb).chacha20Xor(out[cursor .. cursor + big_block], in[cursor .. cursor + big_block], k, c); c[1] += 1; // upper 32-bit of counter, generic chacha20Xor() doesn't know about this. diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index b55466e639..7aa67212e4 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -219,6 +219,7 @@ pub const Hash = struct { const Self = @This(); pub fn init(options: Options) Self { + _ = options; return Self{ .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) }, .buf_off = 0, diff --git a/lib/std/crypto/md5.zig b/lib/std/crypto/md5.zig index d4109eed8a..ef9907d18b 100644 --- a/lib/std/crypto/md5.zig +++ b/lib/std/crypto/md5.zig @@ -45,6 +45,7 @@ pub const Md5 = struct { total_len: u64, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ 0x67452301, diff --git a/lib/std/crypto/pcurves/p256/scalar.zig b/lib/std/crypto/pcurves/p256/scalar.zig index 02474bae08..afdc3fb502 100644 --- a/lib/std/crypto/pcurves/p256/scalar.zig +++ b/lib/std/crypto/pcurves/p256/scalar.zig @@ -63,7 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non /// Return -s (mod L) pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { - return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian); + return (try Scalar.fromBytes(s, endian)).neg().toBytes(endian); } /// Return (a-b) (mod L) diff --git a/lib/std/crypto/sha1.zig b/lib/std/crypto/sha1.zig index 6bf6b469e2..e167a50710 100644 --- a/lib/std/crypto/sha1.zig +++ b/lib/std/crypto/sha1.zig @@ -43,6 +43,7 @@ pub const Sha1 = struct { total_len: u64 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ 0x67452301, diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index ece2a3abfb..eb0eccfa84 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type { total_len: u64 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ params.iv0, @@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type { total_len: u128 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u64{ params.iv0, diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig index d642d631e0..a4637c7fd4 100644 --- a/lib/std/crypto/sha3.zig +++ b/lib/std/crypto/sha3.zig @@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type { rate: usize, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) }; } diff --git a/lib/std/crypto/tlcsprng.zig b/lib/std/crypto/tlcsprng.zig index c2cb119d4a..15a356d3d3 100644 --- a/lib/std/crypto/tlcsprng.zig +++ b/lib/std/crypto/tlcsprng.zig @@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void { os.MAP_PRIVATE | os.MAP_ANONYMOUS, -1, 0, - ) catch |err| { + ) catch { // Could not allocate memory for the local state, fall back to // the OS syscall. return fillWithOsEntropy(buffer); diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 23f4867e81..fa87e5898c 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -53,6 +53,10 @@ pub const SymbolInfo = struct { } } }; +const PdbOrDwarf = union(enum) { + pdb: pdb.Pdb, + dwarf: DW.DwarfInfo, +}; var stderr_mutex = std.Thread.Mutex{}; @@ -321,6 +325,7 @@ pub fn writeStackTrace( debug_info: *DebugInfo, tty_config: TTY.Config, ) !void { + _ = allocator; if (builtin.strip_debug_info) return error.MissingDebugInfo; var frame_index: usize = 0; var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len); @@ -669,10 +674,33 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf var di = ModuleDebugInfo{ .base_address = undefined, .coff = coff_obj, - .pdb = undefined, + .debug_data = undefined, }; try di.coff.loadHeader(); + try di.coff.loadSections(); + if (di.coff.getSection(".debug_info")) |sec| { + // This coff file has embedded DWARF debug info + _ = sec; + // TODO: free the section data slices + const debug_info_data = di.coff.getSectionData(".debug_info", allocator) catch null; + const debug_abbrev_data = di.coff.getSectionData(".debug_abbrev", allocator) catch null; + const debug_str_data = di.coff.getSectionData(".debug_str", allocator) catch null; + const debug_line_data = di.coff.getSectionData(".debug_line", allocator) catch null; + const debug_ranges_data = di.coff.getSectionData(".debug_ranges", allocator) catch null; + + var dwarf = DW.DwarfInfo{ + .endian = native_endian, + .debug_info = debug_info_data orelse return error.MissingDebugInfo, + .debug_abbrev = debug_abbrev_data orelse return error.MissingDebugInfo, + .debug_str = debug_str_data orelse return error.MissingDebugInfo, + .debug_line = debug_line_data orelse return error.MissingDebugInfo, + .debug_ranges = debug_ranges_data, + }; + try DW.openDwarfDebugInfo(&dwarf, allocator); + di.debug_data = PdbOrDwarf{ .dwarf = dwarf }; + return di; + } var path_buf: [windows.MAX_PATH]u8 = undefined; const len = try di.coff.getPdbPath(path_buf[0..]); @@ -681,11 +709,12 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf const path = try fs.path.resolve(allocator, &[_][]const u8{raw_path}); defer allocator.free(path); - di.pdb = try pdb.Pdb.init(allocator, path); - try di.pdb.parseInfoStream(); - try di.pdb.parseDbiStream(); + di.debug_data = PdbOrDwarf{ .pdb = undefined }; + di.debug_data.pdb = try pdb.Pdb.init(allocator, path); + try di.debug_data.pdb.parseInfoStream(); + try di.debug_data.pdb.parseDbiStream(); - if (!mem.eql(u8, &di.coff.guid, &di.pdb.guid) or di.coff.age != di.pdb.age) + if (!mem.eql(u8, &di.coff.guid, &di.debug_data.pdb.guid) or di.coff.age != di.debug_data.pdb.age) return error.InvalidDebugInfo; return di; @@ -869,7 +898,6 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void { var buf: [mem.page_size]u8 = undefined; var line: usize = 1; var column: usize = 1; - var abs_index: usize = 0; while (true) { const amt_read = try f.read(buf[0..]); const slice = buf[0..amt_read]; @@ -904,6 +932,7 @@ const MachoSymbol = struct { } fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool { + _ = context; return lhs.address() < rhs.address(); } }; @@ -1108,6 +1137,7 @@ pub const DebugInfo = struct { if (os.dl_iterate_phdr(&ctx, anyerror, struct { fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void { + _ = size; // The base address is too high if (context.address < info.dlpi_addr) return; @@ -1163,6 +1193,8 @@ pub const DebugInfo = struct { } fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo { + _ = self; + _ = address; @panic("TODO implement lookup module for Haiku"); } }; @@ -1331,7 +1363,7 @@ pub const ModuleDebugInfo = switch (native_os) { }, .uefi, .windows => struct { base_address: usize, - pdb: pdb.Pdb, + debug_data: PdbOrDwarf, coff: *coff.Coff, pub fn allocator(self: @This()) *mem.Allocator { @@ -1342,8 +1374,18 @@ pub const ModuleDebugInfo = switch (native_os) { // Translate the VA into an address into this object const relocated_address = address - self.base_address; + switch (self.debug_data) { + .dwarf => |*dwarf| { + const dwarf_address = relocated_address + self.coff.pe_header.image_base; + return getSymbolFromDwarf(dwarf_address, dwarf); + }, + .pdb => { + // fallthrough to pdb handling + }, + } + var coff_section: *coff.Section = undefined; - const mod_index = for (self.pdb.sect_contribs) |sect_contrib| { + const mod_index = for (self.debug_data.pdb.sect_contribs) |sect_contrib| { if (sect_contrib.Section > self.coff.sections.items.len) continue; // Remember that SectionContribEntry.Section is 1-based. coff_section = &self.coff.sections.items[sect_contrib.Section - 1]; @@ -1358,15 +1400,15 @@ pub const ModuleDebugInfo = switch (native_os) { return SymbolInfo{}; }; - const module = (try self.pdb.getModule(mod_index)) orelse + const module = (try self.debug_data.pdb.getModule(mod_index)) orelse return error.InvalidDebugInfo; const obj_basename = fs.path.basename(module.obj_file_name); - const symbol_name = self.pdb.getSymbolName( + const symbol_name = self.debug_data.pdb.getSymbolName( module, relocated_address - coff_section.header.virtual_address, ) orelse "???"; - const opt_line_info = try self.pdb.getLineNumberInfo( + const opt_line_info = try self.debug_data.pdb.getLineNumberInfo( module, relocated_address - coff_section.header.virtual_address, ); @@ -1386,32 +1428,33 @@ pub const ModuleDebugInfo = switch (native_os) { pub fn getSymbolAtAddress(self: *@This(), address: usize) !SymbolInfo { // Translate the VA into an address into this object const relocated_address = address - self.base_address; - - if (nosuspend self.dwarf.findCompileUnit(relocated_address)) |compile_unit| { - return SymbolInfo{ - .symbol_name = nosuspend self.dwarf.getSymbolName(relocated_address) orelse "???", - .compile_unit_name = compile_unit.die.getAttrString(&self.dwarf, DW.AT_name) catch |err| switch (err) { - error.MissingDebugInfo, error.InvalidDebugInfo => "???", - else => return err, - }, - .line_info = nosuspend self.dwarf.getLineNumberInfo(compile_unit.*, relocated_address) catch |err| switch (err) { - error.MissingDebugInfo, error.InvalidDebugInfo => null, - else => return err, - }, - }; - } else |err| switch (err) { - error.MissingDebugInfo, error.InvalidDebugInfo => { - return SymbolInfo{}; - }, - else => return err, - } - - unreachable; + return getSymbolFromDwarf(relocated_address, &self.dwarf); } }, else => DW.DwarfInfo, }; +fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo { + if (nosuspend di.findCompileUnit(address)) |compile_unit| { + return SymbolInfo{ + .symbol_name = nosuspend di.getSymbolName(address) orelse "???", + .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT_name) catch |err| switch (err) { + error.MissingDebugInfo, error.InvalidDebugInfo => "???", + else => return err, + }, + .line_info = nosuspend di.getLineNumberInfo(compile_unit.*, address) catch |err| switch (err) { + error.MissingDebugInfo, error.InvalidDebugInfo => null, + else => return err, + }, + }; + } else |err| switch (err) { + error.MissingDebugInfo, error.InvalidDebugInfo => { + return SymbolInfo{}; + }, + else => return err, + } +} + /// TODO multithreaded awareness var debug_info_allocator: ?*mem.Allocator = null; var debug_info_arena_allocator: std.heap.ArenaAllocator = undefined; diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig index 93736f3d9c..eb22dba7c0 100644 --- a/lib/std/dwarf.zig +++ b/lib/std/dwarf.zig @@ -144,7 +144,7 @@ const FileEntry = struct { }; const LineNumberProgram = struct { - address: usize, + address: u64, file: usize, line: i64, column: u64, @@ -153,12 +153,12 @@ const LineNumberProgram = struct { end_sequence: bool, default_is_stmt: bool, - target_address: usize, + target_address: u64, include_dirs: []const []const u8, file_entries: *ArrayList(FileEntry), prev_valid: bool, - prev_address: usize, + prev_address: u64, prev_file: usize, prev_line: i64, prev_column: u64, @@ -186,7 +186,7 @@ const LineNumberProgram = struct { self.prev_end_sequence = undefined; } - pub fn init(is_stmt: bool, include_dirs: []const []const u8, file_entries: *ArrayList(FileEntry), target_address: usize) LineNumberProgram { + pub fn init(is_stmt: bool, include_dirs: []const []const u8, file_entries: *ArrayList(FileEntry), target_address: u64) LineNumberProgram { return LineNumberProgram{ .address = 0, .file = 1, @@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu } fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { + _ = allocator; // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here. // `nosuspend` should be removed from all the function calls once it is fixed. return FormValue{ @@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: // TODO the nosuspends here are workarounds fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue { + _ = allocator; return FormValue{ .Ref = switch (size) { 1 => try nosuspend in_stream.readInt(u8, endian), @@ -453,13 +455,13 @@ pub const DwarfInfo = struct { if (this_die_obj.getAttr(AT_name)) |_| { const name = try this_die_obj.getAttrString(di, AT_name); break :x name; - } else if (this_die_obj.getAttr(AT_abstract_origin)) |ref| { + } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| { // Follow the DIE it points to and repeat const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin); if (ref_offset > next_offset) return error.InvalidDebugInfo; try seekable.seekTo(this_unit_offset + ref_offset); this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; - } else if (this_die_obj.getAttr(AT_specification)) |ref| { + } else if (this_die_obj.getAttr(AT_specification)) |_| { // Follow the DIE it points to and repeat const ref_offset = try this_die_obj.getAttrRef(AT_specification); if (ref_offset > next_offset) return error.InvalidDebugInfo; @@ -691,7 +693,7 @@ pub const DwarfInfo = struct { return result; } - pub fn getLineNumberInfo(di: *DwarfInfo, compile_unit: CompileUnit, target_address: usize) !debug.LineInfo { + pub fn getLineNumberInfo(di: *DwarfInfo, compile_unit: CompileUnit, target_address: u64) !debug.LineInfo { var stream = io.fixedBufferStream(di.debug_line); const in = &stream.reader(); const seekable = &stream.seekableStream(); diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 098d245a4a..d1750ef761 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn { } pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { + _ = phdrs; const _DYNAMIC = get_DYNAMIC() orelse { // No PT_DYNAMIC means this is either a statically-linked program or a // badly corrupted dynamically-linked one. @@ -407,7 +408,7 @@ test "dynamic_library" { else => return error.SkipZigTest, }; - const dynlib = DynLib.open(libname) catch |err| { + _ = DynLib.open(libname) catch |err| { try testing.expect(err == error.FileNotFound); return; }; diff --git a/lib/std/elf.zig b/lib/std/elf.zig index b74ea6e837..6c90dff929 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -429,7 +429,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type { if (self.elf_header.endian == native_endian) return phdr; // Convert fields to native endianness. - bswapAllFields(Elf64_Phdr, &phdr); + mem.bswapAllFields(Elf64_Phdr, &phdr); return phdr; } @@ -441,7 +441,7 @@ pub fn ProgramHeaderIterator(ParseSource: anytype) type { // ELF endianness does NOT match native endianness. if (self.elf_header.endian != native_endian) { // Convert fields to native endianness. - bswapAllFields(Elf32_Phdr, &phdr); + mem.bswapAllFields(Elf32_Phdr, &phdr); } // Convert 32-bit header to 64-bit. @@ -479,7 +479,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type { if (self.elf_header.endian == native_endian) return shdr; // Convert fields to native endianness. - bswapAllFields(Elf64_Shdr, &shdr); + mem.bswapAllFields(Elf64_Shdr, &shdr); return shdr; } @@ -491,7 +491,7 @@ pub fn SectionHeaderIterator(ParseSource: anytype) type { // ELF endianness does NOT match native endianness. if (self.elf_header.endian != native_endian) { // Convert fields to native endianness. - bswapAllFields(Elf32_Shdr, &shdr); + mem.bswapAllFields(Elf32_Shdr, &shdr); } // Convert 32-bit header to 64-bit. @@ -531,26 +531,6 @@ pub fn int32(need_bswap: bool, int_32: anytype, comptime Int64: anytype) Int64 { } } -pub fn bswapAllFields(comptime S: type, ptr: *S) void { - if (@typeInfo(S) != .Struct) @compileError("bswapAllFields expects a struct as the first argument"); - inline for (std.meta.fields(S)) |f| { - @field(ptr, f.name) = @byteSwap(f.field_type, @field(ptr, f.name)); - } -} -test "bswapAllFields" { - var s: Elf32_Chdr = .{ - .ch_type = 0x12341234, - .ch_size = 0x56785678, - .ch_addralign = 0x12124242, - }; - bswapAllFields(Elf32_Chdr, &s); - try std.testing.expectEqual(Elf32_Chdr{ - .ch_type = 0x34123412, - .ch_size = 0x78567856, - .ch_addralign = 0x42421212, - }, s); -} - pub const EI_NIDENT = 16; pub const EI_CLASS = 4; diff --git a/lib/std/enums.zig b/lib/std/enums.zig index ac0b543559..95c6fc7ec7 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField; pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type { const StructField = std.builtin.TypeInfo.StructField; var fields: []const StructField = &[_]StructField{}; - for (std.meta.fields(E)) |field, i| { + for (std.meta.fields(E)) |field| { fields = fields ++ &[_]StructField{.{ .name = field.name, .field_type = Data, @@ -144,7 +144,7 @@ pub fn directEnumArrayDefault( ) [directEnumArrayLen(E, max_unused_slots)]Data { const len = comptime directEnumArrayLen(E, max_unused_slots); var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; - inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f, i| { + inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { const enum_value = @field(E, f.name); const index = @intCast(usize, @enumToInt(enum_value)); result[index] = @field(init_values, f.name); @@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { /// TODO: Once #8169 is fixed, consider switching this param /// back to an optional. pub fn NoExtension(comptime Self: type) type { + _ = Self; return NoExt; } const NoExt = struct {}; @@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" { } fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool { + _ = ctx; return a.value < b.value; } pub fn EnumIndexer(comptime E: type) type { @@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type { pub const Key = E; pub const count: usize = 0; pub fn indexOf(e: E) usize { + _ = e; unreachable; } pub fn keyForIndex(i: usize) E { + _ = i; unreachable; } }; @@ -753,10 +757,11 @@ pub fn EnumIndexer(comptime E: type) type { std.sort.sort(EnumField, &fields, {}, ascByValue); const min = fields[0].value; const max = fields[fields.len - 1].value; + const fields_len = fields.len; if (max - min == fields.len - 1) { return struct { pub const Key = E; - pub const count = fields.len; + pub const count = fields_len; pub fn indexOf(e: E) usize { return @intCast(usize, @enumToInt(e) - min); } @@ -774,7 +779,7 @@ pub fn EnumIndexer(comptime E: type) type { return struct { pub const Key = E; - pub const count = fields.len; + pub const count = fields_len; pub fn indexOf(e: E) usize { for (keys) |k, i| { if (k == e) return i; diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index f9c2d4b533..3880d6e286 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -308,7 +308,6 @@ test "std.event.Channel wraparound" { // add items to channel and pull them out until // the buffer wraps around, make sure it doesn't crash. - var result: i32 = undefined; channel.put(5); try testing.expectEqual(@as(i32, 5), channel.get()); channel.put(6); diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index 7ac27a13f2..1d12689aff 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -130,7 +130,7 @@ test "std.event.Group" { // TODO this file has bit-rotted. repair it if (true) return error.SkipZigTest; - const handle = async testGroup(std.heap.page_allocator); + _ = async testGroup(std.heap.page_allocator); } fn testGroup(allocator: *Allocator) callconv(.Async) void { var count: usize = 0; diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index ca55a366f8..5353341363 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -345,7 +345,7 @@ pub const Loop = struct { ); errdefer windows.CloseHandle(self.os_data.io_port); - for (self.eventfd_resume_nodes) |*eventfd_node, i| { + for (self.eventfd_resume_nodes) |*eventfd_node| { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ @@ -680,7 +680,7 @@ pub const Loop = struct { fn run(func_args: Args, loop: *Loop, allocator: *mem.Allocator) void { loop.beginOneEvent(); loop.yield(); - const result = @call(.{}, func, func_args); + @call(.{}, func, func_args); // compile error when called with non-void ret type suspend { loop.finishOneEvent(); allocator.destroy(@frame()); @@ -894,7 +894,7 @@ pub const Loop = struct { self: *Loop, /// This argument is a socket that has been created with `socket`, bound to a local address /// with `bind`, and is listening for connections after a `listen`. - sockfd: os.fd_t, + sockfd: os.socket_t, /// This argument is a pointer to a sockaddr structure. This structure is filled in with the /// address of the peer socket, as known to the communications layer. The exact format of the /// address returned addr is determined by the socket's address family (see `socket` and the @@ -911,7 +911,7 @@ pub const Loop = struct { /// * `SOCK_CLOEXEC` - Set the close-on-exec (`FD_CLOEXEC`) flag on the new file descriptor. See the /// description of the `O_CLOEXEC` flag in `open` for reasons why this may be useful. flags: u32, - ) os.AcceptError!os.fd_t { + ) os.AcceptError!os.socket_t { while (true) { return os.accept(sockfd, addr, addr_size, flags | os.SOCK_NONBLOCK) catch |err| switch (err) { error.WouldBlock => { diff --git a/lib/std/event/rwlock.zig b/lib/std/event/rwlock.zig index 714e50b2a9..3bd0c86035 100644 --- a/lib/std/event/rwlock.zig +++ b/lib/std/event/rwlock.zig @@ -225,7 +225,7 @@ test "std.event.RwLock" { var lock = RwLock.init(); defer lock.deinit(); - const handle = testLock(std.heap.page_allocator, &lock); + _ = testLock(std.heap.page_allocator, &lock); const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; try testing.expectEqualSlices(i32, expected_result, shared_test_data); diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 81b505c952..9ba7b8262c 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -369,6 +369,7 @@ pub fn format( } pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void { + _ = options; const T = @TypeOf(value); switch (@typeInfo(T)) { @@ -553,7 +554,7 @@ pub fn formatType( .Many, .C => { if (actual_fmt.len == 0) @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); - if (ptr_info.sentinel) |sentinel| { + if (ptr_info.sentinel) |_| { return formatType(mem.span(value), actual_fmt, options, writer, max_depth); } if (ptr_info.child == u8) { @@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buf: [2]u8 = undefined; for (bytes) |c| { @@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buf: [4]u8 = undefined; buf[0] = '\\'; @@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type { options: FormatOptions, writer: anytype, ) !void { + _ = fmt; if (value == 0) { return writer.writeAll("0B"); } @@ -903,6 +909,7 @@ pub fn formatAsciiChar( options: FormatOptions, writer: anytype, ) !void { + _ = options; return writer.writeAll(@as(*const [1]u8, &c)); } @@ -1140,7 +1147,7 @@ pub fn formatFloatHexadecimal( // +1 for the decimal part. var buf: [1 + mantissa_digits]u8 = undefined; - const N = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits }); + _ = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits }); try writer.writeAll("0x"); try writer.writeByte(buf[0]); @@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options } fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { + _ = fmt; + _ = options; var ns_remaining = ns; inline for (.{ .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' }, @@ -2152,6 +2161,7 @@ test "custom" { options: FormatOptions, writer: anytype, ) !void { + _ = options; if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) { return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); } else if (comptime std.mem.eql(u8, fmt, "d")) { @@ -2162,7 +2172,6 @@ test "custom" { } }; - var buf1: [32]u8 = undefined; var value = Vec2{ .x = 10.2, .y = 2.22, @@ -2220,7 +2229,7 @@ test "union" { try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@")); const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst}); - try std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@")); + try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@")); } test "enum" { @@ -2341,6 +2350,7 @@ test "formatType max_depth" { options: FormatOptions, writer: anytype, ) !void { + _ = options; if (fmt.len == 0) { return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); } else { diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index 1f6d7222ac..6178398b17 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -200,7 +200,6 @@ const ParseResult = enum { fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult { var digit_index: usize = 0; - var negative = false; var negative_exp = false; var exponent: i32 = 0; diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 390efec50c..9a39bc0425 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -3,6 +3,7 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. +const root = @import("root"); const builtin = std.builtin; const std = @import("std.zig"); const os = std.os; @@ -47,7 +48,10 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) { .windows => os.windows.PATH_MAX_WIDE * 3 + 1, // TODO work out what a reasonable value we should use here .wasi => 4096, - else => @compileError("Unsupported OS"), + else => if (@hasDecl(root, "os") and @hasDecl(root.os, "PATH_MAX")) + root.os.PATH_MAX + else + @compileError("PATH_MAX not implemented for " ++ @tagName(builtin.os.tag)), }; pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*; @@ -473,7 +477,7 @@ pub const Dir = struct { } var stat_info: os.libc_stat = undefined; - const rc2 = os.system._kern_read_stat( + _ = os.system._kern_read_stat( self.dir.fd, &haiku_entry.d_name, false, @@ -1537,7 +1541,7 @@ pub const Dir = struct { self: Dir, target_path: []const u8, sym_link_path: []const u8, - flags: SymLinkFlags, + _: SymLinkFlags, ) !void { return os.symlinkatWasi(target_path, self.fd, sym_link_path); } @@ -1875,6 +1879,7 @@ pub const Dir = struct { /// * NtDll prefixed /// TODO currently this ignores `flags`. pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void { + _ = flags; return os.faccessatW(self.fd, sub_path_w, 0, 0); } @@ -2434,7 +2439,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { }) catch continue; var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; - if (os.realpathZ(&resolved_path_buf, &real_path_buf)) |real_path| { + if (os.realpathZ(resolved_path, &real_path_buf)) |real_path| { // found a file, and hope it is the right file if (real_path.len > out_buffer.len) return error.NameTooLong; diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index fd5c46ff9f..04404a61bb 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 { // Now we know the disk designator to use, if any, and what kind it is. And our result // is big enough to append all the paths to. var correct_disk_designator = true; - for (paths[first_index..]) |p, i| { + for (paths[first_index..]) |p| { const parsed = windowsParsePath(p); if (parsed.kind != WindowsPath.Kind.None) { @@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { } errdefer allocator.free(result); - for (paths[first_index..]) |p, i| { + for (paths[first_index..]) |p| { var it = mem.tokenize(p, "/"); while (it.next()) |component| { if (mem.eql(u8, component, ".")) { diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index a20ec4c1bc..3c7a95432c 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -541,6 +541,7 @@ test "makePath, put some files in it, deleteTree" { try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); try tmp.dir.deleteTree("os_test_tmp"); if (tmp.dir.openDir("os_test_tmp", .{})) |dir| { + _ = dir; @panic("expected error"); } else |err| { try testing.expect(err == error.FileNotFound); @@ -638,6 +639,7 @@ test "access file" { try tmp.dir.makePath("os_test_tmp"); if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| { + _ = ok; @panic("expected error"); } else |err| { try testing.expect(err == error.FileNotFound); diff --git a/lib/std/fs/wasi.zig b/lib/std/fs/wasi.zig index adc20883e5..c41c9a7614 100644 --- a/lib/std/fs/wasi.zig +++ b/lib/std/fs/wasi.zig @@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) { } pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { + _ = fmt; + _ = options; try out_stream.print("PreopenType{{ ", .{}); switch (self) { PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}), diff --git a/lib/std/hash/cityhash.zig b/lib/std/hash/cityhash.zig index 920a006b8f..8796eb0075 100644 --- a/lib/std/hash/cityhash.zig +++ b/lib/std/hash/cityhash.zig @@ -353,7 +353,6 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 { var key: [256]u8 = undefined; var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined; - var final: HashResult = 0; std.mem.set(u8, &key, 0); std.mem.set(u8, &hashes_bytes, 0); @@ -376,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 { } fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { + _ = seed; return CityHash32.hash(str); } diff --git a/lib/std/hash/wyhash.zig b/lib/std/hash/wyhash.zig index 4b9afe6355..83cd5e097c 100644 --- a/lib/std/hash/wyhash.zig +++ b/lib/std/hash/wyhash.zig @@ -166,8 +166,6 @@ pub const Wyhash = struct { } pub fn final(self: *Wyhash) u64 { - const seed = self.state.seed; - const rem_len = @intCast(u5, self.buf_len); const rem_key = self.buf[0..self.buf_len]; return self.state.final(rem_key); diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 274d2d0404..d64e122aaf 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) return struct { fn hash(ctx: Context, key: K) u64 { + _ = ctx; if (comptime trait.hasUniqueRepresentation(K)) { return Wyhash.hash(0, std.mem.asBytes(&key)); } else { @@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return meta.eql(a, b); } }.eql; @@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type { pub const StringContext = struct { pub fn hash(self: @This(), s: []const u8) u64 { + _ = self; return hashString(s); } pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { + _ = self; return eqlString(a, b); } }; @@ -1236,7 +1240,7 @@ pub fn HashMapUnmanaged( metadata[0].fill(fingerprint); const new_key = &self.keys()[idx]; const new_value = &self.values()[idx]; - new_key.* = key; + new_key.* = undefined; new_value.* = undefined; self.size += 1; @@ -1809,7 +1813,7 @@ test "std.hash_map getOrPut" { i = 0; while (i < 20) : (i += 1) { - var n = try map.getOrPutValue(i, 1); + _ = try map.getOrPutValue(i, 1); } i = 0; @@ -1884,6 +1888,54 @@ test "std.hash_map clone" { } } +test "std.hash_map getOrPutAdapted" { + const AdaptedContext = struct { + fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { + _ = self; + return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key; + } + fn hash(self: @This(), adapted_key: []const u8) u64 { + _ = self; + const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable; + return (AutoContext(u64){}).hash(key); + } + }; + var map = AutoHashMap(u64, u64).init(testing.allocator); + defer map.deinit(); + + const keys = [_][]const u8{ + "1231", + "4564", + "7894", + "1132", + "65235", + "95462", + "0112305", + "00658", + "0", + "2", + }; + + var real_keys: [keys.len]u64 = undefined; + + inline for (keys) |key_str, i| { + const result = try map.getOrPutAdapted(key_str, AdaptedContext{}); + try testing.expect(!result.found_existing); + real_keys[i] = std.fmt.parseInt(u64, key_str, 10) catch unreachable; + result.key_ptr.* = real_keys[i]; + result.value_ptr.* = i * 2; + } + + try testing.expectEqual(map.count(), keys.len); + + inline for (keys) |key_str, i| { + const result = try map.getOrPutAdapted(key_str, AdaptedContext{}); + try testing.expect(result.found_existing); + try testing.expectEqual(real_keys[i], result.key_ptr.*); + try testing.expectEqual(@as(u64, i) * 2, result.value_ptr.*); + } +} + test "compile everything" { std.testing.refAllDecls(AutoHashMap(i32, i32)); std.testing.refAllDecls(StringHashMap([]const u8)); diff --git a/lib/std/heap.zig b/lib/std/heap.zig index a5150e50fe..088d6b39bb 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -108,6 +108,8 @@ const CAllocator = struct { len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { + _ = allocator; + _ = return_address; assert(len > 0); assert(std.math.isPowerOfTwo(alignment)); @@ -134,6 +136,9 @@ const CAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = allocator; + _ = buf_align; + _ = return_address; if (new_len == 0) { alignedFree(buf.ptr); return 0; @@ -178,6 +183,9 @@ fn rawCAlloc( len_align: u29, ret_addr: usize, ) Allocator.Error![]u8 { + _ = self; + _ = len_align; + _ = ret_addr; assert(ptr_align <= @alignOf(std.c.max_align_t)); const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory); return ptr[0..len]; @@ -191,6 +199,9 @@ fn rawCResize( len_align: u29, ret_addr: usize, ) Allocator.Error!usize { + _ = self; + _ = old_align; + _ = ret_addr; if (new_len == 0) { c.free(buf.ptr); return 0; @@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null; const PageAllocator = struct { fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { + _ = allocator; + _ = ra; assert(n > 0); const aligned_len = mem.alignForward(n, mem.page_size); @@ -334,6 +347,9 @@ const PageAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = allocator; + _ = buf_align; + _ = return_address; const new_size_aligned = mem.alignForward(new_size, mem.page_size); if (builtin.os.tag == .windows) { @@ -482,6 +498,8 @@ const WasmPageAllocator = struct { } fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { + _ = allocator; + _ = ra; const page_count = nPages(len); const page_idx = try allocPages(page_count, alignment); return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)]; @@ -542,6 +560,9 @@ const WasmPageAllocator = struct { len_align: u29, return_address: usize, ) error{OutOfMemory}!usize { + _ = allocator; + _ = buf_align; + _ = return_address; const aligned_len = mem.alignForward(buf.len, mem.page_size); if (new_len > aligned_len) return error.OutOfMemory; const current_n = nPages(aligned_len); @@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { + _ = return_address; const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); const amt = n + ptr_align - 1 + @sizeOf(usize); @@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) { len_align: u29, return_address: usize, ) error{OutOfMemory}!usize { + _ = buf_align; + _ = return_address; const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); if (new_size == 0) { os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*)); @@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse return error.OutOfMemory; @@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = buf_align; + _ = return_address; const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); assert(self.ownsSlice(buf)); // sanity check @@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator); var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst); while (true) { diff --git a/lib/std/heap/arena_allocator.zig b/lib/std/heap/arena_allocator.zig index 1b301bbb50..356d5c5d81 100644 --- a/lib/std/heap/arena_allocator.zig +++ b/lib/std/heap/arena_allocator.zig @@ -66,6 +66,8 @@ pub const ArenaAllocator = struct { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); var cur_node = if (self.state.buffer_list.first) |first_node| first_node else try self.createNode(0, n + ptr_align); @@ -95,6 +97,9 @@ pub const ArenaAllocator = struct { } fn resize(allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize { + _ = buf_align; + _ = len_align; + _ = ret_addr; const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); const cur_node = self.state.buffer_list.first orelse return error.OutOfMemory; diff --git a/lib/std/heap/log_to_writer_allocator.zig b/lib/std/heap/log_to_writer_allocator.zig index 96c6971f38..c2fd687e0c 100644 --- a/lib/std/heap/log_to_writer_allocator.zig +++ b/lib/std/heap/log_to_writer_allocator.zig @@ -37,9 +37,9 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { const self = @fieldParentPtr(Self, "allocator", allocator); self.writer.print("alloc : {}", .{len}) catch {}; const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); - if (result) |buff| { + if (result) |_| { self.writer.print(" success!\n", .{}) catch {}; - } else |err| { + } else |_| { self.writer.print(" failure!\n", .{}) catch {}; } return result; diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig index ea63a76b72..7baa857f00 100644 --- a/lib/std/heap/logging_allocator.zig +++ b/lib/std/heap/logging_allocator.zig @@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator( ) error{OutOfMemory}![]u8 { const self = @fieldParentPtr(Self, "allocator", allocator); const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); - if (result) |buff| { + if (result) |_| { logHelper( success_log_level, "alloc - success - len: {}, ptr_align: {}, len_align: {}", diff --git a/lib/std/io.zig b/lib/std/io.zig index 1264ba4aef..8bb9c4d2c0 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -161,6 +161,7 @@ pub const null_writer = @as(NullWriter, .{ .context = {} }); const NullWriter = Writer(void, error{}, dummyWrite); fn dummyWrite(context: void, data: []const u8) error{}!usize { + _ = context; return data.len; } diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index 16411b4fa6..9092c8a62d 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { var out_bits_total = @as(usize, 0); //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced if (self.bit_count > 0) { - for (buffer) |*b, i| { + for (buffer) |*b| { b.* = try self.readBits(u8, u8_bit_count, &out_bits); out_bits_total += out_bits; } diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig index 7f80251543..daa0718a18 100644 --- a/lib/std/io/bit_writer.zig +++ b/lib/std/io/bit_writer.zig @@ -128,7 +128,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { pub fn write(self: *Self, buffer: []const u8) Error!usize { // TODO: I'm not sure this is a good idea, maybe flushBits should be forced if (self.bit_count > 0) { - for (buffer) |b, i| + for (buffer) |b| try self.writeBits(b, u8_bit_count); return buffer.len; } diff --git a/lib/std/json.zig b/lib/std/json.zig index 847d38f08d..8759469327 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1221,11 +1221,11 @@ test "json.token premature object close" { pub fn validate(s: []const u8) bool { var p = StreamingParser.init(); - for (s) |c, i| { + for (s) |c| { var token1: ?Token = undefined; var token2: ?Token = undefined; - p.feed(c, &token1, &token2) catch |err| { + p.feed(c, &token1, &token2) catch { return false; }; } @@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool { if (a == null or b == null) return false; return parsedEqual(a.?, b.?); }, - .Union => |unionInfo| { + .Union => { if (info.tag_type) |UnionTag| { const tag_a = std.meta.activeTag(a); const tag_b = std.meta.activeTag(b); @@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: const source_slice = stringToken.slice(tokens.slice, tokens.i - 1); switch (stringToken.escapes) { .None => return allocator.dupe(u8, source_slice), - .Some => |some_escapes| { + .Some => { const output = try allocator.alloc(u8, stringToken.decodedLength()); errdefer allocator.free(output); try unescapeValidString(output, source_slice); @@ -2391,7 +2391,7 @@ pub const Parser = struct { const slice = s.slice(input, i); switch (s.escapes) { .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice }, - .Some => |some_escapes| { + .Some => { const output = try allocator.alloc(u8, s.decodedLength()); errdefer allocator.free(output); try unescapeValidString(output, slice); @@ -2401,6 +2401,7 @@ pub const Parser = struct { } fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value { + _ = p; return if (n.is_integer) Value{ .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) { @@ -2815,7 +2816,7 @@ pub fn stringify( if (child_options.whitespace) |*child_whitespace| { child_whitespace.indent_level += 1; } - inline for (S.fields) |Field, field_i| { + inline for (S.fields) |Field| { // don't include void fields if (Field.field_type == void) continue; @@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" { options: StringifyOptions, out_stream: anytype, ) !void { + _ = value; try out_stream.writeAll("[\"something special\","); try stringify(42, options, out_stream); try out_stream.writeByte(']'); diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig index b1f56e21ab..6535c867f8 100644 --- a/lib/std/leb128.zig +++ b/lib/std/leb128.zig @@ -198,7 +198,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u var reader = std.io.fixedBufferStream(encoded); var i: usize = 0; while (i < N) : (i += 1) { - const v1 = try readILEB128(T, reader.reader()); + _ = try readILEB128(T, reader.reader()); } } @@ -206,7 +206,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u var reader = std.io.fixedBufferStream(encoded); var i: usize = 0; while (i < N) : (i += 1) { - const v1 = try readULEB128(T, reader.reader()); + _ = try readULEB128(T, reader.reader()); } } @@ -309,7 +309,6 @@ fn test_write_leb128(value: anytype) !void { const B = std.meta.Int(signedness, larger_type_bits); const bytes_needed = bn: { - const S = std.meta.Int(signedness, @sizeOf(T) * 8); if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value); diff --git a/lib/std/linked_list.zig b/lib/std/linked_list.zig index 49006343c5..7bab3e2188 100644 --- a/lib/std/linked_list.zig +++ b/lib/std/linked_list.zig @@ -359,8 +359,8 @@ test "basic TailQueue test" { } } - var first = list.popFirst(); // {2, 3, 4, 5} - var last = list.pop(); // {2, 3, 4} + _ = list.popFirst(); // {2, 3, 4, 5} + _ = list.pop(); // {2, 3, 4} list.remove(&three); // {2, 4} try testing.expect(list.first.?.data == 2); diff --git a/lib/std/log.zig b/lib/std/log.zig index 9d9271213b..a20648626e 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -142,6 +142,8 @@ fn log( if (@enumToInt(message_level) <= @enumToInt(effective_log_level)) { if (@hasDecl(root, "log")) { + if (@typeInfo(@TypeOf(root.log)) != .Fn) + @compileError("Expected root.log to be a function"); root.log(message_level, scope, format, args); } else if (std.Target.current.os.tag == .freestanding) { // On freestanding one must provide a log function; we do not have diff --git a/lib/std/macho.zig b/lib/std/macho.zig index 20620b1fbf..cb030e941e 100644 --- a/lib/std/macho.zig +++ b/lib/std/macho.zig @@ -24,6 +24,19 @@ pub const mach_header_64 = extern struct { reserved: u32, }; +pub const fat_header = extern struct { + magic: u32, + nfat_arch: u32, +}; + +pub const fat_arch = extern struct { + cputype: cpu_type_t, + cpusubtype: cpu_subtype_t, + offset: u32, + size: u32, + @"align": u32, +}; + pub const load_command = extern struct { cmd: u32, cmdsize: u32, @@ -1040,6 +1053,20 @@ pub const MH_APP_EXTENSION_SAFE = 0x02000000; /// The external symbols listed in the nlist symbol table do not include all the symbols listed in the dyld info. pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; +// Constants for the flags field of the fat_header + +/// the fat magic number +pub const FAT_MAGIC = 0xcafebabe; + +/// NXSwapLong(FAT_MAGIC) +pub const FAT_CIGAM = 0xbebafeca; + +/// the 64-bit fat magic number +pub const FAT_MAGIC_64 = 0xcafebabf; + +/// NXSwapLong(FAT_MAGIC_64) +pub const FAT_CIGAM_64 = 0xbfbafeca; + /// The flags field of a section structure is separated into two parts a section /// type and section attributes. The section types are mutually exclusive (it /// can only have one type) but the section attributes are not (it may have more diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index b2997536a6..cbae123189 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -458,6 +458,7 @@ pub const Mutable = struct { /// If `allocator` is provided, it will be used for temporary storage to improve /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm. pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void { + _ = opt_allocator; assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing mem.set(Limb, rma.limbs, 0); @@ -676,6 +677,7 @@ pub const Mutable = struct { /// /// `limbs_buffer` is used for temporary storage during the operation. pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { + _ = limbs_buffer; assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing return gcdLehmer(rma, x, y, allocator); @@ -1141,6 +1143,7 @@ pub const Const = struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; comptime var radix = 10; comptime var case: std.fmt.Case = .lower; @@ -1618,6 +1621,7 @@ pub const Managed = struct { /// Converts self to a string in the requested base. Memory is allocated from the provided /// allocator and not the one present in self. pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 { + _ = allocator; if (base < 2 or base > 16) return error.InvalidBase; return self.toConst().toStringAlloc(self.allocator, base, case); } @@ -2000,8 +2004,6 @@ fn llmulacc_karatsuba(allocator: *Allocator, r: []Limb, x: []const Limb, y: []co } else { llsub(j1, y0[0..y0_len], y1[0..y1_len]); } - const j0_len = llnormalize(j0); - const j1_len = llnormalize(j1); if (x_cmp == y_cmp) { mem.set(Limb, tmp[0..length], 0); llmulacc(allocator, tmp, j0, j1); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 987889feca..8b7c2d45d6 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -204,7 +204,6 @@ pub const Rational = struct { const esize = math.floatExponentBits(T); const ebias = (1 << (esize - 1)) - 1; const emin = 1 - ebias; - const emax = ebias; if (self.p.eqZero()) { return 0; diff --git a/lib/std/math/complex/ldexp.zig b/lib/std/math/complex/ldexp.zig index 51ac105256..c0a6c7a934 100644 --- a/lib/std/math/complex/ldexp.zig +++ b/lib/std/math/complex/ldexp.zig @@ -12,8 +12,8 @@ const std = @import("../../std.zig"); const debug = std.debug; const math = std.math; -const cmath = math.complex; const testing = std.testing; +const cmath = math.complex; const Complex = cmath.Complex; /// Returns exp(z) scaled to avoid overflow. diff --git a/lib/std/math/expm1.zig b/lib/std/math/expm1.zig index d7a2e6a844..ebc76165ba 100644 --- a/lib/std/math/expm1.zig +++ b/lib/std/math/expm1.zig @@ -316,16 +316,12 @@ test "math.expm1_64" { } test "math.expm1_32.special" { - const epsilon = 0.000001; - try expect(math.isPositiveInf(expm1_32(math.inf(f32)))); try expect(expm1_32(-math.inf(f32)) == -1.0); try expect(math.isNan(expm1_32(math.nan(f32)))); } test "math.expm1_64.special" { - const epsilon = 0.000001; - try expect(math.isPositiveInf(expm1_64(math.inf(f64)))); try expect(expm1_64(-math.inf(f64)) == -1.0); try expect(math.isNan(expm1_64(math.nan(f64)))); diff --git a/lib/std/math/modf.zig b/lib/std/math/modf.zig index 6eef6fdd37..2a8cf00bbb 100644 --- a/lib/std/math/modf.zig +++ b/lib/std/math/modf.zig @@ -12,6 +12,7 @@ const std = @import("../std.zig"); const math = std.math; const expect = std.testing.expect; +const expectEqual = std.testing.expectEqual; const maxInt = std.math.maxInt; fn modf_result(comptime T: type) type { @@ -131,11 +132,7 @@ test "math.modf" { const a = modf(@as(f32, 1.0)); const b = modf32(1.0); // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still. - try expect(a.ipart == b.ipart and a.fpart == b.fpart); - - const c = modf(@as(f64, 1.0)); - const d = modf64(1.0); - try expect(a.ipart == b.ipart and a.fpart == b.fpart); + try expectEqual(a, b); } test "math.modf32" { diff --git a/lib/std/mem.zig b/lib/std/mem.zig index ecdad6d314..b7b9d92165 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -139,6 +139,11 @@ var failAllocator = Allocator{ .resizeFn = Allocator.noResize, }; fn failAllocatorAlloc(self: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 { + _ = self; + _ = n; + _ = alignment; + _ = len_align; + _ = ra; return error.OutOfMemory; } @@ -1534,6 +1539,34 @@ test "writeIntBig and writeIntLittle" { try testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xfc, 0xff })); } +/// Swap the byte order of all the members of the fields of a struct +/// (Changing their endianess) +pub fn bswapAllFields(comptime S: type, ptr: *S) void { + if (@typeInfo(S) != .Struct) @compileError("bswapAllFields expects a struct as the first argument"); + inline for (std.meta.fields(S)) |f| { + @field(ptr, f.name) = @byteSwap(f.field_type, @field(ptr, f.name)); + } +} + +test "bswapAllFields" { + const T = extern struct { + f0: u8, + f1: u16, + f2: u32, + }; + var s = T{ + .f0 = 0x12, + .f1 = 0x1234, + .f2 = 0x12345678, + }; + bswapAllFields(T, &s); + try std.testing.expectEqual(T{ + .f0 = 0x12, + .f1 = 0x3412, + .f2 = 0x78563412, + }, s); +} + /// Returns an iterator that iterates over the slices of `buffer` that are not /// any of the bytes in `delimiter_bytes`. /// tokenize(" abc def ghi ", " ") diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 6cc888fa10..1e13ed97b7 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -55,6 +55,10 @@ pub fn noResize( len_align: u29, ret_addr: usize, ) Error!usize { + _ = self; + _ = buf_align; + _ = len_align; + _ = ret_addr; if (new_len > buf.len) return error.OutOfMemory; return new_len; diff --git a/lib/std/meta.zig b/lib/std/meta.zig index e19208cd84..03fb4f80f1 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -654,7 +654,6 @@ pub fn TagPayload(comptime U: type, tag: Tag(U)) type { try testing.expect(trait.is(.Union)(U)); const info = @typeInfo(U).Union; - const tag_info = @typeInfo(Tag(U)).Enum; inline for (info.fields) |field_info| { if (comptime mem.eql(u8, field_info.name, @tagName(tag))) @@ -757,12 +756,6 @@ test "std.meta.eql" { .c = "12345".*, }; - const s_2 = S{ - .a = 1, - .b = 123.3, - .c = "54321".*, - }; - var s_3 = S{ .a = 134, .b = 123.3, @@ -850,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { const S = struct { fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool { + _ = context; return mem.lessThan(u8, lhs.name, rhs.name); } }; diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index 94f2043b00..595f6917d9 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -96,18 +96,18 @@ pub fn TrailerFlags(comptime Fields: type) type { pub fn ptr(self: Self, p: [*]align(@alignOf(Fields)) u8, comptime field: FieldEnum) *Field(field) { if (@sizeOf(Field(field)) == 0) return undefined; - const off = self.offset(p, field); + const off = self.offset(field); return @ptrCast(*Field(field), @alignCast(@alignOf(Field(field)), p + off)); } pub fn ptrConst(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) *const Field(field) { if (@sizeOf(Field(field)) == 0) return undefined; - const off = self.offset(p, field); + const off = self.offset(field); return @ptrCast(*const Field(field), @alignCast(@alignOf(Field(field)), p + off)); } - pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize { + pub fn offset(self: Self, comptime field: FieldEnum) usize { var off: usize = 0; inline for (@typeInfo(Fields).Struct.fields) |field_info, i| { const active = (self.bits & (1 << i)) != 0; diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 7a071a8928..9707c0634a 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -92,6 +92,7 @@ pub fn MultiArrayList(comptime S: type) type { } const Sort = struct { fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool { + _ = trash; return lhs.alignment > rhs.alignment; } }; @@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type { /// retain list ordering. pub fn swapRemove(self: *Self, index: usize) void { const slices = self.slice(); - inline for (fields) |field_info, i| { + inline for (fields) |_, i| { const field_slice = slices.items(@intToEnum(Field, i)); field_slice[index] = field_slice[self.len - 1]; field_slice[self.len - 1] = undefined; @@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type { /// after it to preserve order. pub fn orderedRemove(self: *Self, index: usize) void { const slices = self.slice(); - inline for (fields) |field_info, field_index| { + inline for (fields) |_, field_index| { const field_slice = slices.items(@intToEnum(Field, field_index)); var i = index; while (i < self.len - 1) : (i += 1) { diff --git a/lib/std/net.zig b/lib/std/net.zig index ff0e299a7e..46d9bee15d 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -270,6 +270,8 @@ pub const Ip4Address = extern struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; const bytes = @ptrCast(*const [4]u8, &self.sa.addr); try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{ bytes[0], @@ -281,6 +283,7 @@ pub const Ip4Address = extern struct { } pub fn getOsSockLen(self: Ip4Address) os.socklen_t { + _ = self; return @sizeOf(os.sockaddr_in); } }; @@ -556,6 +559,8 @@ pub const Ip6Address = extern struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; const port = mem.bigToNative(u16, self.sa.port); if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{ @@ -598,6 +603,7 @@ pub const Ip6Address = extern struct { } pub fn getOsSockLen(self: Ip6Address) os.socklen_t { + _ = self; return @sizeOf(os.sockaddr_in6); } }; @@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool { // Parameters `b` and `a` swapped to make this descending. fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool { + _ = context; return a.sortkey < b.sortkey; } diff --git a/lib/std/once.zig b/lib/std/once.zig index c56e572570..05f003c796 100644 --- a/lib/std/once.zig +++ b/lib/std/once.zig @@ -61,6 +61,7 @@ test "Once executes its function just once" { for (threads) |*handle| { handle.* = try std.Thread.spawn(struct { fn thread_fn(x: u8) void { + _ = x; global_once.call(); } }.thread_fn, 0); diff --git a/lib/std/os.zig b/lib/std/os.zig index dce1f044ca..968d0a26f6 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions { /// TODO currently, this function does not handle all flag combinations /// or makes use of perm argument. pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t { + _ = perm; var options = openOptionsFromFlags(flags); options.dir = std.fs.cwd().fd; return windows.OpenFile(file_path_w, options) catch |err| switch (err) { @@ -1273,6 +1274,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) /// TODO currently, this function does not handle all flag combinations /// or makes use of perm argument. pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t { + _ = mode; var options = openOptionsFromFlags(flags); options.dir = dir_fd; return windows.OpenFile(file_path_w, options) catch |err| switch (err) { @@ -2169,6 +2171,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { + _ = mode; switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { wasi.ESUCCESS => return, wasi.EACCES => return error.AccessDenied, @@ -2216,6 +2219,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr } pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void { + _ = mode; const sub_dir_handle = windows.OpenFile(sub_path_w, .{ .dir = dir_fd, .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, @@ -2291,6 +2295,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void { /// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded. pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void { + _ = mode; const sub_dir_handle = windows.OpenFile(dir_path_w, .{ .dir = std.fs.cwd().fd, .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, @@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void { /// Otherwise use `access` or `accessC`. /// TODO currently this ignores `mode`. pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void { + _ = mode; const ret = try windows.GetFileAttributesW(path); if (ret != windows.INVALID_FILE_ATTRIBUTES) { return; @@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces /// is NtDll-prefixed, null-terminated, WTF-16 encoded. /// TODO currently this ignores `mode` and `flags` pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void { + _ = mode; + _ = flags; if (sub_path_w[0] == '.' and sub_path_w[1] == 0) { return; } @@ -4895,6 +4903,8 @@ pub fn res_mkquery( newrr: ?[*]const u8, buf: []u8, ) usize { + _ = data; + _ = newrr; // This implementation is ported from musl libc. // A more idiomatic "ziggy" implementation would be welcome. var name = dname; @@ -5341,7 +5351,7 @@ pub fn sendfile( ENXIO => return error.Unseekable, ESPIPE => return error.Unseekable, else => |err| { - const discard = unexpectedErrno(err); + unexpectedErrno(err) catch {}; break :sf; }, } @@ -5422,7 +5432,7 @@ pub fn sendfile( EPIPE => return error.BrokenPipe, else => { - const discard = unexpectedErrno(err); + unexpectedErrno(err) catch {}; if (amt != 0) { return amt; } else { @@ -5484,7 +5494,7 @@ pub fn sendfile( EPIPE => return error.BrokenPipe, else => { - const discard = unexpectedErrno(err); + unexpectedErrno(err) catch {}; if (amt != 0) { return amt; } else { @@ -5542,10 +5552,7 @@ pub const CopyFileRangeError = error{ FileBusy, } || PReadError || PWriteError || UnexpectedError; -var has_copy_file_range_syscall = init: { - const kernel_has_syscall = std.Target.current.os.isAtLeast(.linux, .{ .major = 4, .minor = 5 }) orelse true; - break :init std.atomic.Atomic(bool).init(kernel_has_syscall); -}; +var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true); /// Transfer data between file descriptors at specified offsets. /// Returns the number of bytes written, which can less than requested. @@ -5573,18 +5580,17 @@ var has_copy_file_range_syscall = init: { /// /// Maximum offsets on Linux are `math.maxInt(i64)`. pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize { - const use_c = std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok; - - if (std.Target.current.os.tag == .linux and - (use_c or has_copy_file_range_syscall.load(.Monotonic))) - { - const sys = if (use_c) std.c else linux; + const call_cfr = comptime if (builtin.link_libc) + std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok + else + std.Target.current.os.isAtLeast(.linux, .{ .major = 4, .minor = 5 }) orelse true; + if (call_cfr and has_copy_file_range_syscall.load(.Monotonic)) { var off_in_copy = @bitCast(i64, off_in); var off_out_copy = @bitCast(i64, off_out); - const rc = sys.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); - switch (sys.getErrno(rc)) { + const rc = system.copy_file_range(fd_in, &off_in_copy, fd_out, &off_out_copy, len, flags); + switch (system.getErrno(rc)) { 0 => return @intCast(usize, rc), EBADF => return error.FilesOpenedWithWrongFlags, EFBIG => return error.FileTooBig, @@ -5601,7 +5607,7 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len EXDEV => {}, // syscall added in Linux 4.5, use fallback ENOSYS => { - has_copy_file_range_syscall.store(true, .Monotonic); + has_copy_file_range_syscall.store(false, .Monotonic); }, else => |err| return unexpectedErrno(err), } diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index d4491da6d0..7501d54bbe 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36; pub const CAP_AUDIT_READ = 37; pub const CAP_LAST_CAP = CAP_AUDIT_READ; -pub fn cap_valid(u8: x) bool { +pub fn cap_valid(x: u8) bool { return x >= 0 and x <= CAP_LAST_CAP; } diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 4b3454de52..26f489a345 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -34,6 +34,7 @@ pub usingnamespace switch (native_arch) { }; pub usingnamespace @import("bits.zig"); pub const tls = @import("linux/tls.zig"); +pub const pie = @import("linux/start_pie.zig"); pub const BPF = @import("linux/bpf.zig"); pub usingnamespace @import("linux/io_uring.zig"); @@ -69,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 { }; } fn splitValueBE64(val: i64) [2]u32 { + const u = @bitCast(u64, val); return [2]u32{ @truncate(u32, u >> 32), @truncate(u32, u), @@ -1021,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize for (msgvec[0..kvlen]) |*msg, i| { var size: i32 = 0; const msg_iovlen = @intCast(usize, msg.msg_hdr.msg_iovlen); // kernel side this is treated as unsigned - for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov, j| { + for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) { // batch-send all messages up to the current message if (next_unsent < i) { diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index 4249e7774b..86993083e3 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -1513,7 +1513,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries EINVAL => error.MapTypeOrAttrInvalid, ENOMEM => error.SystemResources, EPERM => error.AccessDenied, - else => |err| unexpectedErrno(rc), + else => |err| unexpectedErrno(err), }; } @@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { EINVAL => return error.FieldInAttrNeedsZeroing, ENOENT => return error.NotFound, EPERM => return error.AccessDenied, - else => |err| return unexpectedErrno(rc), + else => |err| return unexpectedErrno(err), } } diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index ca80a381f5..dd7956f0c1 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -284,6 +284,7 @@ pub const IO_Uring = struct { } fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 { + _ = wait_nr; const ready = self.cq_ready(); const count = std.math.min(cqes.len, ready); var head = self.cq.head.*; @@ -320,6 +321,7 @@ pub const IO_Uring = struct { /// Not idempotent, calling more than once will result in other CQEs being lost. /// Matches the implementation of cqe_seen() in liburing. pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void { + _ = cqe; self.cq_advance(1); } @@ -728,6 +730,7 @@ pub const CompletionQueue = struct { } pub fn deinit(self: *CompletionQueue) void { + _ = self; // A no-op since we now share the mmap with the submission queue. // Here for symmetry with the submission queue, and for any future feature support. } @@ -1272,12 +1275,12 @@ test "accept/connect/send/recv" { var accept_addr: os.sockaddr = undefined; var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr)); - const accept = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0); + _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0); try testing.expectEqual(@as(u32, 1), try ring.submit()); const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0); defer os.close(client); - const connect = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen()); + _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen()); try testing.expectEqual(@as(u32, 1), try ring.submit()); var cqe_accept = try ring.copy_cqe(); @@ -1305,7 +1308,7 @@ test "accept/connect/send/recv" { const send = try ring.send(0xeeeeeeee, client, buffer_send[0..], 0); send.flags |= linux.IOSQE_IO_LINK; - const recv = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0); + _ = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0); try testing.expectEqual(@as(u32, 2), try ring.submit()); const cqe_send = try ring.copy_cqe(); diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index ddb3103cfa..a04a592f3b 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -31,7 +31,8 @@ pub fn syscall_pipe(fd: *[2]i32) usize { \\ sw $3, 4($4) \\ 2: : [ret] "={$2}" (-> usize) - : [number] "{$2}" (@enumToInt(SYS.pipe)) + : [number] "{$2}" (@enumToInt(SYS.pipe)), + [fd] "{$4}" (fd) : "memory", "cc", "$7" ); } diff --git a/lib/std/os/linux/start_pie.zig b/lib/std/os/linux/start_pie.zig index 9ff6124359..19e1a29bc5 100644 --- a/lib/std/os/linux/start_pie.zig +++ b/lib/std/os/linux/start_pie.zig @@ -8,33 +8,35 @@ const R_386_RELATIVE = 8; const R_ARM_RELATIVE = 23; const R_AARCH64_RELATIVE = 1027; const R_RISCV_RELATIVE = 3; +const R_SPARC_RELATIVE = 22; -const ARCH_RELATIVE_RELOC = switch (builtin.cpu.arch) { +const R_RELATIVE = switch (builtin.cpu.arch) { .i386 => R_386_RELATIVE, .x86_64 => R_AMD64_RELATIVE, .arm => R_ARM_RELATIVE, .aarch64 => R_AARCH64_RELATIVE, .riscv64 => R_RISCV_RELATIVE, - else => @compileError("unsupported architecture"), + else => @compileError("Missing R_RELATIVE definition for this target"), }; -// Just a convoluted (but necessary) way to obtain the address of the _DYNAMIC[] -// vector as PC-relative so that we can use it before any relocation is applied +// Obtain a pointer to the _DYNAMIC array. +// We have to compute its address as a PC-relative quantity not to require a +// relocation that, at this point, is not yet applied. fn getDynamicSymbol() [*]elf.Dyn { - const addr = switch (builtin.cpu.arch) { + return switch (builtin.cpu.arch) { .i386 => asm volatile ( \\ .weak _DYNAMIC \\ .hidden _DYNAMIC \\ call 1f \\ 1: pop %[ret] \\ lea _DYNAMIC-1b(%[ret]), %[ret] - : [ret] "=r" (-> usize) + : [ret] "=r" (-> [*]elf.Dyn) ), .x86_64 => asm volatile ( \\ .weak _DYNAMIC \\ .hidden _DYNAMIC \\ lea _DYNAMIC(%%rip), %[ret] - : [ret] "=r" (-> usize) + : [ret] "=r" (-> [*]elf.Dyn) ), // Work around the limited offset range of `ldr` .arm => asm volatile ( @@ -45,7 +47,7 @@ fn getDynamicSymbol() [*]elf.Dyn { \\ b 2f \\ 1: .word _DYNAMIC-1b \\ 2: - : [ret] "=r" (-> usize) + : [ret] "=r" (-> [*]elf.Dyn) ), // A simple `adr` is not enough as it has a limited offset range .aarch64 => asm volatile ( @@ -53,61 +55,39 @@ fn getDynamicSymbol() [*]elf.Dyn { \\ .hidden _DYNAMIC \\ adrp %[ret], _DYNAMIC \\ add %[ret], %[ret], #:lo12:_DYNAMIC - : [ret] "=r" (-> usize) + : [ret] "=r" (-> [*]elf.Dyn) ), .riscv64 => asm volatile ( \\ .weak _DYNAMIC \\ .hidden _DYNAMIC \\ lla %[ret], _DYNAMIC - : [ret] "=r" (-> usize) + : [ret] "=r" (-> [*]elf.Dyn) ), - else => @compileError("???"), + else => { + @compileError("PIE startup is not yet supported for this target!"); + }, }; - return @intToPtr([*]elf.Dyn, addr); } -pub fn apply_relocations() void { +pub fn relocate(phdrs: []elf.Phdr) void { @setRuntimeSafety(false); const dynv = getDynamicSymbol(); - const auxv = std.os.linux.elf_aux_maybe.?; - var at_phent: usize = undefined; - var at_phnum: usize = undefined; - var at_phdr: usize = undefined; - var at_hwcap: usize = undefined; - - { - var i: usize = 0; - while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { - switch (auxv[i].a_type) { - elf.AT_PHENT => at_phent = auxv[i].a_un.a_val, - elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val, - elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val, - else => continue, - } - } - } - - // Sanity check - assert(at_phent == @sizeOf(elf.Phdr)); - - // Search the TLS section - const phdrs = (@intToPtr([*]elf.Phdr, at_phdr))[0..at_phnum]; - - const base_addr = blk: { + // Recover the delta applied by the loader by comparing the effective and + // the theoretical load addresses for the `_DYNAMIC` symbol. + const base_addr = base: { for (phdrs) |*phdr| { - if (phdr.p_type == elf.PT_DYNAMIC) { - break :blk @ptrToInt(&dynv[0]) - phdr.p_vaddr; - } + if (phdr.p_type != elf.PT_DYNAMIC) continue; + break :base @ptrToInt(dynv) - phdr.p_vaddr; } - unreachable; + // This is not supposed to happen for well-formed binaries. + std.os.abort(); }; var rel_addr: usize = 0; var rela_addr: usize = 0; var rel_size: usize = 0; var rela_size: usize = 0; - { var i: usize = 0; while (dynv[i].d_tag != elf.DT_NULL) : (i += 1) { @@ -121,18 +101,18 @@ pub fn apply_relocations() void { } } - // Perform the relocations + // Apply the relocations. if (rel_addr != 0) { const rel = std.mem.bytesAsSlice(elf.Rel, @intToPtr([*]u8, rel_addr)[0..rel_size]); for (rel) |r| { - if (r.r_type() != ARCH_RELATIVE_RELOC) continue; + if (r.r_type() != R_RELATIVE) continue; @intToPtr(*usize, base_addr + r.r_offset).* += base_addr; } } if (rela_addr != 0) { const rela = std.mem.bytesAsSlice(elf.Rela, @intToPtr([*]u8, rela_addr)[0..rela_size]); for (rela) |r| { - if (r.r_type() != ARCH_RELATIVE_RELOC) continue; + if (r.r_type() != R_RELATIVE) continue; @intToPtr(*usize, base_addr + r.r_offset).* += base_addr + @bitCast(usize, r.r_addend); } } diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index 502868f9d4..5649cadd8b 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -190,53 +190,18 @@ pub fn setThreadPointer(addr: usize) void { } } -fn initTLS() void { +fn initTLS(phdrs: []elf.Phdr) void { var tls_phdr: ?*elf.Phdr = null; var img_base: usize = 0; - const auxv = std.os.linux.elf_aux_maybe.?; - var at_phent: usize = undefined; - var at_phnum: usize = undefined; - var at_phdr: usize = undefined; - var at_hwcap: usize = undefined; - - var i: usize = 0; - while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { - switch (auxv[i].a_type) { - elf.AT_PHENT => at_phent = auxv[i].a_un.a_val, - elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val, - elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val, - elf.AT_HWCAP => at_hwcap = auxv[i].a_un.a_val, - else => continue, - } - } - - // Sanity check - assert(at_phent == @sizeOf(elf.Phdr)); - - // Find the TLS section - const phdrs = (@intToPtr([*]elf.Phdr, at_phdr))[0..at_phnum]; - for (phdrs) |*phdr| { switch (phdr.p_type) { - elf.PT_PHDR => img_base = at_phdr - phdr.p_vaddr, + elf.PT_PHDR => img_base = @ptrToInt(phdrs.ptr) - phdr.p_vaddr, elf.PT_TLS => tls_phdr = phdr, else => {}, } } - // ARMv6 targets (and earlier) have no support for TLS in hardware - // FIXME: Elide the check for targets >= ARMv7 when the target feature API - // becomes less verbose (and more usable). - if (comptime native_arch.isARM()) { - if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { - // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls - // For the time being use a simple abort instead of a @panic call to - // keep the binary bloat under control. - std.os.abort(); - } - } - var tls_align_factor: usize = undefined; var tls_data: []const u8 = undefined; var tls_data_alloc_size: usize = undefined; @@ -344,8 +309,8 @@ pub fn prepareTLS(area: []u8) usize { // overhead. var main_thread_tls_buffer: [0x2100]u8 align(mem.page_size) = undefined; -pub fn initStaticTLS() void { - initTLS(); +pub fn initStaticTLS(phdrs: []elf.Phdr) void { + initTLS(phdrs); const tls_area = blk: { // Fast path for the common case where the TLS data is really small, diff --git a/lib/std/os/linux/vdso.zig b/lib/std/os/linux/vdso.zig index f2e4f1f5bc..f42bb06452 100644 --- a/lib/std/os/linux/vdso.zig +++ b/lib/std/os/linux/vdso.zig @@ -15,7 +15,6 @@ pub fn lookup(vername: []const u8, name: []const u8) usize { const eh = @intToPtr(*elf.Ehdr, vdso_addr); var ph_addr: usize = vdso_addr + eh.e_phoff; - const ph = @intToPtr(*elf.Phdr, ph_addr); var maybe_dynv: ?[*]usize = null; var base: usize = maxInt(usize); diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 6e2aa2aeb9..7a88ecd7ca 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -353,6 +353,7 @@ test "spawn threads" { } fn start1(ctx: void) u8 { + _ = ctx; return 0; } @@ -379,6 +380,7 @@ test "thread local storage" { threadlocal var x: i32 = 1234; fn testTls(context: void) !void { + _ = context; if (x != 1234) return error.TlsBadStartValue; x += 1; if (x != 1235) return error.TlsBadEndValue; @@ -425,6 +427,7 @@ const IterFnError = error{ }; fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { + _ = size; // Count how many libraries are loaded counter.* += @as(usize, 1); @@ -731,6 +734,7 @@ test "sigaction" { const S = struct { fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void { + _ = ctx_ptr; // Check that we received the correct signal. switch (native_os) { .netbsd => { diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig index 1942165999..4bb8e37559 100644 --- a/lib/std/os/uefi.zig +++ b/lib/std/os/uefi.zig @@ -37,6 +37,7 @@ pub const Guid = extern struct { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = options; if (f.len == 0) { return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ self.time_low, diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig index 6652107a1a..0da6d902f3 100644 --- a/lib/std/os/uefi/protocols/managed_network_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig @@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct { /// Translates an IP multicast address to a hardware (MAC) multicast address. /// This function may be unsupported in some MNP implementations. pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status { + _ = mac_address; return self._mcast_ip_to_mac(self, ipv6flag, ipaddress); } diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index 23252011c2..1fade2a462 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -1156,7 +1156,6 @@ pub fn GetFinalPathNameByHandle( &mount_points_struct.MountPoints[0], )[0..mount_points_struct.NumberOfMountPoints]; - var found: bool = false; for (mount_points) |mount_point| { const symlink = @ptrCast( [*]const u16, diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig index ec401e98e2..571aae6e4d 100644 --- a/lib/std/packed_int_array.zig +++ b/lib/std/packed_int_array.zig @@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim ///Returns the number of elements in the packed array pub fn len(self: Self) usize { + _ = self; return int_count; } diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig index 4f3962ceb5..30b98941b0 100644 --- a/lib/std/pdb.zig +++ b/lib/std/pdb.zig @@ -594,6 +594,7 @@ pub const Pdb = struct { error.InvalidValue => return error.InvalidDebugInfo, else => |e| return e, }; + _ = version; sect_cont_offset += @sizeOf(u32); } while (sect_cont_offset != section_contrib_size) { @@ -617,6 +618,7 @@ pub const Pdb = struct { // Parse the InfoStreamHeader. const version = try reader.readIntLittle(u32); const signature = try reader.readIntLittle(u32); + _ = signature; const age = try reader.readIntLittle(u32); const guid = try reader.readBytesNoEof(16); @@ -673,6 +675,7 @@ pub const Pdb = struct { } pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 { + _ = self; std.debug.assert(module.populated); var symbol_i: usize = 0; @@ -904,7 +907,7 @@ const Msf = struct { // These streams are not used, but still participate in the file // and must be taken into account when resolving stream indices. const Nil = 0xFFFFFFFF; - for (stream_sizes) |*s, i| { + for (stream_sizes) |*s| { const size = try directory.reader().readIntLittle(u32); s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize); } diff --git a/lib/std/priority_dequeue.zig b/lib/std/priority_dequeue.zig index 0bb1f13503..81329a0a74 100644 --- a/lib/std/priority_dequeue.zig +++ b/lib/std/priority_dequeue.zig @@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type { warn("{}, ", .{e}); } warn("array: ", .{}); - for (self.items) |e, i| { + for (self.items) |e| { warn("{}, ", .{e}); } warn("len: {} ", .{self.len}); diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig index 4e5320a92b..de68442ea7 100644 --- a/lib/std/priority_queue.zig +++ b/lib/std/priority_queue.zig @@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type { warn("{}, ", .{e}); } warn("array: ", .{}); - for (self.items) |e, i| { + for (self.items) |e| { warn("{}, ", .{e}); } warn("len: {} ", .{self.len}); diff --git a/lib/std/process.zig b/lib/std/process.zig index d5a2045699..83926ee5af 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct { }; } fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void { + _ = self; var i: usize = 0; while (i < emit_count) : (i += 1) { try buf.append(std.mem.nativeToLittle(u16, '\\')); @@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] } try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct { fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void { + _ = size; const name = info.dlpi_name orelse return; if (name[0] == '/') { const item = try list.allocator.dupeZ(u8, mem.spanZ(name)); diff --git a/lib/std/rand/ziggurat.zig b/lib/std/rand/ziggurat.zig index fe120943d7..c01f7c659a 100644 --- a/lib/std/rand/ziggurat.zig +++ b/lib/std/rand/ziggurat.zig @@ -175,5 +175,5 @@ test "exp dist sanity" { test "table gen" { if (please_windows_dont_oom) return error.SkipZigTest; - const table = NormDist; + _ = NormDist; } diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 2d84beaef6..67a4394b1e 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -37,9 +37,11 @@ pub fn binarySearch( test "binarySearch" { const S = struct { fn order_u32(context: void, lhs: u32, rhs: u32) math.Order { + _ = context; return math.order(lhs, rhs); } fn order_i32(context: void, lhs: i32, rhs: i32) math.Order { + _ = context; return math.order(lhs, rhs); } }; @@ -1133,6 +1135,7 @@ fn swap( pub fn asc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { + _ = context; return a < b; } }; @@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool { pub fn desc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { + _ = context; return a > b; } }; diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 510dd578c3..7530fae4f0 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -104,6 +104,12 @@ pub fn main() !void { warn("Expected argument after {s}\n\n", .{arg}); return usageAndErr(builder, false, stderr_stream); }; + } else if (mem.eql(u8, arg, "--sysroot")) { + const sysroot = nextArg(args, &arg_idx) orelse { + warn("Expected argument after --sysroot\n\n", .{}); + return usageAndErr(builder, false, stderr_stream); + }; + builder.sysroot = sysroot; } else if (mem.eql(u8, arg, "--search-prefix")) { const search_prefix = nextArg(args, &arg_idx) orelse { warn("Expected argument after --search-prefix\n\n", .{}); @@ -214,6 +220,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void \\ --prefix-exe-dir [path] Override default executable directory path \\ --prefix-include-dir [path] Override default include directory path \\ + \\ --sysroot [path] Set the system root directory (usually /) \\ --search-prefix [path] Add a path to look for binaries, libraries, headers \\ --libc [file] Provide a file which specifies libc paths \\ diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 1377212870..a6de965f90 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -160,6 +160,7 @@ fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int { } fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 { + _ = errnum; return "TODO strerror implementation"; } @@ -173,6 +174,7 @@ test "strncmp" { // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = error_return_trace; if (builtin.is_test) { @setCold(true); std.debug.panic("{s}", .{msg}); diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index a777067800..dcbdebec73 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -602,6 +602,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = error_return_trace; @setCold(true); if (is_test) { std.debug.panic("{s}", .{msg}); diff --git a/lib/std/special/compiler_rt/addXf3.zig b/lib/std/special/compiler_rt/addXf3.zig index 5a2f3c976c..c5c7397680 100644 --- a/lib/std/special/compiler_rt/addXf3.zig +++ b/lib/std/special/compiler_rt/addXf3.zig @@ -83,7 +83,6 @@ fn addXf3(comptime T: type, a: T, b: T) T { const signBit = (@as(Z, 1) << (significandBits + exponentBits)); const maxExponent = ((1 << exponentBits) - 1); - const exponentBias = (maxExponent >> 1); const implicitBit = (@as(Z, 1) << significandBits); const quietBit = implicitBit >> 1; @@ -98,10 +97,6 @@ fn addXf3(comptime T: type, a: T, b: T) T { const aAbs = aRep & absMask; const bAbs = bRep & absMask; - const negative = (aRep & signBit) != 0; - const exponent = @intCast(i32, aAbs >> significandBits) - exponentBias; - const significand = (aAbs & significandMask) | implicitBit; - const infRep = @bitCast(Z, std.math.inf(T)); // Detect if a or b is zero, infinity, or NaN. diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index e448a580ca..1b592da019 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{}; // Those work on any object no matter the pointer alignment nor its size. fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(src)); defer sl.release(); @memcpy(dest, src, size); } fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(dest)); defer sl.release(); @memcpy(dest, src, size); } fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @memcpy(old, ptr, size); @@ -106,6 +109,8 @@ fn __atomic_compare_exchange( success: i32, failure: i32, ) callconv(.C) i32 { + _ = success; + _ = failure; var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); for (ptr[0..size]) |b, i| { @@ -135,6 +140,7 @@ comptime { fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T { return struct { fn atomic_load_N(src: *T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(src)); defer sl.release(); @@ -162,6 +168,7 @@ comptime { fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void { return struct { fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(dst)); defer sl.release(); @@ -189,6 +196,7 @@ comptime { fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { return struct { fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @@ -218,6 +226,8 @@ comptime { fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 { return struct { fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { + _ = success; + _ = failure; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @@ -255,6 +265,7 @@ comptime { fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { return struct { pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); diff --git a/lib/std/special/compiler_rt/comparedf2_test.zig b/lib/std/special/compiler_rt/comparedf2_test.zig index b0916c10ae..018d95c0ae 100644 --- a/lib/std/special/compiler_rt/comparedf2_test.zig +++ b/lib/std/special/compiler_rt/comparedf2_test.zig @@ -100,7 +100,7 @@ const test_vectors = init: { }; test "compare f64" { - for (test_vectors) |vector, i| { + for (test_vectors) |vector| { try std.testing.expect(test__cmpdf2(vector)); } } diff --git a/lib/std/special/compiler_rt/comparesf2_test.zig b/lib/std/special/compiler_rt/comparesf2_test.zig index 9719873f62..10ffc3c063 100644 --- a/lib/std/special/compiler_rt/comparesf2_test.zig +++ b/lib/std/special/compiler_rt/comparesf2_test.zig @@ -100,7 +100,7 @@ const test_vectors = init: { }; test "compare f32" { - for (test_vectors) |vector, i| { + for (test_vectors) |vector| { try std.testing.expect(test__cmpsf2(vector)); } } diff --git a/lib/std/special/compiler_rt/divtf3.zig b/lib/std/special/compiler_rt/divtf3.zig index 9c18e79dd5..d8ef463e49 100644 --- a/lib/std/special/compiler_rt/divtf3.zig +++ b/lib/std/special/compiler_rt/divtf3.zig @@ -12,7 +12,6 @@ const wideMultiply = @import("divdf3.zig").wideMultiply; pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { @setRuntimeSafety(builtin.is_test); const Z = std.meta.Int(.unsigned, 128); - const SignedZ = std.meta.Int(.signed, 128); const significandBits = std.math.floatMantissaBits(f128); const exponentBits = std.math.floatExponentBits(f128); diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig index 59be8441fa..9a42a938b9 100644 --- a/lib/std/special/compiler_rt/extendXfYf2.zig +++ b/lib/std/special/compiler_rt/extendXfYf2.zig @@ -46,7 +46,6 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsi const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); - const SrcShift = std.math.Log2Int(src_rep_t); const DstShift = std.math.Log2Int(dst_rep_t); // Various constants whose values follow from the type parameters. diff --git a/lib/std/special/compiler_rt/fixuint.zig b/lib/std/special/compiler_rt/fixuint.zig index 755e1b8bb2..518b5de4e4 100644 --- a/lib/std/special/compiler_rt/fixuint.zig +++ b/lib/std/special/compiler_rt/fixuint.zig @@ -16,7 +16,6 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t else => unreachable, }; const typeWidth = @typeInfo(rep_t).Int.bits; - const srep_t = @import("std").meta.Int(.signed, typeWidth); const significandBits = switch (fp_t) { f32 => 23, f64 => 52, diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig index e85aa363db..9f34812199 100644 --- a/lib/std/special/compiler_rt/truncXfYf2.zig +++ b/lib/std/special/compiler_rt/truncXfYf2.zig @@ -50,7 +50,6 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); const SrcShift = std.math.Log2Int(src_rep_t); - const DstShift = std.math.Log2Int(dst_rep_t); // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. diff --git a/lib/std/special/ssp.zig b/lib/std/special/ssp.zig index 81db44a534..6eda11b2e2 100644 --- a/lib/std/special/ssp.zig +++ b/lib/std/special/ssp.zig @@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 // Avoid dragging in the runtime safety mechanisms into this .o file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = msg; + _ = error_return_trace; @setCold(true); if (@hasDecl(std.os, "abort")) std.os.abort(); diff --git a/lib/std/start.zig b/lib/std/start.zig index 389caf8da1..7f73ba46db 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -10,6 +10,7 @@ const std = @import("std.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const uefi = std.os.uefi; +const elf = std.elf; const tlcsprng = @import("crypto/tlcsprng.zig"); const native_arch = builtin.cpu.arch; const native_os = builtin.os.tag; @@ -281,49 +282,60 @@ fn posixCallMainAndExit() noreturn { if (native_os == .linux) { // Find the beginning of the auxiliary vector - const auxv = @ptrCast([*]std.elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1)); + const auxv = @ptrCast([*]elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1)); std.os.linux.elf_aux_maybe = auxv; - // Do this as early as possible, the aux vector is needed + var at_hwcap: usize = 0; + const phdrs = init: { + var i: usize = 0; + var at_phdr: usize = 0; + var at_phnum: usize = 0; + while (auxv[i].a_type != elf.AT_NULL) : (i += 1) { + switch (auxv[i].a_type) { + elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val, + elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val, + elf.AT_HWCAP => at_hwcap = auxv[i].a_un.a_val, + else => continue, + } + } + break :init @intToPtr([*]elf.Phdr, at_phdr)[0..at_phnum]; + }; + + // Apply the initial relocations as early as possible in the startup + // process. if (builtin.position_independent_executable) { - @import("os/linux/start_pie.zig").apply_relocations(); + std.os.linux.pie.relocate(phdrs); } - // Initialize the TLS area. We do a runtime check here to make sure - // this code is truly being statically executed and not inside a dynamic - // loader, otherwise this would clobber the thread ID register. - const is_dynamic = @import("dynamic_library.zig").get_DYNAMIC() != null; - if (!is_dynamic) { - std.os.linux.tls.initStaticTLS(); + // ARMv6 targets (and earlier) have no support for TLS in hardware. + // FIXME: Elide the check for targets >= ARMv7 when the target feature API + // becomes less verbose (and more usable). + if (comptime native_arch.isARM()) { + if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { + // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls + // For the time being use a simple abort instead of a @panic call to + // keep the binary bloat under control. + std.os.abort(); + } } + // Initialize the TLS area. + std.os.linux.tls.initStaticTLS(phdrs); + // The way Linux executables represent stack size is via the PT_GNU_STACK // program header. However the kernel does not recognize it; it always gives 8 MiB. // Here we look for the stack size in our program headers and use setrlimit // to ask for more stack space. - { - var i: usize = 0; - var at_phdr: usize = undefined; - var at_phnum: usize = undefined; - while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { - switch (auxv[i].a_type) { - std.elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val, - std.elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val, - else => continue, - } - } - expandStackSize(at_phdr, at_phnum); - } + expandStackSize(phdrs); } std.os.exit(@call(.{ .modifier = .always_inline }, callMainWithArgs, .{ argc, argv, envp })); } -fn expandStackSize(at_phdr: usize, at_phnum: usize) void { - const phdrs = (@intToPtr([*]std.elf.Phdr, at_phdr))[0..at_phnum]; +fn expandStackSize(phdrs: []elf.Phdr) void { for (phdrs) |*phdr| { switch (phdr.p_type) { - std.elf.PT_GNU_STACK => { + elf.PT_GNU_STACK => { const wanted_stack_size = phdr.p_memsz; assert(wanted_stack_size % std.mem.page_size == 0); @@ -362,9 +374,10 @@ fn main(c_argc: i32, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C) const envp = @ptrCast([*][*:0]u8, c_envp)[0..env_count]; if (builtin.os.tag == .linux) { - const at_phdr = std.c.getauxval(std.elf.AT_PHDR); - const at_phnum = std.c.getauxval(std.elf.AT_PHNUM); - expandStackSize(at_phdr, at_phnum); + const at_phdr = std.c.getauxval(elf.AT_PHDR); + const at_phnum = std.c.getauxval(elf.AT_PHNUM); + const phdrs = (@intToPtr([*]elf.Phdr, at_phdr))[0..at_phnum]; + expandStackSize(phdrs); } return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp }); diff --git a/lib/std/target.zig b/lib/std/target.zig index faebe665ab..02ce44d477 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -157,7 +157,7 @@ pub const Target = struct { pub fn format( self: WindowsVersion, comptime fmt: []const u8, - options: std.fmt.FormatOptions, + _: std.fmt.FormatOptions, out_stream: anytype, ) !void { if (fmt.len > 0 and fmt[0] == 's') { diff --git a/lib/std/testing.zig b/lib/std/testing.zig index be3e76dcdb..a370c21c29 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -191,7 +191,6 @@ test "expectEqual.union(enum)" { }; const a10 = T{ .a = 10 }; - const a20 = T{ .a = 20 }; try expectEqual(a10, a10); } diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index 48310e17da..0b0e470efb 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool { return false; } i += cp_len; - } else |err| { + } else |_| { return false; } } diff --git a/lib/std/unicode/throughput_test.zig b/lib/std/unicode/throughput_test.zig index 8f9f9d9cb7..e49da8ceaf 100644 --- a/lib/std/unicode/throughput_test.zig +++ b/lib/std/unicode/throughput_test.zig @@ -47,8 +47,6 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { pub fn main() !void { const stdout = std.io.getStdOut().writer(); - const args = try std.process.argsAlloc(std.heap.page_allocator); - try stdout.print("short ASCII strings\n", .{}); { const result = try benchmarkCodepointCount("abc"); diff --git a/lib/std/x/net/ip.zig b/lib/std/x/net/ip.zig index 7f2d82d208..409a8ebadf 100644 --- a/lib/std/x/net/ip.zig +++ b/lib/std/x/net/ip.zig @@ -53,6 +53,8 @@ pub const Address = union(enum) { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; + _ = layout; switch (self) { .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), diff --git a/lib/std/x/os/io.zig b/lib/std/x/os/io.zig index 1c0e0e9130..b0df3f947e 100644 --- a/lib/std/x/os/io.zig +++ b/lib/std/x/os/io.zig @@ -122,7 +122,6 @@ test "reactor/linux: drive async tcp client/listener pair" { const IPv4 = std.x.os.IPv4; const IPv6 = std.x.os.IPv6; - const Socket = std.x.os.Socket; const reactor = try Reactor.init(.{ .close_on_exec = true }); defer reactor.deinit(); diff --git a/lib/std/x/os/net.zig b/lib/std/x/os/net.zig index bbb2c105a7..d946926932 100644 --- a/lib/std/x/os/net.zig +++ b/lib/std/x/os/net.zig @@ -143,6 +143,7 @@ pub const IPv4 = extern struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; if (comptime layout.len != 0 and layout[0] != 's') { @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'."); } @@ -352,6 +353,7 @@ pub const IPv6 = extern struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) { 'x', 'X' => |specifier| specifier, 's' => 'x', diff --git a/lib/std/x/os/socket.zig b/lib/std/x/os/socket.zig index 61e47939f8..9da74d5b0e 100644 --- a/lib/std/x/os/socket.zig +++ b/lib/std/x/os/socket.zig @@ -117,7 +117,7 @@ pub const Socket = struct { }; } - /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. + /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. pub fn getNativeSize(self: Socket.Address) u32 { return switch (self) { .ipv4 => @sizeOf(os.sockaddr_in), @@ -132,6 +132,8 @@ pub const Socket = struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; + _ = layout; switch (self) { .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), @@ -280,7 +282,7 @@ pub const Socket = struct { /// /// Microsoft's documentation and glibc denote the fields to be unsigned /// short's on Windows, whereas glibc and musl denote the fields to be - /// int's on every other platform. + /// int's on every other platform. pub const Linger = extern struct { pub const Field = switch (native_os.tag) { .windows => c_ushort, diff --git a/lib/std/x/os/socket_windows.zig b/lib/std/x/os/socket_windows.zig index d479d8619a..c08931fedf 100644 --- a/lib/std/x/os/socket_windows.zig +++ b/lib/std/x/os/socket_windows.zig @@ -292,6 +292,7 @@ pub fn Mixin(comptime Socket: type) type { /// with a set of flags specified. It returns the number of bytes that were /// read into the buffer provided. pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize { + _ = flags; const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG); var num_bytes: u32 = undefined; @@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type { /// Query and return the latest cached error on the socket. pub fn getError(self: Socket) !void { + _ = self; return {}; } /// Query the read buffer size of the socket. pub fn getReadBufferSize(self: Socket) !u32 { + _ = self; return 0; } /// Query the write buffer size of the socket. pub fn getWriteBufferSize(self: Socket) !u32 { + _ = self; return 0; } @@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type { /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if - /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. + /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. pub fn setKeepAlive(self: Socket, enabled: bool) !void { return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled)))); } @@ -438,7 +442,7 @@ pub fn Mixin(comptime Socket: type) type { /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is /// set on a non-blocking socket. - /// + /// /// Set a timeout on the socket that is to occur if no messages are successfully written /// to its bound destination after a specified number of milliseconds. A subsequent write /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded. @@ -448,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type { /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is /// set on a non-blocking socket. - /// + /// /// Set a timeout on the socket that is to occur if no messages are successfully read /// from its bound destination after a specified number of milliseconds. A subsequent /// read from the socket will thereafter return `error.WouldBlock` should the timeout be diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 7c67e03b67..59fe2fdff1 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -280,9 +280,6 @@ pub const Tree = struct { token_tags[parse_error.token].symbol(), }); }, - .invalid_and => { - return stream.writeAll("`&&` is invalid; note that `and` is boolean AND"); - }, .invalid_bit_range => { return stream.writeAll("bit range not allowed on slices and arrays"); }, @@ -1869,7 +1866,7 @@ pub const Tree = struct { } fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit { - const token_tags = tree.tokens.items(.tag); + _ = tree; var result: full.StructInit = .{ .ast = info, }; @@ -2412,7 +2409,6 @@ pub const Error = struct { extra_const_qualifier, extra_volatile_qualifier, ptr_mod_on_array_child_type, - invalid_and, invalid_bit_range, invalid_token, same_line_doc_comment, diff --git a/lib/std/zig/c_builtins.zig b/lib/std/zig/c_builtins.zig index d8a23ec8f1..afa3ae0a87 100644 --- a/lib/std/zig/c_builtins.zig +++ b/lib/std/zig/c_builtins.zig @@ -136,6 +136,7 @@ pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int { } pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize { + _ = ptr; // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html // If it is not possible to determine which objects ptr points to at compile time, // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 @@ -186,6 +187,7 @@ pub inline fn __builtin_memcpy( /// The return value of __builtin_expect is `expr`. `c` is the expected value /// of `expr` and is used as a hint to the compiler in C. Here it is unused. pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long { + _ = c; return expr; } diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig index 6e0f721b4f..7851525bb7 100644 --- a/lib/std/zig/c_translation.zig +++ b/lib/std/zig/c_translation.zig @@ -11,7 +11,7 @@ const mem = std.mem; /// Given a type and value, cast the value to the type as c would. pub fn cast(comptime DestType: type, target: anytype) DestType { - // this function should behave like transCCast in translate-c, except it's for macros and enums + // this function should behave like transCCast in translate-c, except it's for macros const SourceType = @TypeOf(target); switch (@typeInfo(DestType)) { .Fn, .Pointer => return castToPtr(DestType, SourceType, target), @@ -20,12 +20,6 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { return castToPtr(DestType, SourceType, target); } }, - .Enum => |enum_type| { - if (@typeInfo(SourceType) == .Int or @typeInfo(SourceType) == .ComptimeInt) { - const intermediate = cast(enum_type.tag_type, target); - return @intToEnum(DestType, intermediate); - } - }, .Int => { switch (@typeInfo(SourceType)) { .Pointer => { @@ -36,9 +30,6 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { return castInt(DestType, @ptrToInt(target)); } }, - .Enum => { - return castInt(DestType, @enumToInt(target)); - }, .Int => { return castInt(DestType, target); }, @@ -106,12 +97,6 @@ fn ptrInfo(comptime PtrType: type) std.builtin.TypeInfo.Pointer { } test "cast" { - const E = enum(u2) { - Zero, - One, - Two, - }; - var i = @as(i64, 10); try testing.expect(cast(*u8, 16) == @intToPtr(*u8, 16)); @@ -122,12 +107,9 @@ test "cast" { try testing.expect(cast(?*i64, @as(*align(1) i64, &i)) == &i); try testing.expect(cast(?*i64, @as(?*align(1) i64, &i)) == &i); - try testing.expect(cast(E, 1) == .One); - try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(*u32, 4))); try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(?*u32, 4))); try testing.expectEqual(@as(u32, 10), cast(u32, @as(u64, 10))); - try testing.expectEqual(@as(u8, 2), cast(u8, E.Two)); try testing.expectEqual(@bitCast(i32, @as(u32, 0x8000_0000)), cast(i32, @as(u32, 0x8000_0000))); @@ -136,17 +118,6 @@ test "cast" { try testing.expectEqual(@intToPtr(?*c_void, 2), cast(?*c_void, @intToPtr(*u8, 2))); - const C_ENUM = enum(c_int) { - A = 0, - B, - C, - _, - }; - try testing.expectEqual(cast(C_ENUM, @as(i64, -1)), @intToEnum(C_ENUM, -1)); - try testing.expectEqual(cast(C_ENUM, @as(i8, 1)), .B); - try testing.expectEqual(cast(C_ENUM, @as(u64, 1)), .B); - try testing.expectEqual(cast(C_ENUM, @as(u64, 42)), @intToEnum(C_ENUM, 42)); - var foo: c_int = -1; try testing.expect(cast(*c_void, -1) == @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)))); try testing.expect(cast(*c_void, foo) == @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)))); @@ -162,7 +133,7 @@ test "cast" { pub fn sizeof(target: anytype) usize { const T: type = if (@TypeOf(target) == type) target else @TypeOf(target); switch (@typeInfo(T)) { - .Float, .Int, .Struct, .Union, .Enum, .Array, .Bool, .Vector => return @sizeOf(T), + .Float, .Int, .Struct, .Union, .Array, .Bool, .Vector => return @sizeOf(T), .Fn => { // sizeof(main) returns 1, sizeof(&main) returns pointer size. // We cannot distinguish those types in Zig, so use pointer size. @@ -228,7 +199,6 @@ pub fn sizeof(target: anytype) usize { } test "sizeof" { - const E = enum(c_int) { One, _ }; const S = extern struct { a: u32 }; const ptr_size = @sizeOf(*c_void); @@ -239,9 +209,6 @@ test "sizeof" { try testing.expect(sizeof(2.0) == @sizeOf(f64)); - try testing.expect(sizeof(E) == @sizeOf(c_int)); - try testing.expect(sizeof(E.One) == @sizeOf(c_int)); - try testing.expect(sizeof(S) == 4); try testing.expect(sizeof([_]u32{ 4, 5, 6 }) == 12); diff --git a/lib/std/zig/fmt.zig b/lib/std/zig/fmt.zig index 3a55b5df30..2afbe1d91b 100644 --- a/lib/std/zig/fmt.zig +++ b/lib/std/zig/fmt.zig @@ -8,6 +8,7 @@ pub fn formatId( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; if (isValidId(bytes)) { return writer.writeAll(bytes); } @@ -41,6 +42,7 @@ pub fn formatEscapes( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = options; for (bytes) |byte| switch (byte) { '\n' => try writer.writeAll("\\n"), '\r' => try writer.writeAll("\\r"), diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index cc323382cd..5bafcce5b1 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -586,7 +586,7 @@ const Parser = struct { const thread_local_token = p.eatToken(.keyword_threadlocal); const var_decl = try p.parseVarDecl(); if (var_decl != 0) { - const semicolon_token = try p.expectToken(.semicolon); + _ = try p.expectToken(.semicolon); return var_decl; } if (thread_local_token != null) { @@ -614,7 +614,7 @@ const Parser = struct { fn expectUsingNamespace(p: *Parser) !Node.Index { const usingnamespace_token = p.assertToken(.keyword_usingnamespace); const expr = try p.expectExpr(); - const semicolon_token = try p.expectToken(.semicolon); + _ = try p.expectToken(.semicolon); return p.addNode(.{ .tag = .@"usingnamespace", .main_token = usingnamespace_token, @@ -647,7 +647,7 @@ const Parser = struct { const align_expr = try p.parseByteAlign(); const section_expr = try p.parseLinkSection(); const callconv_expr = try p.parseCallconv(); - const bang_token = p.eatToken(.bang); + _ = p.eatToken(.bang); const return_type_expr = try p.parseTypeExpr(); if (return_type_expr == 0) { @@ -775,7 +775,7 @@ const Parser = struct { /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)? fn expectContainerField(p: *Parser) !Node.Index { - const comptime_token = p.eatToken(.keyword_comptime); + _ = p.eatToken(.keyword_comptime); const name_token = p.assertToken(.identifier); var align_expr: Node.Index = 0; @@ -967,7 +967,7 @@ const Parser = struct { _ = try p.expectToken(.l_paren); const condition = try p.expectExpr(); _ = try p.expectToken(.r_paren); - const then_payload = try p.parsePtrPayload(); + _ = try p.parsePtrPayload(); // TODO propose to change the syntax so that semicolons are always required // inside if statements, even if there is an `else`. @@ -992,7 +992,7 @@ const Parser = struct { else_required = true; break :blk assign_expr; }; - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { if (else_required) { try p.warn(.expected_semi_or_else); } @@ -1005,7 +1005,7 @@ const Parser = struct { }, }); }; - const else_payload = try p.parsePayload(); + _ = try p.parsePayload(); const else_expr = try p.expectStatement(); return p.addNode(.{ .tag = .@"if", @@ -1087,7 +1087,7 @@ const Parser = struct { else_required = true; break :blk assign_expr; }; - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { if (else_required) { try p.warn(.expected_semi_or_else); } @@ -1122,7 +1122,7 @@ const Parser = struct { _ = try p.expectToken(.l_paren); const condition = try p.expectExpr(); _ = try p.expectToken(.r_paren); - const then_payload = try p.parsePtrPayload(); + _ = try p.parsePtrPayload(); const cont_expr = try p.parseWhileContinueExpr(); // TODO propose to change the syntax so that semicolons are always required @@ -1162,7 +1162,7 @@ const Parser = struct { else_required = true; break :blk assign_expr; }; - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { if (else_required) { try p.warn(.expected_semi_or_else); } @@ -1189,7 +1189,7 @@ const Parser = struct { }); } }; - const else_payload = try p.parsePayload(); + _ = try p.parsePayload(); const else_expr = try p.expectStatement(); return p.addNode(.{ .tag = .@"while", @@ -1333,7 +1333,6 @@ const Parser = struct { .keyword_or = .{ .prec = 10, .tag = .bool_or }, .keyword_and = .{ .prec = 20, .tag = .bool_and }, - .invalid_ampersands = .{ .prec = 20, .tag = .bool_and }, .equal_equal = .{ .prec = 30, .tag = .equal_equal, .assoc = Assoc.none }, .bang_equal = .{ .prec = 30, .tag = .bang_equal, .assoc = Assoc.none }, @@ -1385,9 +1384,6 @@ const Parser = struct { .keyword_catch => { _ = try p.parsePayload(); }, - .invalid_ampersands => { - try p.warn(.invalid_and); - }, else => {}, } const rhs = try p.parseExprPrecedence(info.prec + 1); @@ -1554,7 +1550,7 @@ const Parser = struct { }, .l_bracket => switch (p.token_tags[p.tok_i + 1]) { .asterisk => { - const lbracket = p.nextToken(); + _ = p.nextToken(); const asterisk = p.nextToken(); var sentinel: Node.Index = 0; prefix: { @@ -1911,7 +1907,7 @@ const Parser = struct { if (found_payload == 0) try p.warn(.expected_loop_payload); const then_expr = try p.expectExpr(); - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { return p.addNode(.{ .tag = .for_simple, .main_token = for_token, @@ -1942,11 +1938,11 @@ const Parser = struct { _ = try p.expectToken(.l_paren); const condition = try p.expectExpr(); _ = try p.expectToken(.r_paren); - const then_payload = try p.parsePtrPayload(); + _ = try p.parsePtrPayload(); const cont_expr = try p.parseWhileContinueExpr(); const then_expr = try p.expectExpr(); - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { if (cont_expr == 0) { return p.addNode(.{ .tag = .while_simple, @@ -1970,7 +1966,7 @@ const Parser = struct { }); } }; - const else_payload = try p.parsePayload(); + _ = try p.parsePayload(); const else_expr = try p.expectExpr(); return p.addNode(.{ .tag = .@"while", @@ -2108,7 +2104,7 @@ const Parser = struct { /// FnCallArguments <- LPAREN ExprList RPAREN /// ExprList <- (Expr COMMA)* Expr? fn parseSuffixExpr(p: *Parser) !Node.Index { - if (p.eatToken(.keyword_async)) |async_token| { + if (p.eatToken(.keyword_async)) |_| { var res = try p.expectPrimaryTypeExpr(); while (true) { const node = try p.parseSuffixOp(res); @@ -2569,8 +2565,8 @@ const Parser = struct { p.tok_i += 2; while (true) { if (p.eatToken(.r_brace)) |_| break; - const doc_comment = try p.eatDocComments(); - const identifier = try p.expectToken(.identifier); + _ = try p.eatDocComments(); + _ = try p.expectToken(.identifier); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, .r_brace => { @@ -2638,7 +2634,7 @@ const Parser = struct { if (found_payload == 0) try p.warn(.expected_loop_payload); const then_expr = try p.expectTypeExpr(); - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { return p.addNode(.{ .tag = .for_simple, .main_token = for_token, @@ -2669,11 +2665,11 @@ const Parser = struct { _ = try p.expectToken(.l_paren); const condition = try p.expectExpr(); _ = try p.expectToken(.r_paren); - const then_payload = try p.parsePtrPayload(); + _ = try p.parsePtrPayload(); const cont_expr = try p.parseWhileContinueExpr(); const then_expr = try p.expectTypeExpr(); - const else_token = p.eatToken(.keyword_else) orelse { + _ = p.eatToken(.keyword_else) orelse { if (cont_expr == 0) { return p.addNode(.{ .tag = .while_simple, @@ -2697,7 +2693,7 @@ const Parser = struct { }); } }; - const else_payload = try p.parsePayload(); + _ = try p.parsePayload(); const else_expr = try p.expectTypeExpr(); return p.addNode(.{ .tag = .@"while", @@ -3574,12 +3570,12 @@ const Parser = struct { _ = try p.expectToken(.l_paren); const condition = try p.expectExpr(); _ = try p.expectToken(.r_paren); - const then_payload = try p.parsePtrPayload(); + _ = try p.parsePtrPayload(); const then_expr = try bodyParseFn(p); if (then_expr == 0) return p.fail(.invalid_token); - const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{ + _ = p.eatToken(.keyword_else) orelse return p.addNode(.{ .tag = .if_simple, .main_token = if_token, .data = .{ @@ -3587,7 +3583,7 @@ const Parser = struct { .rhs = then_expr, }, }); - const else_payload = try p.parsePayload(); + _ = try p.parsePayload(); const else_expr = try bodyParseFn(p); if (else_expr == 0) return p.fail(.invalid_token); diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index f6aab4ceca..907e06a1a6 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -4930,7 +4930,6 @@ test "recovery: missing comma" { , &[_]Error{ .expected_token, .expected_token, - .invalid_and, .invalid_token, }); } @@ -4963,7 +4962,6 @@ test "recovery: missing return type" { \\test "" , &[_]Error{ .expected_return_type, - .invalid_and, .expected_block, }); } @@ -4980,7 +4978,6 @@ test "recovery: continue after invalid decl" { .expected_token, .expected_pub_item, .expected_param_list, - .invalid_and, }); try testError( \\threadlocal test "" { @@ -4989,7 +4986,6 @@ test "recovery: continue after invalid decl" { , &[_]Error{ .expected_var_decl, .expected_param_list, - .invalid_and, }); } @@ -4998,13 +4994,11 @@ test "recovery: invalid extern/inline" { \\inline test "" { a && b; } , &[_]Error{ .expected_fn, - .invalid_and, }); try testError( \\extern "" test "" { a && b; } , &[_]Error{ .expected_var_decl_or_fn, - .invalid_and, }); } @@ -5016,9 +5010,7 @@ test "recovery: missing semicolon" { \\ @foo \\} , &[_]Error{ - .invalid_and, .expected_token, - .invalid_and, .expected_token, .expected_param_list, .expected_token, @@ -5038,7 +5030,6 @@ test "recovery: invalid container members" { .expected_expr, .expected_token, .expected_container_members, - .invalid_and, .expected_token, }); } @@ -5076,7 +5067,6 @@ test "recovery: invalid global error set access" { , &[_]Error{ .expected_token, .expected_token, - .invalid_and, }); } @@ -5094,7 +5084,6 @@ test "recovery: invalid asterisk after pointer dereference" { \\} , &[_]Error{ .asterisk_after_ptr_deref, - .invalid_and, }); } @@ -5110,7 +5099,6 @@ test "recovery: missing semicolon after if, for, while stmt" { .expected_semi_or_else, .expected_semi_or_else, .expected_semi_or_else, - .invalid_and, }); } @@ -5213,7 +5201,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b defer tree.deinit(allocator); for (tree.errors) |parse_error| { - const token_start = tree.tokens.items(.start)[parse_error.token]; const loc = tree.tokenLocation(0, parse_error.token); try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 }); try tree.renderError(parse_error, stderr); diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 95b5c7a8d8..36fb7f5e14 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1086,8 +1086,6 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full. } if (while_node.ast.else_expr != 0) { - const first_else_expr_tok = tree.firstToken(while_node.ast.else_expr); - if (indent_then_expr) { ais.pushIndent(); try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .newline); @@ -1133,7 +1131,6 @@ fn renderContainerField( field: ast.full.ContainerField, space: Space, ) Error!void { - const main_tokens = tree.nodes.items(.main_token); if (field.comptime_token) |t| { try renderToken(ais, tree, t, .space); // comptime } @@ -1519,7 +1516,6 @@ fn renderBlock( ) Error!void { const token_tags = tree.tokens.items(.tag); const node_tags = tree.nodes.items(.tag); - const nodes_data = tree.nodes.items(.data); const lbrace = tree.nodes.items(.main_token)[block_node]; if (token_tags[lbrace - 1] == .colon and @@ -1617,7 +1613,6 @@ fn renderArrayInit( space: Space, ) Error!void { const token_tags = tree.tokens.items(.tag); - const token_starts = tree.tokens.items(.start); if (array_init.ast.type_expr == 0) { try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // . @@ -2046,7 +2041,6 @@ fn renderCall( space: Space, ) Error!void { const token_tags = tree.tokens.items(.tag); - const main_tokens = tree.nodes.items(.main_token); if (call.async_token) |async_token| { try renderToken(ais, tree, async_token, .space); diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index bc099b8ec6..a4939b8347 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -200,6 +200,7 @@ pub const NativePaths = struct { } fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void { + _ = self; const item = try array.allocator.dupeZ(u8, s); errdefer array.allocator.free(item); try array.append(item); @@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct { if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| { os.version_range.semver.min = ver; os.version_range.semver.max = ver; - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } }, @@ -478,13 +479,6 @@ pub const NativeTargetInfo = struct { } const ld_info_list = ld_info_list_buffer[0..ld_info_list_len]; - if (cross_target.dynamic_linker.get()) |explicit_ld| { - const explicit_ld_basename = fs.path.basename(explicit_ld); - for (ld_info_list) |ld_info| { - const standard_ld_basename = fs.path.basename(ld_info.ld.get().?); - } - } - // Best case scenario: the executable is dynamically linked, and we can iterate // over our own shared objects and find a dynamic linker. self_exe: { @@ -838,7 +832,7 @@ pub const NativeTargetInfo = struct { if (dynstr) |ds| { const strtab_len = std.math.min(ds.size, strtab_buf.len); - const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, shstrtab_len); + const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, strtab_len); const strtab = strtab_buf[0..strtab_read_len]; // TODO this pointer cast should not be necessary const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) { diff --git a/lib/std/zig/system/macos.zig b/lib/std/zig/system/macos.zig index 0b3e639582..ae450ecae5 100644 --- a/lib/std/zig/system/macos.zig +++ b/lib/std/zig/system/macos.zig @@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void { return; } continue; - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } } diff --git a/lib/std/zig/system/x86.zig b/lib/std/zig/system/x86.zig index 9a33a1daaf..1d9a22d5d2 100644 --- a/lib/std/zig/system/x86.zig +++ b/lib/std/zig/system/x86.zig @@ -28,6 +28,7 @@ inline fn hasMask(input: u32, mask: u32) bool { } pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu { + _ = cross_target; var cpu = Target.Cpu{ .arch = arch, .model = Target.Cpu.Model.generic(arch), diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig index 39d24493e9..94a20d958b 100644 --- a/lib/std/zig/tokenizer.zig +++ b/lib/std/zig/tokenizer.zig @@ -76,7 +76,6 @@ pub const Token = struct { pub const Tag = enum { invalid, - invalid_ampersands, invalid_periodasterisks, identifier, string_literal, @@ -210,7 +209,6 @@ pub const Token = struct { .container_doc_comment, => null, - .invalid_ampersands => "&&", .invalid_periodasterisks => ".**", .bang => "!", .pipe => "|", @@ -418,7 +416,6 @@ pub const Tokenizer = struct { self.pending_invalid_token = null; return token; } - const start_index = self.index; var state: State = .start; var result = Token{ .tag = .eof, @@ -579,11 +576,6 @@ pub const Tokenizer = struct { }, .ampersand => switch (c) { - '&' => { - result.tag = .invalid_ampersands; - self.index += 1; - break; - }, '=' => { result.tag = .ampersand_equal; self.index += 1; diff --git a/src/AstGen.zig b/src/AstGen.zig index 54500675df..bcfb5a45b7 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -17,6 +17,16 @@ tree: *const ast.Tree, instructions: std.MultiArrayList(Zir.Inst) = .{}, extra: ArrayListUnmanaged(u32) = .{}, string_bytes: ArrayListUnmanaged(u8) = .{}, +/// Tracks the current byte offset within the source file. +/// Used to populate line deltas in the ZIR. AstGen maintains +/// this "cursor" throughout the entire AST lowering process in order +/// to avoid starting over the line/column scan for every declaration, which +/// would be O(N^2). +source_offset: u32 = 0, +/// Tracks the current line of `source_offset`. +source_line: u32 = 0, +/// Tracks the current column of `source_offset`. +source_column: u32 = 0, /// Used for temporary allocations; freed after AstGen is complete. /// The resulting ZIR code has no references to anything in this arena. arena: *Allocator, @@ -206,7 +216,6 @@ pub const ResultLoc = union(enum) { }; fn strategy(rl: ResultLoc, block_scope: *GenZir) Strategy { - var elide_store_to_block_ptr_instructions = false; switch (rl) { // In this branch there will not be any store_to_block_ptr instructions. .discard, .none, .none_or_ref, .ty, .ref => return .{ @@ -482,61 +491,61 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .assign => { try assign(gz, scope, node); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_bit_shift_left => { try assignShift(gz, scope, node, .shl); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_bit_shift_right => { try assignShift(gz, scope, node, .shr); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_bit_and => { try assignOp(gz, scope, node, .bit_and); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_bit_or => { try assignOp(gz, scope, node, .bit_or); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_bit_xor => { try assignOp(gz, scope, node, .xor); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_div => { try assignOp(gz, scope, node, .div); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_sub => { try assignOp(gz, scope, node, .sub); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_sub_wrap => { try assignOp(gz, scope, node, .subwrap); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_mod => { try assignOp(gz, scope, node, .mod_rem); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_add => { try assignOp(gz, scope, node, .add); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_add_wrap => { try assignOp(gz, scope, node, .addwrap); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_mul => { try assignOp(gz, scope, node, .mul); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .assign_mul_wrap => { try assignOp(gz, scope, node, .mulwrap); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, // zig fmt: off @@ -551,7 +560,23 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .mul_wrap => return simpleBinOp(gz, scope, rl, node, .mulwrap), .div => return simpleBinOp(gz, scope, rl, node, .div), .mod => return simpleBinOp(gz, scope, rl, node, .mod_rem), - .bit_and => return simpleBinOp(gz, scope, rl, node, .bit_and), + .bit_and => { + const current_ampersand_token = main_tokens[node]; + if (token_tags[current_ampersand_token + 1] == .ampersand) { + const token_starts = tree.tokens.items(.start); + const current_token_offset = token_starts[current_ampersand_token]; + const next_token_offset = token_starts[current_ampersand_token + 1]; + if (current_token_offset + 1 == next_token_offset) { + return astgen.failTok( + current_ampersand_token, + "`&&` is invalid; note that `and` is boolean AND", + .{}, + ); + } + } + + return simpleBinOp(gz, scope, rl, node, .bit_and); + }, .bit_or => return simpleBinOp(gz, scope, rl, node, .bit_or), .bit_xor => return simpleBinOp(gz, scope, rl, node, .xor), @@ -582,10 +607,10 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .asm_simple => return asmExpr(gz, scope, rl, node, tree.asmSimple(node)), .@"asm" => return asmExpr(gz, scope, rl, node, tree.asmFull(node)), - .string_literal => return stringLiteral(gz, scope, rl, node), - .multiline_string_literal => return multilineStringLiteral(gz, scope, rl, node), + .string_literal => return stringLiteral(gz, rl, node), + .multiline_string_literal => return multilineStringLiteral(gz, rl, node), - .integer_literal => return integerLiteral(gz, scope, rl, node), + .integer_literal => return integerLiteral(gz, rl, node), // zig fmt: on .builtin_call_two, .builtin_call_two_comma => { @@ -625,7 +650,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr }, .@"return" => return ret(gz, scope, node), .field_access => return fieldAccess(gz, scope, rl, node), - .float_literal => return floatLiteral(gz, scope, rl, node), + .float_literal => return floatLiteral(gz, rl, node), .if_simple => return ifExpr(gz, scope, rl, node, tree.ifSimple(node)), .@"if" => return ifExpr(gz, scope, rl, node, tree.ifFull(node)), @@ -644,7 +669,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .lhs = lhs, .start = start, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .slice => { const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); @@ -656,7 +681,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .start = start, .end = end, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .slice_sentinel => { const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); @@ -670,7 +695,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .end = end, .sentinel = sentinel, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .deref => { @@ -679,22 +704,22 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .ref, .none_or_ref => return lhs, else => { const result = try gz.addUnNode(.load, lhs, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, } }, .address_of => { const result = try expr(gz, scope, .ref, node_datas[node].lhs); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, - .undefined_literal => return rvalue(gz, scope, rl, .undef, node), - .true_literal => return rvalue(gz, scope, rl, .bool_true, node), - .false_literal => return rvalue(gz, scope, rl, .bool_false, node), - .null_literal => return rvalue(gz, scope, rl, .null_value, node), + .undefined_literal => return rvalue(gz, rl, .undef, node), + .true_literal => return rvalue(gz, rl, .bool_true, node), + .false_literal => return rvalue(gz, rl, .bool_false, node), + .null_literal => return rvalue(gz, rl, .null_value, node), .optional_type => { const operand = try typeExpr(gz, scope, node_datas[node].lhs); const result = try gz.addUnNode(.optional_type, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .unwrap_optional => switch (rl) { .ref => return gz.addUnNode( @@ -702,7 +727,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr try expr(gz, scope, .ref, node_datas[node].lhs), node, ), - else => return rvalue(gz, scope, rl, try gz.addUnNode( + else => return rvalue(gz, rl, try gz.addUnNode( .optional_payload_safe, try expr(gz, scope, .none, node_datas[node].lhs), node, @@ -722,13 +747,13 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs]; return blockExpr(gz, scope, rl, node, statements); }, - .enum_literal => return simpleStrTok(gz, scope, rl, main_tokens[node], node, .enum_literal), - .error_value => return simpleStrTok(gz, scope, rl, node_datas[node].rhs, node, .error_value), - .anyframe_literal => return rvalue(gz, scope, rl, .anyframe_type, node), + .enum_literal => return simpleStrTok(gz, rl, main_tokens[node], node, .enum_literal), + .error_value => return simpleStrTok(gz, rl, node_datas[node].rhs, node, .error_value), + .anyframe_literal => return rvalue(gz, rl, .anyframe_type, node), .anyframe_type => { const return_type = try typeExpr(gz, scope, node_datas[node].rhs); const result = try gz.addUnNode(.anyframe_type, return_type, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .@"catch" => { const catch_token = main_tokens[node]; @@ -822,14 +847,14 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr .grouped_expression => return expr(gz, scope, rl, node_datas[node].lhs), .array_type => return arrayType(gz, scope, rl, node), .array_type_sentinel => return arrayTypeSentinel(gz, scope, rl, node), - .char_literal => return charLiteral(gz, scope, rl, node), - .error_set_decl => return errorSetDecl(gz, scope, rl, node), + .char_literal => return charLiteral(gz, rl, node), + .error_set_decl => return errorSetDecl(gz, rl, node), .array_access => return arrayAccess(gz, scope, rl, node), .@"comptime" => return comptimeExprAst(gz, scope, rl, node), .@"switch", .switch_comma => return switchExpr(gz, scope, rl, node), .@"nosuspend" => return nosuspendExpr(gz, scope, rl, node), - .@"suspend" => return suspendExpr(gz, scope, rl, node), + .@"suspend" => return suspendExpr(gz, scope, node), .@"await" => return awaitExpr(gz, scope, rl, node), .@"resume" => return resumeExpr(gz, scope, rl, node), @@ -889,7 +914,6 @@ fn nosuspendExpr( node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; - const gpa = astgen.gpa; const tree = astgen.tree; const node_datas = tree.nodes.items(.data); const body_node = node_datas[node].lhs; @@ -902,13 +926,12 @@ fn nosuspendExpr( gz.nosuspend_node = node; const result = try expr(gz, scope, rl, body_node); gz.nosuspend_node = 0; - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn suspendExpr( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; @@ -964,7 +987,7 @@ fn awaitExpr( const operand = try expr(gz, scope, .none, rhs_node); const tag: Zir.Inst.Tag = if (gz.nosuspend_node != 0) .await_nosuspend else .@"await"; const result = try gz.addUnNode(tag, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn resumeExpr( @@ -979,7 +1002,7 @@ fn resumeExpr( const rhs_node = node_datas[node].lhs; const operand = try expr(gz, scope, .none, rhs_node); const result = try gz.addUnNode(.@"resume", operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn fnProtoExpr( @@ -1085,7 +1108,7 @@ fn fnProtoExpr( .is_test = false, .is_extern = false, }); - return rvalue(gz, scope, rl, result, fn_proto.ast.proto_node); + return rvalue(gz, rl, result, fn_proto.ast.proto_node); } fn arrayInitExpr( @@ -1097,7 +1120,6 @@ fn arrayInitExpr( ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; - const gpa = astgen.gpa; const node_tags = tree.nodes.items(.tag); const main_tokens = tree.nodes.items(.main_token); @@ -1157,32 +1179,32 @@ fn arrayInitExpr( }, .ref => { if (types.array != .none) { - return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init_ref); + return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init_ref); } else { - return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon_ref); + return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon_ref); } }, .none, .none_or_ref => { if (types.array != .none) { - return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); + return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); } else { - return arrayInitExprRlNone(gz, scope, rl, node, array_init.ast.elements, .array_init_anon); + return arrayInitExprRlNone(gz, scope, node, array_init.ast.elements, .array_init_anon); } }, .ty => |ty_inst| { if (types.array != .none) { - const result = try arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, types.array, types.elem, .array_init); - return rvalue(gz, scope, rl, result, node); + const result = try arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); + return rvalue(gz, rl, result, node); } else { const elem_type = try gz.addUnNode(.elem_type, ty_inst, node); - return arrayInitExprRlTy(gz, scope, rl, node, array_init.ast.elements, ty_inst, elem_type, .array_init); + return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init); } }, .ptr, .inferred_ptr => |ptr_inst| { - return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, ptr_inst); + return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, ptr_inst); }, .block_ptr => |block_gz| { - return arrayInitExprRlPtr(gz, scope, rl, node, array_init.ast.elements, block_gz.rl_ptr); + return arrayInitExprRlPtr(gz, scope, node, array_init.ast.elements, block_gz.rl_ptr); }, } } @@ -1190,7 +1212,6 @@ fn arrayInitExpr( fn arrayInitExprRlNone( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, elements: []const ast.Node.Index, tag: Zir.Inst.Tag, @@ -1213,10 +1234,8 @@ fn arrayInitExprRlNone( fn arrayInitExprRlTy( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, elements: []const ast.Node.Index, - array_ty_inst: Zir.Inst.Ref, elem_ty_inst: Zir.Inst.Ref, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { @@ -1241,7 +1260,6 @@ fn arrayInitExprRlTy( fn arrayInitExprRlPtr( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, elements: []const ast.Node.Index, result_ptr: Zir.Inst.Ref, @@ -1277,11 +1295,10 @@ fn structInitExpr( ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; - const gpa = astgen.gpa; if (struct_init.ast.fields.len == 0) { if (struct_init.ast.type_expr == 0) { - return rvalue(gz, scope, rl, .empty_struct, node); + return rvalue(gz, rl, .empty_struct, node); } array: { const node_tags = tree.nodes.items(.tag); @@ -1303,15 +1320,17 @@ fn structInitExpr( break :blk try gz.addArrayTypeSentinel(.zero_usize, elem_type, sentinel); }; const result = try gz.addUnNode(.struct_init_empty, array_type_inst, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } } const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); const result = try gz.addUnNode(.struct_init_empty, ty_inst, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } switch (rl) { .discard => { + if (struct_init.ast.type_expr != 0) + _ = try typeExpr(gz, scope, struct_init.ast.type_expr); for (struct_init.ast.fields) |field_init| { _ = try expr(gz, scope, .discard, field_init); } @@ -1320,36 +1339,35 @@ fn structInitExpr( .ref => { if (struct_init.ast.type_expr != 0) { const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); - return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init_ref); + return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init_ref); } else { - return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon_ref); + return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon_ref); } }, .none, .none_or_ref => { if (struct_init.ast.type_expr != 0) { const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); - return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); + return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); } else { - return structInitExprRlNone(gz, scope, rl, node, struct_init, .struct_init_anon); + return structInitExprRlNone(gz, scope, node, struct_init, .struct_init_anon); } }, .ty => |ty_inst| { if (struct_init.ast.type_expr == 0) { - return structInitExprRlTy(gz, scope, rl, node, struct_init, ty_inst, .struct_init); + return structInitExprRlTy(gz, scope, node, struct_init, ty_inst, .struct_init); } const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); - const result = try structInitExprRlTy(gz, scope, rl, node, struct_init, inner_ty_inst, .struct_init); - return rvalue(gz, scope, rl, result, node); + const result = try structInitExprRlTy(gz, scope, node, struct_init, inner_ty_inst, .struct_init); + return rvalue(gz, rl, result, node); }, - .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, rl, node, struct_init, ptr_inst), - .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, rl, node, struct_init, block_gz.rl_ptr), + .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst), + .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr), } } fn structInitExprRlNone( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, struct_init: ast.full.StructInit, tag: Zir.Inst.Tag, @@ -1384,7 +1402,6 @@ fn structInitExprRlNone( fn structInitExprRlPtr( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, struct_init: ast.full.StructInit, result_ptr: Zir.Inst.Ref, @@ -1396,6 +1413,9 @@ fn structInitExprRlPtr( const field_ptr_list = try gpa.alloc(Zir.Inst.Index, struct_init.ast.fields.len); defer gpa.free(field_ptr_list); + if (struct_init.ast.type_expr != 0) + _ = try typeExpr(gz, scope, struct_init.ast.type_expr); + for (struct_init.ast.fields) |field_init, i| { const name_token = tree.firstToken(field_init) - 2; const str_index = try astgen.identAsString(name_token); @@ -1416,7 +1436,6 @@ fn structInitExprRlPtr( fn structInitExprRlTy( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, struct_init: ast.full.StructInit, ty_inst: Zir.Inst.Ref, @@ -1641,8 +1660,8 @@ fn blockExpr( return labeledBlockExpr(gz, scope, rl, block_node, statements, .block); } - try blockExprStmts(gz, scope, block_node, statements); - return rvalue(gz, scope, rl, .void_value, block_node); + try blockExprStmts(gz, scope, statements); + return rvalue(gz, rl, .void_value, block_node); } fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void { @@ -1654,9 +1673,6 @@ fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.Toke const gen_zir = scope.cast(GenZir).?; if (gen_zir.label) |prev_label| { if (try astgen.tokenIdentEql(label, prev_label.token)) { - const tree = astgen.tree; - const main_tokens = tree.nodes.items(.main_token); - const label_name = try astgen.identifierTokenString(label); return astgen.failTokNotes(label, "redefinition of label '{s}'", .{ label_name, @@ -1719,7 +1735,7 @@ fn labeledBlockExpr( defer block_scope.labeled_breaks.deinit(astgen.gpa); defer block_scope.labeled_store_to_block_ptr_list.deinit(astgen.gpa); - try blockExprStmts(&block_scope, &block_scope.base, block_node, statements); + try blockExprStmts(&block_scope, &block_scope.base, statements); if (!block_scope.label.?.used) { return astgen.failTok(label_token, "unused block label", .{}); @@ -1755,21 +1771,15 @@ fn labeledBlockExpr( const block_ref = gz.indexToRef(block_inst); switch (rl) { .ref => return block_ref, - else => return rvalue(gz, parent_scope, rl, block_ref, block_node), + else => return rvalue(gz, rl, block_ref, block_node), } }, } } -fn blockExprStmts( - gz: *GenZir, - parent_scope: *Scope, - node: ast.Node.Index, - statements: []const ast.Node.Index, -) !void { +fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const ast.Node.Index) !void { const astgen = gz.astgen; const tree = astgen.tree; - const main_tokens = tree.nodes.items(.main_token); const node_tags = tree.nodes.items(.tag); var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa); @@ -1784,8 +1794,8 @@ fn blockExprStmts( .simple_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.simpleVarDecl(statement)), .aligned_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.alignedVarDecl(statement)), - .@"defer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_normal), - .@"errdefer" => scope = try deferStmt(gz, scope, statement, &block_arena.allocator, .defer_error), + .@"defer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_normal), + .@"errdefer" => scope = try makeDeferScope(scope, statement, &block_arena.allocator, .defer_error), .assign => try assign(gz, scope, statement), @@ -1810,6 +1820,7 @@ fn blockExprStmts( } try genDefers(gz, parent_scope, scope, .none); + try checkUsed(gz, parent_scope, scope); } fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) InnerError!void { @@ -2103,6 +2114,7 @@ fn genDefers( inner_scope: *Scope, err_code: Zir.Inst.Ref, ) InnerError!void { + _ = err_code; const astgen = gz.astgen; const tree = astgen.tree; const node_datas = tree.nodes.items(.data); @@ -2138,8 +2150,49 @@ fn genDefers( } } -fn deferStmt( +fn checkUsed( gz: *GenZir, + outer_scope: *Scope, + inner_scope: *Scope, +) InnerError!void { + const astgen = gz.astgen; + + var scope = inner_scope; + while (scope != outer_scope) { + switch (scope.tag) { + .gen_zir => scope = scope.cast(GenZir).?.parent, + .local_val => { + const s = scope.cast(Scope.LocalVal).?; + switch (s.used) { + .used => {}, + .fn_param => return astgen.failTok(s.token_src, "unused function parameter", .{}), + .constant => return astgen.failTok(s.token_src, "unused local constant", .{}), + .variable => unreachable, + .loop_index => unreachable, + .capture => return astgen.failTok(s.token_src, "unused capture", .{}), + } + scope = s.parent; + }, + .local_ptr => { + const s = scope.cast(Scope.LocalPtr).?; + switch (s.used) { + .used => {}, + .fn_param => unreachable, + .constant => return astgen.failTok(s.token_src, "unused local constant", .{}), + .variable => return astgen.failTok(s.token_src, "unused local variable", .{}), + .loop_index => return astgen.failTok(s.token_src, "unused loop index capture", .{}), + .capture => unreachable, + } + scope = s.parent; + }, + .defer_normal, .defer_error => scope = scope.cast(Scope.Defer).?.parent, + .namespace => unreachable, + .top => unreachable, + } + } +} + +fn makeDeferScope( scope: *Scope, node: ast.Node.Index, block_arena: *Allocator, @@ -2258,6 +2311,7 @@ fn varDecl( .name = ident_name, .inst = init_inst, .token_src = name_token, + .used = .constant, }; return &sub_scope.base; } @@ -2325,6 +2379,7 @@ fn varDecl( .name = ident_name, .inst = init_inst, .token_src = name_token, + .used = .constant, }; return &sub_scope.base; } @@ -2353,7 +2408,8 @@ fn varDecl( .name = ident_name, .ptr = init_scope.rl_ptr, .token_src = name_token, - .is_comptime = true, + .maybe_comptime = true, + .used = .constant, }; return &sub_scope.base; }, @@ -2398,7 +2454,7 @@ fn varDecl( resolve_inferred_alloc = alloc; break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } }; }; - const init_inst = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node); + _ = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node); if (resolve_inferred_alloc != .none) { _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node); } @@ -2409,7 +2465,8 @@ fn varDecl( .name = ident_name, .ptr = var_data.alloc, .token_src = name_token, - .is_comptime = is_comptime, + .maybe_comptime = is_comptime, + .used = .variable, }; return &sub_scope.base; }, @@ -2425,16 +2482,18 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void { const astgen = gz.astgen; const tree = astgen.tree; - const node_tags = tree.nodes.items(.tag); + const source = tree.source; const token_starts = tree.tokens.items(.start); - const decl_start = token_starts[tree.firstToken(gz.decl_node_index)]; const node_start = token_starts[tree.firstToken(node)]; - const source = tree.source[decl_start..node_start]; - const loc = std.zig.findLineColumn(source, source.len); + + astgen.advanceSourceCursor(source, node_start); + const line = @intCast(u32, astgen.source_line); + const column = @intCast(u32, astgen.source_column); + _ = try gz.add(.{ .tag = .dbg_stmt, .data = .{ .dbg_stmt = .{ - .line = @intCast(u32, loc.line), - .column = @intCast(u32, loc.column), + .line = line, + .column = column, }, } }); } @@ -2514,7 +2573,7 @@ fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inne const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs); const result = try gz.addUnNode(.bool_not, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { @@ -2524,7 +2583,7 @@ fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inner const operand = try expr(gz, scope, .none, node_datas[node].lhs); const result = try gz.addUnNode(.bit_not, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn negation( @@ -2540,7 +2599,7 @@ fn negation( const operand = try expr(gz, scope, .none, node_datas[node].lhs); const result = try gz.addUnNode(tag, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn ptrType( @@ -2550,9 +2609,6 @@ fn ptrType( node: ast.Node.Index, ptr_info: ast.full.PtrType, ) InnerError!Zir.Inst.Ref { - const astgen = gz.astgen; - const tree = astgen.tree; - const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type); const simple = ptr_info.ast.align_node == 0 and @@ -2569,7 +2625,7 @@ fn ptrType( .elem_type = elem_type, }, } }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } var sentinel_ref: Zir.Inst.Ref = .none; @@ -2629,7 +2685,7 @@ fn ptrType( } }); gz.instructions.appendAssumeCapacity(new_index); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { @@ -2649,7 +2705,7 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z const elem_type = try typeExpr(gz, scope, node_datas[node].rhs); const result = try gz.addBin(.array_type, len, elem_type); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { @@ -2671,7 +2727,7 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.I const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel); const result = try gz.addArrayTypeSentinel(len, elem_type, sentinel); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } const WipDecls = struct { @@ -2902,6 +2958,10 @@ fn fnDecl( const name_token = param.name_token orelse { return astgen.failNode(param.type_expr, "missing parameter name", .{}); }; + if (param.type_expr != 0) + _ = try typeExpr(&fn_gz, params_scope, param.type_expr); + if (mem.eql(u8, "_", tree.tokenSlice(name_token))) + continue; const param_name = try astgen.identAsString(name_token); // Create an arg instruction. This is needed to emit a semantic analysis // error for shadowing decls. @@ -2914,16 +2974,19 @@ fn fnDecl( .name = param_name, .inst = arg_inst, .token_src = name_token, + .used = .fn_param, }; params_scope = &sub_scope.base; // Additionally put the param name into `string_bytes` and reference it with // `extra` so that we have access to the data in codegen, for debug info. const str_index = try astgen.identAsString(name_token); - astgen.extra.appendAssumeCapacity(str_index); + try astgen.extra.append(astgen.gpa, str_index); } + _ = try typeExpr(&fn_gz, params_scope, fn_proto.ast.return_type); _ = try expr(&fn_gz, params_scope, .none, body_node); + try checkUsed(gz, &fn_gz.base, params_scope); } const need_implicit_ret = blk: { @@ -3508,6 +3571,10 @@ fn structDeclInner( const field_name = try astgen.identAsString(member.ast.name_token); fields_data.appendAssumeCapacity(field_name); + if (member.ast.type_expr == 0) { + return astgen.failTok(member.ast.name_token, "struct field missing type", .{}); + } + const field_type: Zir.Inst.Ref = if (node_tags[member.ast.type_expr] == .@"anytype") .none else @@ -3616,7 +3683,7 @@ fn unionDeclInner( }; defer block_scope.instructions.deinit(gpa); - var namespace: Scope.Namespace = .{ .parent = &gz.base }; + var namespace: Scope.Namespace = .{ .parent = scope }; defer namespace.decls.deinit(gpa); var wip_decls: WipDecls = .{}; @@ -3900,7 +3967,7 @@ fn containerDecl( assert(arg_inst == .none); const result = try structDeclInner(gz, scope, node, container_decl, layout); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .keyword_union => { const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { @@ -3912,7 +3979,7 @@ fn containerDecl( const have_auto_enum = container_decl.ast.enum_token != null; const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, arg_inst, have_auto_enum); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .keyword_enum => { if (container_decl.layout_token) |t| { @@ -4017,7 +4084,7 @@ fn containerDecl( }; defer block_scope.instructions.deinit(gpa); - var namespace: Scope.Namespace = .{ .parent = &gz.base }; + var namespace: Scope.Namespace = .{ .parent = scope }; defer namespace.decls.deinit(gpa); var wip_decls: WipDecls = .{}; @@ -4241,20 +4308,18 @@ fn containerDecl( astgen.extra.appendAssumeCapacity(cur_bit_bag); astgen.extra.appendSliceAssumeCapacity(fields_data.items); - return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); + return rvalue(gz, rl, gz.indexToRef(decl_inst), node); }, .keyword_opaque => { - var namespace: Scope.Namespace = .{ .parent = &gz.base }; + var namespace: Scope.Namespace = .{ .parent = scope }; defer namespace.decls.deinit(gpa); var wip_decls: WipDecls = .{}; defer wip_decls.deinit(gpa); for (container_decl.ast.members) |member_node| { - const member = switch (node_tags[member_node]) { - .container_field_init => tree.containerFieldInit(member_node), - .container_field_align => tree.containerFieldAlign(member_node), - .container_field => tree.containerField(member_node), + switch (node_tags[member_node]) { + .container_field_init, .container_field_align, .container_field => {}, .fn_decl => { const fn_proto = node_datas[member_node].lhs; @@ -4375,7 +4440,7 @@ fn containerDecl( continue; }, else => unreachable, - }; + } } { const empty_slot_count = WipDecls.fields_per_u32 - (wip_decls.decl_index % WipDecls.fields_per_u32); @@ -4404,18 +4469,13 @@ fn containerDecl( } astgen.extra.appendSliceAssumeCapacity(wip_decls.payload.items); - return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); + return rvalue(gz, rl, gz.indexToRef(decl_inst), node); }, else => unreachable, } } -fn errorSetDecl( - gz: *GenZir, - scope: *Scope, - rl: ResultLoc, - node: ast.Node.Index, -) InnerError!Zir.Inst.Ref { +fn errorSetDecl(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const gpa = astgen.gpa; const tree = astgen.tree; @@ -4443,16 +4503,11 @@ fn errorSetDecl( } } - const tag: Zir.Inst.Tag = switch (gz.anon_name_strategy) { - .parent => .error_set_decl, - .anon => .error_set_decl_anon, - .func => .error_set_decl_func, - }; const result = try gz.addPlNode(.error_set_decl, node, Zir.Inst.ErrorSetDecl{ .fields_len = @intCast(u32, field_names.items.len), }); try astgen.extra.appendSlice(gpa, field_names.items); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn tryExpr( @@ -4463,7 +4518,6 @@ fn tryExpr( operand_node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { const astgen = parent_gz.astgen; - const tree = astgen.tree; const fn_block = astgen.fn_block orelse { return astgen.failNode(node, "invalid 'try' outside function scope", .{}); @@ -4512,12 +4566,11 @@ fn tryExpr( const unwrapped_payload = try else_scope.addUnNode(err_ops[2], operand, node); const else_result = switch (rl) { .ref => unwrapped_payload, - else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), + else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), }; return finishThenElseBlock( parent_gz, - scope, rl, node, &block_scope, @@ -4525,8 +4578,6 @@ fn tryExpr( &else_scope, condbr, cond, - node, - node, then_result, else_result, block, @@ -4587,12 +4638,15 @@ fn orelseCatchExpr( .name = err_name, .inst = try then_scope.addUnNode(unwrap_code_op, operand, node), .token_src = payload, + .used = .capture, }; break :blk &err_val_scope.base; }; block_scope.break_count += 1; const then_result = try expr(&then_scope, then_sub_scope, block_scope.break_result_loc, rhs); + try checkUsed(parent_gz, &then_scope.base, then_sub_scope); + // We hold off on the break instructions as well as copying the then/else // instructions into place until we know whether to keep store_to_block_ptr // instructions or not. @@ -4604,12 +4658,11 @@ fn orelseCatchExpr( const unwrapped_payload = try else_scope.addUnNode(unwrap_op, operand, node); const else_result = switch (rl) { .ref => unwrapped_payload, - else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), + else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), }; return finishThenElseBlock( parent_gz, - scope, rl, node, &block_scope, @@ -4617,8 +4670,6 @@ fn orelseCatchExpr( &else_scope, condbr, cond, - node, - node, then_result, else_result, block, @@ -4629,7 +4680,6 @@ fn orelseCatchExpr( fn finishThenElseBlock( parent_gz: *GenZir, - parent_scope: *Scope, rl: ResultLoc, node: ast.Node.Index, block_scope: *GenZir, @@ -4637,8 +4687,6 @@ fn finishThenElseBlock( else_scope: *GenZir, condbr: Zir.Inst.Index, cond: Zir.Inst.Ref, - then_src: ast.Node.Index, - else_src: ast.Node.Index, then_result: Zir.Inst.Ref, else_result: Zir.Inst.Ref, main_block: Zir.Inst.Index, @@ -4648,7 +4696,6 @@ fn finishThenElseBlock( // We now have enough information to decide whether the result instruction should // be communicated via result location pointer or break instructions. const strat = rl.strategy(block_scope); - const astgen = block_scope.astgen; switch (strat.tag) { .break_void => { if (!parent_gz.refIsNoReturn(then_result)) { @@ -4681,7 +4728,7 @@ fn finishThenElseBlock( const block_ref = parent_gz.indexToRef(main_block); switch (rl) { .ref => return block_ref, - else => return rvalue(parent_gz, parent_scope, rl, block_ref, node), + else => return rvalue(parent_gz, rl, block_ref, node), } }, } @@ -4717,7 +4764,7 @@ fn fieldAccess( .lhs = try expr(gz, scope, .ref, object_node), .field_name_start = str_index, }), - else => return rvalue(gz, scope, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ + else => return rvalue(gz, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ .lhs = try expr(gz, scope, .none_or_ref, object_node), .field_name_start = str_index, }), node), @@ -4732,7 +4779,6 @@ fn arrayAccess( ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; - const main_tokens = tree.nodes.items(.main_token); const node_datas = tree.nodes.items(.data); switch (rl) { .ref => return gz.addBin( @@ -4740,7 +4786,7 @@ fn arrayAccess( try expr(gz, scope, .ref, node_datas[node].lhs), try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), ), - else => return rvalue(gz, scope, rl, try gz.addBin( + else => return rvalue(gz, rl, try gz.addBin( .elem_val, try expr(gz, scope, .none_or_ref, node_datas[node].lhs), try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), @@ -4763,12 +4809,11 @@ fn simpleBinOp( .lhs = try expr(gz, scope, .none, node_datas[node].lhs), .rhs = try expr(gz, scope, .none, node_datas[node].rhs), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn simpleStrTok( gz: *GenZir, - scope: *Scope, rl: ResultLoc, ident_token: ast.TokenIndex, node: ast.Node.Index, @@ -4777,7 +4822,7 @@ fn simpleStrTok( const astgen = gz.astgen; const str_index = try astgen.identAsString(ident_token); const result = try gz.addStrTok(op_inst_tag, str_index, ident_token); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn boolBinOp( @@ -4803,7 +4848,7 @@ fn boolBinOp( try rhs_scope.setBoolBrBody(bool_br); const block_ref = gz.indexToRef(bool_br); - return rvalue(gz, scope, rl, block_ref, node); + return rvalue(gz, rl, block_ref, node); } fn ifExpr( @@ -4830,7 +4875,7 @@ fn ifExpr( inst: Zir.Inst.Ref, bool_bit: Zir.Inst.Ref, } = c: { - if (if_full.error_token) |error_token| { + if (if_full.error_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; @@ -4838,7 +4883,7 @@ fn ifExpr( .inst = err_union, .bool_bit = try block_scope.addUnNode(tag, err_union, node), }; - } else if (if_full.payload_token) |payload_token| { + } else if (if_full.payload_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; @@ -4867,27 +4912,38 @@ fn ifExpr( var payload_val_scope: Scope.LocalVal = undefined; const then_sub_scope = s: { - if (if_full.error_token) |error_token| { - const tag: Zir.Inst.Tag = if (payload_is_ref) - .err_union_payload_unsafe_ptr - else - .err_union_payload_unsafe; - const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); - const ident_name = try astgen.identAsString(error_token); - payload_val_scope = .{ - .parent = &then_scope.base, - .gen_zir = &then_scope, - .name = ident_name, - .inst = payload_inst, - .token_src = error_token, - }; - break :s &payload_val_scope.base; + if (if_full.error_token != null) { + if (if_full.payload_token) |payload_token| { + const tag: Zir.Inst.Tag = if (payload_is_ref) + .err_union_payload_unsafe_ptr + else + .err_union_payload_unsafe; + const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); + const token_name_index = payload_token + @boolToInt(payload_is_ref); + const ident_name = try astgen.identAsString(token_name_index); + const token_name_str = tree.tokenSlice(token_name_index); + if (mem.eql(u8, "_", token_name_str)) + break :s &then_scope.base; + payload_val_scope = .{ + .parent = &then_scope.base, + .gen_zir = &then_scope, + .name = ident_name, + .inst = payload_inst, + .token_src = payload_token, + .used = .capture, + }; + break :s &payload_val_scope.base; + } else { + break :s &then_scope.base; + } } else if (if_full.payload_token) |payload_token| { const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; const tag: Zir.Inst.Tag = if (payload_is_ref) .optional_payload_unsafe_ptr else .optional_payload_unsafe; + if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) + break :s &then_scope.base; const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); const ident_name = try astgen.identAsString(ident_token); payload_val_scope = .{ @@ -4896,6 +4952,7 @@ fn ifExpr( .name = ident_name, .inst = payload_inst, .token_src = ident_token, + .used = .capture, }; break :s &payload_val_scope.base; } else { @@ -4905,6 +4962,7 @@ fn ifExpr( block_scope.break_count += 1; const then_result = try expr(&then_scope, then_sub_scope, block_scope.break_result_loc, if_full.ast.then_expr); + try checkUsed(parent_gz, &then_scope.base, then_sub_scope); // We hold off on the break instructions as well as copying the then/else // instructions into place until we know whether to keep store_to_block_ptr // instructions or not. @@ -4926,21 +4984,27 @@ fn ifExpr( .err_union_code; const payload_inst = try else_scope.addUnNode(tag, cond.inst, node); const ident_name = try astgen.identAsString(error_token); + const error_token_str = tree.tokenSlice(error_token); + if (mem.eql(u8, "_", error_token_str)) + break :s &else_scope.base; payload_val_scope = .{ .parent = &else_scope.base, .gen_zir = &else_scope, .name = ident_name, .inst = payload_inst, .token_src = error_token, + .used = .capture, }; break :s &payload_val_scope.base; } else { break :s &else_scope.base; } }; + const e = try expr(&else_scope, sub_scope, block_scope.break_result_loc, else_node); + try checkUsed(parent_gz, &else_scope.base, sub_scope); break :blk .{ .src = else_node, - .result = try expr(&else_scope, sub_scope, block_scope.break_result_loc, else_node), + .result = e, }; } else .{ .src = if_full.ast.then_expr, @@ -4949,7 +5013,6 @@ fn ifExpr( return finishThenElseBlock( parent_gz, - scope, rl, node, &block_scope, @@ -4957,8 +5020,6 @@ fn ifExpr( &else_scope, condbr, cond.bool_bit, - if_full.ast.then_expr, - else_info.src, then_result, else_info.result, block, @@ -5071,7 +5132,7 @@ fn whileExpr( inst: Zir.Inst.Ref, bool_bit: Zir.Inst.Ref, } = c: { - if (while_full.error_token) |error_token| { + if (while_full.error_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; @@ -5079,7 +5140,7 @@ fn whileExpr( .inst = err_union, .bool_bit = try continue_scope.addUnNode(tag, err_union, node), }; - } else if (while_full.payload_token) |payload_token| { + } else if (while_full.payload_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; @@ -5103,46 +5164,35 @@ fn whileExpr( try loop_scope.instructions.append(astgen.gpa, cond_block); try continue_scope.setBlockBody(cond_block); - // TODO avoid emitting the continue expr when there - // are no jumps to it. This happens when the last statement of a while body is noreturn - // and there are no `continue` statements. - if (while_full.ast.cont_expr != 0) { - _ = try expr(&loop_scope, &loop_scope.base, .{ .ty = .void_type }, while_full.ast.cont_expr); - } - const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; - _ = try loop_scope.addNode(repeat_tag, node); - - try loop_scope.setBlockBody(loop_block); - loop_scope.break_block = loop_block; - loop_scope.continue_block = cond_block; - if (while_full.label_token) |label_token| { - loop_scope.label = @as(?GenZir.Label, GenZir.Label{ - .token = label_token, - .block_inst = loop_block, - }); - } - var then_scope = parent_gz.makeSubBlock(&continue_scope.base); defer then_scope.instructions.deinit(astgen.gpa); var payload_val_scope: Scope.LocalVal = undefined; const then_sub_scope = s: { - if (while_full.error_token) |error_token| { - const tag: Zir.Inst.Tag = if (payload_is_ref) - .err_union_payload_unsafe_ptr - else - .err_union_payload_unsafe; - const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); - const ident_name = try astgen.identAsString(error_token); - payload_val_scope = .{ - .parent = &then_scope.base, - .gen_zir = &then_scope, - .name = ident_name, - .inst = payload_inst, - .token_src = error_token, - }; - break :s &payload_val_scope.base; + if (while_full.error_token != null) { + if (while_full.payload_token) |payload_token| { + const tag: Zir.Inst.Tag = if (payload_is_ref) + .err_union_payload_unsafe_ptr + else + .err_union_payload_unsafe; + const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); + const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; + if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) + break :s &then_scope.base; + const ident_name = try astgen.identAsString(payload_token + @boolToInt(payload_is_ref)); + payload_val_scope = .{ + .parent = &then_scope.base, + .gen_zir = &then_scope, + .name = ident_name, + .inst = payload_inst, + .token_src = payload_token, + .used = .capture, + }; + break :s &payload_val_scope.base; + } else { + break :s &then_scope.base; + } } else if (while_full.payload_token) |payload_token| { const ident_token = if (payload_is_ref) payload_token + 1 else payload_token; const tag: Zir.Inst.Tag = if (payload_is_ref) @@ -5151,12 +5201,15 @@ fn whileExpr( .optional_payload_unsafe; const payload_inst = try then_scope.addUnNode(tag, cond.inst, node); const ident_name = try astgen.identAsString(ident_token); + if (mem.eql(u8, "_", tree.tokenSlice(ident_token))) + break :s &then_scope.base; payload_val_scope = .{ .parent = &then_scope.base, .gen_zir = &then_scope, .name = ident_name, .inst = payload_inst, .token_src = ident_token, + .used = .capture, }; break :s &payload_val_scope.base; } else { @@ -5164,8 +5217,29 @@ fn whileExpr( } }; + // This code could be improved to avoid emitting the continue expr when there + // are no jumps to it. This happens when the last statement of a while body is noreturn + // and there are no `continue` statements. + // Tracking issue: https://github.com/ziglang/zig/issues/9185 + if (while_full.ast.cont_expr != 0) { + _ = try expr(&loop_scope, then_sub_scope, .{ .ty = .void_type }, while_full.ast.cont_expr); + } + const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; + _ = try loop_scope.addNode(repeat_tag, node); + + try loop_scope.setBlockBody(loop_block); + loop_scope.break_block = loop_block; + loop_scope.continue_block = cond_block; + if (while_full.label_token) |label_token| { + loop_scope.label = @as(?GenZir.Label, GenZir.Label{ + .token = label_token, + .block_inst = loop_block, + }); + } + loop_scope.break_count += 1; const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, while_full.ast.then_expr); + try checkUsed(parent_gz, &then_scope.base, then_sub_scope); var else_scope = parent_gz.makeSubBlock(&continue_scope.base); defer else_scope.instructions.deinit(astgen.gpa); @@ -5184,21 +5258,26 @@ fn whileExpr( .err_union_code; const payload_inst = try else_scope.addUnNode(tag, cond.inst, node); const ident_name = try astgen.identAsString(error_token); + if (mem.eql(u8, tree.tokenSlice(error_token), "_")) + break :s &else_scope.base; payload_val_scope = .{ .parent = &else_scope.base, .gen_zir = &else_scope, .name = ident_name, .inst = payload_inst, .token_src = error_token, + .used = .capture, }; break :s &payload_val_scope.base; } else { break :s &else_scope.base; } }; + const e = try expr(&else_scope, sub_scope, loop_scope.break_result_loc, else_node); + try checkUsed(parent_gz, &else_scope.base, sub_scope); break :blk .{ .src = else_node, - .result = try expr(&else_scope, sub_scope, loop_scope.break_result_loc, else_node), + .result = e, }; } else .{ .src = while_full.ast.then_expr, @@ -5213,7 +5292,6 @@ fn whileExpr( const break_tag: Zir.Inst.Tag = if (is_inline) .break_inline else .@"break"; return finishThenElseBlock( parent_gz, - scope, rl, node, &loop_scope, @@ -5221,8 +5299,6 @@ fn whileExpr( &else_scope, condbr, cond.bool_bit, - while_full.ast.then_expr, - else_info.src, then_result, else_info.result, loop_block, @@ -5329,6 +5405,7 @@ fn forExpr( .name = name_str_index, .inst = payload_inst, .token_src = ident, + .used = .capture, }; payload_sub_scope = &payload_val_scope.base; } else if (is_ptr) { @@ -5351,13 +5428,15 @@ fn forExpr( .name = index_name, .ptr = index_ptr, .token_src = index_token, - .is_comptime = parent_gz.force_comptime, + .maybe_comptime = is_inline, + .used = .loop_index, }; break :blk &index_scope.base; }; loop_scope.break_count += 1; const then_result = try expr(&then_scope, then_sub_scope, loop_scope.break_result_loc, for_full.ast.then_expr); + try checkUsed(parent_gz, &then_scope.base, then_sub_scope); var else_scope = parent_gz.makeSubBlock(&cond_scope.base); defer else_scope.instructions.deinit(astgen.gpa); @@ -5386,7 +5465,6 @@ fn forExpr( const break_tag: Zir.Inst.Tag = if (is_inline) .break_inline else .@"break"; return finishThenElseBlock( parent_gz, - scope, rl, node, &loop_scope, @@ -5394,8 +5472,6 @@ fn forExpr( &else_scope, condbr, cond, - for_full.ast.then_expr, - else_info.src, then_result, else_info.result, loop_block, @@ -5598,10 +5674,12 @@ fn switchExpr( .name = capture_name, .inst = capture, .token_src = payload_token, + .used = .capture, }; break :blk &capture_val_scope.base; }; const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); + try checkUsed(parent_gz, &case_scope.base, sub_scope); if (!parent_gz.refIsNoReturn(case_result)) { block_scope.break_count += 1; _ = try case_scope.addBreak(.@"break", switch_block, case_result); @@ -5690,6 +5768,7 @@ fn switchExpr( .name = capture_name, .inst = capture, .token_src = payload_token, + .used = .capture, }; break :blk &capture_val_scope.base; }; @@ -5723,6 +5802,7 @@ fn switchExpr( } const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); + try checkUsed(parent_gz, &case_scope.base, sub_scope); if (!parent_gz.refIsNoReturn(case_result)) { block_scope.break_count += 1; _ = try case_scope.addBreak(.@"break", switch_block, case_result); @@ -5736,6 +5816,7 @@ fn switchExpr( const item_node = case.ast.values[0]; const item_inst = try comptimeExpr(parent_gz, scope, item_rl, item_node); const case_result = try expr(&case_scope, sub_scope, block_scope.break_result_loc, case.ast.target_expr); + try checkUsed(parent_gz, &case_scope.base, sub_scope); if (!parent_gz.refIsNoReturn(case_result)) { block_scope.break_count += 1; _ = try case_scope.addBreak(.@"break", switch_block, case_result); @@ -5934,7 +6015,7 @@ fn switchExpr( const block_ref = parent_gz.indexToRef(switch_block); switch (rl) { .ref => return block_ref, - else => return rvalue(parent_gz, scope, rl, block_ref, switch_node), + else => return rvalue(parent_gz, rl, block_ref, switch_node), } }, .break_void => { @@ -6000,27 +6081,59 @@ fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref const astgen = gz.astgen; const tree = astgen.tree; const node_datas = tree.nodes.items(.data); - const main_tokens = tree.nodes.items(.main_token); if (gz.in_defer) return astgen.failNode(node, "cannot return from defer expression", .{}); const operand_node = node_datas[node].lhs; - if (operand_node != 0) { - const rl: ResultLoc = if (nodeMayNeedMemoryLocation(tree, operand_node)) .{ - .ptr = try gz.addNodeExtended(.ret_ptr, node), - } else .{ - .ty = try gz.addNodeExtended(.ret_type, node), - }; - const operand = try expr(gz, scope, rl, operand_node); - // TODO check operand to see if we need to generate errdefers + if (operand_node == 0) { + // Returning a void value; skip error defers. try genDefers(gz, &astgen.fn_block.?.base, scope, .none); - _ = try gz.addUnNode(.ret_node, operand, node); + _ = try gz.addUnNode(.ret_node, .void_value, node); return Zir.Inst.Ref.unreachable_value; } - // Returning a void value; skip error defers. - try genDefers(gz, &astgen.fn_block.?.base, scope, .none); - _ = try gz.addUnNode(.ret_node, .void_value, node); - return Zir.Inst.Ref.unreachable_value; + + const rl: ResultLoc = if (nodeMayNeedMemoryLocation(tree, operand_node)) .{ + .ptr = try gz.addNodeExtended(.ret_ptr, node), + } else .{ + .ty = try gz.addNodeExtended(.ret_type, node), + }; + const operand = try expr(gz, scope, rl, operand_node); + + switch (nodeMayEvalToError(tree, operand_node)) { + .never => { + // Returning a value that cannot be an error; skip error defers. + try genDefers(gz, &astgen.fn_block.?.base, scope, .none); + _ = try gz.addUnNode(.ret_node, operand, node); + return Zir.Inst.Ref.unreachable_value; + }, + .always => { + // Value is always an error. Emit both error defers and regular defers. + const err_code = try gz.addUnNode(.err_union_code, operand, node); + try genDefers(gz, &astgen.fn_block.?.base, scope, err_code); + _ = try gz.addUnNode(.ret_node, operand, node); + return Zir.Inst.Ref.unreachable_value; + }, + .maybe => { + // Emit conditional branch for generating errdefers. + const is_err = try gz.addUnNode(.is_err, operand, node); + const condbr = try gz.addCondBr(.condbr, node); + + var then_scope = gz.makeSubBlock(scope); + defer then_scope.instructions.deinit(astgen.gpa); + const err_code = try then_scope.addUnNode(.err_union_code, operand, node); + try genDefers(&then_scope, &astgen.fn_block.?.base, scope, err_code); + _ = try then_scope.addUnNode(.ret_node, operand, node); + + var else_scope = gz.makeSubBlock(scope); + defer else_scope.instructions.deinit(astgen.gpa); + try genDefers(&else_scope, &astgen.fn_block.?.base, scope, .none); + _ = try else_scope.addUnNode(.ret_node, operand, node); + + try setCondBrPayload(condbr, is_err, &then_scope, &else_scope); + + return Zir.Inst.Ref.unreachable_value; + }, + } } fn identifier( @@ -6043,7 +6156,7 @@ fn identifier( } if (simple_types.get(ident_name)) |zir_const_ref| { - return rvalue(gz, scope, rl, zir_const_ref, ident); + return rvalue(gz, rl, zir_const_ref, ident); } if (ident_name.len >= 2) integer: { @@ -6069,7 +6182,7 @@ fn identifier( .bit_count = bit_count, } }, }); - return rvalue(gz, scope, rl, result, ident); + return rvalue(gz, rl, result, ident); } } @@ -6082,33 +6195,37 @@ fn identifier( while (true) switch (s.tag) { .local_val => { const local_val = s.cast(Scope.LocalVal).?; - if (hit_namespace) { - // captures of non-locals need to be emitted as decl_val or decl_ref - // This *might* be capturable depending on if it is comptime known - break; - } + if (local_val.name == name_str_index) { - return rvalue(gz, scope, rl, local_val.inst, ident); + local_val.used = .used; + // Captures of non-locals need to be emitted as decl_val or decl_ref. + // This *might* be capturable depending on if it is comptime known. + if (!hit_namespace) { + return rvalue(gz, rl, local_val.inst, ident); + } } s = local_val.parent; }, .local_ptr => { const local_ptr = s.cast(Scope.LocalPtr).?; if (local_ptr.name == name_str_index) { + local_ptr.used = .used; if (hit_namespace) { - if (local_ptr.is_comptime) + if (local_ptr.maybe_comptime) break else return astgen.failNodeNotes(ident, "'{s}' not accessible from inner function", .{ident_name}, &.{ try astgen.errNoteTok(local_ptr.token_src, "declared here", .{}), // TODO add crossed function definition here note. + // Maybe add a note to the error about it being because of the var, + // maybe recommend copying it into a const variable. -SpexGuy }); } switch (rl) { .ref, .none_or_ref => return local_ptr.ptr, else => { const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident); - return rvalue(gz, scope, rl, loaded, ident); + return rvalue(gz, rl, loaded, ident); }, } } @@ -6142,14 +6259,13 @@ fn identifier( .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token), else => { const result = try gz.addStrTok(.decl_val, name_str_index, ident_token); - return rvalue(gz, scope, rl, result, ident); + return rvalue(gz, rl, result, ident); }, } } fn stringLiteral( gz: *GenZir, - scope: *Scope, rl: ResultLoc, node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { @@ -6165,19 +6281,17 @@ fn stringLiteral( .len = str.len, } }, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn multilineStringLiteral( gz: *GenZir, - scope: *Scope, rl: ResultLoc, node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; const node_datas = tree.nodes.items(.data); - const main_tokens = tree.nodes.items(.main_token); const start = node_datas[node].lhs; const end = node_datas[node].rhs; @@ -6209,10 +6323,10 @@ fn multilineStringLiteral( .len = @intCast(u32, string_bytes.items.len - str_index), } }, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } -fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { +fn charLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; const main_tokens = tree.nodes.items(.main_token); @@ -6232,15 +6346,10 @@ fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) }, }; const result = try gz.addInt(value); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } -fn integerLiteral( - gz: *GenZir, - scope: *Scope, - rl: ResultLoc, - node: ast.Node.Index, -) InnerError!Zir.Inst.Ref { +fn integerLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; const main_tokens = tree.nodes.items(.main_token); @@ -6252,7 +6361,7 @@ fn integerLiteral( 1 => .one, else => try gz.addInt(small_int), }; - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } else |err| switch (err) { error.InvalidCharacter => unreachable, // Caught by the parser. error.Overflow => {}, @@ -6283,17 +6392,11 @@ fn integerLiteral( const limbs = big_int.limbs[0..big_int.len()]; assert(big_int.isPositive()); const result = try gz.addIntBig(limbs); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } -fn floatLiteral( - gz: *GenZir, - scope: *Scope, - rl: ResultLoc, - node: ast.Node.Index, -) InnerError!Zir.Inst.Ref { +fn floatLiteral(gz: *GenZir, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; - const arena = astgen.arena; const tree = astgen.tree; const main_tokens = tree.nodes.items(.main_token); @@ -6314,7 +6417,7 @@ fn floatLiteral( const bigger_again: f128 = smaller_float; if (bigger_again == float_number) { const result = try gz.addFloat(smaller_float, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } // We need to use 128 bits. Break the float into 4 u32 values so we can // put it into the `extra` array. @@ -6325,7 +6428,7 @@ fn floatLiteral( .piece2 = @truncate(u32, int_bits >> 64), .piece3 = @truncate(u32, int_bits >> 96), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn asmExpr( @@ -6336,7 +6439,6 @@ fn asmExpr( full: ast.full.Asm, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; - const arena = astgen.arena; const tree = astgen.tree; const main_tokens = tree.nodes.items(.main_token); const node_datas = tree.nodes.items(.data); @@ -6378,6 +6480,33 @@ fn asmExpr( // issues and decide how to handle outputs. Do we want this to be identifiers? // Or maybe we want to force this to be expressions with a pointer type. // Until that is figured out this is only hooked up for referencing Decls. + // TODO we have put this as an identifier lookup just so that we don't get + // unused vars for outputs. We need to check if this is correct in the future ^^ + // so we just put in this simple lookup. This is a workaround. + { + var s = scope; + while (true) switch (s.tag) { + .local_val => { + const local_val = s.cast(Scope.LocalVal).?; + if (local_val.name == str_index) { + local_val.used = .used; + break; + } + s = local_val.parent; + }, + .local_ptr => { + const local_ptr = s.cast(Scope.LocalPtr).?; + if (local_ptr.name == str_index) { + local_ptr.used = .used; + break; + } + s = local_ptr.parent; + }, + .gen_zir => s = s.cast(GenZir).?.parent, + .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, + .namespace, .top => break, + }; + } const operand = try gz.addStrTok(.decl_ref, str_index, ident_token); outputs[i] = .{ .name = name, @@ -6398,7 +6527,6 @@ fn asmExpr( const name = try astgen.identAsString(symbolic_name); const constraint_token = symbolic_name + 2; const constraint = (try astgen.strLitAsString(constraint_token)).index; - const has_arrow = token_tags[symbolic_name + 4] == .arrow; const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs); inputs[i] = .{ .name = name, @@ -6443,7 +6571,7 @@ fn asmExpr( .inputs = inputs, .clobbers = clobbers_buffer[0..clobber_i], }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn as( @@ -6458,7 +6586,7 @@ fn as( switch (rl) { .none, .none_or_ref, .discard, .ref, .ty => { const result = try expr(gz, scope, .{ .ty = dest_type }, rhs); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .ptr, .inferred_ptr => |result_ptr| { return asRlPtr(gz, scope, rl, result_ptr, rhs, dest_type); @@ -6480,18 +6608,18 @@ fn unionInit( const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); switch (rl) { .none, .none_or_ref, .discard, .ref, .ty, .inferred_ptr => { - const field_type = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{ + _ = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{ .container_type = union_type, .field_name = field_name, }); const result = try expr(gz, scope, .{ .ty = union_type }, params[2]); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .ptr => |result_ptr| { - return unionInitRlPtr(gz, scope, rl, node, result_ptr, params[2], union_type, field_name); + return unionInitRlPtr(gz, scope, node, result_ptr, params[2], union_type, field_name); }, .block_ptr => |block_scope| { - return unionInitRlPtr(gz, scope, rl, node, block_scope.rl_ptr, params[2], union_type, field_name); + return unionInitRlPtr(gz, scope, node, block_scope.rl_ptr, params[2], union_type, field_name); }, } } @@ -6499,7 +6627,6 @@ fn unionInit( fn unionInitRlPtr( parent_gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, result_ptr: Zir.Inst.Ref, expr_node: ast.Node.Index, @@ -6547,7 +6674,7 @@ fn asRlPtr( parent_zir.appendAssumeCapacity(src_inst); } const casted_result = try parent_gz.addBin(.as, dest_type, result); - return rvalue(parent_gz, scope, rl, casted_result, operand_node); + return rvalue(parent_gz, rl, casted_result, operand_node); } else { try parent_zir.appendSlice(astgen.gpa, as_scope.instructions.items); return result; @@ -6571,16 +6698,16 @@ fn bitCast( .lhs = dest_type, .rhs = operand, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .ref => { return astgen.failNode(node, "cannot take address of `@bitCast` result", .{}); }, .ptr, .inferred_ptr => |result_ptr| { - return bitCastRlPtr(gz, scope, rl, node, dest_type, result_ptr, rhs); + return bitCastRlPtr(gz, scope, node, dest_type, result_ptr, rhs); }, .block_ptr => |block| { - return bitCastRlPtr(gz, scope, rl, node, dest_type, block.rl_ptr, rhs); + return bitCastRlPtr(gz, scope, node, dest_type, block.rl_ptr, rhs); }, } } @@ -6588,7 +6715,6 @@ fn bitCast( fn bitCastRlPtr( gz: *GenZir, scope: *Scope, - rl: ResultLoc, node: ast.Node.Index, dest_type: Zir.Inst.Ref, result_ptr: Zir.Inst.Ref, @@ -6613,7 +6739,7 @@ fn typeOf( } if (params.len == 1) { const result = try gz.addUnNode(.typeof, try expr(gz, scope, .none, params[0]), node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } const arena = gz.astgen.arena; var items = try arena.alloc(Zir.Inst.Ref, params.len); @@ -6622,7 +6748,7 @@ fn typeOf( } const result = try gz.addExtendedMultiOp(.typeof_peer, node, items); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn builtinCall( @@ -6662,7 +6788,6 @@ fn builtinCall( switch (info.tag) { .import => { const node_tags = tree.nodes.items(.tag); - const node_datas = tree.nodes.items(.data); const operand_node = params[0]; if (node_tags[operand_node] != .string_literal) { @@ -6673,7 +6798,7 @@ fn builtinCall( const str = try astgen.strLitAsString(str_lit_token); try astgen.imports.put(astgen.gpa, str.index, {}); const result = try gz.addStrTok(.import, str.index, str_lit_token); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .compile_log => { const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len); @@ -6682,7 +6807,7 @@ fn builtinCall( for (params) |param, i| arg_refs[i] = try expr(gz, scope, .none, param); const result = try gz.addExtendedMultiOp(.compile_log, node, arg_refs); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .field => { const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); @@ -6696,7 +6821,7 @@ fn builtinCall( .lhs = try expr(gz, scope, .none, params[0]), .field_name = field_name, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .as => return as( gz, scope, rl, node, params[0], params[1]), .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]), @@ -6715,9 +6840,32 @@ fn builtinCall( .identifier => { const ident_token = main_tokens[params[0]]; decl_name = try astgen.identAsString(ident_token); - // TODO look for local variables in scope matching `decl_name` and emit a compile - // error. Only top-level declarations can be exported. Until this is done, the - // compile error will end up being "use of undeclared identifier" in Sema. + { + var s = scope; + while (true) switch (s.tag) { + .local_val => { + const local_val = s.cast(Scope.LocalVal).?; + if (local_val.name == decl_name) { + local_val.used = .used; + break; + } + s = local_val.parent; + }, + .local_ptr => { + const local_ptr = s.cast(Scope.LocalPtr).?; + if (local_ptr.name == decl_name) { + if (!local_ptr.maybe_comptime) + return astgen.failNode(params[0], "unable to export runtime-known value", .{}); + local_ptr.used = .used; + break; + } + s = local_ptr.parent; + }, + .gen_zir => s = s.cast(GenZir).?.parent, + .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, + .namespace, .top => break, + }; + } }, .field_access => { const namespace_node = node_datas[params[0]].lhs; @@ -6727,7 +6875,7 @@ fn builtinCall( decl_name = try astgen.identAsString(field_ident); }, else => return astgen.failNode( - params[0], "the first @export parameter must be an identifier", .{}, + params[0], "symbol to export must identify a declaration", .{}, ), } const options = try comptimeExpr(gz, scope, .{ .ty = .export_options_type }, params[1]); @@ -6736,7 +6884,7 @@ fn builtinCall( .decl_name = decl_name, .options = options, }); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); }, .@"extern" => { const type_inst = try typeExpr(gz, scope, params[0]); @@ -6746,18 +6894,18 @@ fn builtinCall( .lhs = type_inst, .rhs = options, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, - .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint), - .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence), + .breakpoint => return simpleNoOpVoid(gz, rl, node, .breakpoint), + .fence => return simpleNoOpVoid(gz, rl, node, .fence), - .This => return rvalue(gz, scope, rl, try gz.addNodeExtended(.this, node), node), - .return_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.ret_addr, node), node), - .src => return rvalue(gz, scope, rl, try gz.addNodeExtended(.builtin_src, node), node), - .error_return_trace => return rvalue(gz, scope, rl, try gz.addNodeExtended(.error_return_trace, node), node), - .frame => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame, node), node), - .frame_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame_address, node), node), + .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node), + .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node), + .src => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src, node), node), + .error_return_trace => return rvalue(gz, rl, try gz.addNodeExtended(.error_return_trace, node), node), + .frame => return rvalue(gz, rl, try gz.addNodeExtended(.frame, node), node), + .frame_address => return rvalue(gz, rl, try gz.addNodeExtended(.frame_address, node), node), .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info), .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of), @@ -6813,7 +6961,7 @@ fn builtinCall( .lhs = dest_align, .rhs = rhs, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl), @@ -6849,7 +6997,7 @@ fn builtinCall( .node = gz.nodeIndexToRelative(node), .operand = operand, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .wasm_memory_grow => { const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); @@ -6859,7 +7007,7 @@ fn builtinCall( .lhs = index_arg, .rhs = delta_arg, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .c_define => { const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]); @@ -6869,7 +7017,7 @@ fn builtinCall( .lhs = name, .rhs = value, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .splat => { @@ -6879,7 +7027,7 @@ fn builtinCall( .lhs = len, .rhs = scalar, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .reduce => { const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]); @@ -6888,7 +7036,7 @@ fn builtinCall( .lhs = op, .rhs = scalar, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow), @@ -6915,7 +7063,7 @@ fn builtinCall( .rhs = rhs, .ptr = ptr, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .atomic_load => { @@ -6935,7 +7083,7 @@ fn builtinCall( .lhs = ptr, .rhs = ordering, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .atomic_rmw => { const int_type = try typeExpr(gz, scope, params[0]); @@ -6958,7 +7106,7 @@ fn builtinCall( .operand = operand, .ordering = ordering, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .atomic_store => { const int_type = try typeExpr(gz, scope, params[0]); @@ -6979,7 +7127,7 @@ fn builtinCall( .operand = operand, .ordering = ordering, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .mul_add => { const float_type = try typeExpr(gz, scope, params[0]); @@ -6991,7 +7139,7 @@ fn builtinCall( .mulend2 = mulend2, .addend = addend, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .call => { const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]); @@ -7002,7 +7150,7 @@ fn builtinCall( .callee = callee, .args = args, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .field_parent_ptr => { const parent_type = try typeExpr(gz, scope, params[0]); @@ -7013,7 +7161,7 @@ fn builtinCall( .field_name = field_name, .field_ptr = try expr(gz, scope, .{ .ty = field_ptr_type }, params[2]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .memcpy => { const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{ @@ -7021,7 +7169,7 @@ fn builtinCall( .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]), .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .memset => { const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{ @@ -7029,7 +7177,7 @@ fn builtinCall( .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]), .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .shuffle => { const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{ @@ -7038,7 +7186,7 @@ fn builtinCall( .b = try expr(gz, scope, .none, params[2]), .mask = try comptimeExpr(gz, scope, .none, params[3]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .async_call => { const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{ @@ -7047,14 +7195,14 @@ fn builtinCall( .fn_ptr = try expr(gz, scope, .none, params[2]), .args = try expr(gz, scope, .none, params[3]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, .Vector => { const result = try gz.addPlNode(.vector_type, node, Zir.Inst.Bin{ .lhs = try comptimeExpr(gz, scope, .{.ty = .u32_type}, params[0]), .rhs = try typeExpr(gz, scope, params[1]), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); }, } @@ -7063,13 +7211,12 @@ fn builtinCall( fn simpleNoOpVoid( gz: *GenZir, - scope: *Scope, rl: ResultLoc, node: ast.Node.Index, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { _ = try gz.addNode(tag, node); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); } fn hasDeclOrField( @@ -7087,7 +7234,7 @@ fn hasDeclOrField( .lhs = container_type, .rhs = name, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn typeCast( @@ -7103,7 +7250,7 @@ fn typeCast( .lhs = try typeExpr(gz, scope, lhs_node), .rhs = try expr(gz, scope, .none, rhs_node), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn simpleUnOpType( @@ -7116,7 +7263,7 @@ fn simpleUnOpType( ) InnerError!Zir.Inst.Ref { const operand = try typeExpr(gz, scope, operand_node); const result = try gz.addUnNode(tag, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn simpleUnOp( @@ -7130,7 +7277,7 @@ fn simpleUnOp( ) InnerError!Zir.Inst.Ref { const operand = try expr(gz, scope, operand_rl, operand_node); const result = try gz.addUnNode(tag, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn cmpxchg( @@ -7160,7 +7307,7 @@ fn cmpxchg( .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]), // zig fmt: on }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn bitBuiltin( @@ -7175,7 +7322,7 @@ fn bitBuiltin( const int_type = try typeExpr(gz, scope, int_type_node); const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node); const result = try gz.addUnNode(tag, operand, node); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn divBuiltin( @@ -7191,7 +7338,7 @@ fn divBuiltin( .lhs = try expr(gz, scope, .none, lhs_node), .rhs = try expr(gz, scope, .none, rhs_node), }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn simpleCBuiltin( @@ -7207,7 +7354,7 @@ fn simpleCBuiltin( .node = gz.nodeIndexToRelative(node), .operand = operand, }); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); } fn offsetOf( @@ -7225,7 +7372,7 @@ fn offsetOf( .lhs = type_inst, .rhs = field_name, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn shiftOp( @@ -7244,7 +7391,7 @@ fn shiftOp( .lhs = lhs, .rhs = rhs, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn cImport( @@ -7269,7 +7416,7 @@ fn cImport( try block_scope.setBlockBody(block_inst); try gz.instructions.append(gpa, block_inst); - return rvalue(gz, scope, rl, .void_value, node); + return rvalue(gz, rl, .void_value, node); } fn overflowArithmetic( @@ -7299,7 +7446,7 @@ fn overflowArithmetic( .rhs = rhs, .ptr = ptr, }); - return rvalue(gz, scope, rl, result, node); + return rvalue(gz, rl, result, node); } fn callExpr( @@ -7351,7 +7498,7 @@ fn callExpr( }; break :res try gz.addCall(tag, lhs, args, node); }; - return rvalue(gz, scope, rl, result, node); // TODO function call with result location + return rvalue(gz, rl, result, node); // TODO function call with result location } pub const simple_types = std.ComptimeStringMap(Zir.Inst.Ref, .{ @@ -7608,13 +7755,225 @@ fn nodeMayNeedMemoryLocation(tree: *const ast.Tree, start_node: ast.Node.Index) } } +fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum { never, always, maybe } { + const node_tags = tree.nodes.items(.tag); + const node_datas = tree.nodes.items(.data); + const main_tokens = tree.nodes.items(.main_token); + const token_tags = tree.tokens.items(.tag); + + var node = start_node; + while (true) { + switch (node_tags[node]) { + .root, + .@"usingnamespace", + .test_decl, + .switch_case, + .switch_case_one, + .container_field_init, + .container_field_align, + .container_field, + .asm_output, + .asm_input, + => unreachable, + + .error_value => return .always, + + .@"asm", + .asm_simple, + .identifier, + .field_access, + .deref, + .array_access, + .while_simple, + .while_cont, + .for_simple, + .if_simple, + .@"while", + .@"if", + .@"for", + .@"switch", + .switch_comma, + .call_one, + .call_one_comma, + .async_call_one, + .async_call_one_comma, + .call, + .call_comma, + .async_call, + .async_call_comma, + => return .maybe, + + .@"return", + .@"break", + .@"continue", + .bit_not, + .bool_not, + .global_var_decl, + .local_var_decl, + .simple_var_decl, + .aligned_var_decl, + .@"defer", + .@"errdefer", + .address_of, + .optional_type, + .negation, + .negation_wrap, + .@"resume", + .array_type, + .array_type_sentinel, + .ptr_type_aligned, + .ptr_type_sentinel, + .ptr_type, + .ptr_type_bit_range, + .@"suspend", + .@"anytype", + .fn_proto_simple, + .fn_proto_multi, + .fn_proto_one, + .fn_proto, + .fn_decl, + .anyframe_type, + .anyframe_literal, + .integer_literal, + .float_literal, + .enum_literal, + .string_literal, + .multiline_string_literal, + .char_literal, + .true_literal, + .false_literal, + .null_literal, + .undefined_literal, + .unreachable_literal, + .error_set_decl, + .container_decl, + .container_decl_trailing, + .container_decl_two, + .container_decl_two_trailing, + .container_decl_arg, + .container_decl_arg_trailing, + .tagged_union, + .tagged_union_trailing, + .tagged_union_two, + .tagged_union_two_trailing, + .tagged_union_enum_tag, + .tagged_union_enum_tag_trailing, + .add, + .add_wrap, + .array_cat, + .array_mult, + .assign, + .assign_bit_and, + .assign_bit_or, + .assign_bit_shift_left, + .assign_bit_shift_right, + .assign_bit_xor, + .assign_div, + .assign_sub, + .assign_sub_wrap, + .assign_mod, + .assign_add, + .assign_add_wrap, + .assign_mul, + .assign_mul_wrap, + .bang_equal, + .bit_and, + .bit_or, + .bit_shift_left, + .bit_shift_right, + .bit_xor, + .bool_and, + .bool_or, + .div, + .equal_equal, + .error_union, + .greater_or_equal, + .greater_than, + .less_or_equal, + .less_than, + .merge_error_sets, + .mod, + .mul, + .mul_wrap, + .switch_range, + .sub, + .sub_wrap, + .slice, + .slice_open, + .slice_sentinel, + .array_init_one, + .array_init_one_comma, + .array_init_dot_two, + .array_init_dot_two_comma, + .array_init_dot, + .array_init_dot_comma, + .array_init, + .array_init_comma, + .struct_init_one, + .struct_init_one_comma, + .struct_init_dot_two, + .struct_init_dot_two_comma, + .struct_init_dot, + .struct_init_dot_comma, + .struct_init, + .struct_init_comma, + => return .never, + + // Forward the question to the LHS sub-expression. + .grouped_expression, + .@"try", + .@"await", + .@"comptime", + .@"nosuspend", + .unwrap_optional, + => node = node_datas[node].lhs, + + // Forward the question to the RHS sub-expression. + .@"catch", + .@"orelse", + => node = node_datas[node].rhs, + + .block_two, + .block_two_semicolon, + .block, + .block_semicolon, + => { + const lbrace = main_tokens[node]; + if (token_tags[lbrace - 1] == .colon) { + // Labeled blocks may need a memory location to forward + // to their break statements. + return .maybe; + } else { + return .never; + } + }, + + .builtin_call, + .builtin_call_comma, + .builtin_call_two, + .builtin_call_two_comma, + => { + const builtin_token = main_tokens[node]; + const builtin_name = tree.tokenSlice(builtin_token); + // If the builtin is an invalid name, we don't cause an error here; instead + // let it pass, and the error will be "invalid builtin function" later. + const builtin_info = BuiltinFn.list.get(builtin_name) orelse return .maybe; + if (builtin_info.tag == .err_set_cast) { + return .always; + } else { + return .never; + } + }, + } + } +} + /// Applies `rl` semantics to `inst`. Expressions which do not do their own handling of /// result locations must call this function on their result. /// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer. /// If the `ResultLoc` is `ty`, it will coerce the result to the type. fn rvalue( gz: *GenZir, - scope: *Scope, rl: ResultLoc, result: Zir.Inst.Ref, src_node: ast.Node.Index, @@ -7762,7 +8121,6 @@ fn parseStrLit( bytes: []const u8, offset: u32, ) InnerError!void { - const tree = astgen.tree; const raw_string = bytes[offset..]; var buf_managed = buf.toManaged(astgen.gpa); const result = std.zig.string_literal.parseAppend(&buf_managed, raw_string); @@ -8065,6 +8423,15 @@ const Scope = struct { top, }; + // either .used or the type of the var/constant + const Used = enum { + fn_param, + constant, + variable, + loop_index, + capture, + used, + }; /// This is always a `const` local and importantly the `inst` is a value type, not a pointer. /// This structure lives as long as the AST generation of the Block /// node that contains the variable. @@ -8079,6 +8446,8 @@ const Scope = struct { token_src: ast.TokenIndex, /// String table index. name: u32, + /// has this variable been referenced? + used: Used, }; /// This could be a `const` or `var` local. It has a pointer instead of a value. @@ -8095,7 +8464,10 @@ const Scope = struct { token_src: ast.TokenIndex, /// String table index. name: u32, - is_comptime: bool, + /// true means we find out during Sema whether the value is comptime. false means it is already known at AstGen the value is runtime-known. + maybe_comptime: bool, + /// has this variable been referenced? + used: Used, }; const Defer = struct { @@ -8205,13 +8577,13 @@ const GenZir = struct { fn calcLine(gz: GenZir, node: ast.Node.Index) u32 { const astgen = gz.astgen; const tree = astgen.tree; - const node_tags = tree.nodes.items(.tag); + const source = tree.source; const token_starts = tree.tokens.items(.start); - const decl_start = token_starts[tree.firstToken(gz.decl_node_index)]; const node_start = token_starts[tree.firstToken(node)]; - const source = tree.source[decl_start..node_start]; - const loc = std.zig.findLineColumn(source, source.len); - return @intCast(u32, gz.decl_line + loc.line); + + astgen.advanceSourceCursor(source, node_start); + + return @intCast(u32, gz.decl_line + astgen.source_line); } fn tokSrcLoc(gz: GenZir, token_index: ast.TokenIndex) LazySrcLoc { @@ -8355,20 +8727,21 @@ const GenZir = struct { const node_tags = tree.nodes.items(.tag); const node_datas = tree.nodes.items(.data); const token_starts = tree.tokens.items(.start); - const decl_start = token_starts[tree.firstToken(gz.decl_node_index)]; const fn_decl = args.src_node; assert(node_tags[fn_decl] == .fn_decl or node_tags[fn_decl] == .test_decl); const block = node_datas[fn_decl].rhs; const lbrace_start = token_starts[tree.firstToken(block)]; const rbrace_start = token_starts[tree.lastToken(block)]; - const lbrace_source = tree.source[decl_start..lbrace_start]; - const lbrace_loc = std.zig.findLineColumn(lbrace_source, lbrace_source.len); - const rbrace_source = tree.source[lbrace_start..rbrace_start]; - const rbrace_loc = std.zig.findLineColumn(rbrace_source, rbrace_source.len); - const lbrace_line = @intCast(u32, lbrace_loc.line); - const rbrace_line = lbrace_line + @intCast(u32, rbrace_loc.line); - const columns = @intCast(u32, lbrace_loc.column) | - (@intCast(u32, rbrace_loc.column) << 16); + + astgen.advanceSourceCursor(tree.source, lbrace_start); + const lbrace_line = @intCast(u32, astgen.source_line); + const lbrace_column = @intCast(u32, astgen.source_column); + + astgen.advanceSourceCursor(tree.source, rbrace_start); + const rbrace_line = @intCast(u32, astgen.source_line); + const rbrace_column = @intCast(u32, astgen.source_column); + + const columns = lbrace_column | (rbrace_column << 16); src_locs_buffer[0] = lbrace_line; src_locs_buffer[1] = rbrace_line; src_locs_buffer[2] = columns; @@ -9184,3 +9557,20 @@ fn declareNewName( } } } + +fn advanceSourceCursor(astgen: *AstGen, source: []const u8, end: usize) void { + var i = astgen.source_offset; + var line = astgen.source_line; + var column = astgen.source_column; + while (i < end) : (i += 1) { + if (source[i] == '\n') { + line += 1; + column = 0; + } else { + column += 1; + } + } + astgen.source_offset = i; + astgen.source_line = line; + astgen.source_column = column; +} diff --git a/src/Compilation.zig b/src/Compilation.zig index dc5fcbf361..f202034242 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -325,7 +325,6 @@ pub const AllErrors = struct { }, pub fn renderToStdErr(msg: Message, ttyconf: std.debug.TTY.Config) void { - const stderr_mutex = std.debug.getStderrMutex(); const held = std.debug.getStderrMutex().acquire(); defer held.release(); const stderr = std.io.getStdErr(); @@ -343,6 +342,7 @@ pub const AllErrors = struct { const stderr = stderr_file.writer(); switch (msg) { .src => |src| { + try stderr.writeByteNTimes(' ', indent); ttyconf.setColor(stderr, .Bold); try stderr.print("{s}:{d}:{d}: ", .{ src.src_path, @@ -350,7 +350,6 @@ pub const AllErrors = struct { src.column + 1, }); ttyconf.setColor(stderr, color); - try stderr.writeByteNTimes(' ', indent); try stderr.writeAll(kind); ttyconf.setColor(stderr, .Reset); ttyconf.setColor(stderr, .Bold); @@ -524,6 +523,7 @@ pub const AllErrors = struct { errors: *std.ArrayList(Message), msg: []const u8, ) !void { + _ = arena; try errors.append(.{ .plain = .{ .msg = msg } }); } @@ -612,6 +612,7 @@ pub const InitOptions = struct { output_mode: std.builtin.OutputMode, thread_pool: *ThreadPool, dynamic_linker: ?[]const u8 = null, + sysroot: ?[]const u8 = null, /// `null` means to not emit a binary file. emit_bin: ?EmitLoc, /// `null` means to not emit a C header file. @@ -731,6 +732,7 @@ fn addPackageTableToCacheHash( hash: *Cache.HashHelper, arena: *std.heap.ArenaAllocator, pkg_table: Package.Table, + seen_table: *std.AutoHashMap(*Package, void), hash_type: union(enum) { path_bytes, files: *Cache.Manifest }, ) (error{OutOfMemory} || std.os.GetCwdError)!void { const allocator = &arena.allocator; @@ -755,6 +757,8 @@ fn addPackageTableToCacheHash( }.lessThan); for (packages) |pkg| { + if ((try seen_table.getOrPut(pkg.value)).found_existing) continue; + // Finally insert the package name and path to the cache hash. hash.addBytes(pkg.key); switch (hash_type) { @@ -770,7 +774,7 @@ fn addPackageTableToCacheHash( }, } // Recurse to handle the package's dependencies - try addPackageTableToCacheHash(hash, arena, pkg.value.table, hash_type); + try addPackageTableToCacheHash(hash, arena, pkg.value.table, seen_table, hash_type); } } @@ -876,25 +880,32 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { break :blk false; }; - const DarwinOptions = struct { - syslibroot: ?[]const u8 = null, - system_linker_hack: bool = false, + const darwin_can_use_system_linker_and_sdk = + // comptime conditions + ((build_options.have_llvm and comptime std.Target.current.isDarwin()) and + // runtime conditions + (use_lld and std.builtin.os.tag == .macos and options.target.isDarwin())); + + const darwin_system_linker_hack = blk: { + if (darwin_can_use_system_linker_and_sdk) { + break :blk std.os.getenv("ZIG_SYSTEM_LINKER_HACK") != null; + } else { + break :blk false; + } }; - const darwin_options: DarwinOptions = if (build_options.have_llvm and comptime std.Target.current.isDarwin()) outer: { - const opts: DarwinOptions = if (use_lld and std.builtin.os.tag == .macos and options.target.isDarwin()) inner: { + const sysroot = blk: { + if (options.sysroot) |sysroot| { + break :blk sysroot; + } else if (darwin_can_use_system_linker_and_sdk) { // TODO Revisit this targeting versions lower than macOS 11 when LLVM 12 is out. // See https://github.com/ziglang/zig/issues/6996 const at_least_big_sur = options.target.os.getVersionRange().semver.min.major >= 11; - const syslibroot = if (at_least_big_sur) try std.zig.system.getSDKPath(arena) else null; - const system_linker_hack = std.os.getenv("ZIG_SYSTEM_LINKER_HACK") != null; - break :inner .{ - .syslibroot = syslibroot, - .system_linker_hack = system_linker_hack, - }; - } else .{}; - break :outer opts; - } else .{}; + break :blk if (at_least_big_sur) try std.zig.system.getSDKPath(arena) else null; + } else { + break :blk null; + } + }; const lto = blk: { if (options.want_lto) |explicit| { @@ -905,7 +916,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { break :blk false; } else if (options.c_source_files.len == 0) { break :blk false; - } else if (darwin_options.system_linker_hack) { + } else if (darwin_system_linker_hack) { break :blk false; } else switch (options.output_mode) { .Lib, .Obj => break :blk false, @@ -1116,7 +1127,8 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { { var local_arena = std.heap.ArenaAllocator.init(gpa); defer local_arena.deinit(); - try addPackageTableToCacheHash(&hash, &local_arena, root_pkg.table, .path_bytes); + var seen_table = std.AutoHashMap(*Package, void).init(&local_arena.allocator); + try addPackageTableToCacheHash(&hash, &local_arena, root_pkg.table, &seen_table, .path_bytes); } hash.add(valgrind); hash.add(single_threaded); @@ -1137,36 +1149,32 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { artifact_sub_dir, }; - // If we rely on stage1, we must not redundantly add these packages. - const use_stage1 = build_options.is_stage1 and use_llvm; - if (!use_stage1) { - const builtin_pkg = try Package.createWithDir( - gpa, - zig_cache_artifact_directory, - null, - "builtin.zig", - ); - errdefer builtin_pkg.destroy(gpa); + const builtin_pkg = try Package.createWithDir( + gpa, + zig_cache_artifact_directory, + null, + "builtin.zig", + ); + errdefer builtin_pkg.destroy(gpa); - const std_pkg = try Package.createWithDir( - gpa, - options.zig_lib_directory, - "std", - "std.zig", - ); - errdefer std_pkg.destroy(gpa); + const std_pkg = try Package.createWithDir( + gpa, + options.zig_lib_directory, + "std", + "std.zig", + ); + errdefer std_pkg.destroy(gpa); - try root_pkg.addAndAdopt(gpa, "builtin", builtin_pkg); - try root_pkg.add(gpa, "root", root_pkg); - try root_pkg.addAndAdopt(gpa, "std", std_pkg); + try root_pkg.addAndAdopt(gpa, "builtin", builtin_pkg); + try root_pkg.add(gpa, "root", root_pkg); + try root_pkg.addAndAdopt(gpa, "std", std_pkg); - try std_pkg.add(gpa, "builtin", builtin_pkg); - try std_pkg.add(gpa, "root", root_pkg); - try std_pkg.add(gpa, "std", std_pkg); + try std_pkg.add(gpa, "builtin", builtin_pkg); + try std_pkg.add(gpa, "root", root_pkg); + try std_pkg.add(gpa, "std", std_pkg); - try builtin_pkg.add(gpa, "std", std_pkg); - try builtin_pkg.add(gpa, "builtin", builtin_pkg); - } + try builtin_pkg.add(gpa, "std", std_pkg); + try builtin_pkg.add(gpa, "builtin", builtin_pkg); // Pre-open the directory handles for cached ZIR code so that it does not need // to redundantly happen for each AstGen operation. @@ -1281,13 +1289,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .module = module, .target = options.target, .dynamic_linker = options.dynamic_linker, + .sysroot = sysroot, .output_mode = options.output_mode, .link_mode = link_mode, .object_format = ofmt, .optimize_mode = options.optimize_mode, .use_lld = use_lld, .use_llvm = use_llvm, - .system_linker_hack = darwin_options.system_linker_hack, + .system_linker_hack = darwin_system_linker_hack, .link_libc = link_libc, .link_libcpp = link_libcpp, .link_libunwind = link_libunwind, @@ -1295,7 +1304,6 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .frameworks = options.frameworks, .framework_dirs = options.framework_dirs, .system_libs = system_libs, - .syslibroot = darwin_options.syslibroot, .wasi_emulated_libs = options.wasi_emulated_libs, .lib_dirs = options.lib_dirs, .rpath_list = options.rpath_list, @@ -1625,30 +1633,39 @@ pub fn update(self: *Compilation) !void { // Add a Job for each C object. try self.c_object_work_queue.ensureUnusedCapacity(self.c_object_table.count()); for (self.c_object_table.keys()) |key| { - assert(@ptrToInt(key) != 0xaaaa_aaaa_aaaa_aaaa); self.c_object_work_queue.writeItemAssumeCapacity(key); } const use_stage1 = build_options.omit_stage2 or (build_options.is_stage1 and self.bin_file.options.use_llvm); - if (!use_stage1) { - if (self.bin_file.options.module) |module| { - module.compile_log_text.shrinkAndFree(module.gpa, 0); - module.generation += 1; - - // Make sure std.zig is inside the import_table. We unconditionally need - // it for start.zig. - const std_pkg = module.root_pkg.table.get("std").?; - _ = try module.importPkg(module.root_pkg, std_pkg); - - // Put a work item in for every known source file to detect if - // it changed, and, if so, re-compute ZIR and then queue the job - // to update it. - try self.astgen_work_queue.ensureUnusedCapacity(module.import_table.count()); - for (module.import_table.values()) |value| { - self.astgen_work_queue.writeItemAssumeCapacity(value); - } + if (self.bin_file.options.module) |module| { + module.compile_log_text.shrinkAndFree(module.gpa, 0); + module.generation += 1; + + // Make sure std.zig is inside the import_table. We unconditionally need + // it for start.zig. + const std_pkg = module.root_pkg.table.get("std").?; + _ = try module.importPkg(std_pkg); + + // Normally we rely on importing std to in turn import the root source file + // in the start code, but when using the stage1 backend that won't happen, + // so in order to run AstGen on the root source file we put it into the + // import_table here. + if (use_stage1) { + _ = try module.importPkg(module.root_pkg); + } + + // Put a work item in for every known source file to detect if + // it changed, and, if so, re-compute ZIR and then queue the job + // to update it. + // We still want AstGen work items for stage1 so that we expose compile errors + // that are implemented in stage2 but not stage1. + try self.astgen_work_queue.ensureUnusedCapacity(module.import_table.count()); + for (module.import_table.values()) |value| { + self.astgen_work_queue.writeItemAssumeCapacity(value); + } + if (!use_stage1) { try self.work_queue.writeItem(.{ .analyze_pkg = std_pkg }); } } @@ -1915,7 +1932,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor // (at least for now) single-threaded main work queue. However, C object compilation // only needs to be finished by the end of this function. - var zir_prog_node = main_progress_node.start("AstGen", self.astgen_work_queue.count); + var zir_prog_node = main_progress_node.start("AST Lowering", self.astgen_work_queue.count); defer zir_prog_node.end(); var c_obj_prog_node = main_progress_node.start("Compile C Objects", self.c_source_files.len); @@ -1936,7 +1953,6 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor } while (self.c_object_work_queue.readItem()) |c_object| { - assert(@ptrToInt(c_object) != 0xaaaa_aaaa_aaaa_aaaa); self.work_queue_wait_group.start(); try self.thread_pool.spawn(workerUpdateCObject, .{ self, c_object, &c_obj_prog_node, &self.work_queue_wait_group, @@ -1944,9 +1960,13 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor } } - // Iterate over all the files and look for outdated and deleted declarations. - if (self.bin_file.options.module) |mod| { - try mod.processOutdatedAndDeletedDecls(); + const use_stage1 = build_options.omit_stage2 or + (build_options.is_stage1 and self.bin_file.options.use_llvm); + if (!use_stage1) { + // Iterate over all the files and look for outdated and deleted declarations. + if (self.bin_file.options.module) |mod| { + try mod.processOutdatedAndDeletedDecls(); + } } while (self.work_queue.readItem()) |work_item| switch (work_item) { @@ -2283,8 +2303,12 @@ fn workerAstGenFile( ) void { defer wg.finish(); + var child_prog_node = prog_node.start(file.sub_file_path, 0); + child_prog_node.activate(); + defer child_prog_node.end(); + const mod = comp.bin_file.options.module.?; - mod.astGenFile(file, prog_node) catch |err| switch (err) { + mod.astGenFile(file) catch |err| switch (err) { error.AnalysisFail => return, else => { file.status = .retryable_failure; @@ -2315,6 +2339,9 @@ fn workerAstGenFile( break :blk mod.importFile(file, import_path) catch continue; }; if (import_result.is_new) { + log.debug("AstGen of {s} has import '{s}'; queuing AstGen of {s}", .{ + file.sub_file_path, import_path, import_result.file.sub_file_path, + }); wg.start(); comp.thread_pool.spawn(workerAstGenFile, .{ comp, import_result.file, prog_node, wg, @@ -2373,7 +2400,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { // We need to "unhit" in this case, to keep the digests matching. const prev_hash_state = man.hash.peekBin(); const actual_hit = hit: { - const is_hit = try man.hit(); + _ = try man.hit(); if (man.files.items.len == 0) { man.unhit(prev_hash_state, 0); break :hit false; @@ -2536,13 +2563,23 @@ fn reportRetryableAstGenError( file.status = .retryable_failure; - const err_msg = try Module.ErrorMsg.create(gpa, .{ + const src_loc: Module.SrcLoc = .{ .file_scope = file, .parent_decl_node = 0, .lazy = .entire_file, - }, "unable to load {s}: {s}", .{ - file.sub_file_path, @errorName(err), - }); + }; + + const err_msg = if (file.pkg.root_src_directory.path) |dir_path| + try Module.ErrorMsg.create( + gpa, + src_loc, + "unable to load {s}" ++ std.fs.path.sep_str ++ "{s}: {s}", + .{ dir_path, file.sub_file_path, @errorName(err) }, + ) + else + try Module.ErrorMsg.create(gpa, src_loc, "unable to load {s}: {s}", .{ + file.sub_file_path, @errorName(err), + }); errdefer err_msg.destroy(gpa); { @@ -2828,7 +2865,7 @@ pub fn addCCArgs( try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple }); switch (ext) { - .c, .cpp, .h => { + .c, .cpp, .m, .h => { try argv.appendSlice(&[_][]const u8{ "-nostdinc", "-fno-spell-checking", @@ -3015,7 +3052,7 @@ pub fn addCCArgs( const prefix: []const u8 = if (target.cpu.arch == .riscv64) "rv64" else "rv32"; const prefix_len = 4; assert(prefix.len == prefix_len); - var march_buf: [prefix_len + letters.len]u8 = undefined; + var march_buf: [prefix_len + letters.len + 1]u8 = undefined; var march_index: usize = prefix_len; mem.copy(u8, &march_buf, prefix); @@ -3119,6 +3156,7 @@ pub const FileExt = enum { c, cpp, h, + m, ll, bc, assembly, @@ -3130,7 +3168,7 @@ pub const FileExt = enum { pub fn clangSupportsDepFile(ext: FileExt) bool { return switch (ext) { - .c, .cpp, .h => true, + .c, .cpp, .h, .m => true, .ll, .bc, @@ -3164,6 +3202,10 @@ pub fn hasCppExt(filename: []const u8) bool { mem.endsWith(u8, filename, ".cxx"); } +pub fn hasObjCExt(filename: []const u8) bool { + return mem.endsWith(u8, filename, ".m"); +} + pub fn hasAsmExt(filename: []const u8) bool { return mem.endsWith(u8, filename, ".s") or mem.endsWith(u8, filename, ".S"); } @@ -3200,6 +3242,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt { return .c; } else if (hasCppExt(filename)) { return .cpp; + } else if (hasObjCExt(filename)) { + return .m; } else if (mem.endsWith(u8, filename, ".ll")) { return .ll; } else if (mem.endsWith(u8, filename, ".bc")) { @@ -3223,6 +3267,7 @@ pub fn classifyFileExt(filename: []const u8) FileExt { test "classifyFileExt" { try std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc")); + try std.testing.expectEqual(FileExt.m, classifyFileExt("foo.m")); try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim")); try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so")); try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1")); @@ -3826,9 +3871,8 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node _ = try man.addFile(main_zig_file, null); { - var local_arena = std.heap.ArenaAllocator.init(comp.gpa); - defer local_arena.deinit(); - try addPackageTableToCacheHash(&man.hash, &local_arena, mod.root_pkg.table, .{ .files = &man }); + var seen_table = std.AutoHashMap(*Package, void).init(&arena_allocator.allocator); + try addPackageTableToCacheHash(&man.hash, &arena_allocator, mod.root_pkg.table, &seen_table, .{ .files = &man }); } man.hash.add(comp.bin_file.options.valgrind); man.hash.add(comp.bin_file.options.single_threaded); @@ -4099,6 +4143,12 @@ fn createStage1Pkg( var children = std.ArrayList(*stage1.Pkg).init(arena); var it = pkg.table.iterator(); while (it.next()) |entry| { + if (mem.eql(u8, entry.key_ptr.*, "std") or + mem.eql(u8, entry.key_ptr.*, "builtin") or + mem.eql(u8, entry.key_ptr.*, "root")) + { + continue; + } try children.append(try createStage1Pkg(arena, entry.key_ptr.*, entry.value_ptr.*, child_pkg)); } break :blk children.items; diff --git a/src/DepTokenizer.zig b/src/DepTokenizer.zig index b21c893850..0fd26532f0 100644 --- a/src/DepTokenizer.zig +++ b/src/DepTokenizer.zig @@ -944,7 +944,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { try out.writeAll(text); var i: usize = text.len; const end = 79; - while (i < 79) : (i += 1) { + while (i < end) : (i += 1) { try out.writeAll(&[_]u8{label[0]}); } try out.writeAll("\n"); @@ -953,7 +953,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { fn printRuler(out: anytype) !void { var i: usize = 0; const end = 79; - while (i < 79) : (i += 1) { + while (i < end) : (i += 1) { try out.writeAll("-"); } try out.writeAll("\n"); @@ -1057,4 +1057,3 @@ const printable_char_tab: [256]u8 = ( "................................................................" ++ "................................................................" ).*; - diff --git a/src/Module.zig b/src/Module.zig index 8e868c4ed8..439256f320 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -774,7 +774,10 @@ pub const Fn = struct { ir.dumpFn(mod, func); } - pub fn deinit(func: *Fn, gpa: *Allocator) void {} + pub fn deinit(func: *Fn, gpa: *Allocator) void { + _ = func; + _ = gpa; + } }; pub const Var = struct { @@ -1148,6 +1151,9 @@ pub const Scope = struct { is_comptime: bool, + /// when null, it is determined by build mode, changed by @setRuntimeSafety + want_safety: ?bool = null, + /// This `Block` maps a block ZIR instruction to the corresponding /// AIR instruction for break instruction analysis. pub const Label = struct { @@ -1192,12 +1198,12 @@ pub const Scope = struct { .runtime_cond = parent.runtime_cond, .runtime_loop = parent.runtime_loop, .runtime_index = parent.runtime_index, + .want_safety = parent.want_safety, }; } pub fn wantSafety(block: *const Block) bool { - // TODO take into account scope's safety overrides - return switch (block.sema.mod.optimizeMode()) { + return block.want_safety orelse switch (block.sema.mod.optimizeMode()) { .Debug => true, .ReleaseSafe => true, .ReleaseFast => false, @@ -1561,7 +1567,6 @@ pub const SrcLoc = struct { .node_offset_array_access_index => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); const node_datas = tree.nodes.items(.data); - const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); const main_tokens = tree.nodes.items(.main_token); const tok_index = main_tokens[node_datas[node].rhs]; @@ -1570,7 +1575,6 @@ pub const SrcLoc = struct { }, .node_offset_slice_sentinel => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); const full = switch (node_tags[node]) { @@ -1586,7 +1590,6 @@ pub const SrcLoc = struct { }, .node_offset_call_func => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); var params: [1]ast.Node.Index = undefined; @@ -1625,7 +1628,6 @@ pub const SrcLoc = struct { .node_offset_deref_ptr => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); const node_datas = tree.nodes.items(.data); - const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); const tok_index = node_datas[node].lhs; const token_starts = tree.tokens.items(.start); @@ -1633,7 +1635,6 @@ pub const SrcLoc = struct { }, .node_offset_asm_source => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); const full = switch (node_tags[node]) { @@ -1648,7 +1649,6 @@ pub const SrcLoc = struct { }, .node_offset_asm_ret_ty => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); const full = switch (node_tags[node]) { @@ -1771,7 +1771,6 @@ pub const SrcLoc = struct { .node_offset_fn_type_cc => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); var params: [1]ast.Node.Index = undefined; @@ -1790,7 +1789,6 @@ pub const SrcLoc = struct { .node_offset_fn_type_ret_ty => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); - const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); const node = src_loc.declRelativeToNodeIndex(node_off); var params: [1]ast.Node.Index = undefined; @@ -1810,7 +1808,6 @@ pub const SrcLoc = struct { .node_offset_anyframe_type => |node_off| { const tree = try src_loc.file_scope.getTree(gpa); const node_datas = tree.nodes.items(.data); - const node_tags = tree.nodes.items(.tag); const parent_node = src_loc.declRelativeToNodeIndex(node_off); const node = node_datas[parent_node].rhs; const main_tokens = tree.nodes.items(.main_token); @@ -2217,7 +2214,7 @@ comptime { } } -pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void { +pub fn astGenFile(mod: *Module, file: *Scope.File) !void { const tracy = trace(@src()); defer tracy.end(); @@ -2502,7 +2499,6 @@ pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr); if (data_has_safety_tag) { // The `Data` union has a safety tag but in the file format we store it without. - const tags = file.zir.instructions.items(.tag); for (file.zir.instructions.items(.data)) |*data, i| { const as_struct = @ptrCast(*const Stage1DataLayout, data); safety_buffer[i] = as_struct.data; @@ -2838,7 +2834,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) InnerError!void { } pub fn semaPkg(mod: *Module, pkg: *Package) !void { - const file = (try mod.importPkg(mod.root_pkg, pkg)).file; + const file = (try mod.importPkg(pkg)).file; return mod.semaFile(file); } @@ -3137,7 +3133,7 @@ pub const ImportFileResult = struct { is_new: bool, }; -pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult { +pub fn importPkg(mod: *Module, pkg: *Package) !ImportFileResult { const gpa = mod.gpa; // The resolved path is used as the key in the import table, to detect if @@ -3190,7 +3186,10 @@ pub fn importFile( import_string: []const u8, ) !ImportFileResult { if (cur_file.pkg.table.get(import_string)) |pkg| { - return mod.importPkg(cur_file.pkg, pkg); + return mod.importPkg(pkg); + } + if (!mem.endsWith(u8, import_string, ".zig")) { + return error.PackageNotFound; } const gpa = mod.gpa; @@ -3386,7 +3385,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo log.debug("scan existing {*} ({s}) of {*}", .{ decl, decl.name, namespace }); // Update the AST node of the decl; even if its contents are unchanged, it may // have been re-ordered. - const prev_src_node = decl.src_node; decl.src_node = decl_node; decl.src_line = line; @@ -3395,7 +3393,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo decl.has_align = has_align; decl.has_linksection = has_linksection; decl.zir_decl_index = @intCast(u32, decl_sub_index); - if (decl.getFunction()) |func| { + if (decl.getFunction()) |_| { switch (mod.comp.bin_file.tag) { .coff => { // TODO Implement for COFF @@ -3764,6 +3762,7 @@ pub fn analyzeExport( errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1); } pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst { + _ = mod; const const_inst = try arena.create(ir.Inst.Constant); const_inst.* = .{ .base = .{ @@ -4132,6 +4131,7 @@ pub fn floatAdd( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4165,6 +4165,7 @@ pub fn floatSub( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4198,6 +4199,7 @@ pub fn floatDiv( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4231,6 +4233,7 @@ pub fn floatMul( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4264,6 +4267,7 @@ pub fn simplePtrType( mutable: bool, size: std.builtin.TypeInfo.Pointer.Size, ) Allocator.Error!Type { + _ = mod; if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { return Type.initTag(.const_slice_u8); } @@ -4298,6 +4302,7 @@ pub fn ptrType( @"volatile": bool, size: std.builtin.TypeInfo.Pointer.Size, ) Allocator.Error!Type { + _ = mod; assert(host_size == 0 or bit_offset < host_size * 8); // TODO check if type can be represented by simplePtrType @@ -4315,6 +4320,7 @@ pub fn ptrType( } pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type { + _ = mod; switch (child_type.tag()) { .single_const_pointer => return Type.Tag.optional_single_const_pointer.create( arena, @@ -4335,6 +4341,7 @@ pub fn arrayType( sentinel: ?Value, elem_type: Type, ) Allocator.Error!Type { + _ = mod; if (elem_type.eql(Type.initTag(.u8))) { if (sentinel) |some| { if (some.eql(Value.initTag(.zero))) { @@ -4365,6 +4372,7 @@ pub fn errorUnionType( error_set: Type, payload: Type, ) Allocator.Error!Type { + _ = mod; assert(error_set.zigTypeTag() == .ErrorSet); if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) { return Type.initTag(.anyerror_void_error_union); @@ -4692,11 +4700,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { const src: LazySrcLoc = .{ .node_offset = union_obj.node_offset }; extra_index += @boolToInt(small.has_src_node); - const tag_type_ref = if (small.has_tag_type) blk: { - const tag_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + if (small.has_tag_type) { extra_index += 1; - break :blk tag_type_ref; - } else .none; + } const body_len = if (small.has_body_len) blk: { const body_len = zir.extra[extra_index]; @@ -4784,6 +4790,7 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { cur_bit_bag >>= 1; const unused = @truncate(u1, cur_bit_bag) != 0; cur_bit_bag >>= 1; + _ = unused; const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]); extra_index += 1; @@ -4800,11 +4807,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void { break :blk align_ref; } else .none; - const tag_ref: Zir.Inst.Ref = if (has_tag) blk: { - const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); + if (has_tag) { extra_index += 1; - break :blk tag_ref; - } else .none; + } // This string needs to outlive the ZIR code. const field_name = try decl_arena.allocator.dupe(u8, field_name_zir); diff --git a/src/Sema.zig b/src/Sema.zig index 68d47b7f3b..ea6f4898c5 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -473,7 +473,7 @@ pub fn analyzeBody( continue; }, .set_cold => { - try sema.zirSetAlignStack(block, inst); + try sema.zirSetCold(block, inst); i += 1; continue; }, @@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I } fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); @@ -776,6 +777,7 @@ fn zirStructDecl( } fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 { + _ = block; switch (name_strategy) { .anon => { // It would be neat to have "struct:line:column" but this name has @@ -1074,6 +1076,10 @@ fn zirOpaqueDecl( const src = inst_data.src(); const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); + _ = name_strategy; + _ = inst_data; + _ = src; + _ = extra; return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{}); } @@ -1230,14 +1236,13 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].str_tok; - const src = inst_data.src(); const arg_name = inst_data.get(sema.code); const arg_index = sema.next_arg_index; sema.next_arg_index += 1; // TODO check if arg_name shadows a Decl - if (block.inlining) |inlining| { + if (block.inlining) |_| { return sema.param_inst_list[arg_index]; } @@ -1636,6 +1641,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In } fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -1644,6 +1650,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In } fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -1661,6 +1668,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! } fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const arena = sema.arena; const inst_data = sema.code.instructions.items(.data)[inst].float; const src = inst_data.src(); @@ -1673,6 +1681,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* } fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const arena = sema.arena; const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; @@ -2031,8 +2040,12 @@ fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { const inst_data = sema.code.instructions.items(.data)[inst].un_node; - const src: LazySrcLoc = inst_data.src(); - return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetRuntimeSafety", .{}); + const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; + + const op = try sema.resolveInst(inst_data.operand); + const op_coerced = try sema.coerce(block, Type.initTag(.bool), op, operand_src); + const b = (try sema.resolveConstValue(block, operand_src, op_coerced)).toBool(); + block.want_safety = b; } fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { @@ -2354,6 +2367,7 @@ fn analyzeCall( } fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -2462,6 +2476,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn } fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -2506,7 +2521,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr } try sema.requireRuntimeBlock(block, src); - return block.addUnOp(src, result_ty, .error_to_int, op_coerced); + return block.addUnOp(src, result_ty, .bitcast, op_coerced); } fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { @@ -2539,7 +2554,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr // const is_gt_max = @panic("TODO get max errors in compilation"); // try sema.addSafetyCheck(block, is_gt_max, .invalid_error_code); } - return block.addUnOp(src, Type.initTag(.anyerror), .int_to_error, op); + return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op); } fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { @@ -2622,6 +2637,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn } fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -3005,7 +3021,6 @@ fn zirFunc( defer tracy.end(); const inst_data = sema.code.instructions.items(.data)[inst].pl_node; - const src = inst_data.src(); const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index); const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); @@ -3061,7 +3076,9 @@ fn funcCommon( const fn_ty: Type = fn_ty: { // Hot path for some common function types. - if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value) { + if (zir_param_types.len == 0 and !var_args and align_val.tag() == .null_value and + !inferred_error_set) + { if (return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) { break :fn_ty Type.initTag(.fn_noreturn_no_args); } @@ -3092,6 +3109,10 @@ fn funcCommon( return mod.fail(&block.base, src, "TODO implement support for function prototypes to have alignment specified", .{}); } + if (inferred_error_set) { + return mod.fail(&block.base, src, "TODO implement functions with inferred error sets", .{}); + } + break :fn_ty try Type.Tag.function.create(sema.arena, .{ .param_types = param_types, .return_type = return_type, @@ -3332,9 +3353,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError defer tracy.end(); const inst_data = sema.code.instructions.items(.data)[inst].pl_node; - const src = inst_data.src(); const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; - const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); @@ -3499,6 +3518,8 @@ fn zirSwitchCapture( const switch_info = zir_datas[capture_info.switch_inst].pl_node; const src = switch_info.src(); + _ = is_ref; + _ = is_multi; return sema.mod.fail(&block.base, src, "TODO implement Sema for zirSwitchCapture", .{}); } @@ -3516,6 +3537,7 @@ fn zirSwitchCaptureElse( const switch_info = zir_datas[capture_info.switch_inst].pl_node; const src = switch_info.src(); + _ = is_ref; return sema.mod.fail(&block.base, src, "TODO implement Sema for zirSwitchCaptureElse", .{}); } @@ -3653,7 +3675,6 @@ fn analyzeSwitch( extra_index += 1; const body_len = sema.code.extra[extra_index]; extra_index += 1; - const body = sema.code.extra[extra_index..][0..body_len]; extra_index += body_len; try sema.validateSwitchItemEnum( @@ -3763,7 +3784,6 @@ fn analyzeSwitch( extra_index += 1; const body_len = sema.code.extra[extra_index]; extra_index += 1; - const body = sema.code.extra[extra_index..][0..body_len]; extra_index += body_len; try sema.validateSwitchItem( @@ -3859,7 +3879,6 @@ fn analyzeSwitch( extra_index += 1; const body_len = sema.code.extra[extra_index]; extra_index += 1; - const body = sema.code.extra[extra_index..][0..body_len]; extra_index += body_len; try sema.validateSwitchItemBool( @@ -3942,7 +3961,6 @@ fn analyzeSwitch( extra_index += 1; const body_len = sema.code.extra[extra_index]; extra_index += 1; - const body = sema.code.extra[extra_index..][0..body_len]; extra_index += body_len; try sema.validateSwitchItemSparse( @@ -4457,6 +4475,7 @@ fn validateSwitchNoRange( fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; + _ = extra; const src = inst_data.src(); return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); @@ -4515,12 +4534,17 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const tracy = trace(@src()); defer tracy.end(); + + _ = block; + _ = inst; return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); } fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const tracy = trace(@src()); defer tracy.end(); + + _ = inst; return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{}); } @@ -4590,18 +4614,24 @@ fn zirBitwise( fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const tracy = trace(@src()); defer tracy.end(); + + _ = inst; return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); } fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const tracy = trace(@src()); defer tracy.end(); + + _ = inst; return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); } fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const tracy = trace(@src()); defer tracy.end(); + + _ = inst; return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{}); } @@ -5061,6 +5091,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro } fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const zir_datas = sema.code.instructions.items(.data); const inst_data = zir_datas[inst].un_node; const src = inst_data.src(); @@ -5069,6 +5100,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! } fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); const operand_ptr = try sema.resolveInst(inst_data.operand); @@ -5594,6 +5626,10 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: return mod.failWithOwnedErrorMsg(&block.base, msg); } + if (is_ref) { + return mod.fail(&block.base, src, "TODO: Sema.zirStructInit is_ref=true", .{}); + } + const is_comptime = for (field_inits) |field_init| { if (field_init.value() == null) { break false; @@ -5617,18 +5653,24 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); + + _ = is_ref; return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); } fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); + + _ = is_ref; return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); } fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); + + _ = is_ref; return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); } @@ -5758,7 +5800,64 @@ fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); - return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToPtr", .{}); + + const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; + + const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; + const operand_res = try sema.resolveInst(extra.rhs); + const operand_coerced = try sema.coerce(block, Type.initTag(.usize), operand_res, operand_src); + + const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; + const type_res = try sema.resolveType(block, src, extra.lhs); + if (type_res.zigTypeTag() != .Pointer) + return sema.mod.fail(&block.base, type_src, "expected pointer, found '{}'", .{type_res}); + const ptr_align = type_res.ptrAlignment(sema.mod.getTarget()); + + if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| { + const addr = val.toUnsignedInt(); + if (!type_res.isAllowzeroPtr() and addr == 0) + return sema.mod.fail(&block.base, operand_src, "pointer type '{}' does not allow address zero", .{type_res}); + if (addr != 0 and addr % ptr_align != 0) + return sema.mod.fail(&block.base, operand_src, "pointer type '{}' requires aligned address", .{type_res}); + + const val_payload = try sema.arena.create(Value.Payload.U64); + val_payload.* = .{ + .base = .{ .tag = .int_u64 }, + .data = addr, + }; + return sema.mod.constInst(sema.arena, src, .{ + .ty = type_res, + .val = Value.initPayload(&val_payload.base), + }); + } + + try sema.requireRuntimeBlock(block, src); + if (block.wantSafety()) { + const zero = try sema.mod.constInst(sema.arena, src, .{ + .ty = Type.initTag(.u64), + .val = Value.initTag(.zero), + }); + if (!type_res.isAllowzeroPtr()) { + const is_non_zero = try block.addBinOp(src, Type.initTag(.bool), .cmp_neq, operand_coerced, zero); + try sema.addSafetyCheck(block, is_non_zero, .cast_to_null); + } + + if (ptr_align > 1) { + const val_payload = try sema.arena.create(Value.Payload.U64); + val_payload.* = .{ + .base = .{ .tag = .int_u64 }, + .data = ptr_align - 1, + }; + const align_minus_1 = try sema.mod.constInst(sema.arena, src, .{ + .ty = Type.initTag(.u64), + .val = Value.initPayload(&val_payload.base), + }); + const remainder = try block.addBinOp(src, Type.initTag(.u64), .bit_and, operand_coerced, align_minus_1); + const is_aligned = try block.addBinOp(src, Type.initTag(.bool), .cmp_eq, remainder, zero); + try sema.addSafetyCheck(block, is_aligned, .incorrect_alignment); + } + } + return block.addUnOp(src, type_res, .bitcast, operand_coerced); } fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { @@ -5967,6 +6066,8 @@ fn zirAwait( ) InnerError!*Inst { const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); + + _ = is_nosuspend; return sema.mod.fail(&block.base, src, "TODO: Sema.zirAwait", .{}); } @@ -5977,7 +6078,6 @@ fn zirVarExtended( ) InnerError!*Inst { const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); const src = sema.src; - const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr @@ -6183,6 +6283,8 @@ pub const PanicId = enum { unreach, unwrap_null, unwrap_errunion, + cast_to_null, + incorrect_alignment, invalid_error_code, }; @@ -6245,6 +6347,8 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: } fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index { + _ = sema; + _ = panic_id; // TODO Once we have a panic function to call, call it here instead of breakpoint. _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); @@ -6558,6 +6662,8 @@ fn elemPtrArray( }); } } + _ = elem_index; + _ = elem_index_src; return sema.mod.fail(&block.base, src, "TODO implement more analyze elemptr for arrays", .{}); } @@ -6805,10 +6911,13 @@ fn storePtr( if ((try sema.typeHasOnePossibleValue(block, src, elem_ty)) != null) return; - if (try sema.resolvePossiblyUndefinedValue(block, src, ptr)) |ptr_val| { + if (try sema.resolvePossiblyUndefinedValue(block, src, ptr)) |ptr_val| blk: { const const_val = (try sema.resolvePossiblyUndefinedValue(block, src, value)) orelse return sema.mod.fail(&block.base, src, "cannot store runtime value in compile time variable", .{}); + if (ptr_val.tag() == .int_u64) + break :blk; // propogate it down to runtime + const comptime_alloc = ptr_val.castTag(.comptime_alloc).?; if (comptime_alloc.data.runtime_index < block.runtime_index) { if (block.runtime_cond) |cond_src| { @@ -6947,7 +7056,10 @@ fn analyzeLoad( .Pointer => ptr.ty.elemType(), else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}), }; - if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| { + if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| blk: { + if (ptr_val.tag() == .int_u64) + break :blk; // do it at runtime + return sema.mod.constInst(sema.arena, src, .{ .ty = elem_ty, .val = try ptr_val.pointerDeref(sema.arena), @@ -7065,6 +7177,7 @@ fn analyzeSlice( ptr_child.isVolatilePtr(), return_ptr_size, ); + _ = return_type; return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{}); } @@ -7410,14 +7523,14 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type struct_obj.status = .have_field_types; return ty; }, - .extern_options => return sema.resolveBuiltinTypeFields(block, src, ty, "ExternOptions"), - .export_options => return sema.resolveBuiltinTypeFields(block, src, ty, "ExportOptions"), - .atomic_ordering => return sema.resolveBuiltinTypeFields(block, src, ty, "AtomicOrdering"), - .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, ty, "AtomicRmwOp"), - .calling_convention => return sema.resolveBuiltinTypeFields(block, src, ty, "CallingConvention"), - .float_mode => return sema.resolveBuiltinTypeFields(block, src, ty, "FloatMode"), - .reduce_op => return sema.resolveBuiltinTypeFields(block, src, ty, "ReduceOp"), - .call_options => return sema.resolveBuiltinTypeFields(block, src, ty, "CallOptions"), + .extern_options => return sema.resolveBuiltinTypeFields(block, src, "ExternOptions"), + .export_options => return sema.resolveBuiltinTypeFields(block, src, "ExportOptions"), + .atomic_ordering => return sema.resolveBuiltinTypeFields(block, src, "AtomicOrdering"), + .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, "AtomicRmwOp"), + .calling_convention => return sema.resolveBuiltinTypeFields(block, src, "CallingConvention"), + .float_mode => return sema.resolveBuiltinTypeFields(block, src, "FloatMode"), + .reduce_op => return sema.resolveBuiltinTypeFields(block, src, "ReduceOp"), + .call_options => return sema.resolveBuiltinTypeFields(block, src, "CallOptions"), .@"union", .union_tagged => { const union_obj = ty.cast(Type.Payload.Union).?.data; @@ -7443,7 +7556,6 @@ fn resolveBuiltinTypeFields( sema: *Sema, block: *Scope.Block, src: LazySrcLoc, - ty: Type, name: []const u8, ) InnerError!Type { const resolved_ty = try sema.getBuiltinType(block, src, name); @@ -7458,7 +7570,7 @@ fn getBuiltinType( ) InnerError!Type { const mod = sema.mod; const std_pkg = mod.root_pkg.table.get("std").?; - const std_file = (mod.importPkg(mod.root_pkg, std_pkg) catch unreachable).file; + const std_file = (mod.importPkg(std_pkg) catch unreachable).file; const opt_builtin_inst = try sema.analyzeNamespaceLookup( block, src, diff --git a/src/ThreadPool.zig b/src/ThreadPool.zig index e66742b49e..4a7fa8cb9b 100644 --- a/src/ThreadPool.zig +++ b/src/ThreadPool.zig @@ -101,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void { pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void { if (std.builtin.single_threaded) { - const result = @call(.{}, func, args); + @call(.{}, func, args); return; } @@ -114,7 +114,7 @@ pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void { fn runFn(runnable: *Runnable) void { const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable); const closure = @fieldParentPtr(@This(), "run_node", run_node); - const result = @call(.{}, func, closure.arguments); + @call(.{}, func, closure.arguments); const held = closure.pool.lock.acquire(); defer held.release(); diff --git a/src/Zir.zig b/src/Zir.zig index 0c8855bbc9..5d75030711 100644 --- a/src/Zir.zig +++ b/src/Zir.zig @@ -3176,6 +3176,7 @@ const Writer = struct { inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel; + _ = inst_data; try stream.writeAll("TODO)"); } @@ -3213,6 +3214,7 @@ const Writer = struct { inst: Inst.Index, ) (@TypeOf(stream).Error || error{OutOfMemory})!void { const inst_data = self.code.instructions.items(.data)[inst].ptr_type; + _ = inst_data; try stream.writeAll("TODO)"); } @@ -3559,6 +3561,8 @@ const Writer = struct { assert(body.len == 0); try stream.writeAll("{}, {})"); } else { + const prev_parent_decl_node = self.parent_decl_node; + if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); self.indent += 2; if (body.len == 0) { try stream.writeAll("{}, {\n"); @@ -3621,6 +3625,7 @@ const Writer = struct { try stream.writeAll(",\n"); } + self.parent_decl_node = prev_parent_decl_node; self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("})"); @@ -3689,6 +3694,8 @@ const Writer = struct { const body = self.code.extra[extra_index..][0..body_len]; extra_index += body.len; + const prev_parent_decl_node = self.parent_decl_node; + if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); self.indent += 2; if (body.len == 0) { try stream.writeAll("{}, {\n"); @@ -3754,6 +3761,7 @@ const Writer = struct { try stream.writeAll(",\n"); } + self.parent_decl_node = prev_parent_decl_node; self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("})"); @@ -3909,6 +3917,8 @@ const Writer = struct { assert(body.len == 0); try stream.writeAll("{}, {})"); } else { + const prev_parent_decl_node = self.parent_decl_node; + if (src_node) |off| self.parent_decl_node = self.relativeToNodeIndex(off); self.indent += 2; if (body.len == 0) { try stream.writeAll("{}, {\n"); @@ -3949,6 +3959,7 @@ const Writer = struct { } try stream.writeAll(",\n"); } + self.parent_decl_node = prev_parent_decl_node; self.indent -= 2; try stream.writeByteNTimes(' ', self.indent); try stream.writeAll("})"); @@ -4431,6 +4442,7 @@ const Writer = struct { } fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void { + _ = self; return stream.print("%{d}", .{inst}); } @@ -4451,6 +4463,7 @@ const Writer = struct { name: []const u8, flag: bool, ) !void { + _ = self; if (!flag) return; try stream.writeAll(name); } @@ -4739,7 +4752,6 @@ fn findDeclsSwitch( var extra_index: usize = special.end; var scalar_i: usize = 0; while (scalar_i < extra.data.cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); extra_index += 1; const body_len = zir.extra[extra_index]; extra_index += 1; @@ -4779,7 +4791,6 @@ fn findDeclsSwitchMulti( { var scalar_i: usize = 0; while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) { - const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]); extra_index += 1; const body_len = zir.extra[extra_index]; extra_index += 1; @@ -4800,12 +4811,11 @@ fn findDeclsSwitchMulti( extra_index += 1; const items = zir.refSlice(extra_index, items_len); extra_index += items_len; + _ = items; var range_i: usize = 0; while (range_i < ranges_len) : (range_i += 1) { - const item_first = @intToEnum(Inst.Ref, zir.extra[extra_index]); extra_index += 1; - const item_last = @intToEnum(Inst.Ref, zir.extra[extra_index]); extra_index += 1; } diff --git a/src/air.zig b/src/air.zig index 8f3ae6d631..37126f8153 100644 --- a/src/air.zig +++ b/src/air.zig @@ -92,10 +92,6 @@ pub const Inst = struct { is_err, /// *E!T => bool is_err_ptr, - /// E => u16 - error_to_int, - /// u16 => E - int_to_error, bool_and, bool_or, /// Read a value from a pointer. @@ -159,8 +155,6 @@ pub const Inst = struct { .is_null_ptr, .is_err, .is_err_ptr, - .int_to_error, - .error_to_int, .ptrtoint, .floatcast, .intcast, @@ -310,9 +304,12 @@ pub const Inst = struct { base: Inst, pub fn operandCount(self: *const NoOp) usize { + _ = self; return 0; } pub fn getOperand(self: *const NoOp, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -322,6 +319,7 @@ pub const Inst = struct { operand: *Inst, pub fn operandCount(self: *const UnOp) usize { + _ = self; return 1; } pub fn getOperand(self: *const UnOp, index: usize) ?*Inst { @@ -337,6 +335,7 @@ pub const Inst = struct { rhs: *Inst, pub fn operandCount(self: *const BinOp) usize { + _ = self; return 2; } pub fn getOperand(self: *const BinOp, index: usize) ?*Inst { @@ -362,9 +361,12 @@ pub const Inst = struct { name: [*:0]const u8, pub fn operandCount(self: *const Arg) usize { + _ = self; return 0; } pub fn getOperand(self: *const Arg, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -397,9 +399,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const Block) usize { + _ = self; return 0; } pub fn getOperand(self: *const Block, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -418,9 +423,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const BrBlockFlat) usize { + _ = self; return 0; } pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -433,9 +441,11 @@ pub const Inst = struct { operand: *Inst, pub fn operandCount(self: *const Br) usize { + _ = self; return 1; } pub fn getOperand(self: *const Br, index: usize) ?*Inst { + _ = self; if (index == 0) return self.operand; return null; @@ -449,9 +459,12 @@ pub const Inst = struct { block: *Block, pub fn operandCount(self: *const BrVoid) usize { + _ = self; return 0; } pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -496,6 +509,7 @@ pub const Inst = struct { else_death_count: u32 = 0, pub fn operandCount(self: *const CondBr) usize { + _ = self; return 1; } pub fn getOperand(self: *const CondBr, index: usize) ?*Inst { @@ -522,9 +536,12 @@ pub const Inst = struct { val: Value, pub fn operandCount(self: *const Constant) usize { + _ = self; return 0; } pub fn getOperand(self: *const Constant, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -536,9 +553,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const Loop) usize { + _ = self; return 0; } pub fn getOperand(self: *const Loop, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -550,9 +570,12 @@ pub const Inst = struct { variable: *Module.Var, pub fn operandCount(self: *const VarPtr) usize { + _ = self; return 0; } pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -565,9 +588,12 @@ pub const Inst = struct { field_index: usize, pub fn operandCount(self: *const StructFieldPtr) usize { + _ = self; return 1; } pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst { + _ = self; + _ = index; var i = index; if (i < 1) @@ -599,6 +625,7 @@ pub const Inst = struct { }; pub fn operandCount(self: *const SwitchBr) usize { + _ = self; return 1; } pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst { @@ -627,9 +654,12 @@ pub const Inst = struct { column: u32, pub fn operandCount(self: *const DbgStmt) usize { + _ = self; return 0; } pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -730,8 +760,6 @@ const DumpTzir = struct { .is_null_ptr, .is_err, .is_err_ptr, - .error_to_int, - .int_to_error, .ptrtoint, .floatcast, .intcast, @@ -865,8 +893,6 @@ const DumpTzir = struct { .is_null_ptr, .is_err, .is_err_ptr, - .error_to_int, - .int_to_error, .ptrtoint, .floatcast, .intcast, diff --git a/src/clang.zig b/src/clang.zig index bd305bc76f..023d1aba4b 100644 --- a/src/clang.zig +++ b/src/clang.zig @@ -389,9 +389,6 @@ pub const ElaboratedType = opaque { }; pub const EnumConstantDecl = opaque { - pub const getInitExpr = ZigClangEnumConstantDecl_getInitExpr; - extern fn ZigClangEnumConstantDecl_getInitExpr(*const EnumConstantDecl) ?*const Expr; - pub const getInitVal = ZigClangEnumConstantDecl_getInitVal; extern fn ZigClangEnumConstantDecl_getInitVal(*const EnumConstantDecl) *const APSInt; }; diff --git a/src/codegen.zig b/src/codegen.zig index b35b8d5986..0b63222242 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -118,7 +118,6 @@ pub fn generateSymbol( if (typed_value.ty.sentinel()) |sentinel| { try code.ensureCapacity(code.items.len + payload.data.len + 1); code.appendSliceAssumeCapacity(payload.data); - const prev_len = code.items.len; switch (try generateSymbol(bin_file, src_loc, .{ .ty = typed_value.ty.elemType(), .val = sentinel, @@ -565,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .r11 = true, // fp .r14 = true, // lr }; - inline for (callee_preserved_regs) |reg, i| { + inline for (callee_preserved_regs) |reg| { if (self.register_manager.isRegAllocated(reg)) { @field(saved_regs, @tagName(reg)) = true; } @@ -603,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } else { if (math.cast(i26, amt)) |offset| { writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32()); - } else |err| { + } else |_| { return self.failSymbol("exitlude jump is too large", .{}); } } @@ -676,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } else { if (math.cast(i28, amt)) |offset| { writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32()); - } else |err| { + } else |_| { return self.failSymbol("exitlude jump is too large", .{}); } } @@ -850,8 +849,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .is_null_ptr => return self.genIsNullPtr(inst.castTag(.is_null_ptr).?), .is_err => return self.genIsErr(inst.castTag(.is_err).?), .is_err_ptr => return self.genIsErrPtr(inst.castTag(.is_err_ptr).?), - .error_to_int => return self.genErrorToInt(inst.castTag(.error_to_int).?), - .int_to_error => return self.genIntToError(inst.castTag(.int_to_error).?), .load => return self.genLoad(inst.castTag(.load).?), .loop => return self.genLoop(inst.castTag(.loop).?), .not => return self.genNot(inst.castTag(.not).?), @@ -1500,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { swap_lhs_and_rhs: bool, op: ir.Inst.Tag, ) !void { + _ = src; assert(lhs_mcv == .register or rhs_mcv == .register); const op1 = if (swap_lhs_and_rhs) rhs_mcv.register else lhs_mcv.register; @@ -1908,6 +1906,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1); }, .immediate => |imm| { + _ = imm; return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{}); }, .embedded_in_code, .memory, .stack_offset => { @@ -2057,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg }); }, .immediate => |imm| { + _ = imm; return self.fail(src, "TODO implement x86 multiply source immediate", .{}); }, .embedded_in_code, .memory, .stack_offset => { @@ -2960,14 +2960,6 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.fail(inst.base.src, "TODO load the operand and call genIsErr", .{}); } - fn genErrorToInt(self: *Self, inst: *ir.Inst.UnOp) !MCValue { - return self.resolveInst(inst.operand); - } - - fn genIntToError(self: *Self, inst: *ir.Inst.UnOp) !MCValue { - return self.resolveInst(inst.operand); - } - fn genLoop(self: *Self, inst: *ir.Inst.Loop) !MCValue { // A loop is a setup to be able to jump back to the beginning. const start_index = self.code.items.len; @@ -2993,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .arm, .armeb => { if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32()); - } else |err| { + } else |_| { return self.fail(src, "TODO: enable larger branch offset", .{}); } }, .aarch64, .aarch64_be, .aarch64_32 => { if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32()); - } else |err| { + } else |_| { return self.fail(src, "TODO: enable larger branch offset", .{}); } }, @@ -3318,9 +3310,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .compare_flags_unsigned => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => { @@ -3328,6 +3322,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); }, .embedded_in_code => |code_offset| { + _ = code_offset; return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { @@ -3364,6 +3359,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .memory => |vaddr| { + _ = vaddr; return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3392,9 +3388,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .compare_flags_unsigned => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => |x_big| { @@ -3447,12 +3445,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .embedded_in_code => |code_offset| { + _ = code_offset; return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89); }, .memory => |vaddr| { + _ = vaddr; return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3481,9 +3481,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .compare_flags_unsigned => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => { @@ -3491,6 +3493,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); }, .embedded_in_code => |code_offset| { + _ = code_offset; return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { @@ -3523,6 +3526,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .memory => |vaddr| { + _ = vaddr; return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3853,6 +3857,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { ); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO set register with compare flags value (signed)", .{}); }, .immediate => |x| { @@ -4179,6 +4184,9 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.fail(src, "TODO codegen non-ELF const Decl pointer", .{}); } } + if (typed_value.val.tag() == .int_u64) { + return MCValue{ .immediate = typed_value.val.toUnsignedInt() }; + } return self.fail(src, "TODO codegen more kinds of const pointers", .{}); }, .Int => { @@ -4468,6 +4476,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { dummy, pub fn allocIndex(self: Register) ?u4 { + _ = self; return null; } }; diff --git a/src/codegen/arm.zig b/src/codegen/arm.zig index cc6abe2e52..891a9e100b 100644 --- a/src/codegen/arm.zig +++ b/src/codegen/arm.zig @@ -674,7 +674,7 @@ pub const Instruction = union(enum) { }; const imm4h: u4 = switch (offset) { .immediate => |imm| @truncate(u4, imm >> 4), - .register => |reg| 0b0000, + .register => 0b0000, }; return Instruction{ diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 68b74d7659..ae439693b8 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buffer = [1]u8{0} ** 128; // We don't care if it gets cut off, it's still more unique than a number var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer; @@ -63,6 +65,8 @@ fn formatIdent( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; for (ident) |c, i| { switch (c) { 'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c), @@ -724,8 +728,6 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi .is_err => try genIsErr(o, inst.castTag(.is_err).?), .is_err_ptr => try genIsErr(o, inst.castTag(.is_err_ptr).?), - .error_to_int => try genErrorToInt(o, inst.castTag(.error_to_int).?), - .int_to_error => try genIntToError(o, inst.castTag(.int_to_error).?), .unwrap_errunion_payload => try genUnwrapErrUnionPay(o, inst.castTag(.unwrap_errunion_payload).?), .unwrap_errunion_err => try genUnwrapErrUnionErr(o, inst.castTag(.unwrap_errunion_err).?), @@ -749,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi } fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue { + _ = o; return CValue{ .decl_ref = inst.variable.owner_decl }; } @@ -939,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue { } fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue { + _ = o; + _ = inst; // TODO emit #line directive here with line number and filename return CValue.none; } @@ -1018,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue { } fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue { + _ = inst; try o.writer().writeAll("zig_breakpoint();\n"); return CValue.none; } fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue { + _ = inst; try o.writer().writeAll("zig_unreachable();\n"); return CValue.none; } @@ -1109,7 +1116,6 @@ fn genAsm(o: *Object, as: *Inst.Assembly) !CValue { for (as.inputs) |i, index| { if (i[0] == '{' and i[i.len - 1] == '}') { const reg = i[1 .. i.len - 1]; - const arg = as.args[index]; if (index > 0) { try writer.writeAll(", "); } @@ -1283,14 +1289,6 @@ fn genIsErr(o: *Object, inst: *Inst.UnOp) !CValue { return local; } -fn genIntToError(o: *Object, inst: *Inst.UnOp) !CValue { - return o.resolveInst(inst.operand); -} - -fn genErrorToInt(o: *Object, inst: *Inst.UnOp) !CValue { - return o.resolveInst(inst.operand); -} - fn IndentWriter(comptime UnderlyingWriter: type) type { return struct { const Self = @This(); diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4e4621ca29..2baedf8c9d 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -154,6 +154,7 @@ pub const Object = struct { object_pathZ: [:0]const u8, pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object { + _ = sub_path; const self = try allocator.create(Object); errdefer allocator.destroy(self); @@ -742,6 +743,7 @@ pub const FuncGen = struct { } fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { + _ = inst; _ = self.builder.buildRetVoid(); return null; } @@ -873,6 +875,7 @@ pub const FuncGen = struct { } fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { + _ = inst; _ = self.builder.buildUnreachable(); return null; } @@ -1013,6 +1016,7 @@ pub const FuncGen = struct { } fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value { + _ = inst; const llvn_fn = self.getIntrinsic("llvm.debugtrap"); _ = self.builder.buildCall(llvn_fn, null, 0, ""); return null; diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 3bff09bd8d..9e0cd19f6f 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -714,7 +714,6 @@ pub const DeclGen = struct { return self.fail(inst.base.src, "TODO: SPIR-V backend: binary operations for strange integers", .{}); } - const is_bool = info.class == .bool; const is_float = info.class == .float; const is_signed = info.signedness == .signed; // **Note**: All these operations must be valid for vectors as well! @@ -802,8 +801,6 @@ pub const DeclGen = struct { const result_id = self.spv.allocResultId(); const result_type_id = try self.genType(inst.base.src, inst.base.ty); - const info = try self.arithmeticTypeInfo(inst.operand.ty); - const opcode = switch (inst.base.tag) { // Bool -> bool .not => Opcode.OpLogicalNot, @@ -867,6 +864,7 @@ pub const DeclGen = struct { // are not allowed to be created from a phi node, and throw an error for those. For now, genType already throws // an error for pointers. const result_type_id = try self.genType(inst.base.src, inst.base.ty); + _ = result_type_id; try writeOpcode(&self.code, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent... diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig index d7fe239d3b..ec4ec66b1e 100644 --- a/src/codegen/wasm.zig +++ b/src/codegen/wasm.zig @@ -702,7 +702,7 @@ pub const Context = struct { try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer. try writer.writeByte(val_type); }, - else => |ret_type| { + else => { try leb.writeULEB128(writer, @as(u32, 1)); // Can we maybe get the source index of the return type? const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type); @@ -721,7 +721,7 @@ pub const Context = struct { // TODO: check for and handle death of instructions const mod_fn = blk: { if (typed_value.val.castTag(.function)) |func| break :blk func.data; - if (typed_value.val.castTag(.extern_fn)) |ext_fn| return Result.appended; // don't need code body for extern functions + if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions unreachable; }; @@ -849,7 +849,6 @@ pub const Context = struct { } fn genCall(self: *Context, inst: *Inst.Call) InnerError!WValue { - const func_inst = inst.func.castTag(.constant).?; const func_val = inst.func.value().?; const target: *Decl = blk: { @@ -914,7 +913,7 @@ pub const Context = struct { .local => |local| { try self.emitWValue(rhs); try writer.writeByte(wasm.opcode(.local_set)); - try leb.writeULEB128(writer, lhs.local); + try leb.writeULEB128(writer, local); }, else => unreachable, } @@ -926,6 +925,7 @@ pub const Context = struct { } fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue { + _ = inst; // arguments share the index with locals defer self.local_index += 1; return WValue{ .local = self.local_index }; @@ -1146,8 +1146,6 @@ pub const Context = struct { } fn genCmp(self: *Context, inst: *Inst.BinOp, op: std.math.CompareOperator) InnerError!WValue { - const ty = inst.lhs.ty.tag(); - // save offset, so potential conditions can insert blocks in front of // the comparison that we can later jump back to const offset = self.code.items.len; @@ -1216,12 +1214,15 @@ pub const Context = struct { } fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue { + _ = self; + _ = breakpoint; // unsupported by wasm itself. Can be implemented once we support DWARF // for wasm return .none; } fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue { + _ = unreach; try self.code.append(wasm.opcode(.@"unreachable")); return .none; } diff --git a/src/codegen/x86_64.zig b/src/codegen/x86_64.zig index 0e1ffefe75..2964d7245e 100644 --- a/src/codegen/x86_64.zig +++ b/src/codegen/x86_64.zig @@ -4,7 +4,6 @@ const mem = std.mem; const assert = std.debug.assert; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; -const Type = @import("../Type.zig"); const DW = std.dwarf; // zig fmt: off diff --git a/src/glibc.zig b/src/glibc.zig index 30bc021ced..c0afc321c9 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -497,7 +497,6 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList( const target = comp.getTarget(); const arch = target.cpu.arch; const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl"; - const glibc = try lib_path(comp, arena, lib_libc ++ "glibc"); const s = path.sep_str; diff --git a/src/link.zig b/src/link.zig index d1508c29cd..c26feb10fd 100644 --- a/src/link.zig +++ b/src/link.zig @@ -38,6 +38,8 @@ pub const Options = struct { /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`. module: ?*Module, dynamic_linker: ?[]const u8, + /// The root path for the dynamic linker and system libraries (as well as frameworks on Darwin) + sysroot: ?[]const u8, /// Used for calculating how much space to reserve for symbols in case the binary file /// does not already have a symbol table. symbol_count_hint: u64 = 32, @@ -104,8 +106,6 @@ pub const Options = struct { llvm_cpu_features: ?[*:0]const u8, /// Extra args passed directly to LLD. Ignored when not linking with LLD. extra_lld_args: []const []const u8, - /// Darwin-only. Set the root path to the system libraries and frameworks. - syslibroot: ?[]const u8, objects: []const []const u8, framework_dirs: []const []const u8, @@ -517,7 +517,7 @@ pub const File = struct { .target = base.options.target, .output_mode = .Obj, }); - const o_directory = base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } diff --git a/src/link/C.zig b/src/link/C.zig index 6cb219db41..1793b95210 100644 --- a/src/link/C.zig +++ b/src/link/C.zig @@ -76,7 +76,10 @@ pub fn deinit(self: *C) void { self.decl_table.deinit(self.base.allocator); } -pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {} +pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void { + _ = self; + _ = decl; +} pub fn freeDecl(self: *C, decl: *Module.Decl) void { _ = self.decl_table.swapRemove(decl); @@ -307,4 +310,9 @@ pub fn updateDeclExports( module: *Module, decl: *Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + _ = exports; + _ = decl; + _ = module; + _ = self; +} diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 9ab1c6d78a..b466cf9136 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { } pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void { + _ = self; + _ = module; + _ = decl; // TODO Implement this } diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 84068ffeca..722077b8b8 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1108,7 +1108,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { for (buf) |*phdr, i| { phdr.* = progHeaderTo32(self.program_headers.items[i]); if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Phdr, phdr); + mem.bswapAllFields(elf.Elf32_Phdr, phdr); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), self.phdr_table_offset.?); @@ -1120,7 +1120,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { for (buf) |*phdr, i| { phdr.* = self.program_headers.items[i]; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Phdr, phdr); + mem.bswapAllFields(elf.Elf64_Phdr, phdr); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), self.phdr_table_offset.?); @@ -1197,7 +1197,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { shdr.* = sectHeaderTo32(self.sections.items[i]); log.debug("writing section {}", .{shdr.*}); if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Shdr, shdr); + mem.bswapAllFields(elf.Elf32_Shdr, shdr); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), self.shdr_table_offset.?); @@ -1210,7 +1210,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { shdr.* = self.sections.items[i]; log.debug("writing section {}", .{shdr.*}); if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Shdr, shdr); + mem.bswapAllFields(elf.Elf64_Shdr, shdr); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), self.shdr_table_offset.?); @@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -1354,6 +1354,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { man.hash.add(allow_shlib_undefined); man.hash.add(self.base.options.bind_global_refs_locally); man.hash.add(self.base.options.tsan); + man.hash.addOptionalBytes(self.base.options.sysroot); // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock. _ = try man.hit(); @@ -1423,6 +1424,10 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { try argv.append("-error-limit=0"); + if (self.base.options.sysroot) |sysroot| { + try argv.append(try std.fmt.allocPrint(arena, "--sysroot={s}", .{sysroot})); + } + if (self.base.options.lto) { switch (self.base.options.optimize_mode) { .Debug => {}, @@ -1938,6 +1943,9 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void { } fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void { + _ = self; + _ = text_block; + _ = new_block_size; // TODO check the new capacity, and if it crosses the size threshold into a big enough // capacity, insert a free list node for it. } @@ -2706,6 +2714,7 @@ pub fn updateDeclExports( /// Must be called only after a successful call to `updateDecl`. pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void { + _ = module; const tracy = trace(@src()); defer tracy.end(); @@ -2736,14 +2745,14 @@ fn writeProgHeader(self: *Elf, index: usize) !void { .p32 => { var phdr = [1]elf.Elf32_Phdr{progHeaderTo32(self.program_headers.items[index])}; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Phdr, &phdr[0]); + mem.bswapAllFields(elf.Elf32_Phdr, &phdr[0]); } return self.base.file.?.pwriteAll(mem.sliceAsBytes(&phdr), offset); }, .p64 => { var phdr = [1]elf.Elf64_Phdr{self.program_headers.items[index]}; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Phdr, &phdr[0]); + mem.bswapAllFields(elf.Elf64_Phdr, &phdr[0]); } return self.base.file.?.pwriteAll(mem.sliceAsBytes(&phdr), offset); }, @@ -2757,7 +2766,7 @@ fn writeSectHeader(self: *Elf, index: usize) !void { var shdr: [1]elf.Elf32_Shdr = undefined; shdr[0] = sectHeaderTo32(self.sections.items[index]); if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Shdr, &shdr[0]); + mem.bswapAllFields(elf.Elf32_Shdr, &shdr[0]); } const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf32_Shdr); return self.base.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset); @@ -2765,7 +2774,7 @@ fn writeSectHeader(self: *Elf, index: usize) !void { .p64 => { var shdr = [1]elf.Elf64_Shdr{self.sections.items[index]}; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Shdr, &shdr[0]); + mem.bswapAllFields(elf.Elf64_Shdr, &shdr[0]); } const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf64_Shdr); return self.base.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset); @@ -2863,7 +2872,7 @@ fn writeSymbol(self: *Elf, index: usize) !void { }, }; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Sym, &sym[0]); + mem.bswapAllFields(elf.Elf32_Sym, &sym[0]); } const off = syms_sect.sh_offset + @sizeOf(elf.Elf32_Sym) * index; try self.base.file.?.pwriteAll(mem.sliceAsBytes(sym[0..1]), off); @@ -2871,7 +2880,7 @@ fn writeSymbol(self: *Elf, index: usize) !void { .p64 => { var sym = [1]elf.Elf64_Sym{self.local_symbols.items[index]}; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Sym, &sym[0]); + mem.bswapAllFields(elf.Elf64_Sym, &sym[0]); } const off = syms_sect.sh_offset + @sizeOf(elf.Elf64_Sym) * index; try self.base.file.?.pwriteAll(mem.sliceAsBytes(sym[0..1]), off); @@ -2902,7 +2911,7 @@ fn writeAllGlobalSymbols(self: *Elf) !void { .st_shndx = self.global_symbols.items[i].st_shndx, }; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf32_Sym, sym); + mem.bswapAllFields(elf.Elf32_Sym, sym); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), global_syms_off); @@ -2921,7 +2930,7 @@ fn writeAllGlobalSymbols(self: *Elf) !void { .st_shndx = self.global_symbols.items[i].st_shndx, }; if (foreign_endian) { - std.elf.bswapAllFields(elf.Elf64_Sym, sym); + mem.bswapAllFields(elf.Elf64_Sym, sym); } } try self.base.file.?.pwriteAll(mem.sliceAsBytes(buf), global_syms_off); @@ -2979,6 +2988,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 { } fn dbgInfoNeededHeaderBytes(self: Elf) u32 { + _ = self; return 120; } @@ -3372,7 +3382,7 @@ const CsuObjects = struct { if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* }); }, else => { - inline for (std.meta.fields(@TypeOf(result))) |f, i| { + inline for (std.meta.fields(@TypeOf(result))) |f| { if (@field(result, f.name)) |*obj| { obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* }); } @@ -3380,7 +3390,7 @@ const CsuObjects = struct { }, } } else { - inline for (std.meta.fields(@TypeOf(result))) |f, i| { + inline for (std.meta.fields(@TypeOf(result))) |f| { if (@field(result, f.name)) |*obj| { if (comp.crt_files.get(obj.*)) |crtf| { obj.* = crtf.full_object_path; diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 8c1d092f12..95389c2d95 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { } pub fn flushModule(self: *MachO, comp: *Compilation) !void { + _ = comp; const tracy = trace(@src()); defer tracy.end(); @@ -513,6 +514,119 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { } } +fn resolvePaths( + arena: *Allocator, + resolved_paths: *std.ArrayList([]const u8), + syslibroot: ?[]const u8, + search_dirs: []const []const u8, + lib_names: []const []const u8, + kind: enum { lib, framework }, +) !void { + var resolved_dirs = std.ArrayList([]const u8).init(arena); + for (search_dirs) |dir| { + if (fs.path.isAbsolute(dir)) { + var candidates = std.ArrayList([]const u8).init(arena); + if (syslibroot) |root| { + const full_path = try fs.path.join(arena, &[_][]const u8{ root, dir }); + try candidates.append(full_path); + } + try candidates.append(dir); + + var found = false; + for (candidates.items) |candidate| { + // Verify that search path actually exists + var tmp = fs.cwd().openDir(candidate, .{}) catch |err| switch (err) { + error.FileNotFound => continue, + else => |e| return e, + }; + defer tmp.close(); + + try resolved_dirs.append(candidate); + found = true; + break; + } + + if (!found) { + switch (kind) { + .lib => log.warn("directory not found for '-L{s}'", .{dir}), + .framework => log.warn("directory not found for '-F{s}'", .{dir}), + } + } + } else { + // Verify that search path actually exists + var tmp = fs.cwd().openDir(dir, .{}) catch |err| switch (err) { + error.FileNotFound => { + switch (kind) { + .lib => log.warn("directory not found for '-L{s}'", .{dir}), + .framework => log.warn("directory not found for '-F{s}'", .{dir}), + } + continue; + }, + else => |e| return e, + }; + defer tmp.close(); + + try resolved_dirs.append(dir); + } + } + + // Assume ld64 default: -search_paths_first + // Look in each directory for a dylib (next, tbd), and then for archive + // TODO implement alternative: -search_dylibs_first + const exts = switch (kind) { + .lib => &[_][]const u8{ "dylib", "tbd", "a" }, + .framework => &[_][]const u8{ "dylib", "tbd" }, + }; + + for (lib_names) |lib_name| { + var found = false; + + ext: for (exts) |ext| { + const lib_name_ext = blk: { + switch (kind) { + .lib => break :blk try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ lib_name, ext }), + .framework => { + const prefix = try std.fmt.allocPrint(arena, "{s}.framework", .{lib_name}); + const nn = try std.fmt.allocPrint(arena, "{s}.{s}", .{ lib_name, ext }); + break :blk try fs.path.join(arena, &[_][]const u8{ prefix, nn }); + }, + } + }; + + for (resolved_dirs.items) |dir| { + const full_path = try fs.path.join(arena, &[_][]const u8{ dir, lib_name_ext }); + + // Check if the lib file exists. + const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { + error.FileNotFound => continue, + else => |e| return e, + }; + defer tmp.close(); + + try resolved_paths.append(full_path); + found = true; + break :ext; + } + } + + if (!found) { + switch (kind) { + .lib => { + log.warn("library not found for '-l{s}'", .{lib_name}); + log.warn("Library search paths:", .{}); + }, + .framework => { + log.warn("framework not found for '-f{s}'", .{lib_name}); + log.warn("Framework search paths:", .{}); + }, + } + for (resolved_dirs.items) |dir| { + log.warn(" {s}", .{dir}); + } + } + } +} + fn linkWithLLD(self: *MachO, comp: *Compilation) !void { const tracy = trace(@src()); defer tracy.end(); @@ -533,7 +647,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -590,7 +704,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { man.hash.add(allow_shlib_undefined); man.hash.add(self.base.options.bind_global_refs_locally); man.hash.add(self.base.options.system_linker_hack); - man.hash.addOptionalBytes(self.base.options.syslibroot); + man.hash.addOptionalBytes(self.base.options.sysroot); // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock. _ = try man.hit(); @@ -675,6 +789,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { zld.deinit(); } zld.arch = target.cpu.arch; + zld.syslibroot = self.base.options.sysroot; zld.stack_size = stack_size; // Positional arguments to the linker such as object files and static archives. @@ -699,7 +814,6 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } // Shared and static libraries passed via `-l` flag. - var libs = std.ArrayList([]const u8).init(arena); var search_lib_names = std.ArrayList([]const u8).init(arena); const system_libs = self.base.options.system_libs.keys(); @@ -715,85 +829,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { try search_lib_names.append(link_lib); } - var search_lib_dirs = std.ArrayList([]const u8).init(arena); - - for (self.base.options.lib_dirs) |path| { - if (fs.path.isAbsolute(path)) { - var candidates = std.ArrayList([]const u8).init(arena); - if (self.base.options.syslibroot) |syslibroot| { - const full_path = try fs.path.join(arena, &[_][]const u8{ syslibroot, path }); - try candidates.append(full_path); - } - try candidates.append(path); - - var found = false; - for (candidates.items) |candidate| { - // Verify that search path actually exists - var tmp = fs.cwd().openDir(candidate, .{}) catch |err| switch (err) { - error.FileNotFound => continue, - else => |e| return e, - }; - defer tmp.close(); - - try search_lib_dirs.append(candidate); - found = true; - break; - } - - if (!found) { - log.warn("directory not found for '-L{s}'", .{path}); - } - } else { - // Verify that search path actually exists - var tmp = fs.cwd().openDir(path, .{}) catch |err| switch (err) { - error.FileNotFound => { - log.warn("directory not found for '-L{s}'", .{path}); - continue; - }, - else => |e| return e, - }; - defer tmp.close(); - - try search_lib_dirs.append(path); - } - } - - // Assume ld64 default: -search_paths_first - // Look in each directory for a dylib (tbd), and then for archive - // TODO implement alternative: -search_dylibs_first - // TODO text-based API, or .tbd files. - const exts = &[_][]const u8{ "dylib", "a" }; - - for (search_lib_names.items) |l_name| { - var found = false; - - ext: for (exts) |ext| { - const l_name_ext = try std.fmt.allocPrint(arena, "lib{s}.{s}", .{ l_name, ext }); - - for (search_lib_dirs.items) |lib_dir| { - const full_path = try fs.path.join(arena, &[_][]const u8{ lib_dir, l_name_ext }); - - // Check if the lib file exists. - const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) { - error.FileNotFound => continue, - else => |e| return e, - }; - defer tmp.close(); - - try libs.append(full_path); - found = true; - break :ext; - } - } - - if (!found) { - log.warn("library not found for '-l{s}'", .{l_name}); - log.warn("Library search paths:", .{}); - for (search_lib_dirs.items) |lib_dir| { - log.warn(" {s}", .{lib_dir}); - } - } - } + var libs = std.ArrayList([]const u8).init(arena); + try resolvePaths( + arena, + &libs, + self.base.options.sysroot, + self.base.options.lib_dirs, + search_lib_names.items, + .lib, + ); // rpaths var rpath_table = std.StringArrayHashMap(void).init(arena); @@ -809,9 +853,14 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } // frameworks - for (self.base.options.frameworks) |framework| { - log.warn("frameworks not yet supported for '-framework {s}'", .{framework}); - } + try resolvePaths( + arena, + &libs, + self.base.options.sysroot, + self.base.options.framework_dirs, + self.base.options.frameworks, + .framework, + ); if (self.base.options.verbose_link) { var argv = std.ArrayList([]const u8).init(arena); @@ -819,7 +868,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { try argv.append("zig"); try argv.append("ld"); - if (self.base.options.syslibroot) |syslibroot| { + if (self.base.options.sysroot) |syslibroot| { try argv.append("-syslibroot"); try argv.append(syslibroot); } @@ -848,6 +897,9 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { try zld.link(positionals.items, full_out_path, .{ .libs = libs.items, .rpaths = rpaths.items, + .libc_stub_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ + "libc", "darwin", "libSystem.B.tbd", + }), }); break :outer; @@ -965,7 +1017,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } } - if (self.base.options.syslibroot) |dir| { + if (self.base.options.sysroot) |dir| { try argv.append("-syslibroot"); try argv.append(dir); } @@ -1254,6 +1306,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void { } fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void { + _ = self; + _ = text_block; + _ = new_block_size; // TODO check the new capacity, and if it crosses the size threshold into a big enough // capacity, insert a free list node for it. } @@ -1725,18 +1780,8 @@ pub fn populateMissingMetadata(self: *MachO) !void { if (self.pagezero_segment_cmd_index == null) { self.pagezero_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__PAGEZERO"), - .vmaddr = 0, + .Segment = SegmentCommand.empty("__PAGEZERO", .{ .vmsize = 0x100000000, // size always set to 4GB - .fileoff = 0, - .filesize = 0, - .maxprot = 0, - .initprot = 0, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -1755,18 +1800,12 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __TEXT segment free space 0x{x} to 0x{x}", .{ 0, needed_size }); try self.load_commands.append(self.base.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__TEXT"), + .Segment = SegmentCommand.empty("__TEXT", .{ .vmaddr = 0x100000000, // always starts at 4GB .vmsize = needed_size, - .fileoff = 0, .filesize = needed_size, .maxprot = maxprot, .initprot = initprot, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -1787,19 +1826,12 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __text section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try text_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__text"), - .segname = makeStaticString("__TEXT"), + try text_segment.addSection(self.base.allocator, "__text", .{ .addr = text_segment.inner.vmaddr + off, .size = @intCast(u32, needed_size), .offset = @intCast(u32, off), .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = flags, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -1825,19 +1857,13 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __stubs section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try text_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__stubs"), - .segname = makeStaticString("__TEXT"), + try text_segment.addSection(self.base.allocator, "__stubs", .{ .addr = text_segment.inner.vmaddr + off, .size = needed_size, .offset = @intCast(u32, off), .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = flags, - .reserved1 = 0, .reserved2 = stub_size, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -1858,19 +1884,12 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __stub_helper section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try text_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__stub_helper"), - .segname = makeStaticString("__TEXT"), + try text_segment.addSection(self.base.allocator, "__stub_helper", .{ .addr = text_segment.inner.vmaddr + off, .size = needed_size, .offset = @intCast(u32, off), .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = flags, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -1887,18 +1906,13 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __DATA_CONST segment free space 0x{x} to 0x{x}", .{ address_and_offset.offset, address_and_offset.offset + needed_size }); try self.load_commands.append(self.base.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__DATA_CONST"), + .Segment = SegmentCommand.empty("__DATA_CONST", .{ .vmaddr = address_and_offset.address, .vmsize = needed_size, .fileoff = address_and_offset.offset, .filesize = needed_size, .maxprot = maxprot, .initprot = initprot, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -1915,19 +1929,12 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __got section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try dc_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__got"), - .segname = makeStaticString("__DATA_CONST"), + try dc_segment.addSection(self.base.allocator, "__got", .{ .addr = dc_segment.inner.vmaddr + off - dc_segment.inner.fileoff, .size = needed_size, .offset = @intCast(u32, off), .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, .flags = flags, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -1944,18 +1951,13 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __DATA segment free space 0x{x} to 0x{x}", .{ address_and_offset.offset, address_and_offset.offset + needed_size }); try self.load_commands.append(self.base.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__DATA"), + .Segment = SegmentCommand.empty("__DATA", .{ .vmaddr = address_and_offset.address, .vmsize = needed_size, .fileoff = address_and_offset.offset, .filesize = needed_size, .maxprot = maxprot, .initprot = initprot, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -1972,19 +1974,12 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __la_symbol_ptr section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try data_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__la_symbol_ptr"), - .segname = makeStaticString("__DATA"), + try data_segment.addSection(self.base.allocator, "__la_symbol_ptr", .{ .addr = data_segment.inner.vmaddr + off - data_segment.inner.fileoff, .size = needed_size, .offset = @intCast(u32, off), .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, .flags = flags, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -1993,26 +1988,17 @@ pub fn populateMissingMetadata(self: *MachO) !void { const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; self.data_section_index = @intCast(u16, data_segment.sections.items.len); - const flags = macho.S_REGULAR; const needed_size = @sizeOf(u64) * self.base.options.symbol_count_hint; const off = data_segment.findFreeSpace(needed_size, @alignOf(u64), null); assert(off + needed_size <= data_segment.inner.fileoff + data_segment.inner.filesize); // TODO Must expand __DATA segment. log.debug("found __data section free space 0x{x} to 0x{x}", .{ off, off + needed_size }); - try data_segment.addSection(self.base.allocator, .{ - .sectname = makeStaticString("__data"), - .segname = makeStaticString("__DATA"), + try data_segment.addSection(self.base.allocator, "__data", .{ .addr = data_segment.inner.vmaddr + off - data_segment.inner.fileoff, .size = needed_size, .offset = @intCast(u32, off), .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, - .flags = flags, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -2027,18 +2013,11 @@ pub fn populateMissingMetadata(self: *MachO) !void { log.debug("found __LINKEDIT segment free space at 0x{x}", .{address_and_offset.offset}); try self.load_commands.append(self.base.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__LINKEDIT"), + .Segment = SegmentCommand.empty("__LINKEDIT", .{ .vmaddr = address_and_offset.address, - .vmsize = 0, .fileoff = address_and_offset.offset, - .filesize = 0, .maxprot = maxprot, .initprot = initprot, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -2396,13 +2375,6 @@ fn allocateTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64, return vaddr; } -pub fn makeStaticString(comptime bytes: []const u8) [16]u8 { - var buf = [_]u8{0} ** 16; - if (bytes.len > buf.len) @compileError("string too long; max 16 bytes"); - mem.copy(u8, &buf, bytes); - return buf; -} - fn makeString(self: *MachO, bytes: []const u8) !u32 { if (self.string_table_directory.get(bytes)) |offset| { log.debug("reusing '{s}' from string table at offset 0x{x}", .{ bytes, offset }); @@ -2918,7 +2890,6 @@ fn relocateSymbolTable(self: *MachO) !void { const nsyms = nlocals + nglobals + nundefs; if (symtab.nsyms < nsyms) { - const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; const needed_size = nsyms * @sizeOf(macho.nlist_64); if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) { // Move the entire symbol table to a new location @@ -3150,7 +3121,6 @@ fn writeExportTrie(self: *MachO) !void { const nwritten = try trie.write(stream.writer()); assert(nwritten == trie.size); - const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly; const allocated_size = self.allocatedSizeLinkedit(dyld_info.export_off); const needed_size = mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64)); @@ -3357,7 +3327,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void { error.EndOfStream => break, else => return err, }; - const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK; const opcode: u8 = inst & macho.BIND_OPCODE_MASK; switch (opcode) { diff --git a/src/link/MachO/Archive.zig b/src/link/MachO/Archive.zig index f47228077c..22439d300a 100644 --- a/src/link/MachO/Archive.zig +++ b/src/link/MachO/Archive.zig @@ -8,12 +8,13 @@ const macho = std.macho; const mem = std.mem; const Allocator = mem.Allocator; +const Arch = std.Target.Cpu.Arch; const Object = @import("Object.zig"); usingnamespace @import("commands.zig"); allocator: *Allocator, -arch: ?std.Target.Cpu.Arch = null, +arch: ?Arch = null, file: ?fs.File = null, header: ?ar_hdr = null, name: ?[]const u8 = null, @@ -85,10 +86,36 @@ const ar_hdr = extern struct { } }; -pub fn init(allocator: *Allocator) Archive { - return .{ +pub fn createAndParseFromPath(allocator: *Allocator, arch: Arch, path: []const u8) !?*Archive { + const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) { + error.FileNotFound => return null, + else => |e| return e, + }; + errdefer file.close(); + + const archive = try allocator.create(Archive); + errdefer allocator.destroy(archive); + + const name = try allocator.dupe(u8, path); + errdefer allocator.free(name); + + archive.* = .{ .allocator = allocator, + .arch = arch, + .name = name, + .file = file, + }; + + archive.parse() catch |err| switch (err) { + error.EndOfStream, error.NotArchive => { + archive.deinit(); + allocator.destroy(archive); + return null; + }, + else => |e| return e, }; + + return archive; } pub fn deinit(self: *Archive) void { @@ -116,15 +143,15 @@ pub fn parse(self: *Archive) !void { const magic = try reader.readBytesNoEof(SARMAG); if (!mem.eql(u8, &magic, ARMAG)) { - log.err("invalid magic: expected '{s}', found '{s}'", .{ ARMAG, magic }); - return error.MalformedArchive; + log.debug("invalid magic: expected '{s}', found '{s}'", .{ ARMAG, magic }); + return error.NotArchive; } self.header = try reader.readStruct(ar_hdr); if (!mem.eql(u8, &self.header.?.ar_fmag, ARFMAG)) { - log.err("invalid header delimiter: expected '{s}', found '{s}'", .{ ARFMAG, self.header.?.ar_fmag }); - return error.MalformedArchive; + log.debug("invalid header delimiter: expected '{s}', found '{s}'", .{ ARFMAG, self.header.?.ar_fmag }); + return error.NotArchive; } var embedded_name = try parseName(self.allocator, self.header.?, reader); @@ -222,20 +249,15 @@ pub fn parseObject(self: Archive, offset: u32) !*Object { var object = try self.allocator.create(Object); errdefer self.allocator.destroy(object); - object.* = Object.init(self.allocator); - object.arch = self.arch.?; - object.file = try fs.cwd().openFile(self.name.?, .{}); - object.name = name; - object.file_offset = @intCast(u32, try reader.context.getPos()); + object.* = .{ + .allocator = self.allocator, + .arch = self.arch.?, + .file = try fs.cwd().openFile(self.name.?, .{}), + .name = name, + .file_offset = @intCast(u32, try reader.context.getPos()), + }; try object.parse(); - try reader.context.seekTo(0); return object; } - -pub fn isArchive(file: fs.File) !bool { - const magic = try file.reader().readBytesNoEof(Archive.SARMAG); - try file.seekTo(0); - return mem.eql(u8, &magic, Archive.ARMAG); -} diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index ca6e5157b3..684861ebf5 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/src/link/MachO/DebugSymbols.zig @@ -19,7 +19,6 @@ const MachO = @import("../MachO.zig"); const SrcFn = MachO.SrcFn; const TextBlock = MachO.TextBlock; const padToIdeal = MachO.padToIdeal; -const makeStaticString = MachO.makeStaticString; usingnamespace @import("commands.zig"); @@ -212,18 +211,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void log.debug("found dSym __DWARF segment free space 0x{x} to 0x{x}", .{ off, off + needed_size }); try self.load_commands.append(allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__DWARF"), + .Segment = SegmentCommand.empty("__DWARF", .{ .vmaddr = vmaddr, .vmsize = needed_size, .fileoff = off, .filesize = needed_size, - .maxprot = 0, - .initprot = 0, - .nsects = 0, - .flags = 0, }), }); self.header_dirty = true; @@ -234,19 +226,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void self.debug_str_section_index = @intCast(u16, dwarf_segment.sections.items.len); assert(self.debug_string_table.items.len == 0); - try dwarf_segment.addSection(allocator, .{ - .sectname = makeStaticString("__debug_str"), - .segname = makeStaticString("__DWARF"), + try dwarf_segment.addSection(allocator, "__debug_str", .{ .addr = dwarf_segment.inner.vmaddr, .size = @intCast(u32, self.debug_string_table.items.len), .offset = @intCast(u32, dwarf_segment.inner.fileoff), .@"align" = 1, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -262,19 +246,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void log.debug("found dSym __debug_info free space 0x{x} to 0x{x}", .{ off, off + file_size_hint }); - try dwarf_segment.addSection(allocator, .{ - .sectname = makeStaticString("__debug_info"), - .segname = makeStaticString("__DWARF"), + try dwarf_segment.addSection(allocator, "__debug_info", .{ .addr = dwarf_segment.inner.vmaddr + off - dwarf_segment.inner.fileoff, .size = file_size_hint, .offset = @intCast(u32, off), .@"align" = p_align, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -290,19 +266,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void log.debug("found dSym __debug_abbrev free space 0x{x} to 0x{x}", .{ off, off + file_size_hint }); - try dwarf_segment.addSection(allocator, .{ - .sectname = makeStaticString("__debug_abbrev"), - .segname = makeStaticString("__DWARF"), + try dwarf_segment.addSection(allocator, "__debug_abbrev", .{ .addr = dwarf_segment.inner.vmaddr + off - dwarf_segment.inner.fileoff, .size = file_size_hint, .offset = @intCast(u32, off), .@"align" = p_align, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -318,19 +286,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void log.debug("found dSym __debug_aranges free space 0x{x} to 0x{x}", .{ off, off + file_size_hint }); - try dwarf_segment.addSection(allocator, .{ - .sectname = makeStaticString("__debug_aranges"), - .segname = makeStaticString("__DWARF"), + try dwarf_segment.addSection(allocator, "__debug_aranges", .{ .addr = dwarf_segment.inner.vmaddr + off - dwarf_segment.inner.fileoff, .size = file_size_hint, .offset = @intCast(u32, off), .@"align" = p_align, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -346,19 +306,11 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: *Allocator) !void log.debug("found dSym __debug_line free space 0x{x} to 0x{x}", .{ off, off + file_size_hint }); - try dwarf_segment.addSection(allocator, .{ - .sectname = makeStaticString("__debug_line"), - .segname = makeStaticString("__DWARF"), + try dwarf_segment.addSection(allocator, "__debug_line", .{ .addr = dwarf_segment.inner.vmaddr + off - dwarf_segment.inner.fileoff, .size = file_size_hint, .offset = @intCast(u32, off), .@"align" = p_align, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); self.header_dirty = true; self.load_commands_dirty = true; @@ -500,7 +452,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt if (self.debug_aranges_section_dirty) { const dwarf_segment = &self.load_commands.items[self.dwarf_segment_cmd_index.?].Segment; const debug_aranges_sect = &dwarf_segment.sections.items[self.debug_aranges_section_index.?]; - const debug_info_sect = dwarf_segment.sections.items[self.debug_info_section_index.?]; var di_buf = std.ArrayList(u8).init(allocator); defer di_buf.deinit(); @@ -693,14 +644,10 @@ pub fn deinit(self: *DebugSymbols, allocator: *Allocator) void { } fn copySegmentCommand(self: *DebugSymbols, allocator: *Allocator, base_cmd: SegmentCommand) !SegmentCommand { - var cmd = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, + var cmd = SegmentCommand.empty("", .{ .cmdsize = base_cmd.inner.cmdsize, - .segname = undefined, .vmaddr = base_cmd.inner.vmaddr, .vmsize = base_cmd.inner.vmsize, - .fileoff = 0, - .filesize = 0, .maxprot = base_cmd.inner.maxprot, .initprot = base_cmd.inner.initprot, .nsects = base_cmd.inner.nsects, @@ -844,7 +791,6 @@ fn relocateSymbolTable(self: *DebugSymbols) !void { const nsyms = nlocals + nglobals; if (symtab.nsyms < nsyms) { - const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; const needed_size = nsyms * @sizeOf(macho.nlist_64); if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) { // Move the entire symbol table to a new location @@ -901,14 +847,10 @@ fn writeStringTable(self: *DebugSymbols) !void { } pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void { + _ = module; const tracy = trace(@src()); defer tracy.end(); - const tree = decl.namespace.file_scope.tree; - const node_tags = tree.nodes.items(.tag); - const node_datas = tree.nodes.items(.data); - const token_starts = tree.tokens.items(.start); - const func = decl.val.castTag(.function).?.data; const line_off = @intCast(u28, decl.src_line + func.lbrace_line); @@ -933,6 +875,8 @@ pub fn initDeclDebugBuffers( module: *Module, decl: *Module.Decl, ) !DeclDebugBuffers { + _ = self; + _ = module; const tracy = trace(@src()); defer tracy.end(); @@ -1195,6 +1139,7 @@ fn addDbgInfoType( dbg_info_buffer: *std.ArrayList(u8), target: std.Target, ) !void { + _ = self; switch (ty.zigTypeTag()) { .Void => unreachable, .NoReturn => unreachable, @@ -1371,6 +1316,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 { } fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { + _ = self; const directory_entry_format_count = 1; const file_name_entry_format_count = 1; const directory_count = 1; @@ -1385,6 +1331,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { } fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 { + _ = self; return 120; } diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index a2a703dc08..2ecd2a20ed 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -1,24 +1,37 @@ const Dylib = @This(); const std = @import("std"); +const builtin = std.builtin; +const assert = std.debug.assert; const fs = std.fs; +const fmt = std.fmt; const log = std.log.scoped(.dylib); const macho = std.macho; +const math = std.math; const mem = std.mem; +const native_endian = builtin.target.cpu.arch.endian(); const Allocator = mem.Allocator; +const Arch = std.Target.Cpu.Arch; const Symbol = @import("Symbol.zig"); +const LibStub = @import("../tapi.zig").LibStub; usingnamespace @import("commands.zig"); allocator: *Allocator, -arch: ?std.Target.Cpu.Arch = null, + +arch: ?Arch = null, header: ?macho.mach_header_64 = null, file: ?fs.File = null, name: ?[]const u8 = null, +syslibroot: ?[]const u8 = null, ordinal: ?u16 = null, +// The actual dylib contents we care about linking with will be embedded at +// an offset within a file if we are linking against a fat lib +library_offset: u64 = 0, + load_commands: std.ArrayListUnmanaged(LoadCommand) = .{}, symtab_cmd_index: ?u16 = null, @@ -27,7 +40,13 @@ id_cmd_index: ?u16 = null, id: ?Id = null, -symbols: std.StringArrayHashMapUnmanaged(*Symbol) = .{}, +/// Parsed symbol table represented as hash map of symbols' +/// names. We can and should defer creating *Symbols until +/// a symbol is referenced by an object file. +symbols: std.StringArrayHashMapUnmanaged(void) = .{}, + +// TODO add parsing re-exported libs from binary dylibs +dependent_libs: std.StringArrayHashMapUnmanaged(void) = .{}, pub const Id = struct { name: []const u8, @@ -35,13 +54,130 @@ pub const Id = struct { current_version: u32, compatibility_version: u32, + pub fn default(name: []const u8) Id { + return .{ + .name = name, + .timestamp = 2, + .current_version = 0x10000, + .compatibility_version = 0x10000, + }; + } + pub fn deinit(id: *Id, allocator: *Allocator) void { allocator.free(id.name); } + + const ParseError = fmt.ParseIntError || fmt.BufPrintError; + + pub fn parseCurrentVersion(id: *Id, version: anytype) ParseError!void { + id.current_version = try parseVersion(version); + } + + pub fn parseCompatibilityVersion(id: *Id, version: anytype) ParseError!void { + id.compatibility_version = try parseVersion(version); + } + + fn parseVersion(version: anytype) ParseError!u32 { + const string = blk: { + switch (version) { + .int => |int| { + var out: u32 = 0; + const major = try math.cast(u16, int); + out += @intCast(u32, major) << 16; + return out; + }, + .float => |float| { + var buf: [256]u8 = undefined; + break :blk try fmt.bufPrint(&buf, "{d:.2}", .{float}); + }, + .string => |string| { + break :blk string; + }, + } + }; + + var out: u32 = 0; + var values: [3][]const u8 = undefined; + + var split = mem.split(string, "."); + var count: u4 = 0; + while (split.next()) |value| { + if (count > 2) { + log.warn("malformed version field: {s}", .{string}); + return 0x10000; + } + values[count] = value; + count += 1; + } + + if (count > 2) { + out += try fmt.parseInt(u8, values[2], 10); + } + if (count > 1) { + out += @intCast(u32, try fmt.parseInt(u8, values[1], 10)) << 8; + } + out += @intCast(u32, try fmt.parseInt(u16, values[0], 10)) << 16; + + return out; + } }; -pub fn init(allocator: *Allocator) Dylib { - return .{ .allocator = allocator }; +pub const Error = error{ + OutOfMemory, + EmptyStubFile, + MismatchedCpuArchitecture, + UnsupportedCpuArchitecture, +} || fs.File.OpenError || std.os.PReadError || Id.ParseError; + +pub fn createAndParseFromPath( + allocator: *Allocator, + arch: Arch, + path: []const u8, + syslibroot: ?[]const u8, +) Error!?[]*Dylib { + const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) { + error.FileNotFound => return null, + else => |e| return e, + }; + errdefer file.close(); + + const dylib = try allocator.create(Dylib); + errdefer allocator.destroy(dylib); + + const name = try allocator.dupe(u8, path); + errdefer allocator.free(name); + + dylib.* = .{ + .allocator = allocator, + .arch = arch, + .name = name, + .file = file, + .syslibroot = syslibroot, + }; + + dylib.parse() catch |err| switch (err) { + error.EndOfStream, error.NotDylib => { + try file.seekTo(0); + + var lib_stub = LibStub.loadFromFile(allocator, file) catch { + dylib.deinit(); + allocator.destroy(dylib); + return null; + }; + defer lib_stub.deinit(); + + try dylib.parseFromStub(lib_stub); + }, + else => |e| return e, + }; + + var dylibs = std.ArrayList(*Dylib).init(allocator); + defer dylibs.deinit(); + + try dylibs.append(dylib); + try dylib.parseDependentLibs(&dylibs); + + return dylibs.toOwnedSlice(); } pub fn deinit(self: *Dylib) void { @@ -50,12 +186,16 @@ pub fn deinit(self: *Dylib) void { } self.load_commands.deinit(self.allocator); - for (self.symbols.values()) |value| { - value.deinit(self.allocator); - self.allocator.destroy(value); + for (self.symbols.keys()) |key| { + self.allocator.free(key); } self.symbols.deinit(self.allocator); + for (self.dependent_libs.keys()) |key| { + self.allocator.free(key); + } + self.dependent_libs.deinit(self.allocator); + if (self.name) |name| { self.allocator.free(name); } @@ -71,25 +211,61 @@ pub fn closeFile(self: Dylib) void { } } +fn decodeArch(cputype: macho.cpu_type_t) !std.Target.Cpu.Arch { + const arch: Arch = switch (cputype) { + macho.CPU_TYPE_ARM64 => .aarch64, + macho.CPU_TYPE_X86_64 => .x86_64, + else => { + return error.UnsupportedCpuArchitecture; + }, + }; + return arch; +} + pub fn parse(self: *Dylib) !void { log.debug("parsing shared library '{s}'", .{self.name.?}); + self.library_offset = offset: { + const fat_header = try readFatStruct(self.file.?.reader(), macho.fat_header); + if (fat_header.magic != macho.FAT_MAGIC) break :offset 0; + + var fat_arch_index: u32 = 0; + while (fat_arch_index < fat_header.nfat_arch) : (fat_arch_index += 1) { + const fat_arch = try readFatStruct(self.file.?.reader(), macho.fat_arch); + // If we come across an architecture that we do not know how to handle, that's + // fine because we can keep looking for one that might match. + const lib_arch = decodeArch(fat_arch.cputype) catch |err| switch (err) { + error.UnsupportedCpuArchitecture => continue, + else => |e| return e, + }; + if (lib_arch == self.arch.?) { + // We have found a matching architecture! + break :offset fat_arch.offset; + } + } else { + log.err("Could not find matching cpu architecture in fat library: expected {s}", .{self.arch.?}); + return error.MismatchedCpuArchitecture; + } + }; + + try self.file.?.seekTo(self.library_offset); + var reader = self.file.?.reader(); self.header = try reader.readStruct(macho.mach_header_64); if (self.header.?.filetype != macho.MH_DYLIB) { - log.err("invalid filetype: expected 0x{x}, found 0x{x}", .{ macho.MH_DYLIB, self.header.?.filetype }); - return error.MalformedDylib; + log.debug("invalid filetype: expected 0x{x}, found 0x{x}", .{ macho.MH_DYLIB, self.header.?.filetype }); + return error.NotDylib; } - const this_arch: std.Target.Cpu.Arch = switch (self.header.?.cputype) { - macho.CPU_TYPE_ARM64 => .aarch64, - macho.CPU_TYPE_X86_64 => .x86_64, - else => |value| { - log.err("unsupported cpu architecture 0x{x}", .{value}); - return error.UnsupportedCpuArchitecture; + const this_arch: Arch = decodeArch(self.header.?.cputype) catch |err| switch (err) { + error.UnsupportedCpuArchitecture => |e| { + log.err("unsupported cpu architecture 0x{x}", .{self.header.?.cputype}); + return e; }, + else => |e| return e, }; + if (this_arch != self.arch.?) { log.err("mismatched cpu architecture: expected {s}, found {s}", .{ self.arch.?, this_arch }); return error.MismatchedCpuArchitecture; @@ -100,7 +276,17 @@ pub fn parse(self: *Dylib) !void { try self.parseSymbols(); } -pub fn readLoadCommands(self: *Dylib, reader: anytype) !void { +fn readFatStruct(reader: anytype, comptime T: type) !T { + // Fat structures (fat_header & fat_arch) are always written and read to/from + // disk in big endian order. + var res: T = try reader.readStruct(T); + if (native_endian != builtin.Endian.Big) { + mem.bswapAllFields(T, &res); + } + return res; +} + +fn readLoadCommands(self: *Dylib, reader: anytype) !void { try self.load_commands.ensureCapacity(self.allocator, self.header.?.ncmds); var i: u16 = 0; @@ -124,15 +310,10 @@ pub fn readLoadCommands(self: *Dylib, reader: anytype) !void { } } -pub fn parseId(self: *Dylib) !void { +fn parseId(self: *Dylib) !void { const index = self.id_cmd_index orelse { log.debug("no LC_ID_DYLIB load command found; using hard-coded defaults...", .{}); - self.id = .{ - .name = try self.allocator.dupe(u8, self.name.?), - .timestamp = 2, - .current_version = 0, - .compatibility_version = 0, - }; + self.id = Id.default(try self.allocator.dupe(u8, self.name.?)); return; }; const id_cmd = self.load_commands.items[index].Dylib; @@ -150,18 +331,18 @@ pub fn parseId(self: *Dylib) !void { }; } -pub fn parseSymbols(self: *Dylib) !void { +fn parseSymbols(self: *Dylib) !void { const index = self.symtab_cmd_index orelse return; const symtab_cmd = self.load_commands.items[index].Symtab; var symtab = try self.allocator.alloc(u8, @sizeOf(macho.nlist_64) * symtab_cmd.nsyms); defer self.allocator.free(symtab); - _ = try self.file.?.preadAll(symtab, symtab_cmd.symoff); + _ = try self.file.?.preadAll(symtab, symtab_cmd.symoff + self.library_offset); const slice = @alignCast(@alignOf(macho.nlist_64), mem.bytesAsSlice(macho.nlist_64, symtab)); var strtab = try self.allocator.alloc(u8, symtab_cmd.strsize); defer self.allocator.free(strtab); - _ = try self.file.?.preadAll(strtab, symtab_cmd.stroff); + _ = try self.file.?.preadAll(strtab, symtab_cmd.stroff + self.library_offset); for (slice) |sym| { const sym_name = mem.spanZ(@ptrCast([*:0]const u8, strtab.ptr + sym.n_strx)); @@ -169,23 +350,191 @@ pub fn parseSymbols(self: *Dylib) !void { if (!(Symbol.isSect(sym) and Symbol.isExt(sym))) continue; const name = try self.allocator.dupe(u8, sym_name); - const proxy = try self.allocator.create(Symbol.Proxy); - errdefer self.allocator.destroy(proxy); + try self.symbols.putNoClobber(self.allocator, name, {}); + } +} - proxy.* = .{ - .base = .{ - .@"type" = .proxy, - .name = name, - }, - .dylib = self, - }; +fn hasTarget(targets: []const []const u8, target: []const u8) bool { + for (targets) |t| { + if (mem.eql(u8, t, target)) return true; + } + return false; +} + +fn addObjCClassSymbols(self: *Dylib, sym_name: []const u8) !void { + const expanded = &[_][]const u8{ + try std.fmt.allocPrint(self.allocator, "_OBJC_CLASS_$_{s}", .{sym_name}), + try std.fmt.allocPrint(self.allocator, "_OBJC_METACLASS_$_{s}", .{sym_name}), + }; - try self.symbols.putNoClobber(self.allocator, name, &proxy.base); + for (expanded) |sym| { + if (self.symbols.contains(sym)) continue; + try self.symbols.putNoClobber(self.allocator, sym, .{}); } } -pub fn isDylib(file: fs.File) !bool { - const header = try file.reader().readStruct(macho.mach_header_64); - try file.seekTo(0); - return header.filetype == macho.MH_DYLIB; +pub fn parseFromStub(self: *Dylib, lib_stub: LibStub) !void { + if (lib_stub.inner.len == 0) return error.EmptyStubFile; + + log.debug("parsing shared library from stub '{s}'", .{self.name.?}); + + const umbrella_lib = lib_stub.inner[0]; + + var id = Id.default(try self.allocator.dupe(u8, umbrella_lib.install_name)); + if (umbrella_lib.current_version) |version| { + try id.parseCurrentVersion(version); + } + if (umbrella_lib.compatibility_version) |version| { + try id.parseCompatibilityVersion(version); + } + self.id = id; + + const target_string: []const u8 = switch (self.arch.?) { + .aarch64 => "arm64-macos", + .x86_64 => "x86_64-macos", + else => unreachable, + }; + + var umbrella_libs = std.StringHashMap(void).init(self.allocator); + defer umbrella_libs.deinit(); + + for (lib_stub.inner) |stub, stub_index| { + if (!hasTarget(stub.targets, target_string)) continue; + + if (stub_index > 0) { + // TODO I thought that we could switch on presence of `parent-umbrella` map; + // however, turns out `libsystem_notify.dylib` is fully reexported by `libSystem.dylib` + // BUT does not feature a `parent-umbrella` map as the only sublib. Apple's bug perhaps? + try umbrella_libs.put(stub.install_name, .{}); + } + + if (stub.exports) |exports| { + for (exports) |exp| { + if (!hasTarget(exp.targets, target_string)) continue; + + if (exp.symbols) |symbols| { + for (symbols) |sym_name| { + if (self.symbols.contains(sym_name)) continue; + try self.symbols.putNoClobber(self.allocator, try self.allocator.dupe(u8, sym_name), {}); + } + } + + if (exp.objc_classes) |classes| { + for (classes) |sym_name| { + try self.addObjCClassSymbols(sym_name); + } + } + } + } + + if (stub.reexports) |reexports| { + for (reexports) |reexp| { + if (!hasTarget(reexp.targets, target_string)) continue; + + if (reexp.symbols) |symbols| { + for (symbols) |sym_name| { + if (self.symbols.contains(sym_name)) continue; + try self.symbols.putNoClobber(self.allocator, try self.allocator.dupe(u8, sym_name), {}); + } + } + + if (reexp.objc_classes) |classes| { + for (classes) |sym_name| { + try self.addObjCClassSymbols(sym_name); + } + } + } + } + + if (stub.objc_classes) |classes| { + for (classes) |sym_name| { + try self.addObjCClassSymbols(sym_name); + } + } + } + + log.debug("{s}", .{umbrella_lib.install_name}); + + // TODO track which libs were already parsed in different steps + for (lib_stub.inner) |stub| { + if (!hasTarget(stub.targets, target_string)) continue; + + if (stub.reexported_libraries) |reexports| { + for (reexports) |reexp| { + if (!hasTarget(reexp.targets, target_string)) continue; + + for (reexp.libraries) |lib| { + if (umbrella_libs.contains(lib)) { + log.debug(" | {s} <= {s}", .{ lib, umbrella_lib.install_name }); + continue; + } + + log.debug(" | {s}", .{lib}); + try self.dependent_libs.put(self.allocator, try self.allocator.dupe(u8, lib), {}); + } + } + } + } +} + +pub fn parseDependentLibs(self: *Dylib, out: *std.ArrayList(*Dylib)) !void { + outer: for (self.dependent_libs.keys()) |lib| { + const dirname = fs.path.dirname(lib) orelse { + log.warn("unable to resolve dependency {s}", .{lib}); + continue; + }; + const filename = fs.path.basename(lib); + const without_ext = if (mem.lastIndexOfScalar(u8, filename, '.')) |index| + filename[0..index] + else + filename; + + for (&[_][]const u8{ "dylib", "tbd" }) |ext| { + const with_ext = try std.fmt.allocPrint(self.allocator, "{s}.{s}", .{ + without_ext, + ext, + }); + defer self.allocator.free(with_ext); + + const lib_path = if (self.syslibroot) |syslibroot| + try fs.path.join(self.allocator, &.{ syslibroot, dirname, with_ext }) + else + try fs.path.join(self.allocator, &.{ dirname, with_ext }); + + log.debug("trying dependency at fully resolved path {s}", .{lib_path}); + + const dylibs = (try createAndParseFromPath( + self.allocator, + self.arch.?, + lib_path, + self.syslibroot, + )) orelse { + continue; + }; + + try out.appendSlice(dylibs); + + continue :outer; + } else { + log.warn("unable to resolve dependency {s}", .{lib}); + } + } +} + +pub fn createProxy(self: *Dylib, sym_name: []const u8) !?*Symbol { + if (!self.symbols.contains(sym_name)) return null; + + const name = try self.allocator.dupe(u8, sym_name); + const proxy = try self.allocator.create(Symbol.Proxy); + errdefer self.allocator.destroy(proxy); + + proxy.* = .{ + .base = .{ + .@"type" = .proxy, + .name = name, + }, + .file = self, + }; + + return &proxy.base; } diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig index c4a044b446..cb55dd1fd8 100644 --- a/src/link/MachO/Object.zig +++ b/src/link/MachO/Object.zig @@ -11,6 +11,7 @@ const mem = std.mem; const reloc = @import("reloc.zig"); const Allocator = mem.Allocator; +const Arch = std.Target.Cpu.Arch; const Relocation = reloc.Relocation; const Symbol = @import("Symbol.zig"); const parseName = @import("Zld.zig").parseName; @@ -18,7 +19,7 @@ const parseName = @import("Zld.zig").parseName; usingnamespace @import("commands.zig"); allocator: *Allocator, -arch: ?std.Target.Cpu.Arch = null, +arch: ?Arch = null, header: ?macho.mach_header_64 = null, file: ?fs.File = null, file_offset: ?u32 = null, @@ -93,7 +94,7 @@ pub const Section = struct { pub fn isCode(self: Section) bool { const attr = self.sectionAttrs(); - return attr & macho.S_ATTR_PURE_INSTRUCTIONS != 0 and attr & macho.S_ATTR_SOME_INSTRUCTIONS != 0; + return attr & macho.S_ATTR_PURE_INSTRUCTIONS != 0 or attr & macho.S_ATTR_SOME_INSTRUCTIONS != 0; } pub fn isDebug(self: Section) bool { @@ -173,10 +174,36 @@ const DebugInfo = struct { } }; -pub fn init(allocator: *Allocator) Object { - return .{ +pub fn createAndParseFromPath(allocator: *Allocator, arch: Arch, path: []const u8) !?*Object { + const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) { + error.FileNotFound => return null, + else => |e| return e, + }; + errdefer file.close(); + + const object = try allocator.create(Object); + errdefer allocator.destroy(object); + + const name = try allocator.dupe(u8, path); + errdefer allocator.free(name); + + object.* = .{ .allocator = allocator, + .arch = arch, + .name = name, + .file = file, }; + + object.parse() catch |err| switch (err) { + error.EndOfStream, error.NotObject => { + object.deinit(); + allocator.destroy(object); + return null; + }, + else => |e| return e, + }; + + return object; } pub fn deinit(self: *Object) void { @@ -220,14 +247,14 @@ pub fn parse(self: *Object) !void { try reader.context.seekTo(offset); } - self.header = try reader.readStruct(macho.mach_header_64); + const header = try reader.readStruct(macho.mach_header_64); - if (self.header.?.filetype != macho.MH_OBJECT) { - log.err("invalid filetype: expected 0x{x}, found 0x{x}", .{ macho.MH_OBJECT, self.header.?.filetype }); - return error.MalformedObject; + if (header.filetype != macho.MH_OBJECT) { + log.debug("invalid filetype: expected 0x{x}, found 0x{x}", .{ macho.MH_OBJECT, header.filetype }); + return error.NotObject; } - const this_arch: std.Target.Cpu.Arch = switch (self.header.?.cputype) { + const this_arch: Arch = switch (header.cputype) { macho.CPU_TYPE_ARM64 => .aarch64, macho.CPU_TYPE_X86_64 => .x86_64, else => |value| { @@ -240,6 +267,8 @@ pub fn parse(self: *Object) !void { return error.MismatchedCpuArchitecture; } + self.header = header; + try self.readLoadCommands(reader); try self.parseSymbols(); try self.parseSections(); @@ -478,7 +507,6 @@ pub fn parseDebugInfo(self: *Object) !void { self.tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name }); self.tu_mtime = mtime: { - var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; const stat = try self.file.?.stat(); break :mtime @intCast(u64, @divFloor(stat.mtime, 1_000_000_000)); }; @@ -534,9 +562,3 @@ pub fn parseDataInCode(self: *Object) !void { try self.data_in_code_entries.append(self.allocator, dice); } } - -pub fn isObject(file: fs.File) !bool { - const header = try file.reader().readStruct(macho.mach_header_64); - try file.seekTo(0); - return header.filetype == macho.MH_OBJECT; -} diff --git a/src/link/MachO/Symbol.zig b/src/link/MachO/Symbol.zig index bb97acdf9f..c58af27672 100644 --- a/src/link/MachO/Symbol.zig +++ b/src/link/MachO/Symbol.zig @@ -84,10 +84,27 @@ pub const Regular = struct { pub const Proxy = struct { base: Symbol, + /// Dynamic binding info - spots within the final + /// executable where this proxy is referenced from. + bind_info: std.ArrayListUnmanaged(struct { + segment_id: u16, + address: u64, + }) = .{}, + /// Dylib where to locate this symbol. - dylib: ?*Dylib = null, + /// null means self-reference. + file: ?*Dylib = null, pub const base_type: Symbol.Type = .proxy; + + pub fn deinit(proxy: *Proxy, allocator: *Allocator) void { + proxy.bind_info.deinit(allocator); + } + + pub fn dylibOrdinal(proxy: *Proxy) u16 { + const dylib = proxy.file orelse return 0; + return dylib.ordinal.?; + } }; pub const Unresolved = struct { @@ -116,6 +133,10 @@ pub const Tentative = struct { pub fn deinit(base: *Symbol, allocator: *Allocator) void { allocator.free(base.name); + switch (base.@"type") { + .proxy => @fieldParentPtr(Proxy, "base", base).deinit(allocator), + else => {}, + } } pub fn cast(base: *Symbol, comptime T: type) ?*T { diff --git a/src/link/MachO/Zld.zig b/src/link/MachO/Zld.zig index dcaf86ed67..6cabdfa73e 100644 --- a/src/link/MachO/Zld.zig +++ b/src/link/MachO/Zld.zig @@ -32,12 +32,16 @@ out_path: ?[]const u8 = null, // TODO these args will become obselete once Zld is coalesced with incremental // linker. +syslibroot: ?[]const u8 = null, stack_size: u64 = 0, objects: std.ArrayListUnmanaged(*Object) = .{}, archives: std.ArrayListUnmanaged(*Archive) = .{}, dylibs: std.ArrayListUnmanaged(*Dylib) = .{}, +libsystem_dylib_index: ?u16 = null, +next_dylib_ordinal: u16 = 1, + load_commands: std.ArrayListUnmanaged(LoadCommand) = .{}, pagezero_segment_cmd_index: ?u16 = null, @@ -49,7 +53,6 @@ dyld_info_cmd_index: ?u16 = null, symtab_cmd_index: ?u16 = null, dysymtab_cmd_index: ?u16 = null, dylinker_cmd_index: ?u16 = null, -libsystem_cmd_index: ?u16 = null, data_in_code_cmd_index: ?u16 = null, function_starts_cmd_index: ?u16 = null, main_cmd_index: ?u16 = null, @@ -69,12 +72,21 @@ gcc_except_tab_section_index: ?u16 = null, unwind_info_section_index: ?u16 = null, eh_frame_section_index: ?u16 = null, +objc_methlist_section_index: ?u16 = null, +objc_methname_section_index: ?u16 = null, +objc_methtype_section_index: ?u16 = null, +objc_classname_section_index: ?u16 = null, + // __DATA_CONST segment sections got_section_index: ?u16 = null, mod_init_func_section_index: ?u16 = null, mod_term_func_section_index: ?u16 = null, data_const_section_index: ?u16 = null, +objc_cfstring_section_index: ?u16 = null, +objc_classlist_section_index: ?u16 = null, +objc_imageinfo_section_index: ?u16 = null, + // __DATA segment sections tlv_section_index: ?u16 = null, tlv_data_section_index: ?u16 = null, @@ -84,6 +96,11 @@ data_section_index: ?u16 = null, bss_section_index: ?u16 = null, common_section_index: ?u16 = null, +objc_const_section_index: ?u16 = null, +objc_selrefs_section_index: ?u16 = null, +objc_classrefs_section_index: ?u16 = null, +objc_data_section_index: ?u16 = null, + globals: std.StringArrayHashMapUnmanaged(*Symbol) = .{}, imports: std.StringArrayHashMapUnmanaged(*Symbol) = .{}, unresolved: std.StringArrayHashMapUnmanaged(*Symbol) = .{}, @@ -108,6 +125,7 @@ const TlvOffset = struct { offset: u64, fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool { + _ = context; return a.source_addr < b.source_addr; } }; @@ -115,10 +133,6 @@ const TlvOffset = struct { /// Default path to dyld const DEFAULT_DYLD_PATH: [*:0]const u8 = "/usr/lib/dyld"; -const LIB_SYSTEM_NAME: [*:0]const u8 = "System"; -/// TODO this should be inferred from included libSystem.tbd or similar. -const LIB_SYSTEM_PATH: [*:0]const u8 = "/usr/lib/libSystem.B.dylib"; - pub fn init(allocator: *Allocator) Zld { return .{ .allocator = allocator }; } @@ -152,9 +166,14 @@ pub fn deinit(self: *Zld) void { } self.dylibs.deinit(self.allocator); + for (self.imports.values()) |proxy| { + proxy.deinit(self.allocator); + self.allocator.destroy(proxy); + } + self.imports.deinit(self.allocator); + self.tentatives.deinit(self.allocator); self.globals.deinit(self.allocator); - self.imports.deinit(self.allocator); self.unresolved.deinit(self.allocator); self.strtab.deinit(self.allocator); @@ -180,6 +199,7 @@ pub fn closeFiles(self: Zld) void { const LinkArgs = struct { libs: []const []const u8, rpaths: []const []const u8, + libc_stub_path: []const u8, }; pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8, args: LinkArgs) !void { @@ -218,185 +238,111 @@ pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8, args: L }); try self.populateMetadata(); - try self.addRpaths(args.rpaths); try self.parseInputFiles(files); try self.parseLibs(args.libs); + try self.parseLibSystem(args.libc_stub_path); try self.resolveSymbols(); try self.resolveStubsAndGotEntries(); try self.updateMetadata(); try self.sortSections(); + try self.addRpaths(args.rpaths); + try self.addDataInCodeLC(); + try self.addCodeSignatureLC(); try self.allocateTextSegment(); try self.allocateDataConstSegment(); try self.allocateDataSegment(); self.allocateLinkeditSegment(); try self.allocateSymbols(); try self.allocateTentativeSymbols(); + try self.allocateProxyBindAddresses(); try self.flush(); } fn parseInputFiles(self: *Zld, files: []const []const u8) !void { - const Input = struct { - kind: enum { - object, - archive, - dylib, - }, - file: fs.File, - name: []const u8, - }; - var classified = std.ArrayList(Input).init(self.allocator); - defer classified.deinit(); - - // First, classify input files: object, archive or dylib. for (files) |file_name| { - const file = try fs.cwd().openFile(file_name, .{}); const full_path = full_path: { var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; const path = try std.fs.realpath(file_name, &buffer); break :full_path try self.allocator.dupe(u8, path); }; - try_object: { - if (!(try Object.isObject(file))) break :try_object; - try classified.append(.{ - .kind = .object, - .file = file, - .name = full_path, - }); + if (try Object.createAndParseFromPath(self.allocator, self.arch.?, full_path)) |object| { + try self.objects.append(self.allocator, object); continue; } - try_archive: { - if (!(try Archive.isArchive(file))) break :try_archive; - try classified.append(.{ - .kind = .archive, - .file = file, - .name = full_path, - }); + if (try Archive.createAndParseFromPath(self.allocator, self.arch.?, full_path)) |archive| { + try self.archives.append(self.allocator, archive); continue; } - try_dylib: { - if (!(try Dylib.isDylib(file))) break :try_dylib; - try classified.append(.{ - .kind = .dylib, - .file = file, - .name = full_path, - }); + if (try Dylib.createAndParseFromPath( + self.allocator, + self.arch.?, + full_path, + self.syslibroot, + )) |dylibs| { + defer self.allocator.free(dylibs); + try self.dylibs.appendSlice(self.allocator, dylibs); continue; } - file.close(); log.warn("unknown filetype for positional input file: '{s}'", .{file_name}); } - - // Based on our classification, proceed with parsing. - for (classified.items) |input| { - switch (input.kind) { - .object => { - const object = try self.allocator.create(Object); - errdefer self.allocator.destroy(object); - - object.* = Object.init(self.allocator); - object.arch = self.arch.?; - object.name = input.name; - object.file = input.file; - try object.parse(); - try self.objects.append(self.allocator, object); - }, - .archive => { - const archive = try self.allocator.create(Archive); - errdefer self.allocator.destroy(archive); - - archive.* = Archive.init(self.allocator); - archive.arch = self.arch.?; - archive.name = input.name; - archive.file = input.file; - try archive.parse(); - try self.archives.append(self.allocator, archive); - }, - .dylib => { - const dylib = try self.allocator.create(Dylib); - errdefer self.allocator.destroy(dylib); - - dylib.* = Dylib.init(self.allocator); - dylib.arch = self.arch.?; - dylib.name = input.name; - dylib.file = input.file; - - const ordinal = @intCast(u16, self.dylibs.items.len); - dylib.ordinal = ordinal + 2; // TODO +2 since 1 is reserved for libSystem - - // TODO Defer parsing of the dylibs until they are actually needed - try dylib.parse(); - try self.dylibs.append(self.allocator, dylib); - - // Add LC_LOAD_DYLIB command - const dylib_id = dylib.id orelse unreachable; - var dylib_cmd = try createLoadDylibCommand( - self.allocator, - dylib_id.name, - dylib_id.timestamp, - dylib_id.current_version, - dylib_id.compatibility_version, - ); - errdefer dylib_cmd.deinit(self.allocator); - - try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd }); - }, - } - } } fn parseLibs(self: *Zld, libs: []const []const u8) !void { for (libs) |lib| { - const file = try fs.cwd().openFile(lib, .{}); - - if (try Dylib.isDylib(file)) { - const dylib = try self.allocator.create(Dylib); - errdefer self.allocator.destroy(dylib); - - dylib.* = Dylib.init(self.allocator); - dylib.arch = self.arch.?; - dylib.name = try self.allocator.dupe(u8, lib); - dylib.file = file; - - const ordinal = @intCast(u16, self.dylibs.items.len); - dylib.ordinal = ordinal + 2; // TODO +2 since 1 is reserved for libSystem - - // TODO Defer parsing of the dylibs until they are actually needed - try dylib.parse(); - try self.dylibs.append(self.allocator, dylib); - - // Add LC_LOAD_DYLIB command - const dylib_id = dylib.id orelse unreachable; - var dylib_cmd = try createLoadDylibCommand( - self.allocator, - dylib_id.name, - dylib_id.timestamp, - dylib_id.current_version, - dylib_id.compatibility_version, - ); - errdefer dylib_cmd.deinit(self.allocator); - - try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd }); - } else if (try Archive.isArchive(file)) { - const archive = try self.allocator.create(Archive); - errdefer self.allocator.destroy(archive); - - archive.* = Archive.init(self.allocator); - archive.arch = self.arch.?; - archive.name = try self.allocator.dupe(u8, lib); - archive.file = file; - try archive.parse(); + if (try Dylib.createAndParseFromPath( + self.allocator, + self.arch.?, + lib, + self.syslibroot, + )) |dylibs| { + defer self.allocator.free(dylibs); + try self.dylibs.appendSlice(self.allocator, dylibs); + continue; + } + + if (try Archive.createAndParseFromPath(self.allocator, self.arch.?, lib)) |archive| { try self.archives.append(self.allocator, archive); - } else { - file.close(); - log.warn("unknown filetype for a library: '{s}'", .{lib}); + continue; } + + log.warn("unknown filetype for a library: '{s}'", .{lib}); } } +fn parseLibSystem(self: *Zld, libc_stub_path: []const u8) !void { + const dylibs = (try Dylib.createAndParseFromPath( + self.allocator, + self.arch.?, + libc_stub_path, + self.syslibroot, + )) orelse return error.FailedToParseLibSystem; + defer self.allocator.free(dylibs); + + assert(dylibs.len == 1); // More than one dylib output from parsing libSystem! + const dylib = dylibs[0]; + + self.libsystem_dylib_index = @intCast(u16, self.dylibs.items.len); + try self.dylibs.append(self.allocator, dylib); + + // Add LC_LOAD_DYLIB load command. + dylib.ordinal = self.next_dylib_ordinal; + const dylib_id = dylib.id orelse unreachable; + var dylib_cmd = try createLoadDylibCommand( + self.allocator, + dylib_id.name, + dylib_id.timestamp, + dylib_id.current_version, + dylib_id.compatibility_version, + ); + errdefer dylib_cmd.deinit(self.allocator); + try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd }); + self.next_dylib_ordinal += 1; +} + fn mapAndUpdateSections( self: *Zld, object: *Object, @@ -421,6 +367,7 @@ fn mapAndUpdateSections( offset, offset + size, }); + log.debug(" | flags 0x{x}", .{source_sect.inner.flags}); source_sect.target_map = .{ .segment_id = target_seg_id, @@ -432,429 +379,22 @@ fn mapAndUpdateSections( fn updateMetadata(self: *Zld) !void { for (self.objects.items) |object| { - const object_seg = object.load_commands.items[object.segment_cmd_index.?].Segment; - const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; - const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment; - const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; - - // Create missing metadata + // Find ideal section alignment and update section mappings for (object.sections.items) |sect, sect_id| { - const segname = sect.segname(); - const sectname = sect.sectname(); - - switch (sect.sectionType()) { - macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS, macho.S_LITERAL_POINTERS => { - if (self.text_const_section_index != null) continue; - - self.text_const_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__const"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_CSTRING_LITERALS => { - if (self.cstring_section_index != null) continue; - - self.cstring_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__cstring"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_CSTRING_LITERALS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_MOD_INIT_FUNC_POINTERS => { - if (self.mod_init_func_section_index != null) continue; - - self.mod_init_func_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__mod_init_func"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_MOD_INIT_FUNC_POINTERS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_MOD_TERM_FUNC_POINTERS => { - if (self.mod_term_func_section_index != null) continue; - - self.mod_term_func_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__mod_term_func"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_MOD_TERM_FUNC_POINTERS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_ZEROFILL => { - if (mem.eql(u8, sectname, "__common")) { - if (self.common_section_index != null) continue; - - self.common_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__common"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_ZEROFILL, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } else { - if (self.bss_section_index != null) continue; - - self.bss_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__bss"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_ZEROFILL, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } - continue; - }, - macho.S_THREAD_LOCAL_VARIABLES => { - if (self.tlv_section_index != null) continue; - - self.tlv_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__thread_vars"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_THREAD_LOCAL_VARIABLES, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_THREAD_LOCAL_REGULAR => { - if (self.tlv_data_section_index != null) continue; - - self.tlv_data_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__thread_data"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_THREAD_LOCAL_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_THREAD_LOCAL_ZEROFILL => { - if (self.tlv_bss_section_index != null) continue; - - self.tlv_bss_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__thread_bss"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_THREAD_LOCAL_ZEROFILL, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_COALESCED => { - if (mem.eql(u8, "__TEXT", segname) and mem.eql(u8, "__eh_frame", sectname)) { - // TODO I believe __eh_frame is currently part of __unwind_info section - // in the latest ld64 output. - if (self.eh_frame_section_index != null) continue; - - self.eh_frame_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__eh_frame"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - } - - // TODO audit this: is this the right mapping? - if (self.data_const_section_index != null) continue; - - self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__const"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - }, - macho.S_REGULAR => { - if (sect.isCode()) { - if (self.text_section_index != null) continue; - - self.text_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__text"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - } - - if (sect.isDebug()) { - if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) { - log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{ - sect.flags(), segname, sectname, - }); - } - continue; - } - - if (mem.eql(u8, segname, "__TEXT")) { - if (mem.eql(u8, sectname, "__ustring")) { - if (self.ustring_section_index != null) continue; - - self.ustring_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__ustring"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } else if (mem.eql(u8, sectname, "__gcc_except_tab")) { - if (self.gcc_except_tab_section_index != null) continue; - - self.gcc_except_tab_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__gcc_except_tab"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } else { - if (self.text_const_section_index != null) continue; - - self.text_const_section_index = @intCast(u16, text_seg.sections.items.len); - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__const"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } - continue; - } - - if (mem.eql(u8, segname, "__DATA_CONST")) { - if (self.data_const_section_index != null) continue; - - self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__const"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - continue; - } - - if (mem.eql(u8, segname, "__DATA")) { - if (mem.eql(u8, sectname, "__const")) { - if (self.data_const_section_index != null) continue; - - self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__const"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } else { - if (self.data_section_index != null) continue; - - self.data_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__data"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, - }); - } - - continue; - } - - if (mem.eql(u8, "__LLVM", segname) and mem.eql(u8, "__asm", sectname)) { - log.debug("TODO LLVM asm section: type 0x{x}, name '{s},{s}'", .{ - sect.flags(), segname, sectname, - }); - continue; - } - }, - else => {}, - } - - log.err("{s}: unhandled section type 0x{x} for '{s},{s}'", .{ - object.name.?, - sect.flags(), - segname, - sectname, - }); - return error.UnhandledSection; - } - - // Find ideal section alignment. - for (object.sections.items) |sect| { - if (self.getMatchingSection(sect)) |res| { - const target_seg = &self.load_commands.items[res.seg].Segment; - const target_sect = &target_seg.sections.items[res.sect]; - target_sect.@"align" = math.max(target_sect.@"align", sect.inner.@"align"); - } - } - - // Update section mappings - for (object.sections.items) |sect, sect_id| { - if (self.getMatchingSection(sect)) |res| { - try self.mapAndUpdateSections(object, @intCast(u16, sect_id), res.seg, res.sect); + const match = (try self.getMatchingSection(sect)) orelse { + log.debug("{s}: unhandled section type 0x{x} for '{s},{s}'", .{ + object.name.?, + sect.flags(), + sect.segname(), + sect.sectname(), + }); continue; - } - log.debug("section '{s},{s}' will be unmapped", .{ sect.segname(), sect.sectname() }); + }; + const target_seg = &self.load_commands.items[match.seg].Segment; + const target_sect = &target_seg.sections.items[match.sect]; + target_sect.@"align" = math.max(target_sect.@"align", sect.inner.@"align"); + + try self.mapAndUpdateSections(object, @intCast(u16, sect_id), match.seg, match.sect); } } @@ -864,19 +404,8 @@ fn updateMetadata(self: *Zld) !void { const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; const common_section_index = self.common_section_index orelse ind: { self.common_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__common"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, - .@"align" = 0, - .reloff = 0, - .nreloc = 0, + try data_seg.addSection(self.allocator, "__common", .{ .flags = macho.S_ZEROFILL, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); break :ind self.common_section_index.?; }; @@ -950,31 +479,116 @@ const MatchingSection = struct { sect: u16, }; -fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { +fn getMatchingSection(self: *Zld, sect: Object.Section) !?MatchingSection { + const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; + const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment; + const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; const segname = sect.segname(); const sectname = sect.sectname(); const res: ?MatchingSection = blk: { switch (sect.sectionType()) { - macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS, macho.S_LITERAL_POINTERS => { + macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS => { + if (self.text_const_section_index == null) { + self.text_const_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__const", .{}); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.text_const_section_index.?, }; }, macho.S_CSTRING_LITERALS => { + if (mem.eql(u8, sectname, "__objc_methname")) { + // TODO it seems the common values within the sections in objects are deduplicated/merged + // on merging the sections' contents. + if (self.objc_methname_section_index == null) { + self.objc_methname_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__objc_methname", .{ + .flags = macho.S_CSTRING_LITERALS, + }); + } + + break :blk .{ + .seg = self.text_segment_cmd_index.?, + .sect = self.objc_methname_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_methtype")) { + if (self.objc_methtype_section_index == null) { + self.objc_methtype_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__objc_methtype", .{ + .flags = macho.S_CSTRING_LITERALS, + }); + } + + break :blk .{ + .seg = self.text_segment_cmd_index.?, + .sect = self.objc_methtype_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_classname")) { + if (self.objc_classname_section_index == null) { + self.objc_classname_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__objc_classname", .{}); + } + + break :blk .{ + .seg = self.text_segment_cmd_index.?, + .sect = self.objc_classname_section_index.?, + }; + } + + if (self.cstring_section_index == null) { + self.cstring_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__cstring", .{ + .flags = macho.S_CSTRING_LITERALS, + }); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.cstring_section_index.?, }; }, + macho.S_LITERAL_POINTERS => { + if (mem.eql(u8, segname, "__DATA") and mem.eql(u8, sectname, "__objc_selrefs")) { + if (self.objc_selrefs_section_index == null) { + self.objc_selrefs_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__objc_selrefs", .{ + .flags = macho.S_LITERAL_POINTERS, + }); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.objc_selrefs_section_index.?, + }; + } + + // TODO investigate + break :blk null; + }, macho.S_MOD_INIT_FUNC_POINTERS => { + if (self.mod_init_func_section_index == null) { + self.mod_init_func_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__mod_init_func", .{ + .flags = macho.S_MOD_INIT_FUNC_POINTERS, + }); + } + break :blk .{ .seg = self.data_const_segment_cmd_index.?, .sect = self.mod_init_func_section_index.?, }; }, macho.S_MOD_TERM_FUNC_POINTERS => { + if (self.mod_term_func_section_index == null) { + self.mod_term_func_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__mod_term_func", .{ + .flags = macho.S_MOD_TERM_FUNC_POINTERS, + }); + } + break :blk .{ .seg = self.data_const_segment_cmd_index.?, .sect = self.mod_term_func_section_index.?, @@ -982,11 +596,25 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { }, macho.S_ZEROFILL => { if (mem.eql(u8, sectname, "__common")) { + if (self.common_section_index == null) { + self.common_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__common", .{ + .flags = macho.S_ZEROFILL, + }); + } + break :blk .{ .seg = self.data_segment_cmd_index.?, .sect = self.common_section_index.?, }; } else { + if (self.bss_section_index == null) { + self.bss_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__bss", .{ + .flags = macho.S_ZEROFILL, + }); + } + break :blk .{ .seg = self.data_segment_cmd_index.?, .sect = self.bss_section_index.?, @@ -994,18 +622,39 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { } }, macho.S_THREAD_LOCAL_VARIABLES => { + if (self.tlv_section_index == null) { + self.tlv_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__thread_vars", .{ + .flags = macho.S_THREAD_LOCAL_VARIABLES, + }); + } + break :blk .{ .seg = self.data_segment_cmd_index.?, .sect = self.tlv_section_index.?, }; }, macho.S_THREAD_LOCAL_REGULAR => { + if (self.tlv_data_section_index == null) { + self.tlv_data_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__thread_data", .{ + .flags = macho.S_THREAD_LOCAL_REGULAR, + }); + } + break :blk .{ .seg = self.data_segment_cmd_index.?, .sect = self.tlv_data_section_index.?, }; }, macho.S_THREAD_LOCAL_ZEROFILL => { + if (self.tlv_bss_section_index == null) { + self.tlv_bss_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__thread_bss", .{ + .flags = macho.S_THREAD_LOCAL_ZEROFILL, + }); + } + break :blk .{ .seg = self.data_segment_cmd_index.?, .sect = self.tlv_bss_section_index.?, @@ -1013,12 +662,25 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { }, macho.S_COALESCED => { if (mem.eql(u8, "__TEXT", segname) and mem.eql(u8, "__eh_frame", sectname)) { + // TODO I believe __eh_frame is currently part of __unwind_info section + // in the latest ld64 output. + if (self.eh_frame_section_index == null) { + self.eh_frame_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__eh_frame", .{}); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.eh_frame_section_index.?, }; } + // TODO audit this: is this the right mapping? + if (self.data_const_section_index == null) { + self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__const", .{}); + } + break :blk .{ .seg = self.data_const_segment_cmd_index.?, .sect = self.data_const_section_index.?, @@ -1026,6 +688,13 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { }, macho.S_REGULAR => { if (sect.isCode()) { + if (self.text_section_index == null) { + self.text_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__text", .{ + .flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, + }); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.text_section_index.?, @@ -1033,21 +702,66 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { } if (sect.isDebug()) { // TODO debug attributes + if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) { + log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{ + sect.flags(), segname, sectname, + }); + } break :blk null; } if (mem.eql(u8, segname, "__TEXT")) { if (mem.eql(u8, sectname, "__ustring")) { + if (self.ustring_section_index == null) { + self.ustring_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__ustring", .{}); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.ustring_section_index.?, }; } else if (mem.eql(u8, sectname, "__gcc_except_tab")) { + if (self.gcc_except_tab_section_index == null) { + self.gcc_except_tab_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__gcc_except_tab", .{}); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.gcc_except_tab_section_index.?, }; + } else if (mem.eql(u8, sectname, "__objc_methlist")) { + if (self.objc_methlist_section_index == null) { + self.objc_methlist_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__objc_methlist", .{}); + } + + break :blk .{ + .seg = self.text_segment_cmd_index.?, + .sect = self.objc_methlist_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__rodata") or + mem.eql(u8, sectname, "__typelink") or + mem.eql(u8, sectname, "__itablink") or + mem.eql(u8, sectname, "__gosymtab") or + mem.eql(u8, sectname, "__gopclntab")) + { + if (self.data_const_section_index == null) { + self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__const", .{}); + } + + break :blk .{ + .seg = self.data_const_segment_cmd_index.?, + .sect = self.data_const_section_index.?, + }; } else { + if (self.text_const_section_index == null) { + self.text_const_section_index = @intCast(u16, text_seg.sections.items.len); + try text_seg.addSection(self.allocator, "__const", .{}); + } + break :blk .{ .seg = self.text_segment_cmd_index.?, .sect = self.text_const_section_index.?, @@ -1056,6 +770,11 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { } if (mem.eql(u8, segname, "__DATA_CONST")) { + if (self.data_const_section_index == null) { + self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__const", .{}); + } + break :blk .{ .seg = self.data_const_segment_cmd_index.?, .sect = self.data_const_section_index.?, @@ -1064,15 +783,92 @@ fn getMatchingSection(self: *Zld, sect: Object.Section) ?MatchingSection { if (mem.eql(u8, segname, "__DATA")) { if (mem.eql(u8, sectname, "__const")) { + if (self.data_const_section_index == null) { + self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__const", .{}); + } + break :blk .{ .seg = self.data_const_segment_cmd_index.?, .sect = self.data_const_section_index.?, }; + } else if (mem.eql(u8, sectname, "__cfstring")) { + if (self.objc_cfstring_section_index == null) { + self.objc_cfstring_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__cfstring", .{}); + } + + break :blk .{ + .seg = self.data_const_segment_cmd_index.?, + .sect = self.objc_cfstring_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_classlist")) { + if (self.objc_classlist_section_index == null) { + self.objc_classlist_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__objc_classlist", .{}); + } + + break :blk .{ + .seg = self.data_const_segment_cmd_index.?, + .sect = self.objc_classlist_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_imageinfo")) { + if (self.objc_imageinfo_section_index == null) { + self.objc_imageinfo_section_index = @intCast(u16, data_const_seg.sections.items.len); + try data_const_seg.addSection(self.allocator, "__objc_imageinfo", .{}); + } + + break :blk .{ + .seg = self.data_const_segment_cmd_index.?, + .sect = self.objc_imageinfo_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_const")) { + if (self.objc_const_section_index == null) { + self.objc_const_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__objc_const", .{}); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.objc_const_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_classrefs")) { + if (self.objc_classrefs_section_index == null) { + self.objc_classrefs_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__objc_classrefs", .{}); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.objc_classrefs_section_index.?, + }; + } else if (mem.eql(u8, sectname, "__objc_data")) { + if (self.objc_data_section_index == null) { + self.objc_data_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__objc_data", .{}); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.objc_data_section_index.?, + }; + } else { + if (self.data_section_index == null) { + self.data_section_index = @intCast(u16, data_seg.sections.items.len); + try data_seg.addSection(self.allocator, "__data", .{}); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.data_section_index.?, + }; } - break :blk .{ - .seg = self.data_segment_cmd_index.?, - .sect = self.data_section_index.?, - }; + } + + if (mem.eql(u8, "__LLVM", segname) and mem.eql(u8, "__asm", sectname)) { + log.debug("TODO LLVM asm section: type 0x{x}, name '{s},{s}'", .{ + sect.flags(), segname, sectname, + }); } break :blk null; @@ -1107,6 +903,9 @@ fn sortSections(self: *Zld) !void { &self.cstring_section_index, &self.ustring_section_index, &self.text_const_section_index, + &self.objc_methname_section_index, + &self.objc_methtype_section_index, + &self.objc_classname_section_index, &self.eh_frame_section_index, }; for (indices) |maybe_index| { @@ -1132,6 +931,9 @@ fn sortSections(self: *Zld) !void { &self.mod_init_func_section_index, &self.mod_term_func_section_index, &self.data_const_section_index, + &self.objc_cfstring_section_index, + &self.objc_classlist_section_index, + &self.objc_imageinfo_section_index, }; for (indices) |maybe_index| { const new_index: u16 = if (maybe_index.*) |index| blk: { @@ -1154,6 +956,10 @@ fn sortSections(self: *Zld) !void { // __DATA segment const indices = &[_]*?u16{ &self.la_symbol_ptr_section_index, + &self.objc_const_section_index, + &self.objc_selrefs_section_index, + &self.objc_classrefs_section_index, + &self.objc_data_section_index, &self.data_section_index, &self.tlv_section_index, &self.tlv_data_section_index, @@ -1294,7 +1100,6 @@ fn allocateLinkeditSegment(self: *Zld) void { } fn allocateSegment(self: *Zld, index: u16, offset: u64) !void { - const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize; const seg = &self.load_commands.items[index].Segment; // Allocate the sections according to their alignment at the beginning of the segment. @@ -1375,7 +1180,7 @@ fn allocateTentativeSymbols(self: *Zld) !void { } // Convert tentative definitions into regular symbols. - for (self.tentatives.values()) |sym, i| { + for (self.tentatives.values()) |sym| { const tent = sym.cast(Symbol.Tentative) orelse unreachable; const reg = try self.allocator.create(Symbol.Regular); errdefer self.allocator.destroy(reg); @@ -1420,6 +1225,31 @@ fn allocateTentativeSymbols(self: *Zld) !void { } } +fn allocateProxyBindAddresses(self: *Zld) !void { + for (self.objects.items) |object| { + for (object.sections.items) |sect| { + const relocs = sect.relocs orelse continue; + + for (relocs) |rel| { + if (rel.@"type" != .unsigned) continue; // GOT is currently special-cased + if (rel.target != .symbol) continue; + + const sym = rel.target.symbol.getTopmostAlias(); + if (sym.cast(Symbol.Proxy)) |proxy| { + const target_map = sect.target_map orelse continue; + const target_seg = self.load_commands.items[target_map.segment_id].Segment; + const target_sect = target_seg.sections.items[target_map.section_id]; + + try proxy.bind_info.append(self.allocator, .{ + .segment_id = target_map.segment_id, + .address = target_sect.addr + target_map.offset + rel.offset, + }); + } + } + } + } +} + fn writeStubHelperCommon(self: *Zld) !void { const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment; const stub_helper = &text_segment.sections.items[self.stub_helper_section_index.?]; @@ -1427,7 +1257,6 @@ fn writeStubHelperCommon(self: *Zld) !void { const got = &data_const_segment.sections.items[self.got_section_index.?]; const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; const data = &data_segment.sections.items[self.data_section_index.?]; - const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?]; self.stub_helper_stubs_start_off = blk: { switch (self.arch.?) { @@ -1761,7 +1590,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void { t_sym.alias = sym; sym_ptr.* = sym; - } else if (sym.cast(Symbol.Unresolved)) |und| { + } else if (sym.cast(Symbol.Unresolved)) |_| { if (self.globals.get(sym.name)) |g_sym| { sym.alias = g_sym; continue; @@ -1816,9 +1645,8 @@ fn resolveSymbols(self: *Zld) !void { next_sym += 1; } } + // Third pass, resolve symbols in dynamic libraries. - // TODO Implement libSystem as a hard-coded library, or ship with - // a libSystem.B.tbd definition file? var unresolved = std.ArrayList(*Symbol).init(self.allocator); defer unresolved.deinit(); @@ -1826,61 +1654,84 @@ fn resolveSymbols(self: *Zld) !void { for (self.unresolved.values()) |value| { unresolved.appendAssumeCapacity(value); } - self.unresolved.clearAndFree(self.allocator); + self.unresolved.clearRetainingCapacity(); - var has_undefined = false; - while (unresolved.popOrNull()) |undef| { - var found = false; - for (self.dylibs.items) |dylib| { - const proxy = dylib.symbols.get(undef.name) orelse continue; - try self.imports.putNoClobber(self.allocator, proxy.name, proxy); - undef.alias = proxy; - found = true; - } + var referenced = std.AutoHashMap(*Dylib, void).init(self.allocator); + defer referenced.deinit(); - if (!found) { - // TODO we currently hardcode all unresolved symbols to libSystem - const proxy = try self.allocator.create(Symbol.Proxy); - errdefer self.allocator.destroy(proxy); + loop: while (unresolved.popOrNull()) |undef| { + const proxy = self.imports.get(undef.name) orelse outer: { + const proxy = inner: { + for (self.dylibs.items) |dylib, i| { + const proxy = (try dylib.createProxy(undef.name)) orelse continue; + if (self.libsystem_dylib_index.? != @intCast(u16, i)) { // LibSystem gets load command seperately. + try referenced.put(dylib, {}); + } + break :inner proxy; + } + if (mem.eql(u8, undef.name, "___dso_handle")) { + // TODO this is just a temp patch until I work out what to actually + // do with ___dso_handle and __mh_execute_header symbols which are + // synthetically created by the linker on macOS. + const name = try self.allocator.dupe(u8, undef.name); + const proxy = try self.allocator.create(Symbol.Proxy); + errdefer self.allocator.destroy(proxy); + proxy.* = .{ + .base = .{ + .@"type" = .proxy, + .name = name, + }, + .file = null, + }; + break :inner &proxy.base; + } - proxy.* = .{ - .base = .{ - .@"type" = .proxy, - .name = try self.allocator.dupe(u8, undef.name), - }, - .dylib = null, // TODO null means libSystem + self.unresolved.putAssumeCapacityNoClobber(undef.name, undef); + continue :loop; }; - try self.imports.putNoClobber(self.allocator, proxy.base.name, &proxy.base); - undef.alias = &proxy.base; + try self.imports.putNoClobber(self.allocator, proxy.name, proxy); + break :outer proxy; + }; + undef.alias = proxy; + } + + // Add LC_LOAD_DYLIB load command for each referenced dylib/stub. + var it = referenced.iterator(); + while (it.next()) |entry| { + const dylib = entry.key_ptr.*; + dylib.ordinal = self.next_dylib_ordinal; + const dylib_id = dylib.id orelse unreachable; + var dylib_cmd = try createLoadDylibCommand( + self.allocator, + dylib_id.name, + dylib_id.timestamp, + dylib_id.current_version, + dylib_id.compatibility_version, + ); + errdefer dylib_cmd.deinit(self.allocator); + try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd }); + self.next_dylib_ordinal += 1; + } - // log.err("undefined reference to symbol '{s}'", .{undef.name}); - // log.err(" | referenced in {s}", .{ - // undef.cast(Symbol.Unresolved).?.file.name.?, - // }); - // has_undefined = true; + if (self.unresolved.count() > 0) { + for (self.unresolved.values()) |undef| { + log.err("undefined reference to symbol '{s}'", .{undef.name}); + log.err(" | referenced in {s}", .{ + undef.cast(Symbol.Unresolved).?.file.name.?, + }); } - } - if (has_undefined) return error.UndefinedSymbolReference; + return error.UndefinedSymbolReference; + } // Finally put dyld_stub_binder as an Import - const dyld_stub_binder = try self.allocator.create(Symbol.Proxy); - errdefer self.allocator.destroy(dyld_stub_binder); - - dyld_stub_binder.* = .{ - .base = .{ - .@"type" = .proxy, - .name = try self.allocator.dupe(u8, "dyld_stub_binder"), - }, - .dylib = null, // TODO null means libSystem + const libsystem_dylib = self.dylibs.items[self.libsystem_dylib_index.?]; + const proxy = (try libsystem_dylib.createProxy("dyld_stub_binder")) orelse { + log.err("undefined reference to symbol 'dyld_stub_binder'", .{}); + return error.UndefinedSymbolReference; }; - - try self.imports.putNoClobber( - self.allocator, - dyld_stub_binder.base.name, - &dyld_stub_binder.base, - ); + try self.imports.putNoClobber(self.allocator, proxy.name, proxy); } fn resolveStubsAndGotEntries(self: *Zld) !void { @@ -1891,6 +1742,7 @@ fn resolveStubsAndGotEntries(self: *Zld) !void { const relocs = sect.relocs orelse continue; for (relocs) |rel| { switch (rel.@"type") { + .unsigned => continue, .got_page, .got_page_off, .got_load, .got, .pointer_to_got => { const sym = rel.target.symbol.getTopmostAlias(); if (sym.got_index != null) continue; @@ -1976,29 +1828,52 @@ fn resolveRelocsAndWriteSections(self: *Zld) !void { args.source_target_sect_addr = source_sect.inner.addr; } - rebases: { - var hit: bool = false; - if (target_map.segment_id == self.data_segment_cmd_index.?) { - if (self.data_section_index) |index| { - if (index == target_map.section_id) hit = true; + const flags = @truncate(u8, target_sect.flags & 0xff); + const should_rebase = rebase: { + if (!unsigned.is_64bit) break :rebase false; + + // TODO actually, a check similar to what dyld is doing, that is, verifying + // that the segment is writable should be enough here. + const is_right_segment = blk: { + if (self.data_segment_cmd_index) |idx| { + if (target_map.segment_id == idx) { + break :blk true; + } + } + if (self.data_const_segment_cmd_index) |idx| { + if (target_map.segment_id == idx) { + break :blk true; + } } + break :blk false; + }; + + if (!is_right_segment) break :rebase false; + if (flags != macho.S_LITERAL_POINTERS and + flags != macho.S_REGULAR) + { + break :rebase false; } - if (target_map.segment_id == self.data_const_segment_cmd_index.?) { - if (self.data_const_section_index) |index| { - if (index == target_map.section_id) hit = true; + if (rel.target == .symbol) { + const final = rel.target.symbol.getTopmostAlias(); + if (final.cast(Symbol.Proxy)) |_| { + break :rebase false; } } - if (!hit) break :rebases; + break :rebase true; + }; + if (should_rebase) { try self.local_rebases.append(self.allocator, .{ .offset = source_addr - target_seg.inner.vmaddr, .segment_id = target_map.segment_id, }); } + // TLV is handled via a separate offset mechanism. // Calculate the offset to the initializer. - if (target_sect.flags == macho.S_THREAD_LOCAL_VARIABLES) tlv: { + if (flags == macho.S_THREAD_LOCAL_VARIABLES) tlv: { // TODO we don't want to save offset to tlv_bootstrap if (mem.eql(u8, rel.target.symbol.name, "__tlv_bootstrap")) break :tlv; @@ -2095,7 +1970,13 @@ fn relocTargetAddr(self: *Zld, object: *const Object, target: reloc.Relocation.T const segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; const stubs = segment.sections.items[self.stubs_section_index.?]; const stubs_index = proxy.base.stubs_index orelse { - log.err("expected stubs index when relocating symbol '{s}'", .{final.name}); + if (proxy.bind_info.items.len > 0) { + break :blk 0; // Dynamically bound by dyld. + } + log.err( + "expected stubs index or dynamic bind address when relocating symbol '{s}'", + .{final.name}, + ); log.err("this is an internal linker error", .{}); return error.FailedToResolveRelocationTarget; }; @@ -2127,18 +2008,8 @@ fn populateMetadata(self: *Zld) !void { if (self.pagezero_segment_cmd_index == null) { self.pagezero_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__PAGEZERO"), - .vmaddr = 0, + .Segment = SegmentCommand.empty("__PAGEZERO", .{ .vmsize = 0x100000000, // size always set to 4GB - .fileoff = 0, - .filesize = 0, - .maxprot = 0, - .initprot = 0, - .nsects = 0, - .flags = 0, }), }); } @@ -2146,18 +2017,10 @@ fn populateMetadata(self: *Zld) !void { if (self.text_segment_cmd_index == null) { self.text_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__TEXT"), + .Segment = SegmentCommand.empty("__TEXT", .{ .vmaddr = 0x100000000, // always starts at 4GB - .vmsize = 0, - .fileoff = 0, - .filesize = 0, .maxprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE, .initprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE, - .nsects = 0, - .flags = 0, }), }); } @@ -2170,19 +2033,9 @@ fn populateMetadata(self: *Zld) !void { .aarch64 => 2, else => unreachable, // unhandled architecture type }; - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__text"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, + try text_seg.addSection(self.allocator, "__text", .{ .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); } @@ -2199,19 +2052,10 @@ fn populateMetadata(self: *Zld) !void { .aarch64 => 3 * @sizeOf(u32), else => unreachable, // unhandled architecture type }; - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__stubs"), - .segname = makeStaticString("__TEXT"), - .addr = 0, - .size = 0, - .offset = 0, + try text_seg.addSection(self.allocator, "__stubs", .{ .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = macho.S_SYMBOL_STUBS | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, - .reserved1 = 0, .reserved2 = stub_size, - .reserved3 = 0, }); } @@ -2228,37 +2072,19 @@ fn populateMetadata(self: *Zld) !void { .aarch64 => 6 * @sizeOf(u32), else => unreachable, }; - try text_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__stub_helper"), - .segname = makeStaticString("__TEXT"), - .addr = 0, + try text_seg.addSection(self.allocator, "__stub_helper", .{ .size = stub_helper_size, - .offset = 0, .@"align" = alignment, - .reloff = 0, - .nreloc = 0, .flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); } if (self.data_const_segment_cmd_index == null) { self.data_const_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__DATA_CONST"), - .vmaddr = 0, - .vmsize = 0, - .fileoff = 0, - .filesize = 0, + .Segment = SegmentCommand.empty("__DATA_CONST", .{ .maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE, .initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE, - .nsects = 0, - .flags = 0, }), }); } @@ -2266,37 +2092,18 @@ fn populateMetadata(self: *Zld) !void { if (self.got_section_index == null) { const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment; self.got_section_index = @intCast(u16, data_const_seg.sections.items.len); - try data_const_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__got"), - .segname = makeStaticString("__DATA_CONST"), - .addr = 0, - .size = 0, - .offset = 0, + try data_const_seg.addSection(self.allocator, "__got", .{ .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, .flags = macho.S_NON_LAZY_SYMBOL_POINTERS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); } if (self.data_segment_cmd_index == null) { self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__DATA"), - .vmaddr = 0, - .vmsize = 0, - .fileoff = 0, - .filesize = 0, + .Segment = SegmentCommand.empty("__DATA", .{ .maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE, .initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE, - .nsects = 0, - .flags = 0, }), }); } @@ -2304,56 +2111,26 @@ fn populateMetadata(self: *Zld) !void { if (self.la_symbol_ptr_section_index == null) { const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; self.la_symbol_ptr_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__la_symbol_ptr"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, + try data_seg.addSection(self.allocator, "__la_symbol_ptr", .{ .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, .flags = macho.S_LAZY_SYMBOL_POINTERS, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); } if (self.data_section_index == null) { const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; self.data_section_index = @intCast(u16, data_seg.sections.items.len); - try data_seg.addSection(self.allocator, .{ - .sectname = makeStaticString("__data"), - .segname = makeStaticString("__DATA"), - .addr = 0, - .size = 0, - .offset = 0, + try data_seg.addSection(self.allocator, "__data", .{ .@"align" = 3, // 2^3 = @sizeOf(u64) - .reloff = 0, - .nreloc = 0, - .flags = macho.S_REGULAR, - .reserved1 = 0, - .reserved2 = 0, - .reserved3 = 0, }); } if (self.linkedit_segment_cmd_index == null) { self.linkedit_segment_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ - .Segment = SegmentCommand.empty(.{ - .cmd = macho.LC_SEGMENT_64, - .cmdsize = @sizeOf(macho.segment_command_64), - .segname = makeStaticString("__LINKEDIT"), - .vmaddr = 0, - .vmsize = 0, - .fileoff = 0, - .filesize = 0, + .Segment = SegmentCommand.empty("__LINKEDIT", .{ .maxprot = macho.VM_PROT_READ, .initprot = macho.VM_PROT_READ, - .nsects = 0, - .flags = 0, }), }); } @@ -2439,15 +2216,6 @@ fn populateMetadata(self: *Zld) !void { try self.load_commands.append(self.allocator, .{ .Dylinker = dylinker_cmd }); } - if (self.libsystem_cmd_index == null) { - self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len); - - var dylib_cmd = try createLoadDylibCommand(self.allocator, mem.spanZ(LIB_SYSTEM_PATH), 2, 0, 0); - errdefer dylib_cmd.deinit(self.allocator); - - try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd }); - } - if (self.main_cmd_index == null) { self.main_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ @@ -2481,24 +2249,28 @@ fn populateMetadata(self: *Zld) !void { std.crypto.random.bytes(&uuid_cmd.uuid); try self.load_commands.append(self.allocator, .{ .Uuid = uuid_cmd }); } +} - if (self.code_signature_cmd_index == null and self.arch.? == .aarch64) { - self.code_signature_cmd_index = @intCast(u16, self.load_commands.items.len); +fn addDataInCodeLC(self: *Zld) !void { + if (self.data_in_code_cmd_index == null) { + self.data_in_code_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ .LinkeditData = .{ - .cmd = macho.LC_CODE_SIGNATURE, + .cmd = macho.LC_DATA_IN_CODE, .cmdsize = @sizeOf(macho.linkedit_data_command), .dataoff = 0, .datasize = 0, }, }); } +} - if (self.data_in_code_cmd_index == null and self.arch.? == .x86_64) { - self.data_in_code_cmd_index = @intCast(u16, self.load_commands.items.len); +fn addCodeSignatureLC(self: *Zld) !void { + if (self.code_signature_cmd_index == null and self.arch.? == .aarch64) { + self.code_signature_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.allocator, .{ .LinkeditData = .{ - .cmd = macho.LC_DATA_IN_CODE, + .cmd = macho.LC_CODE_SIGNATURE, .cmdsize = @sizeOf(macho.linkedit_data_command), .dataoff = 0, .datasize = 0, @@ -2511,7 +2283,7 @@ fn addRpaths(self: *Zld, rpaths: []const []const u8) !void { for (rpaths) |rpath| { const cmdsize = @intCast(u32, mem.alignForwardGeneric( u64, - @sizeOf(macho.rpath_command) + rpath.len, + @sizeOf(macho.rpath_command) + rpath.len + 1, @sizeOf(u64), )); var rpath_cmd = emptyGenericCommandWithData(macho.rpath_command{ @@ -2594,9 +2366,7 @@ fn flush(self: *Zld) !void { try self.writeBindInfoTable(); try self.writeLazyBindInfoTable(); try self.writeExportInfo(); - if (self.arch.? == .x86_64) { - try self.writeDataInCode(); - } + try self.writeDataInCode(); { const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; @@ -2654,7 +2424,6 @@ fn setEntryPoint(self: *Zld) !void { // TODO we should respect the -entry flag passed in by the user to set a custom // entrypoint. For now, assume default of `_main`. const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment; - const text = seg.sections.items[self.text_section_index.?]; const sym = self.globals.get("_main") orelse return error.MissingMainEntrypoint; const entry_sym = sym.cast(Symbol.Regular) orelse unreachable; const ec = &self.load_commands.items[self.main_cmd_index.?].Main; @@ -2749,14 +2518,24 @@ fn writeBindInfoTable(self: *Zld) !void { for (self.got_entries.items) |sym| { if (sym.cast(Symbol.Proxy)) |proxy| { - const dylib_ordinal = ordinal: { - const dylib = proxy.dylib orelse break :ordinal 1; // TODO embedded libSystem - break :ordinal dylib.ordinal.?; - }; try pointers.append(.{ .offset = base_offset + proxy.base.got_index.? * @sizeOf(u64), .segment_id = segment_id, - .dylib_ordinal = dylib_ordinal, + .dylib_ordinal = proxy.dylibOrdinal(), + .name = proxy.base.name, + }); + } + } + } + + for (self.imports.values()) |sym| { + if (sym.cast(Symbol.Proxy)) |proxy| { + for (proxy.bind_info.items) |info| { + const seg = self.load_commands.items[info.segment_id].Segment; + try pointers.append(.{ + .offset = info.address - seg.inner.vmaddr, + .segment_id = info.segment_id, + .dylib_ordinal = proxy.dylibOrdinal(), .name = proxy.base.name, }); } @@ -2771,15 +2550,11 @@ fn writeBindInfoTable(self: *Zld) !void { const sym = self.imports.get("__tlv_bootstrap") orelse unreachable; const proxy = sym.cast(Symbol.Proxy) orelse unreachable; - const dylib_ordinal = ordinal: { - const dylib = proxy.dylib orelse break :ordinal 1; // TODO embedded libSystem - break :ordinal dylib.ordinal.?; - }; try pointers.append(.{ .offset = base_offset, .segment_id = segment_id, - .dylib_ordinal = dylib_ordinal, + .dylib_ordinal = proxy.dylibOrdinal(), .name = proxy.base.name, }); } @@ -2816,15 +2591,10 @@ fn writeLazyBindInfoTable(self: *Zld) !void { for (self.stubs.items) |sym| { const proxy = sym.cast(Symbol.Proxy) orelse unreachable; - const dylib_ordinal = ordinal: { - const dylib = proxy.dylib orelse break :ordinal 1; // TODO embedded libSystem - break :ordinal dylib.ordinal.?; - }; - pointers.appendAssumeCapacity(.{ .offset = base_offset + sym.stubs_index.? * @sizeOf(u64), .segment_id = segment_id, - .dylib_ordinal = dylib_ordinal, + .dylib_ordinal = proxy.dylibOrdinal(), .name = sym.name, }); } @@ -2862,7 +2632,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void { error.EndOfStream => break, else => return err, }; - const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK; const opcode: u8 = inst & macho.BIND_OPCODE_MASK; switch (opcode) { @@ -2959,6 +2728,7 @@ fn writeDebugInfo(self: *Zld) !void { for (self.objects.items) |object| { const tu_path = object.tu_path orelse continue; const tu_mtime = object.tu_mtime orelse continue; + _ = tu_mtime; const dirname = std.fs.path.dirname(tu_path) orelse "./"; // Current dir try stabs.append(.{ @@ -3131,15 +2901,12 @@ fn writeSymbolTable(self: *Zld) !void { defer undefs.deinit(); for (self.imports.values()) |sym| { - const ordinal = ordinal: { - const dylib = sym.cast(Symbol.Proxy).?.dylib orelse break :ordinal 1; // TODO handle libSystem - break :ordinal dylib.ordinal.?; - }; + const proxy = sym.cast(Symbol.Proxy) orelse unreachable; try undefs.append(.{ .n_strx = try self.makeString(sym.name), .n_type = macho.N_UNDF | macho.N_EXT, .n_sect = 0, - .n_desc = (ordinal * macho.N_SYMBOL_RESOLVER) | macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY, + .n_desc = (proxy.dylibOrdinal() * macho.N_SYMBOL_RESOLVER) | macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY, .n_value = 0, }); } @@ -3382,13 +3149,6 @@ fn writeHeader(self: *Zld) !void { try self.file.?.pwriteAll(mem.asBytes(&header), 0); } -pub fn makeStaticString(bytes: []const u8) [16]u8 { - var buf = [_]u8{0} ** 16; - assert(bytes.len <= buf.len); - mem.copy(u8, &buf, bytes); - return buf; -} - fn makeString(self: *Zld, bytes: []const u8) !u32 { if (self.strtab_dir.get(bytes)) |offset| { log.debug("reusing '{s}' from string table at offset 0x{x}", .{ bytes, offset }); diff --git a/src/link/MachO/bind.zig b/src/link/MachO/bind.zig index d234fa8242..402e74d776 100644 --- a/src/link/MachO/bind.zig +++ b/src/link/MachO/bind.zig @@ -10,6 +10,7 @@ pub const Pointer = struct { }; pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool { + _ = context; if (a.segment_id < b.segment_id) return true; if (a.segment_id == b.segment_id) { return a.offset < b.offset; diff --git a/src/link/MachO/commands.zig b/src/link/MachO/commands.zig index 8bceb64f1e..6958b8d1e6 100644 --- a/src/link/MachO/commands.zig +++ b/src/link/MachO/commands.zig @@ -9,7 +9,6 @@ const assert = std.debug.assert; const Allocator = std.mem.Allocator; const MachO = @import("../MachO.zig"); -const makeStaticString = MachO.makeStaticString; const padToIdeal = MachO.padToIdeal; pub const LoadCommand = union(enum) { @@ -187,11 +186,70 @@ pub const SegmentCommand = struct { inner: macho.segment_command_64, sections: std.ArrayListUnmanaged(macho.section_64) = .{}, - pub fn empty(inner: macho.segment_command_64) SegmentCommand { - return .{ .inner = inner }; + const SegmentOptions = struct { + cmdsize: u32 = @sizeOf(macho.segment_command_64), + vmaddr: u64 = 0, + vmsize: u64 = 0, + fileoff: u64 = 0, + filesize: u64 = 0, + maxprot: macho.vm_prot_t = macho.VM_PROT_NONE, + initprot: macho.vm_prot_t = macho.VM_PROT_NONE, + nsects: u32 = 0, + flags: u32 = 0, + }; + + pub fn empty(comptime segname: []const u8, opts: SegmentOptions) SegmentCommand { + return .{ + .inner = .{ + .cmd = macho.LC_SEGMENT_64, + .cmdsize = opts.cmdsize, + .segname = makeStaticString(segname), + .vmaddr = opts.vmaddr, + .vmsize = opts.vmsize, + .fileoff = opts.fileoff, + .filesize = opts.filesize, + .maxprot = opts.maxprot, + .initprot = opts.initprot, + .nsects = opts.nsects, + .flags = opts.flags, + }, + }; } - pub fn addSection(self: *SegmentCommand, alloc: *Allocator, section: macho.section_64) !void { + const SectionOptions = struct { + addr: u64 = 0, + size: u64 = 0, + offset: u32 = 0, + @"align": u32 = 0, + reloff: u32 = 0, + nreloc: u32 = 0, + flags: u32 = macho.S_REGULAR, + reserved1: u32 = 0, + reserved2: u32 = 0, + reserved3: u32 = 0, + }; + + pub fn addSection( + self: *SegmentCommand, + alloc: *Allocator, + comptime sectname: []const u8, + opts: SectionOptions, + ) !void { + var section = macho.section_64{ + .sectname = makeStaticString(sectname), + .segname = undefined, + .addr = opts.addr, + .size = opts.size, + .offset = opts.offset, + .@"align" = opts.@"align", + .reloff = opts.reloff, + .nreloc = opts.nreloc, + .flags = opts.flags, + .reserved1 = opts.reserved1, + .reserved2 = opts.reserved2, + .reserved3 = opts.reserved3, + }; + mem.copy(u8, §ion.segname, &self.inner.segname); try self.sections.append(alloc, section); self.inner.cmdsize += @sizeOf(macho.section_64); self.inner.nsects += 1; @@ -338,6 +396,13 @@ pub fn createLoadDylibCommand( return dylib_cmd; } +fn makeStaticString(bytes: []const u8) [16]u8 { + var buf = [_]u8{0} ** 16; + assert(bytes.len <= buf.len); + mem.copy(u8, &buf, bytes); + return buf; +} + fn testRead(allocator: *Allocator, buffer: []const u8, expected: anytype) !void { var stream = io.fixedBufferStream(buffer); var given = try LoadCommand.read(allocator, stream.reader()); diff --git a/src/link/MachO/reloc/x86_64.zig b/src/link/MachO/reloc/x86_64.zig index 2a457fdea2..6df68b6b3e 100644 --- a/src/link/MachO/reloc/x86_64.zig +++ b/src/link/MachO/reloc/x86_64.zig @@ -175,7 +175,6 @@ pub const Parser = struct { const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); const target = Relocation.Target.from_reloc(rel, parser.symbols); - const is_extern = rel.r_extern == 1; const offset = @intCast(u32, rel.r_address); const inst = parser.code[offset..][0..4]; diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig index 9d64245bbb..bfae799462 100644 --- a/src/link/SpirV.zig +++ b/src/link/SpirV.zig @@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void { } pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void { + _ = module; // Keep track of all decls so we can iterate over them on flush(). _ = try self.decl_table.getOrPut(self.base.allocator, decl); } @@ -111,7 +112,12 @@ pub fn updateDeclExports( module: *Module, decl: *const Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + _ = self; + _ = module; + _ = decl; + _ = exports; +} pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void { assert(self.decl_table.swapRemove(decl)); diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 3fcdc04e71..6d38939a88 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void { try module.failed_decls.put(module.gpa, decl, context.err_msg); return; }, - else => |e| return err, + else => |e| return e, }; const code: []const u8 = switch (result) { @@ -258,7 +258,12 @@ pub fn updateDeclExports( module: *Module, decl: *const Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + _ = self; + _ = module; + _ = decl; + _ = exports; +} pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void { if (self.getFuncidx(decl)) |func_idx| { @@ -300,6 +305,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void { } pub fn flushModule(self: *Wasm, comp: *Compilation) !void { + _ = comp; const tracy = trace(@src()); defer tracy.end(); @@ -496,7 +502,6 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void { if (data_size != 0) { const header_offset = try reserveVecSectionHeader(file); const writer = file.writer(); - var len: u32 = 0; // index to memory section (currently, there can only be 1 memory section in wasm) try leb.writeULEB128(writer, @as(u32, 0)); @@ -558,7 +563,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } diff --git a/src/link/tapi.zig b/src/link/tapi.zig new file mode 100644 index 0000000000..35193b0eec --- /dev/null +++ b/src/link/tapi.zig @@ -0,0 +1,86 @@ +const std = @import("std"); +const fs = std.fs; +const mem = std.mem; +const log = std.log.scoped(.tapi); + +const Allocator = mem.Allocator; +const Yaml = @import("tapi/yaml.zig").Yaml; + +pub const LibStub = struct { + /// Underlying memory for stub's contents. + yaml: Yaml, + + /// Typed contents of the tbd file. + inner: []Tbd, + + const Tbd = struct { + tbd_version: u3, + targets: []const []const u8, + uuids: []const struct { + target: []const u8, + value: []const u8, + }, + install_name: []const u8, + current_version: ?union(enum) { + string: []const u8, + float: f64, + int: u64, + }, + compatibility_version: ?union(enum) { + string: []const u8, + float: f64, + int: u64, + }, + reexported_libraries: ?[]const struct { + targets: []const []const u8, + libraries: []const []const u8, + }, + parent_umbrella: ?[]const struct { + targets: []const []const u8, + umbrella: []const u8, + }, + exports: ?[]const struct { + targets: []const []const u8, + symbols: ?[]const []const u8, + objc_classes: ?[]const []const u8, + }, + reexports: ?[]const struct { + targets: []const []const u8, + symbols: ?[]const []const u8, + objc_classes: ?[]const []const u8, + }, + allowable_clients: ?[]const struct { + targets: []const []const u8, + clients: []const []const u8, + }, + objc_classes: ?[]const []const u8, + }; + + pub fn loadFromFile(allocator: *Allocator, file: fs.File) !LibStub { + const source = try file.readToEndAlloc(allocator, std.math.maxInt(u32)); + defer allocator.free(source); + + var lib_stub = LibStub{ + .yaml = try Yaml.load(allocator, source), + .inner = undefined, + }; + + lib_stub.inner = lib_stub.yaml.parse([]Tbd) catch |err| blk: { + switch (err) { + error.TypeMismatch => { + // TODO clean this up. + var out = try lib_stub.yaml.arena.allocator.alloc(Tbd, 1); + out[0] = try lib_stub.yaml.parse(Tbd); + break :blk out; + }, + else => |e| return e, + } + }; + + return lib_stub; + } + + pub fn deinit(self: *LibStub) void { + self.yaml.deinit(); + } +}; diff --git a/src/link/tapi/Tokenizer.zig b/src/link/tapi/Tokenizer.zig new file mode 100644 index 0000000000..37fcedbfce --- /dev/null +++ b/src/link/tapi/Tokenizer.zig @@ -0,0 +1,439 @@ +const Tokenizer = @This(); + +const std = @import("std"); +const log = std.log.scoped(.tapi); +const testing = std.testing; + +buffer: []const u8, +index: usize = 0, + +pub const Token = struct { + id: Id, + start: usize, + end: usize, + // Count of spaces/tabs. + // Only active for .Space and .Tab tokens. + count: ?usize = null, + + pub const Id = enum { + Eof, + + NewLine, + DocStart, // --- + DocEnd, // ... + SeqItemInd, // - + MapValueInd, // : + FlowMapStart, // { + FlowMapEnd, // } + FlowSeqStart, // [ + FlowSeqEnd, // ] + + Comma, + Space, + Tab, + Comment, // # + Alias, // * + Anchor, // & + Tag, // ! + SingleQuote, // ' + DoubleQuote, // " + + Literal, + }; +}; + +pub const TokenIndex = usize; + +pub const TokenIterator = struct { + buffer: []const Token, + pos: TokenIndex = 0, + + pub fn next(self: *TokenIterator) Token { + const token = self.buffer[self.pos]; + self.pos += 1; + return token; + } + + pub fn peek(self: TokenIterator) ?Token { + if (self.pos >= self.buffer.len) return null; + return self.buffer[self.pos]; + } + + pub fn reset(self: *TokenIterator) void { + self.pos = 0; + } + + pub fn seekTo(self: *TokenIterator, pos: TokenIndex) void { + self.pos = pos; + } + + pub fn seekBy(self: *TokenIterator, offset: isize) void { + const new_pos = @bitCast(isize, self.pos) + offset; + if (new_pos < 0) { + self.pos = 0; + } else { + self.pos = @intCast(usize, new_pos); + } + } +}; + +pub fn next(self: *Tokenizer) Token { + var result = Token{ + .id = .Eof, + .start = self.index, + .end = undefined, + }; + + var state: union(enum) { + Start, + NewLine, + Space: usize, + Tab: usize, + Hyphen: usize, + Dot: usize, + Literal, + } = .Start; + + while (self.index < self.buffer.len) : (self.index += 1) { + const c = self.buffer[self.index]; + switch (state) { + .Start => switch (c) { + ' ' => { + state = .{ .Space = 1 }; + }, + '\t' => { + state = .{ .Tab = 1 }; + }, + '\n' => { + result.id = .NewLine; + self.index += 1; + break; + }, + '\r' => { + state = .NewLine; + }, + '-' => { + state = .{ .Hyphen = 1 }; + }, + '.' => { + state = .{ .Dot = 1 }; + }, + ',' => { + result.id = .Comma; + self.index += 1; + break; + }, + '#' => { + result.id = .Comment; + self.index += 1; + break; + }, + '*' => { + result.id = .Alias; + self.index += 1; + break; + }, + '&' => { + result.id = .Anchor; + self.index += 1; + break; + }, + '!' => { + result.id = .Tag; + self.index += 1; + break; + }, + '\'' => { + result.id = .SingleQuote; + self.index += 1; + break; + }, + '"' => { + result.id = .DoubleQuote; + self.index += 1; + break; + }, + '[' => { + result.id = .FlowSeqStart; + self.index += 1; + break; + }, + ']' => { + result.id = .FlowSeqEnd; + self.index += 1; + break; + }, + ':' => { + result.id = .MapValueInd; + self.index += 1; + break; + }, + '{' => { + result.id = .FlowMapStart; + self.index += 1; + break; + }, + '}' => { + result.id = .FlowMapEnd; + self.index += 1; + break; + }, + else => { + state = .Literal; + }, + }, + .Space => |*count| switch (c) { + ' ' => { + count.* += 1; + }, + else => { + result.id = .Space; + result.count = count.*; + break; + }, + }, + .Tab => |*count| switch (c) { + ' ' => { + count.* += 1; + }, + else => { + result.id = .Tab; + result.count = count.*; + break; + }, + }, + .NewLine => switch (c) { + '\n' => { + result.id = .NewLine; + self.index += 1; + break; + }, + else => {}, // TODO this should be an error condition + }, + .Hyphen => |*count| switch (c) { + ' ' => { + result.id = .SeqItemInd; + self.index += 1; + break; + }, + '-' => { + count.* += 1; + + if (count.* == 3) { + result.id = .DocStart; + self.index += 1; + break; + } + }, + else => { + state = .Literal; + }, + }, + .Dot => |*count| switch (c) { + '.' => { + count.* += 1; + + if (count.* == 3) { + result.id = .DocEnd; + self.index += 1; + break; + } + }, + else => { + state = .Literal; + }, + }, + .Literal => switch (c) { + '\r', '\n', ' ', '\'', '"', ',', ':', ']', '}' => { + result.id = .Literal; + break; + }, + else => { + result.id = .Literal; + }, + }, + } + } + + if (state == .Literal and result.id == .Eof) { + result.id = .Literal; + } + + result.end = self.index; + + log.debug("{any}", .{result}); + log.debug(" | {s}", .{self.buffer[result.start..result.end]}); + + return result; +} + +fn testExpected(source: []const u8, expected: []const Token.Id) !void { + var tokenizer = Tokenizer{ + .buffer = source, + }; + + for (expected) |exp| { + const token = tokenizer.next(); + try testing.expectEqual(exp, token.id); + } +} + +test "empty doc" { + try testExpected("", &[_]Token.Id{.Eof}); +} + +test "empty doc with explicit markers" { + try testExpected( + \\--- + \\... + , &[_]Token.Id{ + .DocStart, .NewLine, .DocEnd, .Eof, + }); +} + +test "sequence of values" { + try testExpected( + \\- 0 + \\- 1 + \\- 2 + , &[_]Token.Id{ + .SeqItemInd, + .Literal, + .NewLine, + .SeqItemInd, + .Literal, + .NewLine, + .SeqItemInd, + .Literal, + .Eof, + }); +} + +test "sequence of sequences" { + try testExpected( + \\- [ val1, val2] + \\- [val3, val4 ] + , &[_]Token.Id{ + .SeqItemInd, + .FlowSeqStart, + .Space, + .Literal, + .Comma, + .Space, + .Literal, + .FlowSeqEnd, + .NewLine, + .SeqItemInd, + .FlowSeqStart, + .Literal, + .Comma, + .Space, + .Literal, + .Space, + .FlowSeqEnd, + .Eof, + }); +} + +test "mappings" { + try testExpected( + \\key1: value1 + \\key2: value2 + , &[_]Token.Id{ + .Literal, + .MapValueInd, + .Space, + .Literal, + .NewLine, + .Literal, + .MapValueInd, + .Space, + .Literal, + .Eof, + }); +} + +test "inline mapped sequence of values" { + try testExpected( + \\key : [ val1, + \\ val2 ] + , &[_]Token.Id{ + .Literal, + .Space, + .MapValueInd, + .Space, + .FlowSeqStart, + .Space, + .Literal, + .Comma, + .Space, + .NewLine, + .Space, + .Literal, + .Space, + .FlowSeqEnd, + .Eof, + }); +} + +test "part of tdb" { + try testExpected( + \\--- !tapi-tbd + \\tbd-version: 4 + \\targets: [ x86_64-macos ] + \\ + \\uuids: + \\ - target: x86_64-macos + \\ value: F86CC732-D5E4-30B5-AA7D-167DF5EC2708 + \\ + \\install-name: '/usr/lib/libSystem.B.dylib' + \\... + , &[_]Token.Id{ + .DocStart, + .Space, + .Tag, + .Literal, + .NewLine, + .Literal, + .MapValueInd, + .Space, + .Literal, + .NewLine, + .Literal, + .MapValueInd, + .Space, + .FlowSeqStart, + .Space, + .Literal, + .Space, + .FlowSeqEnd, + .NewLine, + .NewLine, + .Literal, + .MapValueInd, + .NewLine, + .Space, + .SeqItemInd, + .Literal, + .MapValueInd, + .Space, + .Literal, + .NewLine, + .Space, + .Literal, + .MapValueInd, + .Space, + .Literal, + .NewLine, + .NewLine, + .Literal, + .MapValueInd, + .Space, + .SingleQuote, + .Literal, + .SingleQuote, + .NewLine, + .DocEnd, + .Eof, + }); +} diff --git a/src/link/tapi/parse.zig b/src/link/tapi/parse.zig new file mode 100644 index 0000000000..0c923f961b --- /dev/null +++ b/src/link/tapi/parse.zig @@ -0,0 +1,708 @@ +const std = @import("std"); +const assert = std.debug.assert; +const log = std.log.scoped(.tapi); +const mem = std.mem; +const testing = std.testing; + +const Allocator = mem.Allocator; +const Tokenizer = @import("Tokenizer.zig"); +const Token = Tokenizer.Token; +const TokenIndex = Tokenizer.TokenIndex; +const TokenIterator = Tokenizer.TokenIterator; + +pub const ParseError = error{ + MalformedYaml, + NestedDocuments, + UnexpectedTag, + UnexpectedEof, + UnexpectedToken, + Unhandled, +} || Allocator.Error; + +pub const Node = struct { + tag: Tag, + tree: *const Tree, + + pub const Tag = enum { + doc, + map, + list, + value, + }; + + pub fn cast(self: *const Node, comptime T: type) ?*const T { + if (self.tag != T.base_tag) { + return null; + } + return @fieldParentPtr(T, "base", self); + } + + pub fn deinit(self: *Node, allocator: *Allocator) void { + switch (self.tag) { + .doc => @fieldParentPtr(Node.Doc, "base", self).deinit(allocator), + .map => @fieldParentPtr(Node.Map, "base", self).deinit(allocator), + .list => @fieldParentPtr(Node.List, "base", self).deinit(allocator), + .value => {}, + } + } + + pub fn format( + self: *const Node, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + return switch (self.tag) { + .doc => @fieldParentPtr(Node.Doc, "base", self).format(fmt, options, writer), + .map => @fieldParentPtr(Node.Map, "base", self).format(fmt, options, writer), + .list => @fieldParentPtr(Node.List, "base", self).format(fmt, options, writer), + .value => @fieldParentPtr(Node.Value, "base", self).format(fmt, options, writer), + }; + } + + pub const Doc = struct { + base: Node = Node{ .tag = Tag.doc, .tree = undefined }, + start: ?TokenIndex = null, + end: ?TokenIndex = null, + directive: ?TokenIndex = null, + value: ?*Node = null, + + pub const base_tag: Node.Tag = .doc; + + pub fn deinit(self: *Doc, allocator: *Allocator) void { + if (self.value) |node| { + node.deinit(allocator); + allocator.destroy(node); + } + } + + pub fn format( + self: *const Doc, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + if (self.directive) |id| { + try std.fmt.format(writer, "{{ ", .{}); + const directive = self.base.tree.tokens[id]; + try std.fmt.format(writer, ".directive = {s}, ", .{ + self.base.tree.source[directive.start..directive.end], + }); + } + if (self.value) |node| { + try std.fmt.format(writer, "{}", .{node}); + } + if (self.directive != null) { + try std.fmt.format(writer, " }}", .{}); + } + } + }; + + pub const Map = struct { + base: Node = Node{ .tag = Tag.map, .tree = undefined }, + start: ?TokenIndex = null, + end: ?TokenIndex = null, + values: std.ArrayListUnmanaged(Entry) = .{}, + + pub const base_tag: Node.Tag = .map; + + pub const Entry = struct { + key: TokenIndex, + value: *Node, + }; + + pub fn deinit(self: *Map, allocator: *Allocator) void { + for (self.values.items) |entry| { + entry.value.deinit(allocator); + allocator.destroy(entry.value); + } + self.values.deinit(allocator); + } + + pub fn format( + self: *const Map, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + try std.fmt.format(writer, "{{ ", .{}); + for (self.values.items) |entry| { + const key = self.base.tree.tokens[entry.key]; + try std.fmt.format(writer, "{s} => {}, ", .{ + self.base.tree.source[key.start..key.end], + entry.value, + }); + } + return std.fmt.format(writer, " }}", .{}); + } + }; + + pub const List = struct { + base: Node = Node{ .tag = Tag.list, .tree = undefined }, + start: ?TokenIndex = null, + end: ?TokenIndex = null, + values: std.ArrayListUnmanaged(*Node) = .{}, + + pub const base_tag: Node.Tag = .list; + + pub fn deinit(self: *List, allocator: *Allocator) void { + for (self.values.items) |node| { + node.deinit(allocator); + allocator.destroy(node); + } + self.values.deinit(allocator); + } + + pub fn format( + self: *const List, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + try std.fmt.format(writer, "[ ", .{}); + for (self.values.items) |node| { + try std.fmt.format(writer, "{}, ", .{node}); + } + return std.fmt.format(writer, " ]", .{}); + } + }; + + pub const Value = struct { + base: Node = Node{ .tag = Tag.value, .tree = undefined }, + start: ?TokenIndex = null, + end: ?TokenIndex = null, + + pub const base_tag: Node.Tag = .value; + + pub fn format( + self: *const Value, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) !void { + _ = fmt; + _ = options; + const start = self.base.tree.tokens[self.start.?]; + const end = self.base.tree.tokens[self.end.?]; + return std.fmt.format(writer, "{s}", .{ + self.base.tree.source[start.start..end.end], + }); + } + }; +}; + +pub const Tree = struct { + allocator: *Allocator, + source: []const u8, + tokens: []Token, + docs: std.ArrayListUnmanaged(*Node) = .{}, + + pub fn init(allocator: *Allocator) Tree { + return .{ + .allocator = allocator, + .source = undefined, + .tokens = undefined, + }; + } + + pub fn deinit(self: *Tree) void { + self.allocator.free(self.tokens); + for (self.docs.items) |doc| { + doc.deinit(self.allocator); + self.allocator.destroy(doc); + } + self.docs.deinit(self.allocator); + } + + pub fn parse(self: *Tree, source: []const u8) !void { + var tokenizer = Tokenizer{ .buffer = source }; + var tokens = std.ArrayList(Token).init(self.allocator); + errdefer tokens.deinit(); + + while (true) { + const token = tokenizer.next(); + try tokens.append(token); + if (token.id == .Eof) break; + } + + self.source = source; + self.tokens = tokens.toOwnedSlice(); + + var it = TokenIterator{ .buffer = self.tokens }; + var parser = Parser{ + .allocator = self.allocator, + .tree = self, + .token_it = &it, + }; + defer parser.deinit(); + + try parser.scopes.append(self.allocator, .{ + .indent = 0, + }); + + while (true) { + if (parser.token_it.peek() == null) return; + const pos = parser.token_it.pos; + const token = parser.token_it.next(); + + log.debug("Next token: {}, {}", .{ pos, token }); + + switch (token.id) { + .Space, .Comment, .NewLine => {}, + .Eof => break, + else => { + const doc = try parser.doc(pos); + try self.docs.append(self.allocator, &doc.base); + }, + } + } + } +}; + +const Parser = struct { + allocator: *Allocator, + tree: *Tree, + token_it: *TokenIterator, + scopes: std.ArrayListUnmanaged(Scope) = .{}, + + const Scope = struct { + indent: usize, + }; + + fn deinit(self: *Parser) void { + self.scopes.deinit(self.allocator); + } + + fn doc(self: *Parser, start: TokenIndex) ParseError!*Node.Doc { + const node = try self.allocator.create(Node.Doc); + errdefer self.allocator.destroy(node); + node.* = .{ + .start = start, + }; + node.base.tree = self.tree; + + self.token_it.seekTo(start); + + log.debug("Doc start: {}, {}", .{ start, self.tree.tokens[start] }); + + const explicit_doc: bool = if (self.eatToken(.DocStart)) |_| explicit_doc: { + if (self.eatToken(.Tag)) |_| { + node.directive = try self.expectToken(.Literal); + } + _ = try self.expectToken(.NewLine); + break :explicit_doc true; + } else false; + + while (true) { + const pos = self.token_it.pos; + const token = self.token_it.next(); + + log.debug("Next token: {}, {}", .{ pos, token }); + + switch (token.id) { + .Tag => { + return error.UnexpectedTag; + }, + .Literal, .SingleQuote, .DoubleQuote => { + _ = try self.expectToken(.MapValueInd); + const map_node = try self.map(pos); + node.value = &map_node.base; + }, + .SeqItemInd => { + const list_node = try self.list(pos); + node.value = &list_node.base; + }, + .FlowSeqStart => { + const list_node = try self.list_bracketed(pos); + node.value = &list_node.base; + }, + .DocEnd => { + if (explicit_doc) break; + return error.UnexpectedToken; + }, + .DocStart, .Eof => { + self.token_it.seekBy(-1); + break; + }, + else => { + return error.UnexpectedToken; + }, + } + } + + node.end = self.token_it.pos - 1; + + log.debug("Doc end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] }); + + return node; + } + + fn map(self: *Parser, start: TokenIndex) ParseError!*Node.Map { + const node = try self.allocator.create(Node.Map); + errdefer self.allocator.destroy(node); + node.* = .{ + .start = start, + }; + node.base.tree = self.tree; + + self.token_it.seekTo(start); + + log.debug("Map start: {}, {}", .{ start, self.tree.tokens[start] }); + log.debug("Current scope: {}", .{self.scopes.items[self.scopes.items.len - 1]}); + + while (true) { + // Parse key. + const key_pos = self.token_it.pos; + const key = self.token_it.next(); + switch (key.id) { + .Literal => {}, + else => { + self.token_it.seekBy(-1); + break; + }, + } + + log.debug("Map key: {}, '{s}'", .{ key, self.tree.source[key.start..key.end] }); + + // Separator + _ = try self.expectToken(.MapValueInd); + self.eatCommentsAndSpace(); + + // Parse value. + const value: *Node = value: { + if (self.eatToken(.NewLine)) |_| { + // Explicit, complex value such as list or map. + try self.openScope(); + const value_pos = self.token_it.pos; + const value = self.token_it.next(); + switch (value.id) { + .Literal, .SingleQuote, .DoubleQuote => { + // Assume nested map. + const map_node = try self.map(value_pos); + break :value &map_node.base; + }, + .SeqItemInd => { + // Assume list of values. + const list_node = try self.list(value_pos); + break :value &list_node.base; + }, + else => { + log.err("{}", .{key}); + return error.Unhandled; + }, + } + } else { + const value_pos = self.token_it.pos; + const value = self.token_it.next(); + switch (value.id) { + .Literal, .SingleQuote, .DoubleQuote => { + // Assume leaf value. + const leaf_node = try self.leaf_value(value_pos); + break :value &leaf_node.base; + }, + .FlowSeqStart => { + const list_node = try self.list_bracketed(value_pos); + break :value &list_node.base; + }, + else => { + log.err("{}", .{key}); + return error.Unhandled; + }, + } + } + }; + log.debug("Map value: {}", .{value}); + + try node.values.append(self.allocator, .{ + .key = key_pos, + .value = value, + }); + + if (self.eatToken(.NewLine)) |_| { + if (try self.closeScope()) { + break; + } + } + } + + node.end = self.token_it.pos - 1; + + log.debug("Map end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] }); + + return node; + } + + fn list(self: *Parser, start: TokenIndex) ParseError!*Node.List { + const node = try self.allocator.create(Node.List); + errdefer self.allocator.destroy(node); + node.* = .{ + .start = start, + }; + node.base.tree = self.tree; + + self.token_it.seekTo(start); + + log.debug("List start: {}, {}", .{ start, self.tree.tokens[start] }); + log.debug("Current scope: {}", .{self.scopes.items[self.scopes.items.len - 1]}); + + while (true) { + _ = self.eatToken(.SeqItemInd) orelse { + _ = try self.closeScope(); + break; + }; + self.eatCommentsAndSpace(); + + const pos = self.token_it.pos; + const token = self.token_it.next(); + const value: *Node = value: { + switch (token.id) { + .Literal, .SingleQuote, .DoubleQuote => { + if (self.eatToken(.MapValueInd)) |_| { + if (self.eatToken(.NewLine)) |_| { + try self.openScope(); + } + // nested map + const map_node = try self.map(pos); + break :value &map_node.base; + } else { + // standalone (leaf) value + const leaf_node = try self.leaf_value(pos); + break :value &leaf_node.base; + } + }, + .FlowSeqStart => { + const list_node = try self.list_bracketed(pos); + break :value &list_node.base; + }, + else => { + log.err("{}", .{token}); + return error.Unhandled; + }, + } + }; + try node.values.append(self.allocator, value); + + _ = self.eatToken(.NewLine); + } + + node.end = self.token_it.pos - 1; + + log.debug("List end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] }); + + return node; + } + + fn list_bracketed(self: *Parser, start: TokenIndex) ParseError!*Node.List { + const node = try self.allocator.create(Node.List); + errdefer self.allocator.destroy(node); + node.* = .{ + .start = start, + }; + node.base.tree = self.tree; + + self.token_it.seekTo(start); + + log.debug("List start: {}, {}", .{ start, self.tree.tokens[start] }); + log.debug("Current scope: {}", .{self.scopes.items[self.scopes.items.len - 1]}); + + _ = try self.expectToken(.FlowSeqStart); + + while (true) { + _ = self.eatToken(.NewLine); + self.eatCommentsAndSpace(); + + const pos = self.token_it.pos; + const token = self.token_it.next(); + + log.debug("Next token: {}, {}", .{ pos, token }); + + const value: *Node = value: { + switch (token.id) { + .FlowSeqStart => { + const list_node = try self.list_bracketed(pos); + break :value &list_node.base; + }, + .FlowSeqEnd => { + break; + }, + .Literal, .SingleQuote, .DoubleQuote => { + const leaf_node = try self.leaf_value(pos); + _ = self.eatToken(.Comma); + // TODO newline + break :value &leaf_node.base; + }, + else => { + log.err("{}", .{token}); + return error.Unhandled; + }, + } + }; + try node.values.append(self.allocator, value); + } + + node.end = self.token_it.pos - 1; + + log.debug("List end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] }); + + return node; + } + + fn leaf_value(self: *Parser, start: TokenIndex) ParseError!*Node.Value { + const node = try self.allocator.create(Node.Value); + errdefer self.allocator.destroy(node); + node.* = .{ + .start = start, + }; + node.base.tree = self.tree; + + self.token_it.seekTo(start); + + log.debug("Leaf start: {}, {}", .{ node.start.?, self.tree.tokens[node.start.?] }); + + parse: { + if (self.eatToken(.SingleQuote)) |_| { + node.start = node.start.? + 1; + while (true) { + const tok = self.token_it.next(); + switch (tok.id) { + .SingleQuote => { + node.end = self.token_it.pos - 2; + break :parse; + }, + .NewLine => return error.UnexpectedToken, + else => {}, + } + } + } + + if (self.eatToken(.DoubleQuote)) |_| { + node.start = node.start.? + 1; + while (true) { + const tok = self.token_it.next(); + switch (tok.id) { + .DoubleQuote => { + node.end = self.token_it.pos - 2; + break :parse; + }, + .NewLine => return error.UnexpectedToken, + else => {}, + } + } + } + + // TODO handle multiline strings in new block scope + while (true) { + const tok = self.token_it.next(); + switch (tok.id) { + .Literal => {}, + .Space => { + const trailing = self.token_it.pos - 2; + self.eatCommentsAndSpace(); + if (self.token_it.peek()) |peek| { + if (peek.id != .Literal) { + node.end = trailing; + break; + } + } + }, + else => { + self.token_it.seekBy(-1); + node.end = self.token_it.pos - 1; + break; + }, + } + } + } + + log.debug("Leaf end: {}, {}", .{ node.end.?, self.tree.tokens[node.end.?] }); + + return node; + } + + fn openScope(self: *Parser) !void { + const peek = self.token_it.peek() orelse return error.UnexpectedEof; + if (peek.id != .Space and peek.id != .Tab) { + // No need to open scope. + return; + } + const indent = self.token_it.next().count.?; + const prev_scope = self.scopes.items[self.scopes.items.len - 1]; + if (indent < prev_scope.indent) { + return error.MalformedYaml; + } + + log.debug("Opening scope...", .{}); + + try self.scopes.append(self.allocator, .{ + .indent = indent, + }); + } + + fn closeScope(self: *Parser) !bool { + const indent = indent: { + const peek = self.token_it.peek() orelse return error.UnexpectedEof; + switch (peek.id) { + .Space, .Tab => { + break :indent self.token_it.next().count.?; + }, + else => { + break :indent 0; + }, + } + }; + + const scope = self.scopes.items[self.scopes.items.len - 1]; + if (indent < scope.indent) { + log.debug("Closing scope...", .{}); + _ = self.scopes.pop(); + return true; + } + + return false; + } + + fn eatCommentsAndSpace(self: *Parser) void { + while (true) { + _ = self.token_it.peek() orelse return; + const token = self.token_it.next(); + switch (token.id) { + .Comment, .Space => {}, + else => { + self.token_it.seekBy(-1); + break; + }, + } + } + } + + fn eatToken(self: *Parser, id: Token.Id) ?TokenIndex { + while (true) { + const pos = self.token_it.pos; + _ = self.token_it.peek() orelse return null; + const token = self.token_it.next(); + switch (token.id) { + .Comment, .Space => continue, + else => |next_id| if (next_id == id) { + return pos; + } else { + self.token_it.seekTo(pos); + return null; + }, + } + } + } + + fn expectToken(self: *Parser, id: Token.Id) ParseError!TokenIndex { + return self.eatToken(id) orelse error.UnexpectedToken; + } +}; + +test { + _ = @import("parse/test.zig"); +} diff --git a/src/link/tapi/parse/test.zig b/src/link/tapi/parse/test.zig new file mode 100644 index 0000000000..b96a71fe97 --- /dev/null +++ b/src/link/tapi/parse/test.zig @@ -0,0 +1,556 @@ +const std = @import("std"); +const mem = std.mem; +const testing = std.testing; + +usingnamespace @import("../parse.zig"); + +test "explicit doc" { + const source = + \\--- !tapi-tbd + \\tbd-version: 4 + \\abc-version: 5 + \\... + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + const directive = tree.tokens[doc.directive.?]; + try testing.expectEqual(directive.id, .Literal); + try testing.expect(mem.eql(u8, "tapi-tbd", tree.source[directive.start..directive.end])); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 5); + try testing.expectEqual(map.end.?, 14); + try testing.expectEqual(map.values.items.len, 2); + + { + const entry = map.values.items[0]; + + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "tbd-version", tree.source[key.start..key.end])); + + const value = entry.value.cast(Node.Value).?; + const value_tok = tree.tokens[value.start.?]; + try testing.expectEqual(value_tok.id, .Literal); + try testing.expect(mem.eql(u8, "4", tree.source[value_tok.start..value_tok.end])); + } + + { + const entry = map.values.items[1]; + + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "abc-version", tree.source[key.start..key.end])); + + const value = entry.value.cast(Node.Value).?; + const value_tok = tree.tokens[value.start.?]; + try testing.expectEqual(value_tok.id, .Literal); + try testing.expect(mem.eql(u8, "5", tree.source[value_tok.start..value_tok.end])); + } +} + +test "leaf in quotes" { + const source = + \\key1: no quotes + \\key2: 'single quoted' + \\key3: "double quoted" + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + try testing.expect(doc.directive == null); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 0); + try testing.expectEqual(map.end.?, tree.tokens.len - 2); + try testing.expectEqual(map.values.items.len, 3); + + { + const entry = map.values.items[0]; + + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql( + u8, + "key1", + tree.source[key.start..key.end], + )); + + const value = entry.value.cast(Node.Value).?; + const start = tree.tokens[value.start.?]; + const end = tree.tokens[value.end.?]; + try testing.expectEqual(start.id, .Literal); + try testing.expectEqual(end.id, .Literal); + try testing.expect(mem.eql( + u8, + "no quotes", + tree.source[start.start..end.end], + )); + } +} + +test "nested maps" { + const source = + \\key1: + \\ key1_1 : value1_1 + \\ key1_2 : value1_2 + \\key2 : value2 + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + try testing.expect(doc.directive == null); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 0); + try testing.expectEqual(map.end.?, tree.tokens.len - 2); + try testing.expectEqual(map.values.items.len, 2); + + { + const entry = map.values.items[0]; + + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "key1", tree.source[key.start..key.end])); + + const nested_map = entry.value.cast(Node.Map).?; + try testing.expectEqual(nested_map.start.?, 4); + try testing.expectEqual(nested_map.end.?, 16); + try testing.expectEqual(nested_map.values.items.len, 2); + + { + const nested_entry = nested_map.values.items[0]; + + const nested_key = tree.tokens[nested_entry.key]; + try testing.expectEqual(nested_key.id, .Literal); + try testing.expect(mem.eql( + u8, + "key1_1", + tree.source[nested_key.start..nested_key.end], + )); + + const nested_value = nested_entry.value.cast(Node.Value).?; + const nested_value_tok = tree.tokens[nested_value.start.?]; + try testing.expectEqual(nested_value_tok.id, .Literal); + try testing.expect(mem.eql( + u8, + "value1_1", + tree.source[nested_value_tok.start..nested_value_tok.end], + )); + } + + { + const nested_entry = nested_map.values.items[1]; + + const nested_key = tree.tokens[nested_entry.key]; + try testing.expectEqual(nested_key.id, .Literal); + try testing.expect(mem.eql( + u8, + "key1_2", + tree.source[nested_key.start..nested_key.end], + )); + + const nested_value = nested_entry.value.cast(Node.Value).?; + const nested_value_tok = tree.tokens[nested_value.start.?]; + try testing.expectEqual(nested_value_tok.id, .Literal); + try testing.expect(mem.eql( + u8, + "value1_2", + tree.source[nested_value_tok.start..nested_value_tok.end], + )); + } + } + + { + const entry = map.values.items[1]; + + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "key2", tree.source[key.start..key.end])); + + const value = entry.value.cast(Node.Value).?; + const value_tok = tree.tokens[value.start.?]; + try testing.expectEqual(value_tok.id, .Literal); + try testing.expect(mem.eql( + u8, + "value2", + tree.source[value_tok.start..value_tok.end], + )); + } +} + +test "map of list of values" { + const source = + \\ints: + \\ - 0 + \\ - 1 + \\ - 2 + ; + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 0); + try testing.expectEqual(map.end.?, tree.tokens.len - 2); + try testing.expectEqual(map.values.items.len, 1); + + const entry = map.values.items[0]; + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "ints", tree.source[key.start..key.end])); + + const value = entry.value.cast(Node.List).?; + try testing.expectEqual(value.start.?, 4); + try testing.expectEqual(value.end.?, tree.tokens.len - 2); + try testing.expectEqual(value.values.items.len, 3); + + { + const elem = value.values.items[0].cast(Node.Value).?; + const leaf = tree.tokens[elem.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "0", tree.source[leaf.start..leaf.end])); + } + + { + const elem = value.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[elem.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "1", tree.source[leaf.start..leaf.end])); + } + + { + const elem = value.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[elem.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "2", tree.source[leaf.start..leaf.end])); + } +} + +test "map of list of maps" { + const source = + \\key1: + \\- key2 : value2 + \\- key3 : value3 + \\- key4 : value4 + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 0); + try testing.expectEqual(map.end.?, tree.tokens.len - 2); + try testing.expectEqual(map.values.items.len, 1); + + const entry = map.values.items[0]; + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "key1", tree.source[key.start..key.end])); + + const value = entry.value.cast(Node.List).?; + try testing.expectEqual(value.start.?, 3); + try testing.expectEqual(value.end.?, tree.tokens.len - 2); + try testing.expectEqual(value.values.items.len, 3); + + { + const elem = value.values.items[0].cast(Node.Map).?; + const nested = elem.values.items[0]; + const nested_key = tree.tokens[nested.key]; + try testing.expectEqual(nested_key.id, .Literal); + try testing.expect(mem.eql(u8, "key2", tree.source[nested_key.start..nested_key.end])); + + const nested_v = nested.value.cast(Node.Value).?; + const leaf = tree.tokens[nested_v.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "value2", tree.source[leaf.start..leaf.end])); + } + + { + const elem = value.values.items[1].cast(Node.Map).?; + const nested = elem.values.items[0]; + const nested_key = tree.tokens[nested.key]; + try testing.expectEqual(nested_key.id, .Literal); + try testing.expect(mem.eql(u8, "key3", tree.source[nested_key.start..nested_key.end])); + + const nested_v = nested.value.cast(Node.Value).?; + const leaf = tree.tokens[nested_v.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "value3", tree.source[leaf.start..leaf.end])); + } + + { + const elem = value.values.items[2].cast(Node.Map).?; + const nested = elem.values.items[0]; + const nested_key = tree.tokens[nested.key]; + try testing.expectEqual(nested_key.id, .Literal); + try testing.expect(mem.eql(u8, "key4", tree.source[nested_key.start..nested_key.end])); + + const nested_v = nested.value.cast(Node.Value).?; + const leaf = tree.tokens[nested_v.start.?]; + try testing.expectEqual(leaf.id, .Literal); + try testing.expect(mem.eql(u8, "value4", tree.source[leaf.start..leaf.end])); + } +} + +test "list of lists" { + const source = + \\- [name , hr, avg ] + \\- [Mark McGwire , 65, 0.278] + \\- [Sammy Sosa , 63, 0.288] + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .list); + + const list = doc.value.?.cast(Node.List).?; + try testing.expectEqual(list.start.?, 0); + try testing.expectEqual(list.end.?, tree.tokens.len - 2); + try testing.expectEqual(list.values.items.len, 3); + + { + try testing.expectEqual(list.values.items[0].tag, .list); + const nested = list.values.items[0].cast(Node.List).?; + try testing.expectEqual(nested.values.items.len, 3); + + { + try testing.expectEqual(nested.values.items[0].tag, .value); + const value = nested.values.items[0].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(nested.values.items[1].tag, .value); + const value = nested.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(nested.values.items[2].tag, .value); + const value = nested.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end])); + } + } + + { + try testing.expectEqual(list.values.items[1].tag, .list); + const nested = list.values.items[1].cast(Node.List).?; + try testing.expectEqual(nested.values.items.len, 3); + + { + try testing.expectEqual(nested.values.items[0].tag, .value); + const value = nested.values.items[0].cast(Node.Value).?; + const start = tree.tokens[value.start.?]; + const end = tree.tokens[value.end.?]; + try testing.expect(mem.eql(u8, "Mark McGwire", tree.source[start.start..end.end])); + } + + { + try testing.expectEqual(nested.values.items[1].tag, .value); + const value = nested.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "65", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(nested.values.items[2].tag, .value); + const value = nested.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "0.278", tree.source[leaf.start..leaf.end])); + } + } + + { + try testing.expectEqual(list.values.items[2].tag, .list); + const nested = list.values.items[2].cast(Node.List).?; + try testing.expectEqual(nested.values.items.len, 3); + + { + try testing.expectEqual(nested.values.items[0].tag, .value); + const value = nested.values.items[0].cast(Node.Value).?; + const start = tree.tokens[value.start.?]; + const end = tree.tokens[value.end.?]; + try testing.expect(mem.eql(u8, "Sammy Sosa", tree.source[start.start..end.end])); + } + + { + try testing.expectEqual(nested.values.items[1].tag, .value); + const value = nested.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "63", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(nested.values.items[2].tag, .value); + const value = nested.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "0.288", tree.source[leaf.start..leaf.end])); + } + } +} + +test "inline list" { + const source = + \\[name , hr, avg ] + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .list); + + const list = doc.value.?.cast(Node.List).?; + try testing.expectEqual(list.start.?, 0); + try testing.expectEqual(list.end.?, tree.tokens.len - 2); + try testing.expectEqual(list.values.items.len, 3); + + { + try testing.expectEqual(list.values.items[0].tag, .value); + const value = list.values.items[0].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(list.values.items[1].tag, .value); + const value = list.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(list.values.items[2].tag, .value); + const value = list.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end])); + } +} + +test "inline list as mapping value" { + const source = + \\key : [ + \\ name , + \\ hr, avg ] + ; + + var tree = Tree.init(testing.allocator); + defer tree.deinit(); + try tree.parse(source); + + try testing.expectEqual(tree.docs.items.len, 1); + + const doc = tree.docs.items[0].cast(Node.Doc).?; + try testing.expectEqual(doc.start.?, 0); + try testing.expectEqual(doc.end.?, tree.tokens.len - 2); + + try testing.expect(doc.value != null); + try testing.expectEqual(doc.value.?.tag, .map); + + const map = doc.value.?.cast(Node.Map).?; + try testing.expectEqual(map.start.?, 0); + try testing.expectEqual(map.end.?, tree.tokens.len - 2); + try testing.expectEqual(map.values.items.len, 1); + + const entry = map.values.items[0]; + const key = tree.tokens[entry.key]; + try testing.expectEqual(key.id, .Literal); + try testing.expect(mem.eql(u8, "key", tree.source[key.start..key.end])); + + const list = entry.value.cast(Node.List).?; + try testing.expectEqual(list.start.?, 4); + try testing.expectEqual(list.end.?, tree.tokens.len - 2); + try testing.expectEqual(list.values.items.len, 3); + + { + try testing.expectEqual(list.values.items[0].tag, .value); + const value = list.values.items[0].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "name", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(list.values.items[1].tag, .value); + const value = list.values.items[1].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "hr", tree.source[leaf.start..leaf.end])); + } + + { + try testing.expectEqual(list.values.items[2].tag, .value); + const value = list.values.items[2].cast(Node.Value).?; + const leaf = tree.tokens[value.start.?]; + try testing.expect(mem.eql(u8, "avg", tree.source[leaf.start..leaf.end])); + } +} diff --git a/src/link/tapi/yaml.zig b/src/link/tapi/yaml.zig new file mode 100644 index 0000000000..b58df7609f --- /dev/null +++ b/src/link/tapi/yaml.zig @@ -0,0 +1,651 @@ +const std = @import("std"); +const assert = std.debug.assert; +const math = std.math; +const mem = std.mem; +const testing = std.testing; +const log = std.log.scoped(.tapi); + +const Allocator = mem.Allocator; +const ArenaAllocator = std.heap.ArenaAllocator; + +pub const Tokenizer = @import("Tokenizer.zig"); +pub const parse = @import("parse.zig"); + +const Node = parse.Node; +const Tree = parse.Tree; +const ParseError = parse.ParseError; + +pub const YamlError = error{ + UnexpectedNodeType, + OutOfMemory, +} || ParseError || std.fmt.ParseIntError; + +pub const ValueType = enum { + empty, + int, + float, + string, + list, + map, +}; + +pub const List = []Value; +pub const Map = std.StringArrayHashMap(Value); + +pub const Value = union(ValueType) { + empty, + int: i64, + float: f64, + string: []const u8, + list: List, + map: Map, + + pub fn asInt(self: Value) !i64 { + if (self != .int) return error.TypeMismatch; + return self.int; + } + + pub fn asFloat(self: Value) !f64 { + if (self != .float) return error.TypeMismatch; + return self.float; + } + + pub fn asString(self: Value) ![]const u8 { + if (self != .string) return error.TypeMismatch; + return self.string; + } + + pub fn asList(self: Value) !List { + if (self != .list) return error.TypeMismatch; + return self.list; + } + + pub fn asMap(self: Value) !Map { + if (self != .map) return error.TypeMismatch; + return self.map; + } + + const StringifyArgs = struct { + indentation: usize = 0, + should_inline_first_key: bool = false, + }; + + pub const StringifyError = std.os.WriteError; + + pub fn stringify(self: Value, writer: anytype, args: StringifyArgs) StringifyError!void { + switch (self) { + .empty => return, + .int => |int| return writer.print("{}", .{int}), + .float => |float| return writer.print("{d}", .{float}), + .string => |string| return writer.print("{s}", .{string}), + .list => |list| { + const len = list.len; + if (len == 0) return; + + const first = list[0]; + if (first.is_compound()) { + for (list) |elem, i| { + try writer.writeByteNTimes(' ', args.indentation); + try writer.writeAll("- "); + try elem.stringify(writer, .{ + .indentation = args.indentation + 2, + .should_inline_first_key = true, + }); + if (i < len - 1) { + try writer.writeByte('\n'); + } + } + return; + } + + try writer.writeAll("[ "); + for (list) |elem, i| { + try elem.stringify(writer, args); + if (i < len - 1) { + try writer.writeAll(", "); + } + } + try writer.writeAll(" ]"); + }, + .map => |map| { + const keys = map.keys(); + const len = keys.len; + if (len == 0) return; + + for (keys) |key, i| { + if (!args.should_inline_first_key or i != 0) { + try writer.writeByteNTimes(' ', args.indentation); + } + try writer.print("{s}: ", .{key}); + + const value = map.get(key) orelse unreachable; + const should_inline = blk: { + if (!value.is_compound()) break :blk true; + if (value == .list and value.list.len > 0 and !value.list[0].is_compound()) break :blk true; + break :blk false; + }; + + if (should_inline) { + try value.stringify(writer, args); + } else { + try writer.writeByte('\n'); + try value.stringify(writer, .{ + .indentation = args.indentation + 4, + }); + } + + if (i < len - 1) { + try writer.writeByte('\n'); + } + } + }, + } + } + + fn is_compound(self: Value) bool { + return switch (self) { + .list, .map => true, + else => false, + }; + } + + fn fromNode(arena: *Allocator, tree: *const Tree, node: *const Node, type_hint: ?ValueType) YamlError!Value { + if (node.cast(Node.Doc)) |doc| { + const inner = doc.value orelse { + // empty doc + return Value{ .empty = .{} }; + }; + return Value.fromNode(arena, tree, inner, null); + } else if (node.cast(Node.Map)) |map| { + var out_map = std.StringArrayHashMap(Value).init(arena); + try out_map.ensureUnusedCapacity(map.values.items.len); + + for (map.values.items) |entry| { + const key_tok = tree.tokens[entry.key]; + const key = try arena.dupe(u8, tree.source[key_tok.start..key_tok.end]); + const value = try Value.fromNode(arena, tree, entry.value, null); + + out_map.putAssumeCapacityNoClobber(key, value); + } + + return Value{ .map = out_map }; + } else if (node.cast(Node.List)) |list| { + var out_list = std.ArrayList(Value).init(arena); + try out_list.ensureUnusedCapacity(list.values.items.len); + + if (list.values.items.len > 0) { + const hint = if (list.values.items[0].cast(Node.Value)) |value| hint: { + const start = tree.tokens[value.start.?]; + const end = tree.tokens[value.end.?]; + const raw = tree.source[start.start..end.end]; + _ = std.fmt.parseInt(i64, raw, 10) catch { + _ = std.fmt.parseFloat(f64, raw) catch { + break :hint ValueType.string; + }; + break :hint ValueType.float; + }; + break :hint ValueType.int; + } else null; + + for (list.values.items) |elem| { + const value = try Value.fromNode(arena, tree, elem, hint); + out_list.appendAssumeCapacity(value); + } + } + + return Value{ .list = out_list.toOwnedSlice() }; + } else if (node.cast(Node.Value)) |value| { + const start = tree.tokens[value.start.?]; + const end = tree.tokens[value.end.?]; + const raw = tree.source[start.start..end.end]; + + if (type_hint) |hint| { + return switch (hint) { + .int => Value{ .int = try std.fmt.parseInt(i64, raw, 10) }, + .float => Value{ .float = try std.fmt.parseFloat(f64, raw) }, + .string => Value{ .string = try arena.dupe(u8, raw) }, + else => unreachable, + }; + } + + try_int: { + // TODO infer base for int + const int = std.fmt.parseInt(i64, raw, 10) catch break :try_int; + return Value{ .int = int }; + } + try_float: { + const float = std.fmt.parseFloat(f64, raw) catch break :try_float; + return Value{ .float = float }; + } + return Value{ .string = try arena.dupe(u8, raw) }; + } else { + log.err("Unexpected node type: {}", .{node.tag}); + return error.UnexpectedNodeType; + } + } +}; + +pub const Yaml = struct { + arena: ArenaAllocator, + tree: ?Tree = null, + docs: std.ArrayList(Value), + + pub fn deinit(self: *Yaml) void { + self.arena.deinit(); + } + + pub fn stringify(self: Yaml, writer: anytype) !void { + for (self.docs.items) |doc| { + // if (doc.directive) |directive| { + // try writer.print("--- !{s}\n", .{directive}); + // } + try doc.stringify(writer, .{}); + // if (doc.directive != null) { + // try writer.writeAll("...\n"); + // } + } + } + + pub fn load(allocator: *Allocator, source: []const u8) !Yaml { + var arena = ArenaAllocator.init(allocator); + + var tree = Tree.init(&arena.allocator); + try tree.parse(source); + + var docs = std.ArrayList(Value).init(&arena.allocator); + try docs.ensureUnusedCapacity(tree.docs.items.len); + + for (tree.docs.items) |node| { + const value = try Value.fromNode(&arena.allocator, &tree, node, null); + docs.appendAssumeCapacity(value); + } + + return Yaml{ + .arena = arena, + .tree = tree, + .docs = docs, + }; + } + + pub const Error = error{ + Unimplemented, + TypeMismatch, + StructFieldMissing, + ArraySizeMismatch, + UntaggedUnion, + UnionTagMissing, + Overflow, + OutOfMemory, + }; + + pub fn parse(self: *Yaml, comptime T: type) Error!T { + if (self.docs.items.len == 0) { + if (@typeInfo(T) == .Void) return {}; + return error.TypeMismatch; + } + + if (self.docs.items.len == 1) { + return self.parseValue(T, self.docs.items[0]); + } + + switch (@typeInfo(T)) { + .Array => |info| { + var parsed: T = undefined; + for (self.docs.items) |doc, i| { + parsed[i] = try self.parseValue(info.child, doc); + } + return parsed; + }, + .Pointer => |info| { + switch (info.size) { + .Slice => { + var parsed = try self.arena.allocator.alloc(info.child, self.docs.items.len); + for (self.docs.items) |doc, i| { + parsed[i] = try self.parseValue(info.child, doc); + } + return parsed; + }, + else => return error.TypeMismatch, + } + }, + .Union => return error.Unimplemented, + else => return error.TypeMismatch, + } + } + + fn parseValue(self: *Yaml, comptime T: type, value: Value) Error!T { + return switch (@typeInfo(T)) { + .Int => math.cast(T, try value.asInt()), + .Float => math.lossyCast(T, try value.asFloat()), + .Struct => self.parseStruct(T, try value.asMap()), + .Union => self.parseUnion(T, value), + .Array => self.parseArray(T, try value.asList()), + .Pointer => { + if (value.asList()) |list| { + return self.parsePointer(T, .{ .list = list }); + } else |_| { + return self.parsePointer(T, .{ .string = try value.asString() }); + } + }, + .Void => error.TypeMismatch, + .Optional => unreachable, + else => error.Unimplemented, + }; + } + + fn parseUnion(self: *Yaml, comptime T: type, value: Value) Error!T { + const union_info = @typeInfo(T).Union; + + if (union_info.tag_type) |_| { + inline for (union_info.fields) |field| { + if (self.parseValue(field.field_type, value)) |u_value| { + return @unionInit(T, field.name, u_value); + } else |err| { + if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err; + } + } + } else return error.UntaggedUnion; + + return error.UnionTagMissing; + } + + fn parseOptional(self: *Yaml, comptime T: type, value: ?Value) Error!T { + const unwrapped = value orelse return null; + const opt_info = @typeInfo(T).Optional; + return @as(T, try self.parseValue(opt_info.child, unwrapped)); + } + + fn parseStruct(self: *Yaml, comptime T: type, map: Map) Error!T { + const struct_info = @typeInfo(T).Struct; + var parsed: T = undefined; + + inline for (struct_info.fields) |field| { + const value: ?Value = map.get(field.name) orelse blk: { + const field_name = try mem.replaceOwned(u8, &self.arena.allocator, field.name, "_", "-"); + break :blk map.get(field_name); + }; + + if (@typeInfo(field.field_type) == .Optional) { + @field(parsed, field.name) = try self.parseOptional(field.field_type, value); + continue; + } + + const unwrapped = value orelse { + log.err("missing struct field: {s}: {s}", .{ field.name, @typeName(field.field_type) }); + return error.StructFieldMissing; + }; + @field(parsed, field.name) = try self.parseValue(field.field_type, unwrapped); + } + + return parsed; + } + + fn parsePointer(self: *Yaml, comptime T: type, value: Value) Error!T { + const ptr_info = @typeInfo(T).Pointer; + const arena = &self.arena.allocator; + + switch (ptr_info.size) { + .Slice => { + const child_info = @typeInfo(ptr_info.child); + if (child_info == .Int and child_info.Int.bits == 8) { + return value.asString(); + } + + var parsed = try arena.alloc(ptr_info.child, value.list.len); + for (value.list) |elem, i| { + parsed[i] = try self.parseValue(ptr_info.child, elem); + } + return parsed; + }, + else => return error.Unimplemented, + } + } + + fn parseArray(self: *Yaml, comptime T: type, list: List) Error!T { + const array_info = @typeInfo(T).Array; + if (array_info.len != list.len) return error.ArraySizeMismatch; + + var parsed: T = undefined; + for (list) |elem, i| { + parsed[i] = try self.parseValue(array_info.child, elem); + } + + return parsed; + } +}; + +test { + testing.refAllDecls(@This()); +} + +test "simple list" { + const source = + \\- a + \\- b + \\- c + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectEqual(yaml.docs.items.len, 1); + + const list = yaml.docs.items[0].list; + try testing.expectEqual(list.len, 3); + + try testing.expect(mem.eql(u8, list[0].string, "a")); + try testing.expect(mem.eql(u8, list[1].string, "b")); + try testing.expect(mem.eql(u8, list[2].string, "c")); +} + +test "simple list typed as array of strings" { + const source = + \\- a + \\- b + \\- c + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectEqual(yaml.docs.items.len, 1); + + const arr = try yaml.parse([3][]const u8); + try testing.expectEqual(arr.len, 3); + try testing.expect(mem.eql(u8, arr[0], "a")); + try testing.expect(mem.eql(u8, arr[1], "b")); + try testing.expect(mem.eql(u8, arr[2], "c")); +} + +test "simple list typed as array of ints" { + const source = + \\- 0 + \\- 1 + \\- 2 + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectEqual(yaml.docs.items.len, 1); + + const arr = try yaml.parse([3]u8); + try testing.expectEqual(arr.len, 3); + try testing.expectEqual(arr[0], 0); + try testing.expectEqual(arr[1], 1); + try testing.expectEqual(arr[2], 2); +} + +test "list of mixed sign integer" { + const source = + \\- 0 + \\- -1 + \\- 2 + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectEqual(yaml.docs.items.len, 1); + + const arr = try yaml.parse([3]i8); + try testing.expectEqual(arr.len, 3); + try testing.expectEqual(arr[0], 0); + try testing.expectEqual(arr[1], -1); + try testing.expectEqual(arr[2], 2); +} + +test "simple map untyped" { + const source = + \\a: 0 + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectEqual(yaml.docs.items.len, 1); + + const map = yaml.docs.items[0].map; + try testing.expect(map.contains("a")); + try testing.expectEqual(map.get("a").?.int, 0); +} + +test "simple map typed" { + const source = + \\a: 0 + \\b: hello there + \\c: 'wait, what?' + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + const simple = try yaml.parse(struct { a: usize, b: []const u8, c: []const u8 }); + try testing.expectEqual(simple.a, 0); + try testing.expect(mem.eql(u8, simple.b, "hello there")); + try testing.expect(mem.eql(u8, simple.c, "wait, what?")); +} + +test "typed nested structs" { + const source = + \\a: + \\ b: hello there + \\ c: 'wait, what?' + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + const simple = try yaml.parse(struct { + a: struct { + b: []const u8, + c: []const u8, + }, + }); + try testing.expect(mem.eql(u8, simple.a.b, "hello there")); + try testing.expect(mem.eql(u8, simple.a.c, "wait, what?")); +} + +test "multidoc typed as a slice of structs" { + const source = + \\--- + \\a: 0 + \\--- + \\a: 1 + \\... + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + { + const result = try yaml.parse([2]struct { a: usize }); + try testing.expectEqual(result.len, 2); + try testing.expectEqual(result[0].a, 0); + try testing.expectEqual(result[1].a, 1); + } + + { + const result = try yaml.parse([]struct { a: usize }); + try testing.expectEqual(result.len, 2); + try testing.expectEqual(result[0].a, 0); + try testing.expectEqual(result[1].a, 1); + } +} + +test "multidoc typed as a struct is an error" { + const source = + \\--- + \\a: 0 + \\--- + \\b: 1 + \\... + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize })); + try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { b: usize })); + try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(struct { a: usize, b: usize })); +} + +test "multidoc typed as a slice of structs with optionals" { + const source = + \\--- + \\a: 0 + \\c: 1.0 + \\--- + \\a: 1 + \\b: different field + \\... + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + const result = try yaml.parse([]struct { a: usize, b: ?[]const u8, c: ?f16 }); + try testing.expectEqual(result.len, 2); + + try testing.expectEqual(result[0].a, 0); + try testing.expect(result[0].b == null); + try testing.expect(result[0].c != null); + try testing.expectEqual(result[0].c.?, 1.0); + + try testing.expectEqual(result[1].a, 1); + try testing.expect(result[1].b != null); + try testing.expect(mem.eql(u8, result[1].b.?, "different field")); + try testing.expect(result[1].c == null); +} + +test "empty yaml can be represented as void" { + const source = ""; + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + const result = try yaml.parse(void); + try testing.expect(@TypeOf(result) == void); +} + +test "nonempty yaml cannot be represented as void" { + const source = + \\a: b + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectError(Yaml.Error.TypeMismatch, yaml.parse(void)); +} + +test "typed array size mismatch" { + const source = + \\- 0 + \\- 0 + ; + + var yaml = try Yaml.load(testing.allocator, source); + defer yaml.deinit(); + + try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([1]usize)); + try testing.expectError(Yaml.Error.ArraySizeMismatch, yaml.parse([5]usize)); +} diff --git a/src/main.zig b/src/main.zig index c592653e24..86995c5b9f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -290,6 +290,7 @@ const usage_build_generic = \\ .c C source code (requires LLVM extensions) \\ .cpp C++ source code (requires LLVM extensions) \\ Other C++ extensions: .C .cc .cxx + \\ .m Objective-C source code (requires LLVM extensions) \\ \\General Options: \\ -h, --help Print this help and exit @@ -378,6 +379,7 @@ const usage_build_generic = \\ -T[script], --script [script] Use a custom linker script \\ --version-script [path] Provide a version .map file \\ --dynamic-linker [path] Set the dynamic interpreter path (usually ld.so) + \\ --sysroot [path] Set the system root directory (usually /) \\ --version [ver] Dynamic library semver \\ -fsoname[=name] (Linux) Override the default SONAME value \\ -fno-soname (Linux) Disable emitting a SONAME @@ -500,7 +502,7 @@ const Emit = union(enum) { }; fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool { - if (std.process.getEnvVarOwned(arena, name)) |value| { + if (std.process.getEnvVarOwned(arena, name)) |_| { return true; } else |err| switch (err) { error.EnvironmentVariableNotFound => return false, @@ -603,6 +605,7 @@ fn buildOutputType( var link_eh_frame_hdr = false; var link_emit_relocs = false; var each_lib_rpath: ?bool = null; + var sysroot: ?[]const u8 = null; var libc_paths_file: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LIBC"); var machine_code_model: std.builtin.CodeModel = .default; var runtime_args_start: ?usize = null; @@ -864,6 +867,10 @@ fn buildOutputType( if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg}); i += 1; target_dynamic_linker = args[i]; + } else if (mem.eql(u8, arg, "--sysroot")) { + if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg}); + i += 1; + sysroot = args[i]; } else if (mem.eql(u8, arg, "--libc")) { if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg}); i += 1; @@ -1072,7 +1079,7 @@ fn buildOutputType( .object, .static_library, .shared_library => { try link_objects.append(arg); }, - .assembly, .c, .cpp, .h, .ll, .bc => { + .assembly, .c, .cpp, .h, .ll, .bc, .m => { try c_source_files.append(.{ .src_path = arg, .extra_flags = try arena.dupe([]const u8, extra_cflags.items), @@ -1135,7 +1142,7 @@ fn buildOutputType( .positional => { const file_ext = Compilation.classifyFileExt(mem.spanZ(it.only_arg)); switch (file_ext) { - .assembly, .c, .cpp, .ll, .bc, .h => try c_source_files.append(.{ .src_path = it.only_arg }), + .assembly, .c, .cpp, .ll, .bc, .h, .m => try c_source_files.append(.{ .src_path = it.only_arg }), .unknown, .shared_library, .object, .static_library => { try link_objects.append(it.only_arg); }, @@ -1640,7 +1647,9 @@ fn buildOutputType( want_native_include_dirs = true; } - if (cross_target.isNativeOs() and (system_libs.items.len != 0 or want_native_include_dirs)) { + if (sysroot == null and cross_target.isNativeOs() and + (system_libs.items.len != 0 or want_native_include_dirs)) + { const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| { fatal("unable to detect native system paths: {s}", .{@errorName(err)}); }; @@ -1917,6 +1926,7 @@ fn buildOutputType( .is_native_os = cross_target.isNativeOs(), .is_native_abi = cross_target.isNativeAbi(), .dynamic_linker = target_info.dynamic_linker.get(), + .sysroot = sysroot, .output_mode = output_mode, .root_pkg = root_pkg, .emit_bin = emit_bin_loc, @@ -2565,6 +2575,7 @@ pub fn cmdInit( args: []const []const u8, output_mode: std.builtin.OutputMode, ) !void { + _ = gpa; { var i: usize = 0; while (i < args.len) : (i += 1) { @@ -2960,7 +2971,6 @@ const Fmt = struct { }; pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { - const stderr_file = io.getStdErr(); var color: Color = .auto; var stdin_flag: bool = false; var check_flag: bool = false; @@ -3018,9 +3028,52 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { defer tree.deinit(gpa); for (tree.errors) |parse_error| { - try printErrMsgToFile(gpa, parse_error, tree, "<stdin>", stderr_file, color); + try printErrMsgToStdErr(gpa, parse_error, tree, "<stdin>", color); + } + var has_ast_error = false; + if (check_ast_flag) { + const Module = @import("Module.zig"); + const AstGen = @import("AstGen.zig"); + + var file: Module.Scope.File = .{ + .status = .never_loaded, + .source_loaded = true, + .zir_loaded = false, + .sub_file_path = "<stdin>", + .source = source_code, + .stat_size = undefined, + .stat_inode = undefined, + .stat_mtime = undefined, + .tree = tree, + .tree_loaded = true, + .zir = undefined, + .pkg = undefined, + .root_decl = null, + }; + + file.zir = try AstGen.generate(gpa, file.tree); + file.zir_loaded = true; + defer file.zir.deinit(gpa); + + if (file.zir.hasCompileErrors()) { + var arena_instance = std.heap.ArenaAllocator.init(gpa); + defer arena_instance.deinit(); + var errors = std.ArrayList(Compilation.AllErrors.Message).init(gpa); + defer errors.deinit(); + + try Compilation.AllErrors.addZir(&arena_instance.allocator, &errors, &file); + const ttyconf: std.debug.TTY.Config = switch (color) { + .auto => std.debug.detectTTYConfig(), + .on => .escape_codes, + .off => .no_color, + }; + for (errors.items) |full_err_msg| { + full_err_msg.renderToStdErr(ttyconf); + } + has_ast_error = true; + } } - if (tree.errors.len != 0) { + if (tree.errors.len != 0 or has_ast_error) { process.exit(1); } const formatted = try tree.render(gpa); @@ -3163,7 +3216,7 @@ fn fmtPathFile( defer tree.deinit(fmt.gpa); for (tree.errors) |parse_error| { - try printErrMsgToFile(fmt.gpa, parse_error, tree, file_path, std.io.getStdErr(), fmt.color); + try printErrMsgToStdErr(fmt.gpa, parse_error, tree, file_path, fmt.color); } if (tree.errors.len != 0) { fmt.any_error = true; @@ -3239,25 +3292,16 @@ fn fmtPathFile( } } -fn printErrMsgToFile( +fn printErrMsgToStdErr( gpa: *mem.Allocator, parse_error: ast.Error, tree: ast.Tree, path: []const u8, - file: fs.File, color: Color, ) !void { - const color_on = switch (color) { - .auto => file.isTty(), - .on => true, - .off => false, - }; const lok_token = parse_error.token; - - const token_starts = tree.tokens.items(.start); - const token_tags = tree.tokens.items(.tag); - const first_token_start = token_starts[lok_token]; const start_loc = tree.tokenLocation(0, lok_token); + const source_line = tree.source[start_loc.line_start..start_loc.line_end]; var text_buf = std.ArrayList(u8).init(gpa); defer text_buf.deinit(); @@ -3265,26 +3309,24 @@ fn printErrMsgToFile( try tree.renderError(parse_error, writer); const text = text_buf.items; - const stream = file.writer(); - try stream.print("{s}:{d}:{d}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text }); + const message: Compilation.AllErrors.Message = .{ + .src = .{ + .src_path = path, + .msg = text, + .byte_offset = @intCast(u32, start_loc.line_start), + .line = @intCast(u32, start_loc.line), + .column = @intCast(u32, start_loc.column), + .source_line = source_line, + }, + }; - if (!color_on) return; + const ttyconf: std.debug.TTY.Config = switch (color) { + .auto => std.debug.detectTTYConfig(), + .on => .escape_codes, + .off => .no_color, + }; - // Print \r and \t as one space each so that column counts line up - for (tree.source[start_loc.line_start..start_loc.line_end]) |byte| { - try stream.writeByte(switch (byte) { - '\r', '\t' => ' ', - else => byte, - }); - } - try stream.writeByte('\n'); - try stream.writeByteNTimes(' ', start_loc.column); - if (token_tags[lok_token].lexeme()) |lexeme| { - try stream.writeByteNTimes('~', lexeme.len); - try stream.writeByte('\n'); - } else { - try stream.writeAll("^\n"); - } + message.renderToStdErr(ttyconf); } pub const info_zen = @@ -3718,7 +3760,6 @@ pub fn cmdAstCheck( var color: Color = .auto; var want_output_text = false; - var have_zig_source_file = false; var zig_source_file: ?[]const u8 = null; var i: usize = 0; @@ -3800,7 +3841,7 @@ pub fn cmdAstCheck( defer file.tree.deinit(gpa); for (file.tree.errors) |parse_error| { - try printErrMsgToFile(gpa, parse_error, file.tree, file.sub_file_path, io.getStdErr(), color); + try printErrMsgToStdErr(gpa, parse_error, file.tree, file.sub_file_path, color); } if (file.tree.errors.len != 0) { process.exit(1); @@ -3921,7 +3962,7 @@ pub fn cmdChangelist( defer file.tree.deinit(gpa); for (file.tree.errors) |parse_error| { - try printErrMsgToFile(gpa, parse_error, file.tree, old_source_file, io.getStdErr(), .auto); + try printErrMsgToStdErr(gpa, parse_error, file.tree, old_source_file, .auto); } if (file.tree.errors.len != 0) { process.exit(1); @@ -3958,7 +3999,7 @@ pub fn cmdChangelist( defer new_tree.deinit(gpa); for (new_tree.errors) |parse_error| { - try printErrMsgToFile(gpa, parse_error, new_tree, new_source_file, io.getStdErr(), .auto); + try printErrMsgToStdErr(gpa, parse_error, new_tree, new_source_file, .auto); } if (new_tree.errors.len != 0) { process.exit(1); diff --git a/src/mingw.zig b/src/mingw.zig index ca887dd940..42d1ac47db 100644 --- a/src/mingw.zig +++ b/src/mingw.zig @@ -372,11 +372,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { try child.spawn(); - const stdout_reader = child.stdout.?.reader(); const stderr_reader = child.stderr.?.reader(); // 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); const term = child.wait() catch |err| { diff --git a/src/musl.zig b/src/musl.zig index 4f641a4c7c..fcdc503ccc 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -143,7 +143,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { const dirname = path.dirname(src_file).?; const basename = path.basename(src_file); const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len]; - const before_arch_dir = path.dirname(dirname).?; const dirbasename = path.basename(dirname); var is_arch_specific = false; diff --git a/src/print_env.zig b/src/print_env.zig index d62e1f62fd..8c44e85e65 100644 --- a/src/print_env.zig +++ b/src/print_env.zig @@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator; const fatal = @import("main.zig").fatal; pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void { + _ = args; const self_exe_path = try std.fs.selfExePathAlloc(gpa); defer gpa.free(self_exe_path); diff --git a/src/print_targets.zig b/src/print_targets.zig index e24a2294a1..d0a1d5167a 100644 --- a/src/print_targets.zig +++ b/src/print_targets.zig @@ -17,6 +17,7 @@ pub fn cmdTargets( stdout: anytype, native_target: Target, ) !void { + _ = args; var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| { fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)}); }; diff --git a/src/register_manager.zig b/src/register_manager.zig index 9f47526f13..96cf4f17b7 100644 --- a/src/register_manager.zig +++ b/src/register_manager.zig @@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type { } pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void { + _ = src; + _ = inst; try self.spilled.append(self.allocator, reg); } }; @@ -281,12 +283,6 @@ test "default state" { }; defer function.deinit(); - var mock_instruction = ir.Inst{ - .tag = .breakpoint, - .ty = Type.initTag(.void), - .src = .unneeded, - }; - try expect(!function.register_manager.isRegAllocated(.r2)); try expect(!function.register_manager.isRegAllocated(.r3)); try expect(function.register_manager.isRegFree(.r2)); @@ -365,12 +361,6 @@ test "tryAllocRegs" { }; defer function.deinit(); - var mock_instruction = ir.Inst{ - .tag = .breakpoint, - .ty = Type.initTag(.void), - .src = .unneeded, - }; - try expectEqual([_]MockRegister2{ .r0, .r1, .r2 }, function.register_manager.tryAllocRegs(3, .{ null, null, null }, &.{}).?); // Exceptions diff --git a/src/stage1.zig b/src/stage1.zig index 91e7cd8bed..46d70ea335 100644 --- a/src/stage1.zig +++ b/src/stage1.zig @@ -407,6 +407,8 @@ export fn stage2_add_link_lib( symbol_name_ptr: [*c]const u8, symbol_name_len: usize, ) ?[*:0]const u8 { + _ = symbol_name_len; + _ = symbol_name_ptr; const comp = @intToPtr(*Compilation, stage1.userdata); const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory"; const target = comp.getTarget(); diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index f83849d13b..3fb0cb55b7 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -6291,6 +6291,11 @@ ZigValue *create_const_str_lit(CodeGen *g, Buf *str) { return const_val; } +ZigValue *create_sentineled_str_lit(CodeGen *g, Buf *str, ZigValue *sentinel) { + ZigValue *array_val = create_const_str_lit(g, str)->data.x_ptr.data.ref.pointee; + return create_const_slice(g, array_val, 0, buf_len(str), true, sentinel); +} + void init_const_bigint(ZigValue *const_val, ZigType *type, const BigInt *bigint) { const_val->special = ConstValSpecialStatic; const_val->type = type; @@ -6444,12 +6449,12 @@ ZigValue *create_const_type(CodeGen *g, ZigType *type_value) { } void init_const_slice(CodeGen *g, ZigValue *const_val, ZigValue *array_val, - size_t start, size_t len, bool is_const) + size_t start, size_t len, bool is_const, ZigValue *sentinel) { assert(array_val->type->id == ZigTypeIdArray); - ZigType *ptr_type = get_pointer_to_type_extra(g, array_val->type->data.array.child_type, - is_const, false, PtrLenUnknown, 0, 0, 0, false); + ZigType *ptr_type = get_pointer_to_type_extra2(g, array_val->type->data.array.child_type, + is_const, false, PtrLenUnknown, 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); const_val->special = ConstValSpecialStatic; const_val->type = get_slice_type(g, ptr_type); @@ -6460,9 +6465,9 @@ void init_const_slice(CodeGen *g, ZigValue *const_val, ZigValue *array_val, init_const_usize(g, const_val->data.x_struct.fields[slice_len_index], len); } -ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const) { +ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const, ZigValue *sentinel) { ZigValue *const_val = g->pass1_arena->create<ZigValue>(); - init_const_slice(g, const_val, array_val, start, len, is_const); + init_const_slice(g, const_val, array_val, start, len, is_const, sentinel); return const_val; } diff --git a/src/stage1/analyze.hpp b/src/stage1/analyze.hpp index fee83ab7d0..5c232bf4b6 100644 --- a/src/stage1/analyze.hpp +++ b/src/stage1/analyze.hpp @@ -144,6 +144,7 @@ ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent); void init_const_str_lit(CodeGen *g, ZigValue *const_val, Buf *str, bool move_str); ZigValue *create_const_str_lit(CodeGen *g, Buf *str); +ZigValue *create_sentineled_str_lit(CodeGen *g, Buf *str, ZigValue *sentinel); void init_const_bigint(ZigValue *const_val, ZigType *type, const BigInt *bigint); ZigValue *create_const_bigint(CodeGen *g, ZigType *type, const BigInt *bigint); @@ -186,8 +187,8 @@ ZigValue *create_const_ptr_array(CodeGen *g, ZigValue *array_val, size_t elem_in bool is_const, PtrLen ptr_len); void init_const_slice(CodeGen *g, ZigValue *const_val, ZigValue *array_val, - size_t start, size_t len, bool is_const); -ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const); + size_t start, size_t len, bool is_const, ZigValue *sentinel); +ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const, ZigValue *sentinel); void init_const_null(ZigValue *const_val, ZigType *type); ZigValue *create_const_null(CodeGen *g, ZigType *type); diff --git a/src/stage1/astgen.cpp b/src/stage1/astgen.cpp index 118b920f58..b69cd480c6 100644 --- a/src/stage1/astgen.cpp +++ b/src/stage1/astgen.cpp @@ -4599,8 +4599,11 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode } case BuiltinFnIdShuffle: { + // Used for the type expr and the mask expr + Scope *comptime_scope = create_comptime_scope(ag->codegen, node, scope); + AstNode *arg0_node = node->data.fn_call_expr.params.at(0); - IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); + IrInstSrc *arg0_value = astgen_node(ag, arg0_node, comptime_scope); if (arg0_value == ag->codegen->invalid_inst_src) return arg0_value; @@ -4615,7 +4618,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode return arg2_value; AstNode *arg3_node = node->data.fn_call_expr.params.at(3); - IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); + IrInstSrc *arg3_value = astgen_node(ag, arg3_node, comptime_scope); if (arg3_value == ag->codegen->invalid_inst_src) return arg3_value; diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index d0ec853f06..9193391a36 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -1022,7 +1022,7 @@ static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) { Buf *buf_msg = panic_msg_buf(msg_id); ZigValue *array_val = create_const_str_lit(g, buf_msg)->data.x_ptr.data.ref.pointee; - init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true); + init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true, nullptr); render_const_val(g, val, ""); render_const_val_global(g, val, ""); @@ -9289,6 +9289,10 @@ static void init(CodeGen *g) { ZigLLVMSetModulePIELevel(g->module); } + if (g->code_model != CodeModelDefault) { + ZigLLVMSetModuleCodeModel(g->module, to_llvm_code_model(g)); + } + const char *target_specific_cpu_args = ""; const char *target_specific_features = ""; @@ -9424,7 +9428,7 @@ static void update_test_functions_builtin_decl(CodeGen *g) { ZigValue *name_field = this_val->data.x_struct.fields[0]; ZigValue *name_array_val = create_const_str_lit(g, &test_fn_entry->symbol_name)->data.x_ptr.data.ref.pointee; - init_const_slice(g, name_field, name_array_val, 0, buf_len(&test_fn_entry->symbol_name), true); + init_const_slice(g, name_field, name_array_val, 0, buf_len(&test_fn_entry->symbol_name), true, nullptr); ZigValue *fn_field = this_val->data.x_struct.fields[1]; fn_field->type = fn_type; @@ -9448,7 +9452,7 @@ static void update_test_functions_builtin_decl(CodeGen *g) { } report_errors_and_maybe_exit(g); - ZigValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true); + ZigValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true, nullptr); update_compile_var(g, buf_create_from_str("test_functions"), test_fn_slice); assert(g->test_runner_package != nullptr); diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 053eb87e62..2200e8380d 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -5190,7 +5190,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* sourc // undef_array->type = array_type; // IrInstGen *result = ir_const(ira, source_instr, wanted_type); - // init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false); + // init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false, nullptr); // result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutComptimeConst; // result->value->type = wanted_type; // return result; @@ -5217,7 +5217,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* sourc undef_array->type = array_type; IrInstGen *result = ir_const(ira, source_instr, wanted_type); - init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false); + init_const_slice(ira->codegen, result->value, undef_array, 0, 0, false, nullptr); result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutComptimeConst; result->value->type = wanted_type; return result; @@ -5230,7 +5230,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* sourc IrInstGen *result = ir_const(ira, source_instr, wanted_type); init_const_slice(ira->codegen, result->value, array_val, array_ptr_val->data.x_ptr.data.base_array.elem_index, - array_type->data.array.len, wanted_const); + array_type->data.array.len, wanted_const, nullptr); result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; result->value->type = wanted_type; return result; @@ -5243,7 +5243,7 @@ static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* sourc assert(array_ptr_val->type->id == ZigTypeIdPointer); IrInstGen *result = ir_const(ira, source_instr, wanted_type); - init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, wanted_const); + init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, wanted_const, nullptr); result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; result->value->type = wanted_type; return result; @@ -14449,7 +14449,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP } init_const_slice(ira->codegen, array_ptr_val, array_init_val, 0, actual_array_type->data.array.len, - false); + false, nullptr); array_ptr_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutInfer; } else { ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, @@ -16864,26 +16864,27 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa if (type_is_invalid(casted_value->value->type)) return ira->codegen->invalid_inst_gen; - ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, - true, false, PtrLenUnknown, 0, 0, 0, false); - ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); if (instr_is_comptime(casted_value)) { ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); if (val == nullptr) return ira->codegen->invalid_inst_gen; ErrorTableEntry *err = casted_value->value->data.x_err_set; if (!err->cached_error_name_val) { - ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; - err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); + err->cached_error_name_val = create_sentineled_str_lit( + ira->codegen, &err->name, + ira->codegen->intern.for_zero_byte()); } IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); - copy_const_val(ira->codegen, result->value, err->cached_error_name_val); - result->value->type = str_type; + result->value = err->cached_error_name_val; return result; } ira->codegen->generate_error_name_table = true; + ZigType *u8_ptr_type = get_pointer_to_type_extra2(ira->codegen, ira->codegen->builtin_types.entry_u8, + true, false, PtrLenUnknown, 0, 0, 0, false, + VECTOR_INDEX_NONE, nullptr, ira->codegen->intern.for_zero_byte()); + ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); return ir_build_err_name_gen(ira, &instruction->base.base, value, str_type); } @@ -16898,8 +16899,9 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc if (target_type->id == ZigTypeIdEnumLiteral) { IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); Buf *field_name = target->value->data.x_enum_literal; - ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); + result->value = create_sentineled_str_lit( + ira->codegen, field_name, + ira->codegen->intern.for_zero_byte()); return result; } @@ -16918,9 +16920,10 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc if (can_fold_enum_type(target_type)) { TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; - ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); - init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); + result->value = create_sentineled_str_lit( + ira->codegen, only_field->name, + ira->codegen->intern.for_zero_byte()); return result; } @@ -16936,16 +16939,17 @@ static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrc buf_sprintf("no tag by value %s", buf_ptr(int_buf))); return ira->codegen->invalid_inst_gen; } - ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); - init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); + result->value = create_sentineled_str_lit( + ira->codegen, field->name, + ira->codegen->intern.for_zero_byte()); return result; } - ZigType *u8_ptr_type = get_pointer_to_type_extra( + ZigType *u8_ptr_type = get_pointer_to_type_extra2( ira->codegen, ira->codegen->builtin_types.entry_u8, - true, false, PtrLenUnknown, - 0, 0, 0, false); + true, false, PtrLenUnknown, 0, 0, 0, false, + VECTOR_INDEX_NONE, nullptr, ira->codegen->intern.for_zero_byte()); ZigType *result_type = get_slice_type(ira->codegen, u8_ptr_type); return ir_build_tag_name_gen(ira, &instruction->base.base, target, result_type); } @@ -17249,7 +17253,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); declaration_array->data.x_array.special = ConstArraySpecialNone; declaration_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(declaration_count); - init_const_slice(ira->codegen, out_val, declaration_array, 0, declaration_count, false); + init_const_slice(ira->codegen, out_val, declaration_array, 0, declaration_count, false, nullptr); // Loop through the declarations and generate info. decl_it = decls_scope->decl_table.entry_iterator(); @@ -17272,7 +17276,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa ZigValue **inner_fields = alloc_const_vals_ptrs(ira->codegen, 3); ZigValue *name = create_const_str_lit(ira->codegen, curr_entry->key)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); + init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true, nullptr); inner_fields[1]->special = ConstValSpecialStatic; inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; inner_fields[1]->data.x_bool = curr_entry->value->visib_mod == VisibModPub; @@ -17368,7 +17372,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { ZigValue *slice_val = ira->codegen->pass1_arena->create<ZigValue>(); ZigValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, slice_val, lib_name, 0, buf_len(fn_node->lib_name), true); + init_const_slice(ira->codegen, slice_val, lib_name, 0, buf_len(fn_node->lib_name), true, nullptr); set_optional_payload(fn_decl_fields[5], slice_val); } else { set_optional_payload(fn_decl_fields[5], nullptr); @@ -17388,14 +17392,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa fn_arg_name_array->data.x_array.special = ConstArraySpecialNone; fn_arg_name_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); - init_const_slice(ira->codegen, fn_decl_fields[7], fn_arg_name_array, 0, fn_arg_count, false); + init_const_slice(ira->codegen, fn_decl_fields[7], fn_arg_name_array, 0, fn_arg_count, false, nullptr); for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index); ZigValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index]; ZigValue *arg_name = create_const_str_lit(ira->codegen, buf_create_from_str(arg_var->name))->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true); + init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true, nullptr); fn_arg_name_val->parent.id = ConstParentIdArray; fn_arg_name_val->parent.data.p_array.array_val = fn_arg_name_array; fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index; @@ -17531,7 +17535,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; ZigValue *name = create_const_str_lit(ira->codegen, enum_field->name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true); + init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true, nullptr); bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); @@ -17732,7 +17736,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy enum_field_array->data.x_array.special = ConstArraySpecialNone; enum_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(enum_field_count); - init_const_slice(ira->codegen, fields[2], enum_field_array, 0, enum_field_count, false); + init_const_slice(ira->codegen, fields[2], enum_field_array, 0, enum_field_count, false, nullptr); for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) { @@ -17785,7 +17789,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy error_array->data.x_array.special = ConstArraySpecialNone; error_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(error_count); - init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false); + init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false, nullptr); for (uint32_t error_index = 0; error_index < error_count; error_index++) { ErrorTableEntry *error = type_entry->data.error_set.errors[error_index]; ZigValue *error_val = &error_array->data.x_array.data.s_none.elements[error_index]; @@ -17800,7 +17804,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy name = error->cached_error_name_val; if (name == nullptr) name = create_const_str_lit(ira->codegen, &error->name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(&error->name), true); + init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(&error->name), true, nullptr); error_val->data.x_struct.fields = inner_fields; error_val->parent.id = ConstParentIdArray; @@ -17881,7 +17885,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy union_field_array->data.x_array.special = ConstArraySpecialNone; union_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(union_field_count); - init_const_slice(ira->codegen, fields[2], union_field_array, 0, union_field_count, false); + init_const_slice(ira->codegen, fields[2], union_field_array, 0, union_field_count, false, nullptr); for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) { TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index]; @@ -17902,7 +17906,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy bigint_init_unsigned(&inner_fields[2]->data.x_bigint, union_field->align); ZigValue *name = create_const_str_lit(ira->codegen, union_field->name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true); + init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true, nullptr); union_field_val->data.x_struct.fields = inner_fields; union_field_val->parent.id = ConstParentIdArray; @@ -17958,7 +17962,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy struct_field_array->data.x_array.special = ConstArraySpecialNone; struct_field_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(struct_field_count); - init_const_slice(ira->codegen, fields[1], struct_field_array, 0, struct_field_count, false); + init_const_slice(ira->codegen, fields[1], struct_field_array, 0, struct_field_count, false, nullptr); for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { TypeStructField *struct_field = type_entry->data.structure.fields[struct_field_index]; @@ -17994,7 +17998,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy bigint_init_unsigned(&inner_fields[4]->data.x_bigint, struct_field->align); ZigValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true); + init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true, nullptr); struct_field_val->data.x_struct.fields = inner_fields; struct_field_val->parent.id = ConstParentIdArray; @@ -18074,7 +18078,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy fn_arg_array->data.x_array.special = ConstArraySpecialNone; fn_arg_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); - init_const_slice(ira->codegen, fields[5], fn_arg_array, 0, fn_arg_count, false); + init_const_slice(ira->codegen, fields[5], fn_arg_array, 0, fn_arg_count, false, nullptr); for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; @@ -24150,7 +24154,7 @@ static IrInstGen *ir_analyze_instruction_src(IrAnalyze *ira, IrInstSrcSrc *instr RootStruct *root_struct = import->data.structure.root_struct; Buf *path = root_struct->path; ZigValue *file_name = create_const_str_lit(ira->codegen, path)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, fields[0], file_name, 0, buf_len(path), true); + init_const_slice(ira->codegen, fields[0], file_name, 0, buf_len(path), true, nullptr); fields[0]->type = u8_slice; // fn_name: [:0]const u8 @@ -24158,7 +24162,7 @@ static IrInstGen *ir_analyze_instruction_src(IrAnalyze *ira, IrInstSrcSrc *instr fields[1]->special = ConstValSpecialStatic; ZigValue *fn_name = create_const_str_lit(ira->codegen, &fn_entry->symbol_name)->data.x_ptr.data.ref.pointee; - init_const_slice(ira->codegen, fields[1], fn_name, 0, buf_len(&fn_entry->symbol_name), true); + init_const_slice(ira->codegen, fields[1], fn_name, 0, buf_len(&fn_entry->symbol_name), true, nullptr); fields[1]->type = u8_slice; diff --git a/src/test.zig b/src/test.zig index a7f11d93df..1d2a552662 100644 --- a/src/test.zig +++ b/src/test.zig @@ -70,6 +70,8 @@ const ErrorMsg = union(enum) { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; switch (self) { .src => |src| { return writer.print("{s}:{d}:{d}: {s}: {s}", .{ @@ -592,6 +594,7 @@ pub const TestContext = struct { thread_pool: *ThreadPool, global_cache_directory: Compilation.Directory, ) !void { + _ = self; const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target); const target = target_info.target; diff --git a/src/tracy.zig b/src/tracy.zig index 6f56a87ce6..9ea15d721b 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct { }; pub const Ctx = if (enable) ___tracy_c_zone_context else struct { - pub fn end(self: Ctx) void {} + pub fn end(self: Ctx) void { + _ = self; + } }; pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { diff --git a/src/translate_c.zig b/src/translate_c.zig index 4b07618391..93ad4a421b 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -151,6 +151,12 @@ const Scope = struct { return true; return scope.base.parent.?.contains(name); } + + fn discardVariable(scope: *Block, c: *Context, name: []const u8) Error!void { + const name_node = try Tag.identifier.create(c.arena, name); + const discard = try Tag.discard.create(c.arena, name_node); + try scope.statements.append(discard); + } }; const Root = struct { @@ -206,6 +212,7 @@ const Scope = struct { } fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType { + _ = c; var scope = inner; while (true) { switch (scope.id) { @@ -601,7 +608,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { var scope = &block_scope.base; var param_id: c_uint = 0; - for (proto_node.data.params) |*param, i| { + for (proto_node.data.params) |*param| { const param_name = param.name orelse { proto_node.data.is_extern = true; proto_node.data.is_export = false; @@ -624,6 +631,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { const redecl_node = try Tag.arg_redecl.create(c.arena, .{ .actual = mangled_param_name, .mangled = arg_name }); try block_scope.statements.append(redecl_node); } + try block_scope.discardVariable(c, mangled_param_name); param_id += 1; } @@ -785,7 +793,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{ }); fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void { - if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const toplevel = scope.id == .root; const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; @@ -826,6 +834,7 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa try addTopLevelDecl(c, name, node); } else { try scope.appendNode(node); + try bs.discardVariable(c, name); } } @@ -935,7 +944,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool } fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void { - if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const record_loc = record_decl.getLocation(); const toplevel = scope.id == .root; @@ -1076,11 +1085,12 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD try c.alias_list.append(.{ .alias = bare_name, .name = name }); } else { try scope.appendNode(Node.initPayload(&payload.base)); + try bs.discardVariable(c, name); } } fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void { - if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const enum_loc = enum_decl.getLocation(); const toplevel = scope.id == .root; @@ -1099,27 +1109,39 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E } name = try std.fmt.allocPrint(c.arena, "enum_{s}", .{bare_name}); } - if (!toplevel) _ = try bs.makeMangledName(c, name); + if (!toplevel) name = try bs.makeMangledName(c, name); try c.decl_table.putNoClobber(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name); - const is_pub = toplevel and !is_unnamed; - var redecls = std.ArrayList(Tag.enum_redecl.Data()).init(c.gpa); - defer redecls.deinit(); - - const init_node = if (enum_decl.getDefinition()) |enum_def| blk: { - var pure_enum = true; + const enum_type_node = if (enum_decl.getDefinition()) |enum_def| blk: { var it = enum_def.enumerator_begin(); - var end_it = enum_def.enumerator_end(); + const end_it = enum_def.enumerator_end(); while (it.neq(end_it)) : (it = it.next()) { const enum_const = it.deref(); - if (enum_const.getInitExpr()) |_| { - pure_enum = false; - break; + var enum_val_name: []const u8 = try c.str(@ptrCast(*const clang.NamedDecl, enum_const).getName_bytes_begin()); + if (!toplevel) { + enum_val_name = try bs.makeMangledName(c, enum_val_name); } - } - var fields = std.ArrayList(ast.Payload.Enum.Field).init(c.gpa); - defer fields.deinit(); + const enum_const_qt = @ptrCast(*const clang.ValueDecl, enum_const).getType(); + const enum_const_loc = @ptrCast(*const clang.Decl, enum_const).getLocation(); + const enum_const_type_node: ?Node = transQualType(c, scope, enum_const_qt, enum_const_loc) catch |err| switch (err) { + error.UnsupportedType => null, + else => |e| return e, + }; + + const enum_const_def = try Tag.enum_constant.create(c.arena, .{ + .name = enum_val_name, + .is_public = toplevel, + .type = enum_const_type_node, + .value = try transCreateNodeAPInt(c, enum_const.getInitVal()), + }); + if (toplevel) + try addTopLevelDecl(c, enum_val_name, enum_const_def) + else { + try scope.appendNode(enum_const_def); + try bs.discardVariable(c, enum_val_name); + } + } const int_type = enum_decl.getIntegerType(); // The underlying type may be null in case of forward-declared enum @@ -1127,61 +1149,27 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E // default to the usual integer type used for all the enums. // default to c_int since msvc and gcc default to different types - const init_arg_expr = if (int_type.ptr != null) + break :blk if (int_type.ptr != null) transQualType(c, scope, int_type, enum_loc) catch |err| switch (err) { error.UnsupportedType => { - return failDecl(c, enum_loc, name, "unable to translate enum tag type", .{}); + return failDecl(c, enum_loc, name, "unable to translate enum integer type", .{}); }, else => |e| return e, } else try Tag.type.create(c.arena, "c_int"); - - it = enum_def.enumerator_begin(); - end_it = enum_def.enumerator_end(); - while (it.neq(end_it)) : (it = it.next()) { - const enum_const = it.deref(); - const enum_val_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_const).getName_bytes_begin()); - - const field_name = if (!is_unnamed and mem.startsWith(u8, enum_val_name, bare_name)) - enum_val_name[bare_name.len..] - else - enum_val_name; - - const int_node = if (!pure_enum) - try transCreateNodeAPInt(c, enum_const.getInitVal()) - else - null; - - try fields.append(.{ - .name = field_name, - .value = int_node, - }); - - // In C each enum value is in the global namespace. So we put them there too. - // At this point we can rely on the enum emitting successfully. - try redecls.append(.{ - .enum_val_name = enum_val_name, - .field_name = field_name, - .enum_name = name, - }); - } - - break :blk try Tag.@"enum".create(c.arena, .{ - .int_type = init_arg_expr, - .fields = try c.arena.dupe(ast.Payload.Enum.Field, fields.items), - }); } else blk: { try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {}); break :blk Tag.opaque_literal.init(); }; + const is_pub = toplevel and !is_unnamed; const payload = try c.arena.create(ast.Payload.SimpleVarDecl); payload.* = .{ .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(is_pub)] }, .data = .{ + .init = enum_type_node, .name = name, - .init = init_node, }, }; @@ -1191,18 +1179,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E try c.alias_list.append(.{ .alias = bare_name, .name = name }); } else { try scope.appendNode(Node.initPayload(&payload.base)); - } - - for (redecls.items) |redecl| { - if (toplevel) { - try addTopLevelDecl(c, redecl.field_name, try Tag.pub_enum_redecl.create(c.arena, redecl)); - } else { - try scope.appendNode(try Tag.enum_redecl.create(c.arena, .{ - .enum_val_name = try bs.makeMangledName(c, redecl.enum_val_name), - .field_name = redecl.field_name, - .enum_name = redecl.enum_name, - })); - } + try bs.discardVariable(c, name); } } @@ -1312,6 +1289,7 @@ fn transConvertVectorExpr( source_loc: clang.SourceLocation, expr: *const clang.ConvertVectorExpr, ) TransError!Node { + _ = source_loc; const base_stmt = @ptrCast(*const clang.Stmt, expr); var block_scope = try Scope.Block.init(c, scope, true); @@ -1321,7 +1299,6 @@ fn transConvertVectorExpr( const src_type = qualTypeCanon(src_expr.getType()); const src_vector_ty = @ptrCast(*const clang.VectorType, src_type); const src_element_qt = src_vector_ty.getElementType(); - const src_element_type_node = try transQualType(c, &block_scope.base, src_element_qt, base_stmt.getBeginLoc()); const src_expr_node = try transExpr(c, &block_scope.base, src_expr, .used); @@ -1387,11 +1364,10 @@ fn makeShuffleMask(c: *Context, scope: *Scope, expr: *const clang.ShuffleVectorE init.* = converted_index; } - const mask_init = try Tag.array_init.create(c.arena, .{ + return Tag.array_init.create(c.arena, .{ .cond = mask_type, .cases = init_list, }); - return Tag.@"comptime".create(c.arena, mask_init); } /// @typeInfo(@TypeOf(vec_node)).Vector.<field> @@ -1434,6 +1410,7 @@ fn transSimpleOffsetOfExpr( scope: *Scope, expr: *const clang.OffsetOfExpr, ) TransError!Node { + _ = scope; assert(expr.getNumComponents() == 1); const component = expr.getComponent(0); if (component.getKind() == .Field) { @@ -1800,6 +1777,7 @@ fn transDeclStmtOne( node = try Tag.static_local_var.create(c.arena, .{ .name = mangled_name, .init = node }); } try block_scope.statements.append(node); + try block_scope.discardVariable(c, mangled_name); const cleanup_attr = var_decl.getCleanupAttribute(); if (cleanup_attr) |fn_decl| { @@ -2096,8 +2074,7 @@ fn finishBoolExpr( }, .Enum => { // node != 0 - const int_val = try Tag.enum_to_int.create(c.arena, node); - return Tag.not_equal.create(c.arena, .{ .lhs = int_val, .rhs = Tag.zero_literal.init() }); + return Tag.not_equal.create(c.arena, .{ .lhs = node, .rhs = Tag.zero_literal.init() }); }, .Elaborated => { const elaborated_ty = @ptrCast(*const clang.ElaboratedType, ty); @@ -2270,6 +2247,7 @@ fn transStringLiteralInitializer( /// both operands resolve to addresses. The C standard requires that both operands /// point to elements of the same array object, but we do not verify that here. fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool { + _ = c; const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); return stmt.getOpcode() == .Sub and @@ -2309,21 +2287,22 @@ fn transCCast( if (dst_type.eq(src_type)) return expr; if (qualTypeIsPtr(dst_type) and qualTypeIsPtr(src_type)) return transCPtrCast(c, scope, loc, dst_type, src_type, expr); + if (cIsEnum(dst_type)) return transCCast(c, scope, loc, cIntTypeForEnum(dst_type), src_type, expr); + if (cIsEnum(src_type)) return transCCast(c, scope, loc, dst_type, cIntTypeForEnum(src_type), expr); const dst_node = try transQualType(c, scope, dst_type, loc); - if (cIsInteger(dst_type) and (cIsInteger(src_type) or cIsEnum(src_type))) { + if (cIsInteger(dst_type) and cIsInteger(src_type)) { // 1. If src_type is an enum, determine the underlying signed int type // 2. Extend or truncate without changing signed-ness. // 3. Bit-cast to correct signed-ness - const src_int_type = if (cIsInteger(src_type)) src_type else cIntTypeForEnum(src_type); - const src_type_is_signed = cIsSignedInteger(src_int_type); - var src_int_expr = if (cIsInteger(src_type)) expr else try Tag.enum_to_int.create(c.arena, expr); + const src_type_is_signed = cIsSignedInteger(src_type); + var src_int_expr = expr; if (isBoolRes(src_int_expr)) { src_int_expr = try Tag.bool_to_int.create(c.arena, src_int_expr); } - switch (cIntTypeCmp(dst_type, src_int_type)) { + switch (cIntTypeCmp(dst_type, src_type)) { .lt => { // @truncate(SameSignSmallerInt, src_int_expr) const ty_node = try transQualTypeIntWidthOf(c, dst_type, src_type_is_signed); @@ -2376,14 +2355,6 @@ fn transCCast( const bool_to_int = try Tag.bool_to_int.create(c.arena, expr); return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = bool_to_int }); } - if (cIsEnum(dst_type)) { - // import("std").meta.cast(dest_type, val) - return Tag.helpers_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr }); - } - if (cIsEnum(src_type) and !cIsEnum(dst_type)) { - // @enumToInt(val) - return Tag.enum_to_int.create(c.arena, expr); - } // @as(dest_type, val) return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = expr }); } @@ -2573,6 +2544,7 @@ fn transInitListExprVector( expr: *const clang.InitListExpr, ty: *const clang.Type, ) TransError!Node { + _ = ty; const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); const vector_type = try transQualType(c, scope, qt, loc); const init_count = expr.getNumInits(); @@ -2722,6 +2694,7 @@ fn transImplicitValueInitExpr( expr: *const clang.Expr, used: ResultUsed, ) TransError!Node { + _ = used; const source_loc = expr.getBeginLoc(); const qt = getExprQualType(c, expr); const ty = qt.getTypePtr(); @@ -3408,6 +3381,7 @@ fn transUnaryExprOrTypeTraitExpr( stmt: *const clang.UnaryExprOrTypeTraitExpr, result_used: ResultUsed, ) TransError!Node { + _ = result_used; const loc = stmt.getBeginLoc(); const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); @@ -3802,7 +3776,6 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang const res_is_bool = qualTypeIsBoolean(qt); const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt); const cond_expr = casted_stmt.getCond(); - const true_expr = casted_stmt.getTrueExpr(); const false_expr = casted_stmt.getFalseExpr(); // c: (cond_expr)?:(false_expr) @@ -3895,6 +3868,7 @@ fn maybeSuppressResult( used: ResultUsed, result: Node, ) TransError!Node { + _ = scope; if (used == .used) return result; return Tag.discard.create(c.arena, result); } @@ -4336,12 +4310,10 @@ fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float } fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: *ast.Payload.Func) !Node { - const scope = &c.global_scope.base; - var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa); defer fn_params.deinit(); - for (proto_alias.data.params) |param, i| { + for (proto_alias.data.params) |param| { const param_name = param.name orelse try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()}); @@ -4943,6 +4915,10 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void { const scope = &c.global_scope.base; const init_node = try parseCExpr(c, m, scope); + if (init_node.castTag(.identifier)) |ident_node| { + if (mem.eql(u8, "_", ident_node.data)) + return m.fail(c, "unable to translate C expr: illegal identifier _", .{}); + } const last = m.next().?; if (last != .Eof and last != .Nl) return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)}); @@ -4973,7 +4949,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { .name = mangled_name, .type = Tag.@"anytype".init(), }); - + try block_scope.discardVariable(c, mangled_name); if (m.peek().? != .Comma) break; _ = m.next(); } @@ -5657,6 +5633,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ } fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { + _ = scope; const KwCounter = struct { double: u8 = 0, long: u8 = 0, @@ -5758,6 +5735,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { } fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node { + _ = scope; switch (m.next().?) { .Asterisk => { // last token of `node` @@ -5969,7 +5947,6 @@ fn getContainer(c: *Context, node: Node) ?Node { switch (node.tag()) { .@"union", .@"struct", - .@"enum", .address_of, .bit_not, .not, diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig index 59e84c6ba0..70c8c6559f 100644 --- a/src/translate_c/ast.zig +++ b/src/translate_c/ast.zig @@ -64,8 +64,6 @@ pub const Node = extern union { static_local_var, func, warning, - /// All enums are non-exhaustive - @"enum", @"struct", @"union", @"comptime", @@ -146,10 +144,6 @@ pub const Node = extern union { float_to_int, /// @intToFloat(lhs, rhs) int_to_float, - /// @intToEnum(lhs, rhs) - int_to_enum, - /// @enumToInt(operand) - enum_to_int, /// @intToPtr(lhs, rhs) int_to_ptr, /// @ptrToInt(operand) @@ -215,9 +209,8 @@ pub const Node = extern union { var_simple, /// pub const name = init; pub_var_simple, - /// pub const enum_field_name = @enumToInt(enum_name.field_name); - pub_enum_redecl, - enum_redecl, + /// pub? const name (: type)? = value + enum_constant, /// pub inline fn name(params) return_type body pub_inline_fn, @@ -266,7 +259,6 @@ pub const Node = extern union { .unwrap, .deref, .ptr_to_int, - .enum_to_int, .empty_array, .while_true, .if_not_break, @@ -324,7 +316,6 @@ pub const Node = extern union { .float_cast, .float_to_int, .int_to_float, - .int_to_enum, .int_to_ptr, .array_cat, .ellipsis3, @@ -357,7 +348,6 @@ pub const Node = extern union { .call => Payload.Call, .var_decl => Payload.VarDecl, .func => Payload.Func, - .@"enum" => Payload.Enum, .@"struct", .@"union" => Payload.Record, .tuple => Payload.TupleInit, .container_init => Payload.ContainerInit, @@ -369,7 +359,7 @@ pub const Node = extern union { .arg_redecl, .alias, .fail_decl => Payload.ArgRedecl, .log2_int_type => Payload.Log2IntType, .var_simple, .pub_var_simple, .static_local_var => Payload.SimpleVarDecl, - .pub_enum_redecl, .enum_redecl => Payload.EnumRedecl, + .enum_constant => Payload.EnumConstant, .array_filler => Payload.ArrayFiller, .pub_inline_fn => Payload.PubInlineFn, .field_access => Payload.FieldAccess, @@ -554,19 +544,6 @@ pub const Payload = struct { type: Node, }; - pub const Enum = struct { - base: Payload, - data: struct { - int_type: Node, - fields: []Field, - }, - - pub const Field = struct { - name: []const u8, - value: ?Node, - }; - }; - pub const Record = struct { base: Payload, data: struct { @@ -658,12 +635,13 @@ pub const Payload = struct { }, }; - pub const EnumRedecl = struct { + pub const EnumConstant = struct { base: Payload, data: struct { - enum_val_name: []const u8, - field_name: []const u8, - enum_name: []const u8, + name: []const u8, + is_public: bool, + type: ?Node, + value: Node, }, }; @@ -1307,14 +1285,6 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { const payload = node.castTag(.int_to_float).?.data; return renderBuiltinCall(c, "@intToFloat", &.{ payload.lhs, payload.rhs }); }, - .int_to_enum => { - const payload = node.castTag(.int_to_enum).?.data; - return renderBuiltinCall(c, "@intToEnum", &.{ payload.lhs, payload.rhs }); - }, - .enum_to_int => { - const payload = node.castTag(.enum_to_int).?.data; - return renderBuiltinCall(c, "@enumToInt", &.{payload}); - }, .int_to_ptr => { const payload = node.castTag(.int_to_ptr).?.data; return renderBuiltinCall(c, "@intToPtr", &.{ payload.lhs, payload.rhs }); @@ -1814,91 +1784,28 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { return renderFieldAccess(c, lhs, payload.field_name); }, .@"struct", .@"union" => return renderRecord(c, node), - .@"enum" => { - const payload = node.castTag(.@"enum").?.data; - _ = try c.addToken(.keyword_extern, "extern"); - const enum_tok = try c.addToken(.keyword_enum, "enum"); - _ = try c.addToken(.l_paren, "("); - const arg_expr = try renderNode(c, payload.int_type); - _ = try c.addToken(.r_paren, ")"); - _ = try c.addToken(.l_brace, "{"); - const members = try c.gpa.alloc(NodeIndex, payload.fields.len + 1); - defer c.gpa.free(members); - members[0] = 0; - - for (payload.fields) |field, i| { - const name_tok = try c.addIdentifier(field.name); - const value_expr = if (field.value) |some| blk: { - _ = try c.addToken(.equal, "="); - break :blk try renderNode(c, some); - } else 0; - - members[i] = try c.addNode(.{ - .tag = .container_field_init, - .main_token = name_tok, - .data = .{ - .lhs = 0, - .rhs = value_expr, - }, - }); - _ = try c.addToken(.comma, ","); - } - // make non-exhaustive - members[payload.fields.len] = try c.addNode(.{ - .tag = .container_field_init, - .main_token = try c.addIdentifier("_"), - .data = .{ - .lhs = 0, - .rhs = 0, - }, - }); - _ = try c.addToken(.comma, ","); - _ = try c.addToken(.r_brace, "}"); + .enum_constant => { + const payload = node.castTag(.enum_constant).?.data; - const span = try c.listToSpan(members); - return c.addNode(.{ - .tag = .container_decl_arg_trailing, - .main_token = enum_tok, - .data = .{ - .lhs = arg_expr, - .rhs = try c.addExtra(NodeSubRange{ - .start = span.start, - .end = span.end, - }), - }, - }); - }, - .pub_enum_redecl, .enum_redecl => { - const payload = @fieldParentPtr(Payload.EnumRedecl, "base", node.ptr_otherwise).data; - if (node.tag() == .pub_enum_redecl) _ = try c.addToken(.keyword_pub, "pub"); + if (payload.is_public) _ = try c.addToken(.keyword_pub, "pub"); const const_tok = try c.addToken(.keyword_const, "const"); - _ = try c.addIdentifier(payload.enum_val_name); + _ = try c.addIdentifier(payload.name); + + const type_node = if (payload.type) |enum_const_type| blk: { + _ = try c.addToken(.colon, ":"); + break :blk try renderNode(c, enum_const_type); + } else 0; + _ = try c.addToken(.equal, "="); - const enum_to_int_tok = try c.addToken(.builtin, "@enumToInt"); - _ = try c.addToken(.l_paren, "("); - const enum_name = try c.addNode(.{ - .tag = .identifier, - .main_token = try c.addIdentifier(payload.enum_name), - .data = undefined, - }); - const field_access = try renderFieldAccess(c, enum_name, payload.field_name); - const init_node = try c.addNode(.{ - .tag = .builtin_call_two, - .main_token = enum_to_int_tok, - .data = .{ - .lhs = field_access, - .rhs = 0, - }, - }); - _ = try c.addToken(.r_paren, ")"); + const init_node = try renderNode(c, payload.value); _ = try c.addToken(.semicolon, ";"); return c.addNode(.{ .tag = .simple_var_decl, .main_token = const_tok, .data = .{ - .lhs = 0, + .lhs = type_node, .rhs = init_node, }, }); @@ -2210,7 +2117,7 @@ fn renderNullSentinelArrayType(c: *Context, len: usize, elem_type: Node) !NodeIn fn addSemicolonIfNeeded(c: *Context, node: Node) !void { switch (node.tag()) { .warning => unreachable, - .var_decl, .var_simple, .arg_redecl, .alias, .enum_redecl, .block, .empty_block, .block_single, .@"switch" => {}, + .var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch" => {}, .while_true => { const payload = node.castTag(.while_true).?.data; return addSemicolonIfNotBlock(c, payload); @@ -2258,13 +2165,11 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex { .float_cast, .float_to_int, .int_to_float, - .int_to_enum, .int_to_ptr, .std_mem_zeroes, .std_math_Log2Int, .log2_int_type, .ptr_to_int, - .enum_to_int, .sizeof, .alignof, .typeof, @@ -2340,7 +2245,6 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex { .array_cat, .array_filler, .@"if", - .@"enum", .@"struct", .@"union", .array_init, @@ -2366,8 +2270,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex { .alias, .var_simple, .pub_var_simple, - .pub_enum_redecl, - .enum_redecl, + .enum_constant, .@"while", .@"switch", .@"break", diff --git a/src/type.zig b/src/type.zig index 410773b649..853a4b7914 100644 --- a/src/type.zig +++ b/src/type.zig @@ -600,9 +600,11 @@ pub const Type = extern union { pub const HashContext = struct { pub fn hash(self: @This(), t: Type) u64 { + _ = self; return t.hash(); } pub fn eql(self: @This(), a: Type, b: Type) bool { + _ = self; return a.eql(b); } }; @@ -777,6 +779,7 @@ pub const Type = extern union { options: std.fmt.FormatOptions, writer: anytype, ) @TypeOf(writer).Error!void { + _ = options; comptime assert(fmt.len == 0); var ty = start_type; while (true) { @@ -1538,7 +1541,7 @@ pub const Type = extern union { .optional_single_const_pointer, .optional_single_mut_pointer, => { - if (self.elemType().hasCodeGenBits()) return 1; + if (!self.elemType().hasCodeGenBits()) return 1; return @divExact(target.cpu.arch.ptrBitWidth(), 8); }, @@ -1550,7 +1553,7 @@ pub const Type = extern union { .c_mut_pointer, .pointer, => { - if (self.elemType().hasCodeGenBits()) return 0; + if (!self.elemType().hasCodeGenBits()) return 0; return @divExact(target.cpu.arch.ptrBitWidth(), 8); }, @@ -3013,7 +3016,7 @@ pub const Type = extern union { .base = .{ .tag = t }, .data = data, }; - return Type{ .ptr_otherwise = &ptr.base }; + return file_struct.Type{ .ptr_otherwise = &ptr.base }; } pub fn Data(comptime t: Tag) type { @@ -3163,7 +3166,6 @@ pub const CType = enum { longdouble, pub fn sizeInBits(self: CType, target: Target) u16 { - const arch = target.cpu.arch; switch (target.os.tag) { .freestanding, .other => switch (target.cpu.arch) { .msp430 => switch (self) { diff --git a/src/value.zig b/src/value.zig index c358975667..008cc3c2fe 100644 --- a/src/value.zig +++ b/src/value.zig @@ -626,6 +626,7 @@ pub const Value = extern union { return std.mem.dupe(allocator, u8, payload.data); } if (self.castTag(.repeated)) |payload| { + _ = payload; @panic("TODO implement toAllocatedBytes for this Value tag"); } if (self.castTag(.decl_ref)) |payload| { @@ -747,6 +748,7 @@ pub const Value = extern union { /// Asserts the type is an enum type. pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E { + _ = enum_ty; // TODO this needs to resolve other kinds of Value tags rather than // assuming the tag will be .enum_field_index. const field_index = val.castTag(.enum_field_index).?.data; @@ -935,6 +937,7 @@ pub const Value = extern union { /// Converts an integer or a float to a float. /// Returns `error.Overflow` if the value does not fit in the new type. pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value { + _ = target; switch (ty.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -979,6 +982,26 @@ pub const Value = extern union { }; } + /// Asserts the value is numeric + pub fn isZero(self: Value) bool { + return switch (self.tag()) { + .zero => true, + .one => false, + + .int_u64 => self.castTag(.int_u64).?.data == 0, + .int_i64 => self.castTag(.int_i64).?.data == 0, + + .float_16 => self.castTag(.float_16).?.data == 0, + .float_32 => self.castTag(.float_32).?.data == 0, + .float_64 => self.castTag(.float_64).?.data == 0, + .float_128 => self.castTag(.float_128).?.data == 0, + + .int_big_positive => self.castTag(.int_big_positive).?.asBigInt().eqZero(), + .int_big_negative => self.castTag(.int_big_negative).?.asBigInt().eqZero(), + else => unreachable, + }; + } + pub fn orderAgainstZero(lhs: Value) std.math.Order { return switch (lhs.tag()) { .zero, @@ -1272,17 +1295,21 @@ pub const Value = extern union { pub const ArrayHashContext = struct { pub fn hash(self: @This(), v: Value) u32 { + _ = self; return v.hash_u32(); } pub fn eql(self: @This(), a: Value, b: Value) bool { + _ = self; return a.eql(b); } }; pub const HashContext = struct { pub fn hash(self: @This(), v: Value) u64 { + _ = self; return v.hash(); } pub fn eql(self: @This(), a: Value, b: Value) bool { + _ = self; return a.eql(b); } }; @@ -1325,6 +1352,7 @@ pub const Value = extern union { } pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value { + _ = allocator; switch (val.tag()) { .@"struct" => { const field_values = val.castTag(.@"struct").?.data; diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index 8a60a1210e..7c923021d8 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -3228,12 +3228,6 @@ bool ZigClangEnumDecl_enumerator_iterator_neq( return casted_a != casted_b; } -const struct ZigClangExpr *ZigClangEnumConstantDecl_getInitExpr(const struct ZigClangEnumConstantDecl *self) { - auto casted = reinterpret_cast<const clang::EnumConstantDecl *>(self); - const clang::Expr *result = casted->getInitExpr(); - return reinterpret_cast<const ZigClangExpr *>(result); -} - const struct ZigClangAPSInt *ZigClangEnumConstantDecl_getInitVal(const struct ZigClangEnumConstantDecl *self) { auto casted = reinterpret_cast<const clang::EnumConstantDecl *>(self); const llvm::APSInt *result = &casted->getInitVal(); diff --git a/src/zig_clang.h b/src/zig_clang.h index 5ffba627df..634534dfb4 100644 --- a/src/zig_clang.h +++ b/src/zig_clang.h @@ -1326,6 +1326,5 @@ ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangFieldDecl_getLocation(const s ZIG_EXTERN_C const struct ZigClangRecordDecl *ZigClangFieldDecl_getParent(const struct ZigClangFieldDecl *); ZIG_EXTERN_C unsigned ZigClangFieldDecl_getFieldIndex(const struct ZigClangFieldDecl *); -ZIG_EXTERN_C const struct ZigClangExpr *ZigClangEnumConstantDecl_getInitExpr(const struct ZigClangEnumConstantDecl *); ZIG_EXTERN_C const struct ZigClangAPSInt *ZigClangEnumConstantDecl_getInitVal(const struct ZigClangEnumConstantDecl *); #endif diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index 722b77406e..8c54af4bb4 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -969,6 +969,12 @@ void ZigLLVMSetModulePIELevel(LLVMModuleRef module) { unwrap(module)->setPIELevel(PIELevel::Level::Large); } +void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model) { + bool JIT; + unwrap(module)->setCodeModel(*unwrap(code_model, JIT)); + assert(!JIT); +} + static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) { switch (Ordering) { case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic; diff --git a/src/zig_llvm.h b/src/zig_llvm.h index 0d08980835..32a969f70e 100644 --- a/src/zig_llvm.h +++ b/src/zig_llvm.h @@ -208,6 +208,7 @@ ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module); ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module); ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module); ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module); +ZIG_EXTERN_C void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model); ZIG_EXTERN_C void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column, struct ZigLLVMDIScope *scope); diff --git a/test/behavior.zig b/test/behavior.zig index 479fe9b422..56c1b8ec05 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -51,6 +51,7 @@ comptime { _ = @import("behavior/bugs/3384.zig"); _ = @import("behavior/bugs/3586.zig"); _ = @import("behavior/bugs/3742.zig"); + _ = @import("behavior/bugs/3779.zig"); _ = @import("behavior/bugs/4328.zig"); _ = @import("behavior/bugs/4560.zig"); _ = @import("behavior/bugs/4769_a.zig"); diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 06173ef40f..e99cf1e0e2 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -167,6 +167,7 @@ test "generic function with align param" { } fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 { + _ = align_bytes; return 0x1; } diff --git a/test/behavior/async_fn.zig b/test/behavior/async_fn.zig index b0e6c548ed..6d734669fc 100644 --- a/test/behavior/async_fn.zig +++ b/test/behavior/async_fn.zig @@ -13,6 +13,7 @@ test "simple coroutine suspend and resume" { resume frame; try expect(global_x == 3); const af: anyframe->void = &frame; + _ = af; resume frame; try expect(global_x == 4); } @@ -45,6 +46,7 @@ test "suspend at end of function" { fn doTheTest() !void { try expect(x == 1); const p = async suspendAtEnd(); + _ = p; try expect(x == 2); } @@ -131,7 +133,9 @@ test "@frameSize" { other(1); } fn other(param: i32) void { + _ = param; var local: i32 = undefined; + _ = local; suspend {} } }; @@ -181,6 +185,7 @@ test "coroutine suspend, resume" { test "coroutine suspend with block" { const p = async testSuspendBlock(); + _ = p; try expect(!global_result); resume a_promise; try expect(global_result); @@ -207,6 +212,7 @@ var await_final_result: i32 = 0; test "coroutine await" { await_seq('a'); var p = async await_amain(); + _ = p; await_seq('f'); resume await_a_promise; await_seq('i'); @@ -243,6 +249,7 @@ var early_final_result: i32 = 0; test "coroutine await early return" { early_seq('a'); var p = async early_amain(); + _ = p; early_seq('f'); try expect(early_final_result == 1234); try expect(std.mem.eql(u8, &early_points, "abcdef")); @@ -276,6 +283,7 @@ test "async function with dot syntax" { } }; const p = async S.foo(); + _ = p; try expect(S.y == 2); } @@ -362,11 +370,13 @@ test "error return trace across suspend points - early return" { const p = nonFailing(); resume p; const p2 = async printTrace(p); + _ = p2; } test "error return trace across suspend points - async return" { const p = nonFailing(); const p2 = async printTrace(p); + _ = p2; resume p; } @@ -396,6 +406,7 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void { test "break from suspend" { var my_result: i32 = 1; const p = async testBreakFromSuspend(&my_result); + _ = p; try std.testing.expect(my_result == 2); } fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void { @@ -619,11 +630,14 @@ test "returning a const error from async function" { fn amain() !void { var download_frame = async fetchUrl(10, "a string"); const download_text = try await download_frame; + _ = download_text; @panic("should not get here"); } fn fetchUrl(unused: i32, url: []const u8) ![]u8 { + _ = unused; + _ = url; frame = @frame(); suspend {} ok = true; @@ -700,6 +714,7 @@ fn testAsyncAwaitTypicalUsage( var global_download_frame: anyframe = undefined; fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 { + _ = url; const result = try std.mem.dupe(allocator, u8, "expected download text"); errdefer allocator.free(result); if (suspend_download) { @@ -713,6 +728,7 @@ fn testAsyncAwaitTypicalUsage( var global_file_frame: anyframe = undefined; fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 { + _ = filename; const result = try std.mem.dupe(allocator, u8, "expected file text"); errdefer allocator.free(result); if (suspend_file) { @@ -730,6 +746,7 @@ test "alignment of local variables in async functions" { const S = struct { fn doTheTest() !void { var y: u8 = 123; + _ = y; var x: u8 align(128) = 1; try expect(@ptrToInt(&x) % 128 == 0); } @@ -742,6 +759,7 @@ test "no reason to resolve frame still works" { } fn simpleNothing() void { var x: i32 = 1234; + _ = x; } test "async call a generic function" { @@ -802,6 +820,7 @@ test "struct parameter to async function is copied to the frame" { if (x == 0) return; clobberStack(x - 1); var y: i32 = x; + _ = y; } fn bar(f: *@Frame(foo)) void { @@ -1212,6 +1231,7 @@ test "suspend in while loop" { suspend {} return val; } else |err| { + err catch {}; return 0; } } @@ -1341,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" { } fn bar(x: i32, args: anytype) anyerror!void { + _ = args; global_frame = @frame(); suspend {} global_int = x; @@ -1636,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" { pub const AT = [5]u8; pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void { + _ = s; + _ = a; // Check that the array and struct arguments passed by value don't // end up overflowing the adjacent fields in the frame structure. expectEqual(F0, _fill0) catch @panic("test failure"); @@ -1654,6 +1677,7 @@ test "@asyncCall with pass-by-value arguments" { [_]u8{ 1, 2, 3, 4, 5 }, F2, }); + _ = frame_ptr; } test "@asyncCall with arguments having non-standard alignment" { @@ -1662,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" { const S = struct { pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void { + _ = s; // The compiler inserts extra alignment for s, check that the // generated code picks the right slot for fill1. expectEqual(F0, _fill0) catch @panic("test failure"); @@ -1673,4 +1698,5 @@ test "@asyncCall with arguments having non-standard alignment" { // The function pointer must not be comptime-known. var t = S.f; var frame_ptr = @asyncCall(&buffer, {}, t, .{ F0, undefined, F1 }); + _ = frame_ptr; } diff --git a/test/behavior/atomics.zig b/test/behavior/atomics.zig index 3d808b3fb6..7ac30b57c7 100644 --- a/test/behavior/atomics.zig +++ b/test/behavior/atomics.zig @@ -97,7 +97,6 @@ test "cmpxchg with ptr" { test "cmpxchg with ignored result" { var x: i32 = 1234; - var ptr = &x; _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic); @@ -195,7 +194,6 @@ fn testAtomicRmwInt() !void { test "atomics with different types" { try testAtomicsWithType(bool, true, false); inline for (.{ u1, i4, u5, i15, u24 }) |T| { - var x: T = 0; try testAtomicsWithType(T, 0, 1); } try testAtomicsWithType(u0, 0, 0); diff --git a/test/behavior/await_struct.zig b/test/behavior/await_struct.zig index 9e01aecc8c..229a72b9ff 100644 --- a/test/behavior/await_struct.zig +++ b/test/behavior/await_struct.zig @@ -12,6 +12,7 @@ var await_final_result = Foo{ .x = 0 }; test "coroutine await struct" { await_seq('a'); var p = async await_amain(); + _ = p; await_seq('f'); resume await_a_promise; await_seq('i'); diff --git a/test/behavior/bit_shifting.zig b/test/behavior/bit_shifting.zig index a58026e88d..c1f84a99d4 100644 --- a/test/behavior/bit_shifting.zig +++ b/test/behavior/bit_shifting.zig @@ -100,5 +100,5 @@ test "comptime shr of BigInt" { } test "comptime shift safety check" { - const x = @as(usize, 42) << @sizeOf(usize); + _ = @as(usize, 42) << @sizeOf(usize); } diff --git a/test/behavior/bugs/1310.zig b/test/behavior/bugs/1310.zig index a291b217ec..31911d5014 100644 --- a/test/behavior/bugs/1310.zig +++ b/test/behavior/bugs/1310.zig @@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_; pub const VM_ = struct_VM_; fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { + _ = _vm; + _ = options; return 11; } diff --git a/test/behavior/bugs/1467.zig b/test/behavior/bugs/1467.zig index 71c55dc59c..e062e66c8d 100644 --- a/test/behavior/bugs/1467.zig +++ b/test/behavior/bugs/1467.zig @@ -4,4 +4,5 @@ pub const S = extern struct { }; test "bug 1467" { const s: S = undefined; + _ = s; } diff --git a/test/behavior/bugs/1500.zig b/test/behavior/bugs/1500.zig index e24cfe5a9c..5683d53721 100644 --- a/test/behavior/bugs/1500.zig +++ b/test/behavior/bugs/1500.zig @@ -7,4 +7,8 @@ const B = fn (A) void; test "allow these dependencies" { var a: A = undefined; var b: B = undefined; + if (false) { + a; + b; + } } diff --git a/test/behavior/bugs/2346.zig b/test/behavior/bugs/2346.zig index c8cea34813..52c1e3ac6b 100644 --- a/test/behavior/bugs/2346.zig +++ b/test/behavior/bugs/2346.zig @@ -1,6 +1,8 @@ test "fixed" { const a: *void = undefined; const b: *[1]void = a; + _ = b; const c: *[0]u8 = undefined; const d: []u8 = c; + _ = d; } diff --git a/test/behavior/bugs/2578.zig b/test/behavior/bugs/2578.zig index cf7d941562..547aee9b22 100644 --- a/test/behavior/bugs/2578.zig +++ b/test/behavior/bugs/2578.zig @@ -5,7 +5,9 @@ const Foo = struct { var foo: Foo = undefined; const t = &foo; -fn bar(pointer: ?*c_void) void {} +fn bar(pointer: ?*c_void) void { + _ = pointer; +} test "fixed" { bar(t); diff --git a/test/behavior/bugs/2692.zig b/test/behavior/bugs/2692.zig index 267c3a131a..1bc38a0274 100644 --- a/test/behavior/bugs/2692.zig +++ b/test/behavior/bugs/2692.zig @@ -1,4 +1,6 @@ -fn foo(a: []u8) void {} +fn foo(a: []u8) void { + _ = a; +} test "address of 0 length array" { var pt: [0]u8 = undefined; diff --git a/test/behavior/bugs/3367.zig b/test/behavior/bugs/3367.zig index 3df3adbff7..b77b979b8a 100644 --- a/test/behavior/bugs/3367.zig +++ b/test/behavior/bugs/3367.zig @@ -3,7 +3,9 @@ const Foo = struct { }; const Mixin = struct { - pub fn two(self: Foo) void {} + pub fn two(self: Foo) void { + _ = self; + } }; test "container member access usingnamespace decls" { diff --git a/test/behavior/bugs/3586.zig b/test/behavior/bugs/3586.zig index 7bb1ba5d31..047cb5d205 100644 --- a/test/behavior/bugs/3586.zig +++ b/test/behavior/bugs/3586.zig @@ -8,4 +8,5 @@ test "fixed" { var ctr = Container{ .params = NoteParams{}, }; + _ = ctr; } diff --git a/test/behavior/bugs/3779.zig b/test/behavior/bugs/3779.zig new file mode 100644 index 0000000000..1bf5bfcc90 --- /dev/null +++ b/test/behavior/bugs/3779.zig @@ -0,0 +1,42 @@ +const std = @import("std"); + +const TestEnum = enum { TestEnumValue }; +const tag_name = @tagName(TestEnum.TestEnumValue); +const ptr_tag_name: [*:0]const u8 = tag_name; + +test "@tagName() returns a string literal" { + try std.testing.expectEqual([:0]const u8, @TypeOf(tag_name)); + try std.testing.expectEqualStrings("TestEnumValue", tag_name); + try std.testing.expectEqualStrings("TestEnumValue", ptr_tag_name[0..tag_name.len]); +} + +const TestError = error{TestErrorCode}; +const error_name = @errorName(TestError.TestErrorCode); +const ptr_error_name: [*:0]const u8 = error_name; + +test "@errorName() returns a string literal" { + try std.testing.expectEqual([:0]const u8, @TypeOf(error_name)); + try std.testing.expectEqualStrings("TestErrorCode", error_name); + try std.testing.expectEqualStrings("TestErrorCode", ptr_error_name[0..error_name.len]); +} + +const TestType = struct {}; +const type_name = @typeName(TestType); +const ptr_type_name: [*:0]const u8 = type_name; + +test "@typeName() returns a string literal" { + try std.testing.expectEqual(*const [type_name.len:0]u8, @TypeOf(type_name)); + try std.testing.expectEqualStrings("TestType", type_name); + try std.testing.expectEqualStrings("TestType", ptr_type_name[0..type_name.len]); +} + +const actual_contents = @embedFile("3779_file_to_embed.txt"); +const ptr_actual_contents: [*:0]const u8 = actual_contents; +const expected_contents = "hello zig\n"; + +test "@embedFile() returns a string literal" { + try std.testing.expectEqual(*const [expected_contents.len:0]u8, @TypeOf(actual_contents)); + try std.testing.expect(std.mem.eql(u8, expected_contents, actual_contents)); + try std.testing.expectEqualStrings(expected_contents, actual_contents); + try std.testing.expectEqualStrings(expected_contents, ptr_actual_contents[0..actual_contents.len]); +} diff --git a/test/behavior/bugs/3779_file_to_embed.txt b/test/behavior/bugs/3779_file_to_embed.txt new file mode 100644 index 0000000000..0436280ed3 --- /dev/null +++ b/test/behavior/bugs/3779_file_to_embed.txt @@ -0,0 +1 @@ +hello zig diff --git a/test/behavior/bugs/4328.zig b/test/behavior/bugs/4328.zig index 76c3e788fd..26b96d8d6f 100644 --- a/test/behavior/bugs/4328.zig +++ b/test/behavior/bugs/4328.zig @@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" { test "Extern function calls, dereferences and field access in @TypeOf" { const Test = struct { fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) { + _ = a; return .{ .dummy_field = 0 }; } fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) { + _ = a; return 255; } diff --git a/test/behavior/bugs/4560.zig b/test/behavior/bugs/4560.zig index 682d3f2125..3119bd99b9 100644 --- a/test/behavior/bugs/4560.zig +++ b/test/behavior/bugs/4560.zig @@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type { } pub fn HashMap(comptime K: type, comptime V: type) type { + if (false) { + K; + V; + } return struct { size: usize, max_distance_from_start_index: usize, diff --git a/test/behavior/bugs/4954.zig b/test/behavior/bugs/4954.zig index b5a9bdf851..3dea934895 100644 --- a/test/behavior/bugs/4954.zig +++ b/test/behavior/bugs/4954.zig @@ -1,5 +1,5 @@ fn f(buf: []u8) void { - var ptr = &buf[@sizeOf(u32)]; + _ = &buf[@sizeOf(u32)]; } test "crash" { diff --git a/test/behavior/bugs/529_other_file_2.zig b/test/behavior/bugs/529_other_file_2.zig index b493959e50..9f4636dce8 100644 --- a/test/behavior/bugs/529_other_file_2.zig +++ b/test/behavior/bugs/529_other_file_2.zig @@ -1,4 +1,6 @@ pub const A = extern struct { field: c_int, }; -export fn issue529(a: ?*A) void {} +export fn issue529(a: ?*A) void { + _ = a; +} diff --git a/test/behavior/bugs/5487.zig b/test/behavior/bugs/5487.zig index bf530a8a02..4f67e6e846 100644 --- a/test/behavior/bugs/5487.zig +++ b/test/behavior/bugs/5487.zig @@ -1,6 +1,7 @@ const io = @import("std").io; pub fn write(_: void, bytes: []const u8) !usize { + _ = bytes; return 0; } pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) { diff --git a/test/behavior/bugs/624.zig b/test/behavior/bugs/624.zig index 4d52aad693..b8bf09f22e 100644 --- a/test/behavior/bugs/624.zig +++ b/test/behavior/bugs/624.zig @@ -12,6 +12,7 @@ const ListenerContext = struct { const ContextAllocator = MemoryPool(TestContext); fn MemoryPool(comptime T: type) type { + _ = T; return struct { n: usize, }; diff --git a/test/behavior/bugs/679.zig b/test/behavior/bugs/679.zig index 9b402defca..6420e7f99f 100644 --- a/test/behavior/bugs/679.zig +++ b/test/behavior/bugs/679.zig @@ -2,6 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; pub fn List(comptime T: type) type { + _ = T; return u32; } diff --git a/test/behavior/bugs/7003.zig b/test/behavior/bugs/7003.zig index 75fc9068b1..3568f36d2b 100644 --- a/test/behavior/bugs/7003.zig +++ b/test/behavior/bugs/7003.zig @@ -5,4 +5,5 @@ test "@Type should resolve its children types" { comptime var sparse_info = @typeInfo(anyerror!sparse); sparse_info.ErrorUnion.payload = dense; const B = @Type(sparse_info); + _ = B; } diff --git a/test/behavior/bugs/7027.zig b/test/behavior/bugs/7027.zig index 782eebbfc9..064c511ca8 100644 --- a/test/behavior/bugs/7027.zig +++ b/test/behavior/bugs/7027.zig @@ -9,7 +9,9 @@ const Foobar = struct { } }; -fn foo(arg: anytype) void {} +fn foo(arg: anytype) void { + _ = arg; +} test "" { comptime var foobar = Foobar.foo(); diff --git a/test/behavior/bugs/704.zig b/test/behavior/bugs/704.zig index 765336c95f..15fe9419a6 100644 --- a/test/behavior/bugs/704.zig +++ b/test/behavior/bugs/704.zig @@ -1,5 +1,7 @@ const xxx = struct { - pub fn bar(self: *xxx) void {} + pub fn bar(self: *xxx) void { + _ = self; + } }; test "bug 704" { var x: xxx = undefined; diff --git a/test/behavior/bugs/7250.zig b/test/behavior/bugs/7250.zig index b0f1aa15df..862b75f851 100644 --- a/test/behavior/bugs/7250.zig +++ b/test/behavior/bugs/7250.zig @@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct { drv_inst_idx: u8, }; -pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {} +pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void { + _ = p_instance; +} threadlocal var g_uart0 = nrfx_uart_t{ .p_reg = 0, diff --git a/test/behavior/bugs/828.zig b/test/behavior/bugs/828.zig index 50ae0fd279..d54664f9c6 100644 --- a/test/behavior/bugs/828.zig +++ b/test/behavior/bugs/828.zig @@ -4,6 +4,7 @@ const CountBy = struct { const One = CountBy{ .a = 1 }; pub fn counter(self: *const CountBy) Counter { + _ = self; return Counter{ .i = 0 }; } }; @@ -18,6 +19,7 @@ const Counter = struct { }; fn constCount(comptime cb: *const CountBy, comptime unused: u32) void { + _ = unused; comptime { var cnt = cb.counter(); if (cnt.i != 0) @compileError("Counter instance reused!"); @@ -30,4 +32,8 @@ test "comptime struct return should not return the same instance" { //a second parameter is required to trigger the bug const ValA = constCount(&CountBy.One, 12); const ValB = constCount(&CountBy.One, 15); + if (false) { + ValA; + ValB; + } } diff --git a/test/behavior/bugs/920.zig b/test/behavior/bugs/920.zig index b148fce578..8d30f01369 100644 --- a/test/behavior/bugs/920.zig +++ b/test/behavior/bugs/920.zig @@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 { return math.sqrt(-2.0 * math.ln(y)); } fn norm_zero_case(random: *Random, u: f64) f64 { + _ = random; + _ = u; return 0.0; } diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 864579c8f0..e9e2df991e 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -102,6 +102,7 @@ fn castToOptionalTypeError(z: i32) !void { const f = z; const g: anyerror!?i32 = f; + _ = g catch {}; const a = A{ .a = z }; const b: anyerror!?A = a; @@ -114,7 +115,9 @@ test "implicitly cast from int to anyerror!?T" { } fn implicitIntLitToOptional() void { const f: ?i32 = 1; + _ = f; const g: anyerror!?i32 = 1; + _ = g catch {}; } test "return null from fn() anyerror!?&T" { @@ -821,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the test "cast between [*c]T and ?[*:0]T on fn parameter" { const S = struct { const Handler = ?fn ([*c]const u8) callconv(.C) void; - fn addCallback(handler: Handler) void {} + fn addCallback(handler: Handler) void { + _ = handler; + } - fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {} + fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void { + _ = cstr; + } fn doTheTest() void { addCallback(myCallback); diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig index a1a4bbdca8..dbda9f3238 100644 --- a/test/behavior/enum.zig +++ b/test/behavior/enum.zig @@ -111,6 +111,8 @@ test "enum type" { .y = 5678, }, }; + try expect(foo1.One == 13); + try expect(foo2.Two.x == 1234 and foo2.Two.y == 5678); const bar = Bar.B; try expect(bar == Bar.B); diff --git a/test/behavior/error.zig b/test/behavior/error.zig index c0b4dc0231..b1ef55af9e 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -103,6 +103,7 @@ fn testErrorSetType() !void { const a: MyErrSet!i32 = 5678; const b: MyErrSet!i32 = MyErrSet.OutOfMemory; + try expect(b catch error.OutOfMemory == error.OutOfMemory); if (a) |value| try expect(value == 5678) else |err| switch (err) { error.OutOfMemory => unreachable, @@ -138,7 +139,10 @@ test "comptime test error for empty error set" { const EmptyErrorSet = error{}; fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void { - if (x) |v| try expect(v == 1234) else |err| @compileError("bad"); + if (x) |v| try expect(v == 1234) else |err| { + _ = err; + @compileError("bad"); + } } test "syntax: optional operator in front of error union operator" { @@ -162,6 +166,7 @@ fn testErrToIntWithOnePossibleValue( test "empty error union" { const x = error{} || error{}; + _ = x; } test "error union peer type resolution" { @@ -204,6 +209,7 @@ fn entry() void { fn foo2(f: fn () anyerror!void) void { const x = f(); + x catch {}; } fn bar2() (error{}!void) {} @@ -338,6 +344,7 @@ test "optional error set is the same size as error set" { test "debug info for optional error set" { const SomeError = error{Hello}; var a_local_variable: ?SomeError = null; + _ = a_local_variable; } test "nested catch" { @@ -349,7 +356,7 @@ test "nested catch" { return error.Wrong; } fn func() anyerror!Foo { - const x = fail() catch + _ = fail() catch fail() catch return error.Bad; unreachable; @@ -390,6 +397,7 @@ test "function pointer with return type that is error union with payload which i const Err = error{UnspecifiedErr}; fn bar(a: i32) anyerror!*Foo { + _ = a; return Err.UnspecifiedErr; } @@ -444,7 +452,9 @@ test "error payload type is correctly resolved" { test "error union comptime caching" { const S = struct { - fn foo(comptime arg: anytype) void {} + fn foo(comptime arg: anytype) void { + arg catch {}; + } }; S.foo(@as(anyerror!void, {})); diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig index f86ee79761..80a3bccb7c 100644 --- a/test/behavior/eval.zig +++ b/test/behavior/eval.zig @@ -184,6 +184,7 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize { comptime var i: usize = 0; inline while (i < 10) : (i += 1) { const result = if (b) false else true; + _ = result; } comptime { return i; @@ -195,6 +196,7 @@ test "inlined loop has array literal with elided runtime scope on first iteratio comptime var i: usize = 0; inline while (i < 2) : (i += 1) { const result = if (i == 0) [1]i32{2} else runtime; + _ = result; } comptime { try expect(i == 2); @@ -420,6 +422,7 @@ test { } pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type { + _ = field_name; return struct { pub const Node = struct {}; }; @@ -696,7 +699,9 @@ test "refer to the type of a generic function" { f(i32); } -fn doNothingWithType(comptime T: type) void {} +fn doNothingWithType(comptime T: type) void { + _ = T; +} test "zero extend from u0 to u1" { var zero_u0: u0 = 0; @@ -817,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" { result.getCpuArch(); } - pub fn getCpuArch(self: CrossTarget) void {} + pub fn getCpuArch(self: CrossTarget) void { + _ = self; + } }; const DynamicLinker = struct { diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig index 75a1131072..2567582cd3 100644 --- a/test/behavior/fn.zig +++ b/test/behavior/fn.zig @@ -23,6 +23,7 @@ test "void parameters" { try voidFun(1, void{}, 2, {}); } fn voidFun(a: i32, b: void, c: i32, d: void) !void { + _ = d; const v = b; const vv: void = if (a == 1) v else {}; try expect(a + c == 3); @@ -57,7 +58,9 @@ test "call function with empty string" { acceptsString(""); } -fn acceptsString(foo: []u8) void {} +fn acceptsString(foo: []u8) void { + _ = foo; +} fn @"weird function name"() i32 { return 1234; @@ -70,7 +73,9 @@ test "implicit cast function unreachable return" { wantsFnWithVoid(fnWithUnreachable); } -fn wantsFnWithVoid(f: fn () void) void {} +fn wantsFnWithVoid(f: fn () void) void { + _ = f; +} fn fnWithUnreachable() noreturn { unreachable; @@ -162,6 +167,7 @@ const Point3 = struct { y: i32, fn addPointCoords(self: Point3, comptime T: type) i32 { + _ = T; return self.x + self.y; } }; diff --git a/test/behavior/for.zig b/test/behavior/for.zig index 9f08d41246..b022df0958 100644 --- a/test/behavior/for.zig +++ b/test/behavior/for.zig @@ -29,10 +29,14 @@ test "for loop with pointer elem var" { mangleString(target[0..]); try expect(mem.eql(u8, &target, "bcdefgh")); - for (source) |*c, i| + for (source) |*c, i| { + _ = i; try expect(@TypeOf(c) == *const u8); - for (target) |*c, i| + } + for (target) |*c, i| { + _ = i; try expect(@TypeOf(c) == *u8); + } } fn mangleString(s: []u8) void { @@ -53,6 +57,7 @@ test "basic for loop" { buf_index += 1; } for (array) |item, index| { + _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -62,6 +67,7 @@ test "basic for loop" { buf_index += 1; } for (array_ptr) |item, index| { + _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -70,7 +76,7 @@ test "basic for loop" { buffer[buf_index] = item; buf_index += 1; } - for (unknown_size) |item, index| { + for (unknown_size) |_, index| { buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -118,6 +124,7 @@ test "2 break statements and an else" { var buf: [10]u8 = undefined; var ok = false; ok = for (buf) |item| { + _ = item; if (f) break false; if (t) break true; } else false; @@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" { break item; } } else null) |v| { + _ = v; @panic("fail"); } } diff --git a/test/behavior/if.zig b/test/behavior/if.zig index 1951a9262a..e8c84f4570 100644 --- a/test/behavior/if.zig +++ b/test/behavior/if.zig @@ -45,7 +45,7 @@ var global_with_err: anyerror!u32 = error.SomeError; test "unwrap mutable global var" { if (global_with_val) |v| { try expect(v == 0); - } else |e| { + } else |_| { unreachable; } if (global_with_err) |_| { diff --git a/test/behavior/import.zig b/test/behavior/import.zig index 2b037637da..2018ee0b93 100644 --- a/test/behavior/import.zig +++ b/test/behavior/import.zig @@ -18,5 +18,5 @@ test "import in non-toplevel scope" { } test "import empty file" { - const empty = @import("import/empty.zig"); + _ = @import("import/empty.zig"); } diff --git a/test/behavior/inttoptr.zig b/test/behavior/inttoptr.zig index de6e8e3a1e..7c07a63b7c 100644 --- a/test/behavior/inttoptr.zig +++ b/test/behavior/inttoptr.zig @@ -5,7 +5,7 @@ test "casting random address to function pointer" { fn randomAddressToFunction() void { var addr: usize = 0xdeadbeef; - var ptr = @intToPtr(fn () void, addr); + _ = @intToPtr(fn () void, addr); } test "mutate through ptr initialized with constant intToPtr value" { diff --git a/test/behavior/ir_block_deps.zig b/test/behavior/ir_block_deps.zig index aacb7b7658..09c1532bff 100644 --- a/test/behavior/ir_block_deps.zig +++ b/test/behavior/ir_block_deps.zig @@ -5,6 +5,7 @@ fn foo(id: u64) !i32 { 1 => getErrInt(), 2 => { const size = try getErrInt(); + _ = size; return try getErrInt(); }, else => error.ItBroke, diff --git a/test/behavior/math.zig b/test/behavior/math.zig index e615c36551..5c746816e2 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -333,6 +333,12 @@ test "quad hex float literal parsing in range" { const b = 0x1.dedafcff354b6ae9758763545432p-9; const c = 0x1.2f34dd5f437e849b4baab754cdefp+4534; const d = 0x1.edcbff8ad76ab5bf46463233214fp-435; + if (false) { + a; + b; + c; + d; + } } test "quad hex float literal parsing accurate" { @@ -457,6 +463,11 @@ test "hex float literal within range" { const a = 0x1.0p16383; const b = 0x0.1p16387; const c = 0x1.0p-16382; + if (false) { + a; + b; + c; + } } test "truncating shift left" { diff --git a/test/behavior/misc.zig b/test/behavior/misc.zig index 35f088eb4d..6fabbf487b 100644 --- a/test/behavior/misc.zig +++ b/test/behavior/misc.zig @@ -234,6 +234,7 @@ test "compile time global reinterpret" { test "explicit cast maybe pointers" { const a: ?*i32 = undefined; const b: ?*f32 = @ptrCast(?*f32, a); + _ = b; } test "generic malloc free" { @@ -244,14 +245,18 @@ var some_mem: [100]u8 = undefined; fn memAlloc(comptime T: type, n: usize) anyerror![]T { return @ptrCast([*]T, &some_mem[0])[0..n]; } -fn memFree(comptime T: type, memory: []T) void {} +fn memFree(comptime T: type, memory: []T) void { + _ = memory; +} test "cast undefined" { const array: [100]u8 = undefined; const slice = @as([]const u8, &array); testCastUndefined(slice); } -fn testCastUndefined(x: []const u8) void {} +fn testCastUndefined(x: []const u8) void { + _ = x; +} test "cast small unsigned to larger signed" { try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200)); @@ -451,6 +456,7 @@ test "@typeName" { } fn TypeFromFn(comptime T: type) type { + _ = T; return struct {}; } @@ -554,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" { }), &(PackedUnion{ .a = 1 })); } -export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {} +export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { + if (false) { + a; + b; + } +} test "slicing zero length array" { const s1 = ""[0..]; @@ -583,6 +594,7 @@ test "self reference through fn ptr field" { }; fn foo(a: A) u8 { + _ = a; return 12; } }; @@ -752,7 +764,9 @@ test "extern variable with non-pointer opaque type" { test "lazy typeInfo value as generic parameter" { const S = struct { - fn foo(args: anytype) void {} + fn foo(args: anytype) void { + _ = args; + } }; S.foo(@typeInfo(@TypeOf(.{}))); } diff --git a/test/behavior/null.zig b/test/behavior/null.zig index 45401f621a..3bd652772b 100644 --- a/test/behavior/null.zig +++ b/test/behavior/null.zig @@ -39,6 +39,7 @@ test "test maybe object and get a pointer to the inner value" { test "rhs maybe unwrap return" { const x: ?bool = true; const y = x orelse return; + _ = y; } test "maybe return" { @@ -129,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined; test "unwrap optional which is field of global var" { struct_with_optional.field = null; if (struct_with_optional.field) |payload| { + _ = payload; unreachable; } struct_with_optional.field = 1234; diff --git a/test/behavior/optional.zig b/test/behavior/optional.zig index 75b4311159..2943915869 100644 --- a/test/behavior/optional.zig +++ b/test/behavior/optional.zig @@ -128,6 +128,7 @@ test "nested orelse" { const x = maybe() orelse maybe() orelse return null; + _ = x; unreachable; } const Foo = struct { @@ -160,6 +161,7 @@ test "self-referential struct through a slice of optional" { test "assigning to an unwrapped optional field in an inline loop" { comptime var maybe_pos_arg: ?comptime_int = null; inline for ("ab") |x| { + _ = x; maybe_pos_arg = 0; if (maybe_pos_arg.? != 0) { @compileError("bad"); diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig index a078e58ab5..bb95d3c219 100644 --- a/test/behavior/pointers.zig +++ b/test/behavior/pointers.zig @@ -65,6 +65,10 @@ test "assigning integer to C pointer" { var x: i32 = 0; var ptr: [*c]u8 = 0; var ptr2: [*c]u8 = x; + if (false) { + ptr; + ptr2; + } } test "implicit cast single item pointer to C pointer and back" { @@ -78,7 +82,6 @@ test "implicit cast single item pointer to C pointer and back" { test "C pointer comparison and arithmetic" { const S = struct { fn doTheTest() !void { - var one: usize = 1; var ptr1: [*c]u32 = 0; var ptr2 = ptr1 + 10; try expect(ptr1 == 0); @@ -176,6 +179,7 @@ test "assign null directly to C pointer and test null equality" { try expect(!(x != null)); try expect(!(null != x)); if (x) |same_x| { + _ = same_x; @panic("fail"); } var otherx: i32 = undefined; @@ -186,7 +190,10 @@ test "assign null directly to C pointer and test null equality" { comptime try expect(null == y); comptime try expect(!(y != null)); comptime try expect(!(null != y)); - if (y) |same_y| @panic("fail"); + if (y) |same_y| { + _ = same_y; + @panic("fail"); + } const othery: i32 = undefined; comptime try expect((y orelse &othery) == &othery); @@ -325,6 +332,7 @@ test "@ptrToInt on null optional at comptime" { { const pointer = @intToPtr(?*u8, 0x000); const x = @ptrToInt(pointer); + _ = x; comptime try expect(0 == @ptrToInt(pointer)); } { diff --git a/test/behavior/reflection.zig b/test/behavior/reflection.zig index 3e5e4087c4..e8596c2844 100644 --- a/test/behavior/reflection.zig +++ b/test/behavior/reflection.zig @@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" { } fn dummy(a: bool, b: i32, c: f32) i32 { + if (false) { + a; + b; + c; + } return 1234; } diff --git a/test/behavior/sizeof_and_typeof.zig b/test/behavior/sizeof_and_typeof.zig index d241448e05..60951a4c5a 100644 --- a/test/behavior/sizeof_and_typeof.zig +++ b/test/behavior/sizeof_and_typeof.zig @@ -195,11 +195,11 @@ test "branching logic inside @TypeOf" { fn fn1(alpha: bool) void { const n: usize = 7; - const v = if (alpha) n else @sizeOf(usize); + _ = if (alpha) n else @sizeOf(usize); } test "lazy @sizeOf result is checked for definedness" { - const f = fn1; + _ = fn1; } test "@bitSizeOf" { diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index d324c34477..38d0faa25a 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -104,6 +104,7 @@ test "obtaining a null terminated slice" { // now we obtain a null terminated slice: const ptr = buf[0..3 :0]; + _ = ptr; var runtime_len: usize = 3; const ptr2 = buf[0..runtime_len :0]; diff --git a/test/behavior/slice_sentinel_comptime.zig b/test/behavior/slice_sentinel_comptime.zig index 79da5d3c52..368860547e 100644 --- a/test/behavior/slice_sentinel_comptime.zig +++ b/test/behavior/slice_sentinel_comptime.zig @@ -3,6 +3,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { comptime { var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; const slice = target[0..3 :'d']; + _ = slice; } // ptr_array @@ -10,6 +11,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target = &buf; const slice = target[0..3 :'d']; + _ = slice; } // vector_ConstPtrSpecialBaseArray @@ -17,6 +19,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } // vector_ConstPtrSpecialRef @@ -24,6 +27,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = @ptrCast([*]u8, &buf); const slice = target[0..3 :'d']; + _ = slice; } // cvector_ConstPtrSpecialBaseArray @@ -31,6 +35,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } // cvector_ConstPtrSpecialRef @@ -38,6 +43,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = @ptrCast([*c]u8, &buf); const slice = target[0..3 :'d']; + _ = slice; } // slice @@ -45,6 +51,7 @@ test "comptime slice-sentinel in bounds (unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: []u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } } @@ -53,6 +60,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { comptime { var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; const slice = target[0..13 :0xff]; + _ = slice; } // ptr_array @@ -60,6 +68,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target = &buf; const slice = target[0..13 :0xff]; + _ = slice; } // vector_ConstPtrSpecialBaseArray @@ -67,6 +76,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target: [*]u8 = &buf; const slice = target[0..13 :0xff]; + _ = slice; } // vector_ConstPtrSpecialRef @@ -74,6 +84,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target: [*]u8 = @ptrCast([*]u8, &buf); const slice = target[0..13 :0xff]; + _ = slice; } // cvector_ConstPtrSpecialBaseArray @@ -81,6 +92,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target: [*c]u8 = &buf; const slice = target[0..13 :0xff]; + _ = slice; } // cvector_ConstPtrSpecialRef @@ -88,6 +100,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target: [*c]u8 = @ptrCast([*c]u8, &buf); const slice = target[0..13 :0xff]; + _ = slice; } // slice @@ -95,6 +108,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" { var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; var target: []u8 = &buf; const slice = target[0..13 :0xff]; + _ = slice; } } @@ -103,6 +117,7 @@ test "comptime slice-sentinel in bounds (terminated)" { comptime { var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; const slice = target[0..3 :'d']; + _ = slice; } // ptr_array @@ -110,6 +125,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target = &buf; const slice = target[0..3 :'d']; + _ = slice; } // vector_ConstPtrSpecialBaseArray @@ -117,6 +133,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } // vector_ConstPtrSpecialRef @@ -124,6 +141,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = @ptrCast([*]u8, &buf); const slice = target[0..3 :'d']; + _ = slice; } // cvector_ConstPtrSpecialBaseArray @@ -131,6 +149,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } // cvector_ConstPtrSpecialRef @@ -138,6 +157,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = @ptrCast([*c]u8, &buf); const slice = target[0..3 :'d']; + _ = slice; } // slice @@ -145,6 +165,7 @@ test "comptime slice-sentinel in bounds (terminated)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: []u8 = &buf; const slice = target[0..3 :'d']; + _ = slice; } } @@ -153,6 +174,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { comptime { var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; const slice = target[0..14 :0]; + _ = slice; } // ptr_array @@ -160,6 +182,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target = &buf; const slice = target[0..14 :0]; + _ = slice; } // vector_ConstPtrSpecialBaseArray @@ -167,6 +190,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = &buf; const slice = target[0..14 :0]; + _ = slice; } // vector_ConstPtrSpecialRef @@ -174,6 +198,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*]u8 = @ptrCast([*]u8, &buf); const slice = target[0..14 :0]; + _ = slice; } // cvector_ConstPtrSpecialBaseArray @@ -181,6 +206,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = &buf; const slice = target[0..14 :0]; + _ = slice; } // cvector_ConstPtrSpecialRef @@ -188,6 +214,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: [*c]u8 = @ptrCast([*c]u8, &buf); const slice = target[0..14 :0]; + _ = slice; } // slice @@ -195,5 +222,6 @@ test "comptime slice-sentinel in bounds (on target sentinel)" { var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; var target: []u8 = &buf; const slice = target[0..14 :0]; + _ = slice; } } diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 9773680922..4f7e0c2d71 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -182,6 +182,7 @@ test "empty struct method call" { } const EmptyStruct = struct { fn method(es: *const EmptyStruct) i32 { + _ = es; return 1234; } }; @@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T { test "call method with mutable reference to struct with no fields" { const S = struct { fn doC(s: *const @This()) bool { + _ = s; return true; } fn do(s: *@This()) bool { + _ = s; return true; } }; @@ -584,13 +587,14 @@ test "default struct initialization fields" { const x = S{ .b = 5, }; - if (x.a + x.b != 1239) { - @compileError("it should be comptime known"); - } var five: i32 = 5; const y = S{ .b = five, }; + if (x.a + x.b != 1239) { + @compileError("it should be comptime known"); + } + try expectEqual(y, x); try expectEqual(1239, x.a + x.b); } @@ -624,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" { var ok = true; fn eql(a: []const u8) bool { + _ = a; return true; } const ArrayList = struct { fn toSlice(self: *ArrayList) []*Foo { + _ = self; return @as([*]*Foo, undefined)[0..0]; } }; @@ -654,6 +660,7 @@ test "zero-bit field in packed struct" { y: void, }; var x: S = undefined; + _ = x; } test "struct field init with catch" { diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 9d05e3edea..e512565b80 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -103,6 +103,7 @@ fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void { }, SwitchProngWithVarEnum.Meh => |x| { const v: void = x; + _ = v; }, } } @@ -385,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" { 0 => true, else => null, }) |v| { + _ = v; @panic("fail"); } } @@ -410,12 +412,18 @@ test "switch prongs with cases with identical payload types" { try expect(@TypeOf(e) == usize); try expect(e == 8); }, - .B => |e| @panic("fail"), + .B => |e| { + _ = e; + @panic("fail"); + }, } } fn doTheSwitch2(u: Union) !void { switch (u) { - .A, .C => |e| @panic("fail"), + .A, .C => |e| { + _ = e; + @panic("fail"); + }, .B => |e| { try expect(@TypeOf(e) == isize); try expect(e == -8); @@ -454,6 +462,7 @@ test "switch variable for range and multiple prongs" { } } }; + _ = S; } var state: u32 = 0; @@ -506,7 +515,10 @@ test "switch on error set with single else" { fn doTheTest() !void { var some: error{Foo} = error.Foo; try expect(switch (some) { - else => |a| true, + else => |a| blk: { + a catch {}; + break :blk true; + }, }); } }; diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig index 29d44d582f..632e5be013 100644 --- a/test/behavior/tuple.zig +++ b/test/behavior/tuple.zig @@ -105,6 +105,7 @@ test "tuple initializer for var" { .id = @as(usize, 2), .name = Bytes{ .id = 20 }, }; + _ = tmp; } }; diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 5d12ea494f..3a56f2171f 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -431,11 +431,14 @@ test "Type.Fn" { const foo = struct { fn func(a: usize, b: bool) align(4) callconv(.C) usize { + _ = a; + _ = b; return 0; } }.func; const Foo = @Type(@typeInfo(@TypeOf(foo))); const foo_2: Foo = foo; + _ = foo_2; } test "Type.BoundFn" { @@ -443,7 +446,9 @@ test "Type.BoundFn" { if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest; const TestStruct = packed struct { - pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {} + pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void { + _ = self; + } }; const test_instance: TestStruct = undefined; try testing.expect(std.meta.eql( diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index 6e9fbe676d..8e8039372c 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -277,7 +277,9 @@ const TestStruct = packed struct { fieldC: *Self, fieldD: u32 = 4, - pub fn foo(self: *const Self) void {} + pub fn foo(self: *const Self) void { + _ = self; + } const Self = @This(); }; @@ -326,9 +328,12 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize; test "typeInfo with comptime parameter in struct fn def" { const S = struct { - pub fn func(comptime x: f32) void {} + pub fn func(comptime x: f32) void { + _ = x; + } }; comptime var info = @typeInfo(S); + _ = info; } test "type info: vectors" { @@ -368,6 +373,7 @@ test "type info: pass to function" { } fn passTypeInfo(comptime info: TypeInfo) type { + _ = info; return void; } diff --git a/test/behavior/underscore.zig b/test/behavior/underscore.zig index 516d33a4eb..abe219f3e0 100644 --- a/test/behavior/underscore.zig +++ b/test/behavior/underscore.zig @@ -7,7 +7,9 @@ test "ignore lval with underscore" { test "ignore lval with underscore (for loop)" { for ([_]void{}) |_, i| { + _ = i; for ([_]void{}) |_, j| { + _ = j; break; } break; diff --git a/test/behavior/union.zig b/test/behavior/union.zig index bcdd3fa247..f7c0c93696 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -374,7 +374,9 @@ const Attribute = union(enum) { B: u8, }; -fn setAttribute(attr: Attribute) void {} +fn setAttribute(attr: Attribute) void { + _ = attr; +} fn Setter(attr: Attribute) type { return struct { @@ -465,7 +467,9 @@ test "union no tag with struct member" { const Struct = struct {}; const Union = union { s: Struct, - pub fn foo(self: *@This()) void {} + pub fn foo(self: *@This()) void { + _ = self; + } }; var u = Union{ .s = Struct{} }; u.foo(); @@ -703,6 +707,7 @@ test "method call on an empty union" { X2: [0]u8, pub fn useIt(self: *@This()) bool { + _ = self; return true; } }; @@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" { no_op: void, pub fn decode(buf: []const u8) Data { + _ = buf; return @unionInit(Data, "no_op", {}); } }; @@ -781,6 +787,7 @@ test "@unionInit on union w/ tag but no fields" { fn doTheTest() !void { var data: Data = .{ .no_op = .{} }; + _ = data; var o = Data.decode(&[_]u8{}); try expectEqual(Type.no_op, o); } diff --git a/test/behavior/var_args.zig b/test/behavior/var_args.zig index 8935877167..40770e1334 100644 --- a/test/behavior/var_args.zig +++ b/test/behavior/var_args.zig @@ -18,7 +18,7 @@ test "add arbitrary args" { } fn readFirstVarArg(args: anytype) void { - const value = args[0]; + _ = args[0]; } test "send void arg to var args" { @@ -48,6 +48,7 @@ test "runtime parameter before var args" { } fn extraFn(extra: u32, args: anytype) !usize { + _ = extra; if (args.len >= 1) { try expect(args[0] == false); } @@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{ }; fn foo1(args: anytype) bool { + _ = args; return true; } fn foo2(args: anytype) bool { + _ = args; return false; } @@ -79,5 +82,5 @@ test "pass zero length array to var args param" { } fn doNothingWithFirstArg(args: anytype) void { - const a = args[0]; + _ = args[0]; } diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 77793b67e6..2c615b542b 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -113,6 +113,7 @@ test "array to vector" { var foo: f32 = 3.14; var arr = [4]f32{ foo, 1.5, 0.0, 0.0 }; var vec: Vector(4, f32) = arr; + _ = vec; } test "vector casts of sizes not divisable by 8" { @@ -264,6 +265,7 @@ test "initialize vector which is a struct field" { var foo = Vec4Obj{ .data = [_]f32{ 1, 2, 3, 4 }, }; + _ = foo; } }; try S.doTheTest(); @@ -632,3 +634,16 @@ test "vector reduce operation" { try S.doTheTest(); comptime try S.doTheTest(); } + +test "mask parameter of @shuffle is comptime scope" { + const __v4hi = std.meta.Vector(4, i16); + var v4_a = __v4hi{ 0, 0, 0, 0 }; + var v4_b = __v4hi{ 0, 0, 0, 0 }; + var shuffled: __v4hi = @shuffle(i16, v4_a, v4_b, std.meta.Vector(4, i32){ + std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), + std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), + std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), + std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), + }); + _ = shuffled; +} diff --git a/test/behavior/void.zig b/test/behavior/void.zig index 4f49d5fca1..17778d42de 100644 --- a/test/behavior/void.zig +++ b/test/behavior/void.zig @@ -36,5 +36,5 @@ test "void optional" { test "void array as a local variable initializer" { var x = [_]void{{}} ** 1004; - var y = x[0]; + _ = x[0]; } diff --git a/test/behavior/while.zig b/test/behavior/while.zig index a237b4b866..e52adfdbcf 100644 --- a/test/behavior/while.zig +++ b/test/behavior/while.zig @@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" { test "while on error union with else result follow else prong" { const result = while (returnError()) |value| { break value; - } else |err| @as(i32, 2); + } else |_| @as(i32, 2); try expect(result == 2); } test "while on error union with else result follow break prong" { const result = while (returnSuccess(10)) |value| { break value; - } else |err| @as(i32, 2); + } else |_| @as(i32, 2); try expect(result == 10); } diff --git a/test/cli.zig b/test/cli.zig index 556452f832..e3a00fe735 100644 --- a/test/cli.zig +++ b/test/cli.zig @@ -116,6 +116,8 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void { \\} \\extern fn zig_panic() noreturn; \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn { + \\ _ = msg; + \\ _ = error_return_trace; \\ zig_panic(); \\} ); diff --git a/test/compare_output.zig b/test/compare_output.zig index b6d333a073..742e43e6c7 100644 --- a/test/compare_output.zig +++ b/test/compare_output.zig @@ -10,6 +10,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @cInclude("stdio.h"); \\}); \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int { + \\ _ = argc; + \\ _ = argv; \\ _ = c.puts("Hello, world!"); \\ return 0; \\} @@ -143,6 +145,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\}); \\ \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int { + \\ _ = argc; + \\ _ = argv; \\ if (is_windows) { \\ // we want actual \n, not \r\n \\ _ = c._setmode(1, c._O_BINARY); @@ -265,8 +269,10 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const y : u16 = 5678; \\pub fn main() void { \\ var x_local : i32 = print_ok(x); + \\ _ = x_local; \\} \\fn print_ok(val: @TypeOf(x)) @TypeOf(foo) { + \\ _ = val; \\ const stdout = io.getStdOut().writer(); \\ stdout.print("OK\n", .{}) catch unreachable; \\ return 0; @@ -318,6 +324,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\}); \\ \\pub export fn main(argc: c_int, argv: [*][*]u8) c_int { + \\ _ = argc; + \\ _ = argv; \\ if (is_windows) { \\ // we want actual \n, not \r\n \\ _ = c._setmode(1, c._O_BINARY); @@ -337,13 +345,19 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const Foo = struct { \\ field1: Bar, \\ - \\ fn method(a: *const Foo) bool { return true; } + \\ fn method(a: *const Foo) bool { + \\ _ = a; + \\ return true; + \\ } \\}; \\ \\const Bar = struct { \\ field2: i32, \\ - \\ fn method(b: *const Bar) bool { return true; } + \\ fn method(b: *const Bar) bool { + \\ _ = b; + \\ return true; + \\ } \\}; \\ \\pub fn main() void { diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 65c7de6dec..bb7cfcfc1d 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -8439,4 +8439,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { , &[_][]const u8{ "tmp.zig:2:30: error: `.*` cannot be followed by `*`. Are you missing a space?", }); + + cases.add("Issue #9165: windows tcp server compilation error", + \\const std = @import("std"); + \\pub const io_mode = .evented; + \\pub fn main() !void { + \\ if (std.builtin.os.tag == .windows) { + \\ _ = try (std.net.StreamServer.init(.{})).accept(); + \\ } else { + \\ @compileError("Unsupported OS"); + \\ } + \\} + , &[_][]const u8{ + "error: Unsupported OS", + }); } diff --git a/test/run_translated_c.zig b/test/run_translated_c.zig index 4440802c33..03f06ed8ca 100644 --- a/test/run_translated_c.zig +++ b/test/run_translated_c.zig @@ -1598,4 +1598,53 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { \\ return 0; \\} , ""); + + cases.add("Enum constants are assigned correct type. Issue #9153", + \\enum A { A0, A1=0xFFFFFFFF }; + \\enum B { B0=-1, B1=0xFFFFFFFF }; + \\enum C { C0=-1, C1=0 }; + \\enum D { D0, D1=0xFFFFFFFFFFL }; + \\enum E { E0=-1, E1=0xFFFFFFFFFFL }; + \\int main(void) { + \\ signed char a0 = A0, a1 = A1; + \\ signed char b0 = B0, b1 = B1; + \\ signed char c0 = C0, c1 = C1; + \\ signed char d0 = D0, d1 = D1; + \\ signed char e0 = E0, e1 = E1; + \\ return 0; + \\} + , ""); + + cases.add("Enum constant matches enum name; multiple enumerations with same value", + \\#include <stdlib.h> + \\enum FOO { + \\ FOO = 1, + \\ BAR = 2, + \\ BAZ = 1, + \\}; + \\int main(void) { + \\ enum FOO x = BAZ; + \\ if (x != 1) abort(); + \\ if (x != BAZ) abort(); + \\ if (x != FOO) abort(); + \\} + , ""); + + cases.add("Scoped enums", + \\#include <stdlib.h> + \\int main(void) { + \\ enum Foo { A, B, C }; + \\ enum Foo a = B; + \\ if (a != B) abort(); + \\ if (a != 1) abort(); + \\ { + \\ enum Foo { A = 5, B = 6, C = 7 }; + \\ enum Foo a = B; + \\ if (a != B) abort(); + \\ if (a != 6) abort(); + \\ } + \\ if (a != B) abort(); + \\ if (a != 1) abort(); + \\} + , ""); } diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 16286e0a56..6d68a2e1dd 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -4,6 +4,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { { const check_panic_msg = \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "reached unreachable code")) { \\ std.process.exit(126); // good \\ } @@ -45,6 +46,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { { const check_panic_msg = \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "invalid enum value")) { \\ std.process.exit(126); // good \\ } @@ -62,6 +64,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var e: E = undefined; \\ @memset(@ptrCast([*]u8, &e), 0x55, @sizeOf(E)); \\ var n = @tagName(e); + \\ _ = n; \\} ); @@ -76,6 +79,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @memset(@ptrCast([*]u8, &u), 0x55, @sizeOf(U)); \\ var t: @typeInfo(U).Union.tag_type.? = u; \\ var n = @tagName(t); + \\ _ = n; \\} ); } @@ -83,6 +87,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { { const check_panic_msg = \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "index out of bounds")) { \\ std.process.exit(126); // good \\ } @@ -96,6 +101,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf = [4]u8{'a','b','c',0}; \\ const slice = buf[0..4 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -104,6 +110,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf = [4]u8{'a','b','c',0}; \\ const slice = buf[0..:0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -112,6 +119,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf_zero = [0]u8{}; \\ const slice = buf_zero[0..0 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -120,6 +128,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf_zero = [0]u8{}; \\ const slice = buf_zero[0..:0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -129,6 +138,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var buf_sentinel = [2:0]u8{'a','b'}; \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; \\ const slice = buf_sentinel[0..3 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -137,6 +147,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; \\ const slice = buf_slice[0..3 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slicing operator with sentinel", @@ -145,6 +156,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; \\ const slice = buf_slice[0.. :0]; + \\ _ = slice; \\} ); } @@ -153,6 +165,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); \\const V = @import("std").meta.Vector; \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { \\ std.process.exit(126); // good \\ } @@ -161,6 +174,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var x = @splat(4, @as(u32, 0xdeadbeef)); \\ var y = @intCast(V(4, u16), x); + \\ _ = y; \\} ); @@ -168,6 +182,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); \\const V = @import("std").meta.Vector; \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "integer cast truncated bits")) { \\ std.process.exit(126); // good \\ } @@ -176,6 +191,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var x = @splat(4, @as(u32, 0x80000000)); \\ var y = @intCast(V(4, i32), x); + \\ _ = y; \\} ); @@ -183,6 +199,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); \\const V = @import("std").meta.Vector; \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "attempt to cast negative value to unsigned integer")) { \\ std.process.exit(126); // good \\ } @@ -191,12 +208,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var x = @splat(4, @as(i32, -2147483647)); \\ var y = @intCast(V(4, u32), x); + \\ _ = y; \\} ); cases.addRuntimeSafety("shift left by huge amount", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { \\ std.process.exit(126); // good \\ } @@ -206,12 +225,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var x: u24 = 42; \\ var y: u5 = 24; \\ var z = x >> y; + \\ _ = z; \\} ); cases.addRuntimeSafety("shift right by huge amount", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "shift amount is greater than the type size")) { \\ std.process.exit(126); // good \\ } @@ -221,12 +242,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var x: u24 = 42; \\ var y: u5 = 24; \\ var z = x << y; + \\ _ = z; \\} ); cases.addRuntimeSafety("slice sentinel mismatch - optional pointers", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { \\ std.process.exit(126); // good \\ } @@ -235,12 +258,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf: [4]?*i32 = undefined; \\ const slice = buf[0..3 :null]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slice sentinel mismatch - floats", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { \\ std.process.exit(126); // good \\ } @@ -249,12 +274,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf: [4]f32 = undefined; \\ const slice = buf[0..3 :1.2]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("pointer slice sentinel mismatch", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { \\ std.process.exit(126); // good \\ } @@ -264,12 +291,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var buf: [4]u8 = undefined; \\ const ptr: [*]u8 = &buf; \\ const slice = ptr[0..3 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("slice slice sentinel mismatch", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { \\ std.process.exit(126); // good \\ } @@ -279,12 +308,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var buf: [4]u8 = undefined; \\ const slice = buf[0..]; \\ const slice2 = slice[0..3 :0]; + \\ _ = slice2; \\} ); cases.addRuntimeSafety("array slice sentinel mismatch", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "sentinel mismatch")) { \\ std.process.exit(126); // good \\ } @@ -293,12 +324,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var buf: [4]u8 = undefined; \\ const slice = buf[0..3 :0]; + \\ _ = slice; \\} ); cases.addRuntimeSafety("intToPtr with misaligned address", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "incorrect alignment")) { \\ std.os.exit(126); // good \\ } @@ -307,16 +340,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ var x: usize = 5; \\ var y = @intToPtr([*]align(4) u8, x); + \\ _ = y; \\} ); cases.addRuntimeSafety("resuming a non-suspended function which never been suspended", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\fn foo() void { \\ var f = async bar(@frame()); + \\ _ = f; \\ std.os.exit(0); \\} \\ @@ -335,6 +372,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("resuming a non-suspended function which has been suspended and resumed", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\fn foo() void { @@ -342,6 +381,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ global_frame = @frame(); \\ } \\ var f = async bar(@frame()); + \\ _ = f; \\ std.os.exit(0); \\} \\ @@ -363,6 +403,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("nosuspend function call, callee suspends", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -379,6 +421,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("awaiting twice", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\var frame: anyframe = undefined; @@ -404,12 +448,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("@asyncCall with too small a frame", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var bytes: [1]u8 align(16) = undefined; \\ var ptr = other; \\ var frame = @asyncCall(&bytes, {}, ptr, .{}); + \\ _ = frame; \\} \\fn other() callconv(.Async) void { \\ suspend {} @@ -419,6 +466,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("resuming a function which is awaiting a frame", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -437,6 +486,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("resuming a function which is awaiting a call", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -454,6 +505,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("invalid resume of async function", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -469,61 +522,78 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety(".? operator on null pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var ptr: ?*i32 = null; \\ var b = ptr.?; + \\ _ = b; \\} ); cases.addRuntimeSafety(".? operator on C pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var ptr: [*c]i32 = null; \\ var b = ptr.?; + \\ _ = b; \\} ); cases.addRuntimeSafety("@intToPtr address zero to non-optional pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var zero: usize = 0; \\ var b = @intToPtr(*i32, zero); + \\ _ = b; \\} ); cases.addRuntimeSafety("@intToPtr address zero to non-optional byte-aligned pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var zero: usize = 0; \\ var b = @intToPtr(*u8, zero); + \\ _ = b; \\} ); cases.addRuntimeSafety("pointer casting null to non-optional pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var c_ptr: [*c]u8 = 0; \\ var zig_ptr: *u8 = c_ptr; + \\ _ = zig_ptr; \\} ); cases.addRuntimeSafety("@intToEnum - no matching tag value", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\const Foo = enum { @@ -537,12 +607,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\fn bar(a: u2) Foo { \\ return @intToEnum(Foo, a); \\} - \\fn baz(a: Foo) void {} + \\fn baz(_: Foo) void {} ); cases.addRuntimeSafety("@floatToInt cannot fit - negative to unsigned", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -551,12 +623,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\fn bar(a: f32) u8 { \\ return @floatToInt(u8, a); \\} - \\fn baz(a: u8) void { } + \\fn baz(_: u8) void { } ); cases.addRuntimeSafety("@floatToInt cannot fit - negative out of range", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -565,12 +639,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\fn bar(a: f32) i8 { \\ return @floatToInt(i8, a); \\} - \\fn baz(a: i8) void { } + \\fn baz(_: i8) void { } ); cases.addRuntimeSafety("@floatToInt cannot fit - positive out of range", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -579,12 +655,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\fn bar(a: f32) u8 { \\ return @floatToInt(u8, a); \\} - \\fn baz(a: u8) void { } + \\fn baz(_: u8) void { } ); cases.addRuntimeSafety("calling panic", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -595,6 +673,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("out of bounds slice access", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -604,12 +684,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\fn bar(a: []const i32) i32 { \\ return a[4]; \\} - \\fn baz(a: i32) void { } + \\fn baz(_: i32) void { } ); cases.addRuntimeSafety("integer addition overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -624,12 +706,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("vector integer addition overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 }; \\ var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 }; \\ const x = add(a, b); + \\ _ = x; \\} \\fn add(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { \\ return a + b; @@ -639,12 +724,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("vector integer subtraction overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var a: std.meta.Vector(4, u32) = [_]u32{ 1, 2, 8, 4 }; \\ var b: std.meta.Vector(4, u32) = [_]u32{ 5, 6, 7, 8 }; \\ const x = sub(b, a); + \\ _ = x; \\} \\fn sub(a: std.meta.Vector(4, u32), b: std.meta.Vector(4, u32)) std.meta.Vector(4, u32) { \\ return a - b; @@ -654,12 +742,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("vector integer multiplication overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var a: std.meta.Vector(4, u8) = [_]u8{ 1, 2, 200, 4 }; \\ var b: std.meta.Vector(4, u8) = [_]u8{ 5, 6, 2, 8 }; \\ const x = mul(b, a); + \\ _ = x; \\} \\fn mul(a: std.meta.Vector(4, u8), b: std.meta.Vector(4, u8)) std.meta.Vector(4, u8) { \\ return a * b; @@ -669,11 +760,14 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("vector integer negation overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var a: std.meta.Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 }; \\ const x = neg(a); + \\ _ = x; \\} \\fn neg(a: std.meta.Vector(4, i16)) std.meta.Vector(4, i16) { \\ return -a; @@ -683,6 +777,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("integer subtraction overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -697,6 +793,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("integer multiplication overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -711,6 +809,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("integer negation overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -725,6 +825,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed integer division overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -739,6 +841,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed integer division overflow - vectors", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -755,6 +859,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed shift left overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -769,6 +875,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("unsigned shift left overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -783,6 +891,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed shift right overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -797,6 +907,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("unsigned shift right overflow", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -811,10 +923,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("integer division by zero", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ const x = div0(999, 0); + \\ _ = x; \\} \\fn div0(a: i32, b: i32) i32 { \\ return @divTrunc(a, b); @@ -824,12 +939,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("integer division by zero - vectors", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 0, 333, 444}; \\ const x = div0(a, b); + \\ _ = x; \\} \\fn div0(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { \\ return @divTrunc(a, b); @@ -839,6 +957,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("exact division failure", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -853,12 +973,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("exact division failure - vectors", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444}; \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 441}; \\ const x = divExact(a, b); + \\ _ = x; \\} \\fn divExact(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) { \\ return @divExact(a, b); @@ -868,6 +991,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -882,6 +1007,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("value does not fit in shortening cast", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -896,6 +1023,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("value does not fit in shortening cast - u0", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -910,6 +1039,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -924,28 +1055,35 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer - widening", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var value: c_short = -1; \\ var casted = @intCast(u32, value); + \\ _ = casted; \\} ); cases.addRuntimeSafety("unsigned integer not fitting in cast to signed integer - same bit count", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { \\ var value: u8 = 245; \\ var casted = @intCast(i8, value); + \\ _ = casted; \\} ); cases.addRuntimeSafety("unwrap error", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = stack_trace; \\ if (std.mem.eql(u8, message, "attempt to unwrap error: Whatever")) { \\ std.os.exit(126); // good \\ } @@ -962,6 +1100,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("cast integer to global error and no code matches", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() void { @@ -975,6 +1115,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("@errSetCast error not present in destination", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\const Set1 = error{A, B}; @@ -990,6 +1132,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("@alignCast misaligned", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\pub fn main() !void { @@ -1007,6 +1151,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("bad union field access", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\ @@ -1031,6 +1177,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("@intCast to u0", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\ @@ -1040,6 +1188,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ \\fn bar(one: u1, not_zero: i32) void { \\ var x = one << @intCast(u0, not_zero); + \\ _ = x; \\} ); @@ -1049,6 +1198,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); \\ \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\ @@ -1058,6 +1209,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ const p = nonFailing(); \\ resume p; \\ const p2 = async printTrace(p); + \\ _ = p2; \\} \\ \\fn nonFailing() anyframe->anyerror!void { @@ -1084,12 +1236,15 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.addRuntimeSafety("slicing null C pointer", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { + \\ _ = message; + \\ _ = stack_trace; \\ std.os.exit(126); \\} \\ \\pub fn main() void { \\ var ptr: [*c]const u32 = null; \\ var slice = ptr[0..3]; + \\ _ = slice; \\} ); } diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index eec475e3da..fd55015dd5 100644 --- a/test/stage2/cbe.zig +++ b/test/stage2/cbe.zig @@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void { , ""); case.addError( \\pub export fn main() c_int { - \\ const c = @intToError(0); + \\ _ = @intToError(0); \\ return 0; \\} - , &.{":2:27: error: integer value 0 represents no error"}); + , &.{":2:21: error: integer value 0 represents no error"}); case.addError( \\pub export fn main() c_int { - \\ const c = @intToError(3); + \\ _ = @intToError(3); \\ return 0; \\} - , &.{":2:27: error: integer value 3 represents no error"}); + , &.{":2:21: error: integer value 3 represents no error"}); } { @@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ true => 2, \\ false => 3, \\ }; + \\ _ = b; \\} , &.{ ":6:9: error: duplicate switch value", @@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ f64, i32 => 3, \\ else => 4, \\ }; + \\ _ = b; \\} , &.{ ":6:14: error: duplicate switch value", @@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ f16...f64 => 3, \\ else => 4, \\ }; + \\ _ = b; \\} , &.{ ":3:30: error: ranges not allowed when switching on type 'type'", @@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ 3 => 40, \\ else => 50, \\ }; + \\ _ = b; \\} , &.{ ":8:14: error: unreachable else prong; all cases already handled", @@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void { \\const E1 = packed enum { a, b, c }; \\const E2 = extern enum { a, b, c }; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} \\export fn bar() void { - \\ const x = E2.a; + \\ _ = E2.a; \\} , &.{ ":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type", @@ -579,10 +583,10 @@ pub fn addCases(ctx: *TestContext) !void { \\ c, \\}; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} \\export fn bar() void { - \\ const x = E2.a; + \\ _ = E2.a; \\} , &.{ ":3:5: error: enum fields cannot be marked comptime", @@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ c, \\}; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":3:7: error: expected ',', found 'align'", @@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ _, \\}; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":6:5: error: redundant non-exhaustive enum mark", @@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ _ = 10, \\}; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value", @@ -662,7 +666,7 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\const E1 = enum {}; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":1:12: error: enum declarations must have at least one tag", @@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\const E1 = enum { a, b, _ }; \\export fn foo() void { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":1:12: error: non-exhaustive enum missing integer tag type", @@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\const E1 = enum { a, b, c, b, d }; \\pub export fn main() c_int { - \\ const x = E1.a; + \\ _ = E1.a; \\} , &.{ ":1:28: error: duplicate enum tag", @@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\pub export fn main() c_int { \\ const a = true; - \\ const b = @enumToInt(a); + \\ _ = @enumToInt(a); \\} , &.{ - ":3:26: error: expected enum or tagged union, found bool", + ":3:20: error: expected enum or tagged union, found bool", }); case.addError( \\pub export fn main() c_int { \\ const a = 1; - \\ const b = @intToEnum(bool, a); + \\ _ = @intToEnum(bool, a); \\} , &.{ - ":3:26: error: expected enum, found bool", + ":3:20: error: expected enum, found bool", }); case.addError( \\const E = enum { a, b, c }; \\pub export fn main() c_int { - \\ const b = @intToEnum(E, 3); + \\ _ = @intToEnum(E, 3); \\} , &.{ - ":3:15: error: enum 'test_case.E' has no tag with value 3", + ":3:9: error: enum 'test_case.E' has no tag with value 3", ":1:11: note: enum declared here", }); @@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\const E = enum { a, b, c }; \\pub export fn main() c_int { - \\ var x = E.d; + \\ _ = E.d; \\} , &.{ - ":3:14: error: enum 'test_case.E' has no member named 'd'", + ":3:10: error: enum 'test_case.E' has no member named 'd'", ":1:11: note: enum declared here", }); @@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void { \\const E = enum { a, b, c }; \\pub export fn main() c_int { \\ var x: E = .d; + \\ _ = x; \\} , &.{ ":3:17: error: enum 'test_case.E' has no field named 'd'", @@ -818,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void { \\ ); ctx.h("header with single param function", linux_x64, - \\export fn start(a: u8) void{} + \\export fn start(a: u8) void{ + \\ _ = a; + \\} , \\ZIG_EXTERN_C void start(uint8_t a0); \\ ); ctx.h("header with multiple param function", linux_x64, - \\export fn start(a: u8, b: u8, c: u8) void{} + \\export fn start(a: u8, b: u8, c: u8) void{ + \\ _ = a; _ = b; _ = c; + \\} , \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2); \\ ); ctx.h("header with u32 param function", linux_x64, - \\export fn start(a: u32) void{} + \\export fn start(a: u32) void{ _ = a; } , \\ZIG_EXTERN_C void start(uint32_t a0); \\ ); ctx.h("header with usize param function", linux_x64, - \\export fn start(a: usize) void{} + \\export fn start(a: usize) void{ _ = a; } , \\ZIG_EXTERN_C void start(uintptr_t a0); \\ ); ctx.h("header with bool param function", linux_x64, - \\export fn start(a: bool) void{} + \\export fn start(a: bool) void{_ = a;} , \\ZIG_EXTERN_C void start(bool a0); \\ @@ -866,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ ); ctx.h("header with multiple includes", linux_x64, - \\export fn start(a: u32, b: usize) void{} + \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; } , \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1); \\ diff --git a/test/stage2/darwin.zig b/test/stage2/darwin.zig index 1c4dc5c2d3..e65702f230 100644 --- a/test/stage2/darwin.zig +++ b/test/stage2/darwin.zig @@ -14,7 +14,7 @@ pub fn addCases(ctx: *TestContext) !void { { var case = ctx.exe("hello world with updates", target); case.addError("", &[_][]const u8{ - ":84:9: error: struct 'test_case.test_case' has no member named 'main'", + ":85:9: error: struct 'test_case.test_case' has no member named 'main'", }); // Incorrect return type diff --git a/test/stage2/test.zig b/test/stage2/test.zig index 46f5fa1ba0..8ce46f2064 100644 --- a/test/stage2/test.zig +++ b/test/stage2/test.zig @@ -24,7 +24,7 @@ pub fn addCases(ctx: *TestContext) !void { var case = ctx.exe("hello world with updates", linux_x64); case.addError("", &[_][]const u8{ - ":84:9: error: struct 'test_case.test_case' has no member named 'main'", + ":85:9: error: struct 'test_case.test_case' has no member named 'main'", }); // Incorrect return type @@ -247,10 +247,19 @@ pub fn addCases(ctx: *TestContext) !void { ); } { + var case = ctx.exe("unused vars", linux_x64); + case.addError( + \\pub fn main() void { + \\ const x = 1; + \\} + , &.{":2:11: error: unused local constant"}); + } + { var case = ctx.exe("@TypeOf", linux_x64); case.addCompareOutput( \\pub fn main() void { \\ var x: usize = 0; + \\ _ = x; \\ const z = @TypeOf(x, @as(u128, 5)); \\ assert(z == u128); \\} @@ -275,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void { ); case.addError( \\pub fn main() void { - \\ const z = @TypeOf(true, 1); + \\ _ = @TypeOf(true, 1); \\} - , &[_][]const u8{":2:15: error: incompatible types: 'bool' and 'comptime_int'"}); + , &[_][]const u8{":2:9: error: incompatible types: 'bool' and 'comptime_int'"}); } { @@ -738,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ \\ cool thx \\ \\ \\ ; + \\ _ = ignore; \\ add('ぁ', '\x03'); \\} \\ @@ -889,6 +899,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ try expect(false); \\ } \\ }; + \\ _ = S; \\} , &.{":4:13: error: invalid 'try' outside function scope"}, @@ -979,6 +990,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ return bar; \\ } \\ }; + \\ _ = S; \\} , &.{ ":5:20: error: 'bar' not accessible from inner function", @@ -1001,6 +1013,24 @@ pub fn addCases(ctx: *TestContext) !void { , &[_][]const u8{":2:3: error: this is an error"}); { + var case = ctx.exe("intToPtr", linux_x64); + case.addError( + \\pub fn main() void { + \\ _ = @intToPtr(*u8, 0); + \\} + , &[_][]const u8{ + ":2:24: error: pointer type '*u8' does not allow address zero", + }); + case.addError( + \\pub fn main() void { + \\ _ = @intToPtr(*u32, 2); + \\} + , &[_][]const u8{ + ":2:25: error: pointer type '*u32' requires aligned address", + }); + } + + { var case = ctx.obj("variable shadowing", linux_x64); case.addError( \\pub fn main() void { @@ -1046,6 +1076,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ @compileLog(b, 20, f, x); \\ @compileLog(1000); \\ var bruh: usize = true; + \\ _ = bruh; \\ unreachable; \\} \\export fn other() void { @@ -1191,6 +1222,7 @@ pub fn addCases(ctx: *TestContext) !void { case.addError( \\pub fn main() void { \\ var x = null; + \\ _ = x; \\} , &[_][]const u8{ ":2:9: error: variable of type '@Type(.Null)' must be const or comptime", @@ -1360,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void { \\pub fn main() void { \\ doNothing(0); \\} - \\fn doNothing(arg: u0) void {} + \\fn doNothing(arg: u0) void { + \\ _ = arg; + \\} , "", ); @@ -1430,14 +1464,14 @@ pub fn addCases(ctx: *TestContext) !void { case.addCompareOutput( \\pub fn main() void { \\ const E = error{ A, B, D } || error { A, B, C }; - \\ const a = E.A; - \\ const b = E.B; - \\ const c = E.C; - \\ const d = E.D; + \\ E.A catch {}; + \\ E.B catch {}; + \\ E.C catch {}; + \\ E.D catch {}; \\ const E2 = error { X, Y } || @TypeOf(error.Z); - \\ const x = E2.X; - \\ const y = E2.Y; - \\ const z = E2.Z; + \\ E2.X catch {}; + \\ E2.Y catch {}; + \\ E2.Z catch {}; \\ assert(anyerror || error { Z } == anyerror); \\} \\fn assert(b: bool) void { @@ -1459,6 +1493,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ [arg1] "{rdi}" (code) \\ : "rcx", "r11", "memory" \\ ); + \\ _ = x; \\} , &[_][]const u8{":4:27: error: expected type, found comptime_int"}); } @@ -1565,4 +1600,27 @@ pub fn addCases(ctx: *TestContext) !void { \\} , "HeHelHellHello"); } + + { + var case = ctx.exe("double ampersand", linux_x64); + + case.addError( + \\pub const a = if (true && false) 1 else 2; + , &[_][]const u8{":1:24: error: `&&` is invalid; note that `and` is boolean AND"}); + + case.addError( + \\pub fn main() void { + \\ const a = true; + \\ const b = false; + \\ _ = a & &b; + \\} + , &[_][]const u8{":4:11: error: incompatible types: 'bool' and '*const bool'"}); + + case.addCompareOutput( + \\pub fn main() void { + \\ const b: u8 = 1; + \\ _ = &&b; + \\} + , ""); + } } diff --git a/test/stage2/wasm.zig b/test/stage2/wasm.zig index 947f90ff0f..07386e8212 100644 --- a/test/stage2/wasm.zig +++ b/test/stage2/wasm.zig @@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ foo(10, 20); \\ return 5; \\} - \\fn foo(x: u32, y: u32) void {} + \\fn foo(x: u32, y: u32) void { _ = x; _ = y; } , "5\n"); } @@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void { \\ var i: u32 = 5; \\ var y: f32 = 42.0; \\ var x: u32 = 10; + \\ if (false) { + \\ y; + \\ x; + \\ } \\ return i; \\} , "5\n"); @@ -84,12 +88,14 @@ pub fn addCases(ctx: *TestContext) !void { \\pub export fn _start() u32 { \\ var i: u32 = 5; \\ var y: f32 = 42.0; + \\ _ = y; \\ var x: u32 = 10; \\ foo(i, x); \\ i = x; \\ return i; \\} \\fn foo(x: u32, y: u32) void { + \\ _ = y; \\ var i: u32 = 10; \\ i = x; \\} @@ -388,6 +394,10 @@ pub fn addCases(ctx: *TestContext) !void { \\pub export fn _start() i32 { \\ var number1 = Number.One; \\ var number2: Number = .Two; + \\ if (false) { + \\ number1; + \\ number2; + \\ } \\ const number3 = @intToEnum(Number, 2); \\ \\ return @enumToInt(number3); diff --git a/test/standalone.zig b/test/standalone.zig index 4ac046de0c..a483097f4a 100644 --- a/test/standalone.zig +++ b/test/standalone.zig @@ -33,6 +33,11 @@ pub fn addCases(cases: *tests.StandaloneContext) void { } cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ .build_modes = true, .cross_targets = true }); + // Try to build and run a PIE executable. + if (std.Target.current.os.tag == .linux) { + cases.addBuildFile("test/standalone/pie/build.zig", .{}); + } + // Ensure the development tools are buildable. cases.add("tools/gen_spirv_spec.zig"); cases.add("tools/gen_stubs.zig"); diff --git a/test/standalone/hello_world/hello_libc.zig b/test/standalone/hello_world/hello_libc.zig index 5c0a233f1c..42ba4db4b1 100644 --- a/test/standalone/hello_world/hello_libc.zig +++ b/test/standalone/hello_world/hello_libc.zig @@ -8,6 +8,8 @@ const c = @cImport({ const msg = "Hello, world!\n"; pub export fn main(argc: c_int, argv: **u8) c_int { + _ = argv; + _ = argc; if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1; return 0; } diff --git a/test/standalone/issue_339/test.zig b/test/standalone/issue_339/test.zig index 2d0c14c0f5..5e0aafc182 100644 --- a/test/standalone/issue_339/test.zig +++ b/test/standalone/issue_339/test.zig @@ -1,5 +1,7 @@ const StackTrace = @import("std").builtin.StackTrace; pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn { + _ = msg; + _ = stack_trace; @breakpoint(); while (true) {} } diff --git a/test/standalone/issue_8550/main.zig b/test/standalone/issue_8550/main.zig index 7dae7f856c..615e9aed6a 100644 --- a/test/standalone/issue_8550/main.zig +++ b/test/standalone/issue_8550/main.zig @@ -1,6 +1,11 @@ export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn { + _ = r0; + _ = r1; + _ = atags; unreachable; // never gets run so it doesn't matter } pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn { + _ = msg; + _ = error_return_trace; while (true) {} } diff --git a/test/standalone/pie/build.zig b/test/standalone/pie/build.zig new file mode 100644 index 0000000000..d008fd31c9 --- /dev/null +++ b/test/standalone/pie/build.zig @@ -0,0 +1,12 @@ +const Builder = @import("std").build.Builder; + +pub fn build(b: *Builder) void { + const main = b.addTest("main.zig"); + main.setBuildMode(b.standardReleaseOptions()); + main.pie = true; + + const test_step = b.step("test", "Test the program"); + test_step.dependOn(&main.step); + + b.default_step.dependOn(test_step); +} diff --git a/test/standalone/pie/main.zig b/test/standalone/pie/main.zig new file mode 100644 index 0000000000..6a49c45e97 --- /dev/null +++ b/test/standalone/pie/main.zig @@ -0,0 +1,15 @@ +const std = @import("std"); +const elf = std.elf; + +threadlocal var foo: u8 = 42; + +test "Check ELF header" { + // PIE executables are marked as ET_DYN, regular exes as ET_EXEC. + const header = @intToPtr(*elf.Ehdr, std.process.getBaseAddress()); + try std.testing.expectEqual(elf.ET.DYN, header.e_type); +} + +test "TLS is initialized" { + // Ensure the TLS is initialized by the startup code. + try std.testing.expectEqual(@as(u8, 42), foo); +} diff --git a/test/tests.zig b/test/tests.zig index 26f38d4e28..8871c18428 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: [] } pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step { + _ = test_filter; + _ = modes; const step = b.step("test-cli", "Test the command line interface"); const exe = b.addExecutable("test-cli", "test/cli.zig"); @@ -525,7 +527,6 @@ pub fn addPkgTests( if (skip_single_threaded and test_target.single_threaded) continue; - const ArchTag = std.meta.Tag(std.Target.Cpu.Arch); if (test_target.disable_native and test_target.target.getOsTag() == std.Target.current.os.tag and test_target.target.getCpuArch() == std.Target.current.cpu.arch) diff --git a/test/translate_c.zig b/test/translate_c.zig index 21350a8600..b1ef771c67 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -12,9 +12,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_x: c_ulong) c_ulong { \\ var x = arg_x; + \\ _ = x; \\ const union_unnamed_1 = extern union { \\ _x: c_ulong, \\ }; + \\ _ = union_unnamed_1; \\ return (union_unnamed_1{ \\ ._x = x, \\ })._x; @@ -30,15 +32,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ int a, b; \\} Bar; , &[_][]const u8{ - \\pub const Foo = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ _, - \\}; - \\pub const FooA = @enumToInt(Foo.A); - \\pub const FooB = @enumToInt(Foo.B); + \\pub const FooA: c_int = 0; + \\pub const FooB: c_int = 1; + \\pub const Foo = + ++ " " ++ default_enum_type ++ + \\; \\pub const Bar = extern struct { \\ a: c_int, \\ b: c_int, @@ -58,8 +56,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ while (true) if (true) { \\ var a: c_int = 1; + \\ _ = a; \\ } else { \\ var b: c_int = 2; + \\ _ = b; \\ }; \\ if (true) if (true) {}; \\} @@ -75,6 +75,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub extern fn bar(...) c_int; \\pub export fn foo() void { \\ var a: c_int = undefined; + \\ _ = a; \\ if (a != 0) a = 2 else _ = bar(); \\} }); @@ -103,54 +104,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const PTR = ?*c_void; }); - cases.add("scoped enum", - \\void foo() { - \\ enum Foo { - \\ A, - \\ B, - \\ C, - \\ }; - \\ enum Foo a = B; - \\ { - \\ enum Foo { - \\ A, - \\ B, - \\ C, - \\ }; - \\ enum Foo a = B; - \\ } - \\} - , &[_][]const u8{ - \\pub export fn foo() void { - \\ const enum_Foo = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ C, - \\ _, - \\ }; - \\ const A = @enumToInt(enum_Foo.A); - \\ const B = @enumToInt(enum_Foo.B); - \\ const C = @enumToInt(enum_Foo.C); - \\ var a: enum_Foo = @import("std").zig.c_translation.cast(enum_Foo, B); - \\ { - \\ const enum_Foo = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ C, - \\ _, - \\ }; - \\ const A_2 = @enumToInt(enum_Foo.A); - \\ const B_3 = @enumToInt(enum_Foo.B); - \\ const C_4 = @enumToInt(enum_Foo.C); - \\ var a_5: enum_Foo = @import("std").zig.c_translation.cast(enum_Foo, B_3); - \\ } - \\} - }); - cases.add("scoped record", \\void foo() { \\ struct Foo { @@ -175,22 +128,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ B: c_int, \\ C: c_int, \\ }; + \\ _ = struct_Foo; \\ var a: struct_Foo = struct_Foo{ \\ .A = @as(c_int, 0), \\ .B = 0, \\ .C = 0, \\ }; + \\ _ = a; \\ { \\ const struct_Foo_1 = extern struct { \\ A: c_int, \\ B: c_int, \\ C: c_int, \\ }; + \\ _ = struct_Foo_1; \\ var a_2: struct_Foo_1 = struct_Foo_1{ \\ .A = @as(c_int, 0), \\ .B = 0, \\ .C = 0, \\ }; + \\ _ = a_2; \\ } \\} }); @@ -219,20 +176,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ B: c_int, \\ C: c_int, \\ }; + \\ _ = union_unnamed_1; \\ const Foo = union_unnamed_1; + \\ _ = Foo; \\ var a: Foo = Foo{ \\ .A = @as(c_int, 0), \\ }; + \\ _ = a; \\ { \\ const union_unnamed_2 = extern union { \\ A: c_int, \\ B: c_int, \\ C: c_int, \\ }; + \\ _ = union_unnamed_2; \\ const Foo_1 = union_unnamed_2; + \\ _ = Foo_1; \\ var a_2: Foo_1 = Foo_1{ \\ .A = @as(c_int, 0), \\ }; + \\ _ = a_2; \\ } \\} }); @@ -242,6 +205,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define MEM_PHYSICAL_TO_K0(x) (void*)((uint32_t)(x) + SYS_BASE_CACHED) , &[_][]const u8{ \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void { + \\ _ = x; \\ return @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(u32, x) + SYS_BASE_CACHED); \\} }); @@ -283,6 +247,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); , \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { + \\ _ = p; \\ return (@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); \\} }); @@ -298,6 +263,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ const bar_1 = struct { \\ threadlocal var static: c_int = 2; \\ }; + \\ _ = bar_1; \\ return 0; \\} }); @@ -316,6 +282,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} \\pub export fn bar() c_int { \\ var a: c_int = 2; + \\ _ = a; \\ return 0; \\} \\pub export fn baz() c_int { @@ -330,6 +297,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn main() void { \\ var a: c_int = @bitCast(c_int, @truncate(c_uint, @alignOf(c_int))); + \\ _ = a; \\} }); @@ -360,6 +328,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const Color = struct_Color; , \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { + \\ _ = type_1; \\ return type_1; \\} , @@ -377,6 +346,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\}; , \\pub inline fn A(_x: anytype) MyCStruct { + \\ _ = _x; \\ return @import("std").mem.zeroInit(MyCStruct, .{ \\ .x = _x, \\ }); @@ -407,6 +377,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) , &[_][]const u8{ \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { + \\ _ = _fp; \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); \\} }); @@ -416,6 +387,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define BAR 1 && 2 > 4 , &[_][]const u8{ \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { + \\ _ = x; \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); \\} , @@ -478,6 +450,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\}; , \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { + \\ _ = x; \\ return blk: { \\ _ = &x; \\ _ = @as(c_int, 3); @@ -607,6 +580,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\}; \\pub export fn foo(arg_x: [*c]outer) void { \\ var x = arg_x; + \\ _ = x; \\ x.*.unnamed_0.unnamed_0.y = @bitCast(c_int, @as(c_uint, x.*.unnamed_0.x)); \\} }); @@ -693,7 +667,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const struct_opaque_2 = opaque {}; \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { \\ var opaque_1 = arg_opaque_1; + \\ _ = opaque_1; \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); + \\ _ = cast; \\} }); @@ -725,6 +701,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn my_fn() align(128) void {} \\pub export fn other_fn() void { \\ var ARR: [16]u8 align(16) = undefined; + \\ _ = ARR; \\} }); @@ -760,11 +737,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: u8 = 123; + \\ _ = b; \\ const c: c_int = undefined; + \\ _ = c; \\ const d: c_uint = @bitCast(c_uint, @as(c_int, 440)); + \\ _ = d; \\ var e: c_int = 10; + \\ _ = e; \\ var f: c_uint = 10; + \\ _ = f; \\} }); @@ -780,6 +763,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = undefined; + \\ _ = a; \\ _ = @as(c_int, 1); \\ _ = "hey"; \\ _ = @as(c_int, 1) + @as(c_int, 1); @@ -823,6 +807,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ const v2 = struct { \\ const static: [5:0]u8 = "2.2.2".*; \\ }; + \\ _ = v2; \\} }); @@ -864,7 +849,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub extern fn foo() void; \\pub export fn bar() void { \\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo); + \\ _ = func_ptr; \\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); + \\ _ = typed_func_ptr; \\} }); @@ -894,8 +881,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn s() c_int { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: c_int = undefined; + \\ _ = b; \\ var c: c_int = undefined; + \\ _ = c; \\ c = a + b; \\ c = a - b; \\ c = a * b; @@ -905,8 +895,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} \\pub export fn u() c_uint { \\ var a: c_uint = undefined; + \\ _ = a; \\ var b: c_uint = undefined; + \\ _ = b; \\ var c: c_uint = undefined; + \\ _ = c; \\ c = a +% b; \\ c = a -% b; \\ c = a *% b; @@ -1208,32 +1201,30 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ VAL23 = 0xFFFFFFFFFFFFFFFF, \\}; , &[_][]const u8{ - \\pub const enum_EnumWithInits = extern enum(c_longlong) { - \\ VAL01 = 0, - \\ VAL02 = 1, - \\ VAL03 = 2, - \\ VAL04 = 3, - \\ VAL05 = -1, - \\ VAL06 = -2, - \\ VAL07 = -3, - \\ VAL08 = -4, - \\ VAL09 = -3, - \\ VAL10 = -1000012000, - \\ VAL11 = -1000161000, - \\ VAL12 = -1000174001, - \\ VAL13 = -3, - \\ VAL14 = -1000012000, - \\ VAL15 = -1000161000, - \\ VAL16 = -3, - \\ VAL17 = 1000011998, - \\ VAL18 = 1152921504606846976, - \\ VAL19 = 3458764513820540927, - \\ VAL20 = 6917529027641081854, - \\ VAL21 = 6917529027641081853, - \\ VAL22 = 0, - \\ VAL23 = -1, - \\ _, - \\}; + \\pub const VAL01: c_int = 0; + \\pub const VAL02: c_int = 1; + \\pub const VAL03: c_int = 2; + \\pub const VAL04: c_int = 3; + \\pub const VAL05: c_int = -1; + \\pub const VAL06: c_int = -2; + \\pub const VAL07: c_int = -3; + \\pub const VAL08: c_int = -4; + \\pub const VAL09: c_int = -3; + \\pub const VAL10: c_int = -1000012000; + \\pub const VAL11: c_int = -1000161000; + \\pub const VAL12: c_int = -1000174001; + \\pub const VAL13: c_int = -3; + \\pub const VAL14: c_int = -1000012000; + \\pub const VAL15: c_int = -1000161000; + \\pub const VAL16: c_int = -3; + \\pub const VAL17: c_int = 1000011998; + \\pub const VAL18: c_longlong = 1152921504606846976; + \\pub const VAL19: c_longlong = 3458764513820540927; + \\pub const VAL20: c_longlong = 6917529027641081854; + \\pub const VAL21: c_longlong = 6917529027641081853; + \\pub const VAL22: c_int = 0; + \\pub const VAL23: c_longlong = -1; + \\pub const enum_EnumWithInits = c_longlong; }); } @@ -1272,6 +1263,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ var a: c_int = undefined; \\ _ = a; + \\ _ = a; \\} }); @@ -1283,6 +1275,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() ?*c_void { \\ var x: [*c]c_ushort = undefined; + \\ _ = x; \\ return @ptrCast(?*c_void, x); \\} }); @@ -1339,6 +1332,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ { \\ var i: c_int = 0; + \\ _ = i; \\ while (i != 0) : (i += 1) {} \\ } \\} @@ -1362,6 +1356,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var i: c_int = undefined; + \\ _ = i; \\ { \\ i = 3; \\ while (i != 0) : (i -= 1) {} @@ -1405,6 +1400,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn ptrcast() [*c]f32 { \\ var a: [*c]c_int = undefined; + \\ _ = a; \\ return @ptrCast([*c]f32, @alignCast(@import("std").meta.alignment(f32), a)); \\} }); @@ -1428,17 +1424,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn test_ptr_cast() void { \\ var p: ?*c_void = undefined; + \\ _ = p; \\ { \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), p)); + \\ _ = to_char; \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment(c_short), p)); + \\ _ = to_short; \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment(c_int), p)); + \\ _ = to_int; \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment(c_longlong), p)); + \\ _ = to_longlong; \\ } \\ { \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), p)); + \\ _ = to_char; \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment(c_short), p)); + \\ _ = to_short; \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment(c_int), p)); + \\ _ = to_int; \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment(c_longlong), p)); + \\ _ = to_longlong; \\ } \\} }); @@ -1456,8 +1461,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn while_none_bool() c_int { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: f32 = undefined; + \\ _ = b; \\ var c: ?*c_void = undefined; + \\ _ = c; \\ while (a != 0) return 0; \\ while (b != 0) return 1; \\ while (c != null) return 2; @@ -1478,8 +1486,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn for_none_bool() c_int { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: f32 = undefined; + \\ _ = b; \\ var c: ?*c_void = undefined; + \\ _ = c; \\ while (a != 0) return 0; \\ while (b != 0) return 1; \\ while (c != null) return 2; @@ -1516,6 +1527,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var x: [*c]c_int = undefined; + \\ _ = x; \\ x.* = 1; \\} }); @@ -1529,7 +1541,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() c_int { \\ var x: c_int = 1234; + \\ _ = x; \\ var ptr: [*c]c_int = &x; + \\ _ = ptr; \\ return ptr.*; \\} }); @@ -1542,6 +1556,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() c_int { \\ var x: c_int = undefined; + \\ _ = x; \\ return ~x; \\} }); @@ -1559,8 +1574,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() c_int { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: f32 = undefined; + \\ _ = b; \\ var c: ?*c_void = undefined; + \\ _ = c; \\ return @boolToInt(!(a == @as(c_int, 0))); \\ return @boolToInt(!(a != 0)); \\ return @boolToInt(!(b != 0)); @@ -1591,11 +1609,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\extern enum enum_ty my_enum; \\enum enum_ty { FOO }; , &[_][]const u8{ - \\pub const enum_enum_ty = extern enum(c_int) { - \\ FOO, - \\ _, - \\}; - \\pub const FOO = @enumToInt(enum_enum_ty.FOO); + \\pub const FOO: c_int = 0; + \\pub const enum_enum_ty = c_int; \\pub extern var my_enum: enum_enum_ty; }); @@ -1685,9 +1700,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ var arr: [10]u8 = [1]u8{ \\ 1, \\ } ++ [1]u8{0} ** 9; + \\ _ = arr; \\ var arr1: [10][*c]u8 = [1][*c]u8{ \\ null, \\ } ++ [1][*c]u8{null} ** 9; + \\ _ = arr1; \\} }); @@ -1716,57 +1733,37 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ p, \\}; , &[_][]const u8{ - \\pub const d = extern enum( - ++ default_enum_type ++ - \\) { - \\ a, - \\ b, - \\ c, - \\ _, - \\}; - \\pub const a = @enumToInt(d.a); - \\pub const b = @enumToInt(d.b); - \\pub const c = @enumToInt(d.c); - \\const enum_unnamed_1 = extern enum( - ++ default_enum_type ++ - \\) { - \\ e = 0, - \\ f = 4, - \\ g = 5, - \\ _, - \\}; - \\pub const e = @enumToInt(enum_unnamed_1.e); - \\pub const f = @enumToInt(enum_unnamed_1.f); - \\pub const g = @enumToInt(enum_unnamed_1.g); - \\pub export var h: enum_unnamed_1 = @import("std").zig.c_translation.cast(enum_unnamed_1, e); - \\const enum_unnamed_2 = extern enum( - ++ default_enum_type ++ - \\) { - \\ i, - \\ j, - \\ k, - \\ _, - \\}; - \\pub const i = @enumToInt(enum_unnamed_2.i); - \\pub const j = @enumToInt(enum_unnamed_2.j); - \\pub const k = @enumToInt(enum_unnamed_2.k); + \\pub const a: c_int = 0; + \\pub const b: c_int = 1; + \\pub const c: c_int = 2; + \\pub const d = + ++ " " ++ default_enum_type ++ + \\; + \\pub const e: c_int = 0; + \\pub const f: c_int = 4; + \\pub const g: c_int = 5; + \\const enum_unnamed_1 = + ++ " " ++ default_enum_type ++ + \\; + \\pub export var h: enum_unnamed_1 = @bitCast(c_uint, e); + \\pub const i: c_int = 0; + \\pub const j: c_int = 1; + \\pub const k: c_int = 2; + \\const enum_unnamed_2 = + ++ " " ++ default_enum_type ++ + \\; \\pub const struct_Baz = extern struct { \\ l: enum_unnamed_2, \\ m: d, \\}; - \\pub const enum_i = extern enum( - ++ default_enum_type ++ - \\) { - \\ n, - \\ o, - \\ p, - \\ _, - \\}; - \\pub const n = @enumToInt(enum_i.n); - \\pub const o = @enumToInt(enum_i.o); - \\pub const p = @enumToInt(enum_i.p); + \\pub const n: c_int = 0; + \\pub const o: c_int = 1; + \\pub const p: c_int = 2; + \\pub const enum_i = + ++ " " ++ default_enum_type ++ + \\; , - \\pub const Baz = struct_Baz; + "pub const Baz = struct_Baz;", }); cases.add("#define a char literal", @@ -1894,10 +1891,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub extern var c: c_int; , \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) { + \\ _ = c_1; \\ return c_1 * @as(c_int, 2); \\} , \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { + \\ _ = L; + \\ _ = b; \\ return L + b; \\} , @@ -1949,13 +1949,18 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub var c: c_int = 4; \\pub export fn foo(arg_c_1: u8) void { \\ var c_1 = arg_c_1; + \\ _ = c_1; \\ var a_2: c_int = undefined; + \\ _ = a_2; \\ var b_3: u8 = 123; + \\ _ = b_3; \\ b_3 = @bitCast(u8, @truncate(i8, a_2)); \\ { \\ var d: c_int = 5; + \\ _ = d; \\ } \\ var d: c_uint = @bitCast(c_uint, @as(c_int, 440)); + \\ _ = d; \\} }); @@ -1989,7 +1994,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = undefined; + \\ _ = a; \\ var b: c_int = undefined; + \\ _ = b; \\ a = blk: { \\ const tmp = @as(c_int, 2); \\ b = tmp; @@ -2019,11 +2026,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() c_int { \\ var a: c_int = 5; + \\ _ = a; \\ while (true) { \\ a = 2; \\ } \\ while (true) { \\ var a_1: c_int = 4; + \\ _ = a_1; \\ a_1 = 9; \\ return blk: { \\ _ = @as(c_int, 6); @@ -2032,6 +2041,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ } \\ while (true) { \\ var a_1: c_int = 2; + \\ _ = a_1; \\ a_1 = 12; \\ } \\ while (true) { @@ -2053,9 +2063,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ { \\ var i: c_int = 2; + \\ _ = i; \\ var b: c_int = 4; + \\ _ = b; \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) { \\ var a: c_int = 2; + \\ _ = a; \\ _ = blk: { \\ _ = blk_1: { \\ a = 6; @@ -2066,6 +2079,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ } \\ } \\ var i: u8 = 2; + \\ _ = i; \\} }); @@ -2138,7 +2152,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn switch_fn(arg_i: c_int) void { \\ var i = arg_i; + \\ _ = i; \\ var res: c_int = 0; + \\ _ = res; \\ while (true) { \\ switch (i) { \\ @as(c_int, 0) => { @@ -2227,7 +2243,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int) void { \\ var a = arg_a; + \\ _ = a; \\ var tmp: c_int = undefined; + \\ _ = tmp; \\ tmp = a; \\ a = tmp; \\} @@ -2241,8 +2259,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int) void { \\ var a = arg_a; + \\ _ = a; \\ var b: c_int = undefined; + \\ _ = b; \\ var c: c_int = undefined; + \\ _ = c; \\ c = blk: { \\ const tmp = a; \\ b = tmp; @@ -2257,15 +2278,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ Two, \\}; , &[_][]const u8{ - \\const enum_unnamed_1 = extern enum( - ++ default_enum_type ++ - \\) { - \\ One, - \\ Two, - \\ _, - \\}; - \\pub const One = @enumToInt(enum_unnamed_1.One); - \\pub const Two = @enumToInt(enum_unnamed_1.Two); + \\pub const One: c_int = 0; + \\pub const Two: c_int = 1; + \\const enum_unnamed_1 = + ++ " " ++ default_enum_type ++ + \\; }); cases.add("c style cast", @@ -2275,6 +2292,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn float_to_int(arg_a: f32) c_int { \\ var a = arg_a; + \\ _ = a; \\ return @floatToInt(c_int, a); \\} }); @@ -2298,16 +2316,27 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn escapes() [*c]const u8 { \\ var a: u8 = '\''; + \\ _ = a; \\ var b: u8 = '\\'; + \\ _ = b; \\ var c: u8 = '\x07'; + \\ _ = c; \\ var d: u8 = '\x08'; + \\ _ = d; \\ var e: u8 = '\x0c'; + \\ _ = e; \\ var f: u8 = '\n'; + \\ _ = f; \\ var g: u8 = '\r'; + \\ _ = g; \\ var h: u8 = '\t'; + \\ _ = h; \\ var i: u8 = '\x0b'; + \\ _ = i; \\ var j: u8 = '\x00'; + \\ _ = j; \\ var k: u8 = '"'; + \\ _ = k; \\ return "'\\\x07\x08\x0c\n\r\t\x0b\x00\""; \\} }); @@ -2327,11 +2356,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = 2; + \\ _ = a; \\ while (true) { \\ a = a - @as(c_int, 1); \\ if (!(a != 0)) break; \\ } \\ var b: c_int = 2; + \\ _ = b; \\ while (true) { \\ b = b - @as(c_int, 1); \\ if (!(b != 0)) break; @@ -2363,35 +2394,46 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ return ((((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p); \\} , &[_][]const u8{ - \\pub const enum_Foo = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ C, - \\ _, - \\}; - \\pub const FooA = @enumToInt(enum_Foo.A); - \\pub const FooB = @enumToInt(enum_Foo.B); - \\pub const FooC = @enumToInt(enum_Foo.C); + \\pub const FooA: c_int = 0; + \\pub const FooB: c_int = 1; + \\pub const FooC: c_int = 2; + \\pub const enum_Foo = + ++ " " ++ default_enum_type ++ + \\; \\pub const SomeTypedef = c_int; \\pub export fn and_or_non_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ var c = arg_c; - \\ var d: enum_Foo = @import("std").zig.c_translation.cast(enum_Foo, FooA); + \\ _ = c; + \\ var d: enum_Foo = @bitCast(c_uint, FooA); + \\ _ = d; \\ var e: c_int = @boolToInt((a != 0) and (b != 0)); + \\ _ = e; \\ var f: c_int = @boolToInt((b != 0) and (c != null)); + \\ _ = f; \\ var g: c_int = @boolToInt((a != 0) and (c != null)); + \\ _ = g; \\ var h: c_int = @boolToInt((a != 0) or (b != 0)); + \\ _ = h; \\ var i: c_int = @boolToInt((b != 0) or (c != null)); + \\ _ = i; \\ var j: c_int = @boolToInt((a != 0) or (c != null)); - \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, @enumToInt(d)) != 0)); - \\ var l: c_int = @boolToInt((@bitCast(c_int, @enumToInt(d)) != 0) and (b != 0)); - \\ var m: c_int = @boolToInt((c != null) or (@bitCast(c_uint, @enumToInt(d)) != 0)); + \\ _ = j; + \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0)); + \\ _ = k; + \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0)); + \\ _ = l; + \\ var m: c_int = @boolToInt((c != null) or (d != 0)); + \\ _ = m; \\ var td: SomeTypedef = 44; + \\ _ = td; \\ var o: c_int = @boolToInt((td != 0) or (b != 0)); + \\ _ = o; \\ var p: c_int = @boolToInt((c != null) and (td != 0)); + \\ _ = p; \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p; \\} , @@ -2413,16 +2455,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ x: c_int, \\ y: c_int, \\}; - , - \\pub const enum_Bar = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ _, - \\}; - \\pub const BarA = @enumToInt(enum_Bar.A); - \\pub const BarB = @enumToInt(enum_Bar.B); + \\pub const BarA: c_int = 0; + \\pub const BarB: c_int = 1; + \\pub const enum_Bar = + ++ " " ++ default_enum_type ++ + \\; \\pub extern fn func(a: [*c]struct_Foo, b: [*c][*c]enum_Bar) void; , \\pub const Foo = struct_Foo; @@ -2436,7 +2473,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ return (a & b) ^ (a | b); \\} }); @@ -2455,14 +2494,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ var c: c_int = @boolToInt(a < b); + \\ _ = c; \\ var d: c_int = @boolToInt(a > b); + \\ _ = d; \\ var e: c_int = @boolToInt(a <= b); + \\ _ = e; \\ var f: c_int = @boolToInt(a >= b); + \\ _ = f; \\ var g: c_int = @boolToInt(c < d); + \\ _ = g; \\ var h: c_int = @boolToInt(e < f); + \\ _ = h; \\ var i: c_int = @boolToInt(g < h); + \\ _ = i; \\ return i; \\} }); @@ -2478,7 +2526,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ if (a == b) return a; \\ if (a != b) return b; \\ return a; @@ -2495,6 +2545,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const yes = [*c]u8; \\pub export fn foo() void { \\ var a: yes = undefined; + \\ _ = a; \\ if (a != null) { \\ _ = @as(c_int, 2); \\ } @@ -2514,6 +2565,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ return blk: { \\ var a: c_int = 1; \\ _ = a; + \\ _ = a; \\ break :blk a; \\ }; \\} @@ -2539,6 +2591,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export var b: f32 = 2.0; \\pub export fn foo() void { \\ var c: [*c]struct_Foo = undefined; + \\ _ = c; \\ _ = a.b; \\ _ = c.*.b; \\} @@ -2558,6 +2611,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export var array: [100]c_int = [1]c_int{0} ** 100; \\pub export fn foo(arg_index: c_int) c_int { \\ var index = arg_index; + \\ _ = index; \\ return array[@intCast(c_uint, index)]; \\} , @@ -2572,7 +2626,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: [10]c_int = undefined; + \\ _ = a; \\ var i: c_int = 0; + \\ _ = i; \\ a[@intCast(c_uint, i)] = 0; \\} }); @@ -2585,7 +2641,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: [10]c_longlong = undefined; + \\ _ = a; \\ var i: c_longlong = 0; + \\ _ = i; \\ a[@intCast(usize, i)] = 0; \\} }); @@ -2598,7 +2656,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: [10]c_uint = undefined; + \\ _ = a; \\ var i: c_uint = 0; + \\ _ = i; \\ a[i] = 0; \\} }); @@ -2607,6 +2667,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define CALL(arg) bar(arg) , &[_][]const u8{ \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { + \\ _ = arg; \\ return bar(arg); \\} }); @@ -2615,6 +2676,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define CALL(arg) bar() , &[_][]const u8{ \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) { + \\ _ = arg; \\ return bar(); \\} }); @@ -2630,7 +2692,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ if ((a < b) or (a == b)) return b; \\ if ((a >= b) and (a == b)) return a; \\ return a; @@ -2652,7 +2716,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn max(arg_a: c_int, arg_b: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ if (a < b) return b; \\ if (a < b) return b else return a; \\ if (a < b) {} else {} @@ -2673,12 +2739,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn foo() void { \\ if (true) { \\ var a: c_int = 2; + \\ _ = a; \\ } \\ if ((blk: { \\ _ = @as(c_int, 2); \\ break :blk @as(c_int, 5); \\ }) != 0) { \\ var a: c_int = 2; + \\ _ = a; \\ } \\} }); @@ -2693,26 +2761,25 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ return 4; \\} , &[_][]const u8{ - \\pub const enum_SomeEnum = extern enum( - ++ default_enum_type ++ - \\) { - \\ A, - \\ B, - \\ C, - \\ _, - \\}; - \\pub const A = @enumToInt(enum_SomeEnum.A); - \\pub const B = @enumToInt(enum_SomeEnum.B); - \\pub const C = @enumToInt(enum_SomeEnum.C); + \\pub const A: c_int = 0; + \\pub const B: c_int = 1; + \\pub const C: c_int = 2; + \\pub const enum_SomeEnum = + ++ " " ++ default_enum_type ++ + \\; \\pub export fn if_none_bool(arg_a: c_int, arg_b: f32, arg_c: ?*c_void, arg_d: enum_SomeEnum) c_int { \\ var a = arg_a; + \\ _ = a; \\ var b = arg_b; + \\ _ = b; \\ var c = arg_c; + \\ _ = c; \\ var d = arg_d; + \\ _ = d; \\ if (a != 0) return 0; \\ if (b != 0) return 1; \\ if (c != null) return 2; - \\ if (@enumToInt(d) != 0) return 3; + \\ if (d != 0) return 3; \\ return 4; \\} }); @@ -2736,6 +2803,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn abs(arg_a: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ return if (a < @as(c_int, 0)) -a else a; \\} }); @@ -2756,16 +2824,19 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo1(arg_a: c_uint) c_uint { \\ var a = arg_a; + \\ _ = a; \\ a +%= 1; \\ return a; \\} \\pub export fn foo2(arg_a: c_int) c_int { \\ var a = arg_a; + \\ _ = a; \\ a += 1; \\ return a; \\} \\pub export fn foo3(arg_a: [*c]c_int) [*c]c_int { \\ var a = arg_a; + \\ _ = a; \\ a += 1; \\ return a; \\} @@ -2791,7 +2862,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} \\pub export fn bar() void { \\ var f: ?fn () callconv(.C) void = foo; + \\ _ = f; \\ var b: ?fn () callconv(.C) c_int = baz; + \\ _ = b; \\ f.?(); \\ f.?(); \\ foo(); @@ -2817,7 +2890,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var i: c_int = 0; + \\ _ = i; \\ var u: c_uint = 0; + \\ _ = u; \\ i += 1; \\ i -= 1; \\ u +%= 1; @@ -2856,7 +2931,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn log2(arg_a: c_uint) c_int { \\ var a = arg_a; + \\ _ = a; \\ var i: c_int = 0; + \\ _ = i; \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); \\ } @@ -2876,7 +2953,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn log2(arg_a: u32) c_int { \\ var a = arg_a; + \\ _ = a; \\ var i: c_int = 0; + \\ _ = i; \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); \\ } @@ -2904,7 +2983,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = 0; + \\ _ = a; \\ var b: c_uint = 0; + \\ _ = b; \\ a += blk: { \\ const ref = &a; \\ ref.* += @as(c_int, 1); @@ -2983,6 +3064,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_uint = 0; + \\ _ = a; \\ a +%= blk: { \\ const ref = &a; \\ ref.* +%= @bitCast(c_uint, @as(c_int, 1)); @@ -3042,7 +3124,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo() void { \\ var i: c_int = 0; + \\ _ = i; \\ var u: c_uint = 0; + \\ _ = u; \\ i += 1; \\ i -= 1; \\ u +%= 1; @@ -3137,6 +3221,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub fn bar() callconv(.C) void {} \\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void { \\ var baz = arg_baz; + \\ _ = baz; \\ bar(); \\ _ = baz.?(); \\} @@ -3161,17 +3246,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ Foo1, \\}; , &[_][]const u8{ - \\pub const enum_Foo = extern enum( - ++ default_enum_type ++ - \\) { - \\ A = 2, - \\ B = 5, - \\ @"1" = 6, - \\ _, - \\}; - \\pub const FooA = @enumToInt(enum_Foo.A); - \\pub const FooB = @enumToInt(enum_Foo.B); - \\pub const Foo1 = @enumToInt(enum_Foo.@"1"); + \\pub const FooA: c_int = 2; + \\pub const FooB: c_int = 5; + \\pub const Foo1: c_int = 6; + \\pub const enum_Foo = + ++ " " ++ default_enum_type ++ + \\; , \\pub const Foo = enum_Foo; }); @@ -3183,6 +3263,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define BAZ (uint32_t)(2) , &[_][]const u8{ \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").zig.c_translation.cast(?*c_void, baz))) { + \\ _ = bar; \\ return baz(@import("std").zig.c_translation.cast(?*c_void, baz)); \\} , @@ -3223,10 +3304,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) , &[_][]const u8{ \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { + \\ _ = a; + \\ _ = b; \\ return if (b < a) b else a; \\} , \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { + \\ _ = a; + \\ _ = b; \\ return if (b > a) b else a; \\} }); @@ -3238,7 +3323,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_p: [*c]c_int, arg_x: c_int) c_int { \\ var p = arg_p; + \\ _ = p; \\ var x = arg_x; + \\ _ = x; \\ return blk: { \\ const tmp = x; \\ (blk_1: { @@ -3265,6 +3352,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} \\pub export fn bar(arg_x: c_long) c_ushort { \\ var x = arg_x; + \\ _ = x; \\ return @bitCast(c_ushort, @truncate(c_short, x)); \\} }); @@ -3277,6 +3365,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_bar_1: c_int) void { \\ var bar_1 = arg_bar_1; + \\ _ = bar_1; \\ bar_1 = 2; \\} \\pub export var bar: c_int = 4; @@ -3290,6 +3379,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_bar_1: c_int) void { \\ var bar_1 = arg_bar_1; + \\ _ = bar_1; \\ bar_1 = 2; \\} , @@ -3319,13 +3409,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_a: [*c]c_int) void { \\ var a = arg_a; + \\ _ = a; \\} \\pub export fn bar(arg_a: [*c]const c_int) void { \\ var a = arg_a; + \\ _ = a; \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); \\} \\pub export fn baz(arg_a: [*c]volatile c_int) void { \\ var a = arg_a; + \\ _ = a; \\ foo(@intToPtr([*c]c_int, @ptrToInt(a))); \\} }); @@ -3340,9 +3433,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub export fn foo(arg_x: bool) bool { \\ var x = arg_x; + \\ _ = x; \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1); + \\ _ = a; \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0); + \\ _ = b; \\ var c: bool = @ptrToInt(foo) != 0; + \\ _ = c; \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b))); \\} }); @@ -3353,7 +3450,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\} , &[_][]const u8{ \\pub export fn max(x: c_int, arg_y: c_int) c_int { + \\ _ = x; \\ var y = arg_y; + \\ _ = y; \\ return if (x > y) x else y; \\} }); @@ -3414,6 +3513,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ , &[_][]const u8{ \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen) { + \\ _ = dpy; \\ return @import("std").zig.c_translation.cast(_XPrivDisplay, dpy).*.default_screen; \\} }); @@ -3633,6 +3733,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ const foo = struct { \\ var static: struct_FOO = @import("std").mem.zeroes(struct_FOO); \\ }; + \\ _ = foo; \\ return foo.static.x; \\} }); @@ -3645,4 +3746,31 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub const MAP_FAILED = @import("std").zig.c_translation.cast(?*c_void, -@as(c_int, 1)); \\pub const INVALID_HANDLE_VALUE = @import("std").zig.c_translation.cast(?*c_void, @import("std").zig.c_translation.cast(LONG_PTR, -@as(c_int, 1))); }); + + cases.add("discard local variables and function parameters", + \\#define FOO(A, B) (A) + (B) + \\int bar(int x, int y) { + \\ return x; + \\} + , &[_][]const u8{ + \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int { + \\ var x = arg_x; + \\ _ = x; + \\ var y = arg_y; + \\ _ = y; + \\ return x; + \\} + , + \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A + B) { + \\ _ = A; + \\ _ = B; + \\ return A + B; + \\} + }); + + cases.add("Don't allow underscore identifier in macros", + \\#define FOO _ + , &[_][]const u8{ + \\pub const FOO = @compileError("unable to translate C expr: illegal identifier _"); + }); } diff --git a/tools/process_headers.zig b/tools/process_headers.zig index c087688732..51fc69e579 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -236,12 +236,14 @@ const DestTarget = struct { const HashContext = struct { pub fn hash(self: @This(), a: DestTarget) u32 { + _ = self; return @enumToInt(a.arch) +% (@enumToInt(a.os) *% @as(u32, 4202347608)) +% (@enumToInt(a.abi) *% @as(u32, 4082223418)); } pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool { + _ = self; return a.arch.eql(b.arch) and a.os == b.os and a.abi == b.abi; @@ -256,6 +258,7 @@ const Contents = struct { is_generic: bool, fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool { + _ = context; return lhs.hit_count < rhs.hit_count; } }; diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index f5f5cc8e24..04cdbf44de 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -585,6 +585,8 @@ const Syntax = union(enum) { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; switch (self) { .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }), else => return out_stream.print(".{s}", .{@tagName(self)}), @@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool { } fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { + _ = context; // Priority is determined by exact matches first, followed by prefix matches in descending // length, with key as a final tiebreaker. const a_syntax = objSyntax(a); diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig index dfaeec2862..68d9b233a7 100644 --- a/tools/update_cpu_features.zig +++ b/tools/update_cpu_features.zig @@ -1227,14 +1227,17 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { } fn featureLessThan(context: void, a: Feature, b: Feature) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); } fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); } fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a, b); } diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index 94e4ab756e..ba12f6e0e6 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -155,7 +155,7 @@ pub fn main() !void { } const fn_set = &target_funcs_gop.value_ptr.list; - for (lib_names) |lib_name, lib_name_index| { + for (lib_names) |lib_name| { const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib"; const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name }); const abi_list_filename = blk: { @@ -263,7 +263,7 @@ pub fn main() !void { // Now the mapping of version and function to integer index is complete. // Here we create a mapping of function name to list of versions. - for (abi_lists) |*abi_list, abi_index| { + for (abi_lists) |*abi_list| { const value = target_functions.getPtr(@ptrToInt(abi_list)).?; const fn_vers_list = &value.fn_vers_list; for (value.list.items) |*ver_fn| { @@ -286,7 +286,7 @@ pub fn main() !void { const abilist_txt = buffered.writer(); // first iterate over the abi lists - for (abi_lists) |*abi_list, abi_index| { + for (abi_lists) |*abi_list| { const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list; for (abi_list.targets) |target, it_i| { if (it_i != 0) try abilist_txt.writeByte(' '); @@ -312,10 +312,12 @@ pub fn main() !void { } pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; return std.mem.order(u8, a, b) == .lt; } pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; const sep_chars = "GLIBC_."; var a_tokens = std.mem.tokenize(a, sep_chars); var b_tokens = std.mem.tokenize(b, sep_chars); diff --git a/tools/update_spirv_features.zig b/tools/update_spirv_features.zig index 5f2bab6c28..0de1c56934 100644 --- a/tools/update_spirv_features.zig +++ b/tools/update_spirv_features.zig @@ -37,6 +37,7 @@ const Version = struct { } fn lessThan(ctx: void, a: Version, b: Version) bool { + _ = ctx; return if (a.major == b.major) a.minor < b.minor else |
