authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-22 17:03:24-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-22 17:09:20-08:00
logeb3c7f570601a6e00cbf03f0a026b3493887a534
treee621eb6aa4ab49bb72018d33c373b258f55922df
parentc0c911bfa78ea2968cd110ad64a4ba0d70ca93e5

zig build fmt


40 files changed, 1244 insertions(+), 1248 deletions(-)

lib/compiler/aro/aro/Parser.zig+1-1
......@@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
979979 _ = try p.expectToken(.semicolon);
980980 if (decl_spec.ty.is(.@"enum") or
981981 (decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
982 !decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
982 !decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
983983 {
984984 const specifier = decl_spec.ty.canonicalize(.standard).specifier;
985985 const attrs = p.attr_buf.items(.attr)[attr_buf_top..];
lib/compiler/aro/aro/pragmas/gcc.zig+3-3
......@@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
114114
115115 const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
116116 return pp.comp.addDiagnostic(.{
117 .tag = .unknown_gcc_pragma,
118 .loc = directive_tok.loc,
119 }, pp.expansionSlice(start_idx + 1));
117 .tag = .unknown_gcc_pragma,
118 .loc = directive_tok.loc,
119 }, pp.expansionSlice(start_idx + 1));
120120
121121 switch (gcc_pragma) {
122122 .warning, .@"error" => {
lib/compiler/resinator/lang.zig+1-1
......@@ -255,7 +255,7 @@ pub fn parse(lang_tag: []const u8) error{InvalidLanguageTag}!Parsed {
255255 // Special case for qps-ploca and qps-plocm
256256 else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
257257 (std.ascii.eqlIgnoreCase(part_str, "ploca") or
258 std.ascii.eqlIgnoreCase(part_str, "plocm")))
258 std.ascii.eqlIgnoreCase(part_str, "plocm")))
259259 {
260260 parsed.suffix = part_str;
261261 } else {
lib/compiler_rt/count0bits.zig+1-1
......@@ -143,7 +143,7 @@ pub const __clzsi2 = switch (builtin.cpu.arch) {
143143 .arm, .armeb, .thumb, .thumbeb => impl: {
144144 const use_thumb1 =
145145 (builtin.cpu.arch.isThumb() or
146 std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
146 std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
147147 !std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
148148
149149 if (use_thumb1) {
lib/compiler_rt/int.zig+26-26
......@@ -81,19 +81,19 @@ fn test_one_divmoddi4(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {
8181
8282const cases__divmoddi4 =
8383 [_][4]i64{
84 [_]i64{ 0, 1, 0, 0 },
85 [_]i64{ 0, -1, 0, 0 },
86 [_]i64{ 2, 1, 2, 0 },
87 [_]i64{ 2, -1, -2, 0 },
88 [_]i64{ -2, 1, -2, 0 },
89 [_]i64{ -2, -1, 2, 0 },
90 [_]i64{ 7, 5, 1, 2 },
91 [_]i64{ -7, 5, -1, -2 },
92 [_]i64{ 19, 5, 3, 4 },
93 [_]i64{ 19, -5, -3, 4 },
94 [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
95 [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
96};
84 [_]i64{ 0, 1, 0, 0 },
85 [_]i64{ 0, -1, 0, 0 },
86 [_]i64{ 2, 1, 2, 0 },
87 [_]i64{ 2, -1, -2, 0 },
88 [_]i64{ -2, 1, -2, 0 },
89 [_]i64{ -2, -1, 2, 0 },
90 [_]i64{ 7, 5, 1, 2 },
91 [_]i64{ -7, 5, -1, -2 },
92 [_]i64{ 19, 5, 3, 4 },
93 [_]i64{ 19, -5, -3, 4 },
94 [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
95 [_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
96 };
9797
9898test "test_divmoddi4" {
9999 for (cases__divmoddi4) |case| {
......@@ -215,19 +215,19 @@ pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {
215215
216216const cases__divmodsi4 =
217217 [_][4]i32{
218 [_]i32{ 0, 1, 0, 0 },
219 [_]i32{ 0, -1, 0, 0 },
220 [_]i32{ 2, 1, 2, 0 },
221 [_]i32{ 2, -1, -2, 0 },
222 [_]i32{ -2, 1, -2, 0 },
223 [_]i32{ -2, -1, 2, 0 },
224 [_]i32{ 7, 5, 1, 2 },
225 [_]i32{ -7, 5, -1, -2 },
226 [_]i32{ 19, 5, 3, 4 },
227 [_]i32{ 19, -5, -3, 4 },
228 [_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
229 [_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
230};
218 [_]i32{ 0, 1, 0, 0 },
219 [_]i32{ 0, -1, 0, 0 },
220 [_]i32{ 2, 1, 2, 0 },
221 [_]i32{ 2, -1, -2, 0 },
222 [_]i32{ -2, 1, -2, 0 },
223 [_]i32{ -2, -1, 2, 0 },
224 [_]i32{ 7, 5, 1, 2 },
225 [_]i32{ -7, 5, -1, -2 },
226 [_]i32{ 19, 5, 3, 4 },
227 [_]i32{ 19, -5, -3, 4 },
228 [_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
229 [_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
230 };
231231
232232fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
233233 var r: i32 = undefined;
lib/compiler_rt/popcount.zig+1-1
......@@ -40,7 +40,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
4040 var x: UT = @bitCast(a);
4141 x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
4242 x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
43 + (x & (~@as(UT, 0) / 5));
43 + (x & (~@as(UT, 0) / 5));
4444 x += x >> 4;
4545 x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
4646 // 8 most significant bits of x + (x<<8) + (x<<16) + ..
lib/docs/wasm/markdown/Parser.zig+1-1
......@@ -374,7 +374,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
374374 // or not of the same marker type.
375375 const should_close_list = last_pending_block.tag == .list and
376376 (block_start.tag != .list_item or
377 block_start.data.list_item.marker != last_pending_block.data.list.marker);
377 block_start.data.list_item.marker != last_pending_block.data.list.marker);
378378 // The last block should also be closed if the new block is not a table
379379 // row, which is the only allowed child of a table.
380380 const should_close_table = last_pending_block.tag == .table and
lib/std/Target.zig+1-1
......@@ -299,7 +299,7 @@ pub const Os = struct {
299299 pub fn parse(str: []const u8) !WindowsVersion {
300300 return std.meta.stringToEnum(WindowsVersion, str) orelse
301301 @enumFromInt(std.fmt.parseInt(u32, str, 0) catch
302 return error.InvalidOperatingSystemVersion);
302 return error.InvalidOperatingSystemVersion);
303303 }
304304
305305 /// This function is defined to serialize a Zig source code representation of this
lib/std/c.zig+4-4
......@@ -9879,10 +9879,10 @@ pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8
98799879
98809880pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
98819881{} // android bionic and openbsd libc does not implement getcontext
9882else if (native_os == .linux and builtin.target.abi.isMusl())
9883 linux.getcontext
9884else
9885 private.getcontext;
9882 else if (native_os == .linux and builtin.target.abi.isMusl())
9883 linux.getcontext
9884 else
9885 private.getcontext;
98869886
98879887pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
98889888 f64
lib/std/crypto/tls/Client.zig+7-7
......@@ -692,7 +692,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
692692 const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
693693 int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
694694 array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
695 array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
695 array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
696696 const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
697697 int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
698698 array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
......@@ -720,11 +720,11 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
720720 );
721721 const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
722722 array(u24, u8, hmacExpandLabel(
723 P.Hmac,
724 &master_secret,
725 &.{ "client finished", &p.transcript_hash.peek() },
726 P.verify_data_length,
727 ));
723 P.Hmac,
724 &master_secret,
725 &.{ "client finished", &p.transcript_hash.peek() },
726 P.verify_data_length,
727 ));
728728 p.transcript_hash.update(&client_verify_cleartext);
729729 p.version = .{ .tls_1_2 = .{
730730 .expected_server_verify_data = hmacExpandLabel(
......@@ -745,7 +745,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
745745 var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
746746 int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
747747 array(u16, u8, nonce[P.fixed_iv_length..].* ++
748 @as([client_verify_cleartext.len + P.mac_length]u8, undefined));
748 @as([client_verify_cleartext.len + P.mac_length]u8, undefined));
749749 P.AEAD.encrypt(
750750 client_verify_msg[client_verify_msg.len - P.mac_length -
751751 client_verify_cleartext.len ..][0..client_verify_cleartext.len],
lib/std/debug/SelfInfo.zig+9-9
......@@ -689,15 +689,15 @@ pub const Module = switch (native_os) {
689689 const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
690690 const o_file_info = self.ofiles.getPtr(o_file_path) orelse
691691 (self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
692 error.FileNotFound,
693 error.MissingDebugInfo,
694 error.InvalidDebugInfo,
695 => return .{
696 .relocated_address = relocated_address,
697 .symbol = symbol,
698 },
699 else => return err,
700 });
692 error.FileNotFound,
693 error.MissingDebugInfo,
694 error.InvalidDebugInfo,
695 => return .{
696 .relocated_address = relocated_address,
697 .symbol = symbol,
698 },
699 else => return err,
700 });
701701
702702 return .{
703703 .relocated_address = relocated_address,
lib/std/http/Client.zig+12-12
......@@ -960,13 +960,13 @@ pub const Request = struct {
960960 pub const WaitError = RequestError || SendError || TransferReadError ||
961961 proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
962962 error{
963 TooManyHttpRedirects,
964 RedirectRequiresResend,
965 HttpRedirectLocationMissing,
966 HttpRedirectLocationInvalid,
967 CompressionInitializationFailed,
968 CompressionUnsupported,
969 };
963 TooManyHttpRedirects,
964 RedirectRequiresResend,
965 HttpRedirectLocationMissing,
966 HttpRedirectLocationInvalid,
967 CompressionInitializationFailed,
968 CompressionUnsupported,
969 };
970970
971971 /// Waits for a response from the server and parses any headers that are sent.
972972 /// This function will block until the final response is received.
......@@ -1540,12 +1540,12 @@ pub fn connect(
15401540pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
15411541 std.fmt.ParseIntError || Connection.WriteError ||
15421542 error{
1543 UnsupportedUriScheme,
1544 UriMissingHost,
1543 UnsupportedUriScheme,
1544 UriMissingHost,
15451545
1546 CertificateBundleLoadFailure,
1547 UnsupportedTransferEncoding,
1548};
1546 CertificateBundleLoadFailure,
1547 UnsupportedTransferEncoding,
1548 };
15491549
15501550pub const RequestOptions = struct {
15511551 version: http.Version = .@"HTTP/1.1",
lib/std/posix.zig+6-6
......@@ -2851,12 +2851,12 @@ pub fn renameatW(
28512851
28522852 rc =
28532853 windows.ntdll.NtSetInformationFile(
2854 src_fd,
2855 &io_status_block,
2856 rename_info,
2857 @intCast(struct_len), // already checked for error.NameTooLong
2858 .FileRenameInformation,
2859 );
2854 src_fd,
2855 &io_status_block,
2856 rename_info,
2857 @intCast(struct_len), // already checked for error.NameTooLong
2858 .FileRenameInformation,
2859 );
28602860 }
28612861
28622862 switch (rc) {
lib/std/zig/render.zig+4-4
......@@ -372,7 +372,7 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
372372 if (!ais.indentStackEmpty() and
373373 token_tags[i] != .colon and
374374 ((token_tags[i] != .semicolon and token_tags[i] != .comma) or
375 ais.lastSpaceModeIndent() < ais.currentIndent()))
375 ais.lastSpaceModeIndent() < ais.currentIndent()))
376376 {
377377 ais.popIndent();
378378 try ais.pushIndent(.normal);
......@@ -1185,9 +1185,9 @@ fn renderVarDeclWithoutFixups(
11851185 {
11861186 const name_space = if (var_decl.ast.type_node == 0 and
11871187 (var_decl.ast.align_node != 0 or
1188 var_decl.ast.addrspace_node != 0 or
1189 var_decl.ast.section_node != 0 or
1190 var_decl.ast.init_node != 0))
1188 var_decl.ast.addrspace_node != 0 or
1189 var_decl.ast.section_node != 0 or
1190 var_decl.ast.init_node != 0))
11911191 Space.space
11921192 else
11931193 Space.none;
src/Sema.zig+11-11
......@@ -23443,7 +23443,7 @@ fn ptrCastFull(
2344323443 errdefer msg.destroy(sema.gpa);
2344423444 if (dest_info.flags.size == .many and
2344523445 (src_info.flags.size == .slice or
23446 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
23446 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
2344723447 {
2344823448 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
2344923449 } else {
......@@ -28136,9 +28136,9 @@ fn fieldCallBind(
2813628136 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
2813728137 if (first_param_type.isGenericPoison() or
2813828138 (first_param_type.zigTypeTag(zcu) == .pointer and
28139 (first_param_type.ptrSize(zcu) == .one or
28140 first_param_type.ptrSize(zcu) == .c) and
28141 first_param_type.childType(zcu).eql(concrete_ty, zcu)))
28139 (first_param_type.ptrSize(zcu) == .one or
28140 first_param_type.ptrSize(zcu) == .c) and
28141 first_param_type.childType(zcu).eql(concrete_ty, zcu)))
2814228142 {
2814328143 // Note that if the param type is generic poison, we know that it must
2814428144 // specifically be `anytype` since it's the first parameter, meaning we
......@@ -29652,7 +29652,7 @@ fn coerceExtra(
2965229652
2965329653 if (dest_info.sentinel == .none or inst_info.sentinel == .none or
2965429654 Air.internedToRef(dest_info.sentinel) !=
29655 try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
29655 try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
2965629656 break :p;
2965729657
2965829658 const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
......@@ -30492,12 +30492,12 @@ pub fn coerceInMemoryAllowed(
3049230492 }
3049330493 const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
3049430494 (src_info.sentinel != null and
30495 dest_info.sentinel != null and
30496 dest_info.sentinel.?.eql(
30497 try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
30498 dest_info.elem_type,
30499 zcu,
30500 ));
30495 dest_info.sentinel != null and
30496 dest_info.sentinel.?.eql(
30497 try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
30498 dest_info.elem_type,
30499 zcu,
30500 ));
3050130501 if (!ok_sent) {
3050230502 return .{ .array_sentinel = .{
3050330503 .actual = src_info.sentinel orelse Value.@"unreachable",
src/Type.zig+6-5
......@@ -610,11 +610,12 @@ pub fn hasRuntimeBitsInner(
610610 // in which case we want control flow to continue down below.
611611 if (tag_ty != .none and
612612 try Type.fromInterned(tag_ty).hasRuntimeBitsInner(
613 ignore_comptime_only,
614 strat,
615 zcu,
616 tid,
617 )) {
613 ignore_comptime_only,
614 strat,
615 zcu,
616 tid,
617 ))
618 {
618619 return true;
619620 }
620621 },
src/Zcu.zig+4-4
......@@ -1496,8 +1496,8 @@ pub const SrcLoc = struct {
14961496 const case = tree.fullSwitchCase(case_node).?;
14971497 const is_special = (case.ast.values.len == 0) or
14981498 (case.ast.values.len == 1 and
1499 node_tags[case.ast.values[0]] == .identifier and
1500 mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
1499 node_tags[case.ast.values[0]] == .identifier and
1500 mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
15011501 if (!is_special) continue;
15021502
15031503 return tree.nodeToSpan(case_node);
......@@ -1516,8 +1516,8 @@ pub const SrcLoc = struct {
15161516 const case = tree.fullSwitchCase(case_node).?;
15171517 const is_special = (case.ast.values.len == 0) or
15181518 (case.ast.values.len == 1 and
1519 node_tags[case.ast.values[0]] == .identifier and
1520 mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
1519 node_tags[case.ast.values[0]] == .identifier and
1520 mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
15211521 if (is_special) continue;
15221522
15231523 for (case.ast.values) |item_node| {
src/arch/riscv64/CodeGen.zig+10-11
......@@ -685,8 +685,7 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
685685
686686 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
687687 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
688 if (opts.update_tracking)
689 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
688 if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
690689
691690 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
692691 stack.get(),
......@@ -2260,7 +2259,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void {
22602259
22612260 const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
22622261 math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
2263 math.divCeil(u32, src_storage_bits, 64) catch unreachable and
2262 math.divCeil(u32, src_storage_bits, 64) catch unreachable and
22642263 func.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
22652264 const dst_mcv = try func.allocRegOrMem(dst_ty, inst, true);
22662265 try func.genCopy(min_ty, dst_mcv, src_mcv);
......@@ -2311,9 +2310,9 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
23112310
23122311 const dst_reg: Register =
23132312 if (func.reuseOperand(inst, ty_op.operand, 0, operand) and operand == .register)
2314 operand.register
2315 else
2316 (try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
2313 operand.register
2314 else
2315 (try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
23172316
23182317 switch (ty.zigTypeTag(zcu)) {
23192318 .bool => {
......@@ -6222,11 +6221,11 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
62226221
62236222 const instruction: union(enum) { mnem: Mnemonic, pseudo: Pseudo } =
62246223 if (std.meta.stringToEnum(Mnemonic, mnem_str)) |mnem|
6225 .{ .mnem = mnem }
6226 else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
6227 .{ .pseudo = pseudo }
6228 else
6229 return func.fail("invalid mnem str '{s}'", .{mnem_str});
6224 .{ .mnem = mnem }
6225 else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
6226 .{ .pseudo = pseudo }
6227 else
6228 return func.fail("invalid mnem str '{s}'", .{mnem_str});
62306229
62316230 const Operand = union(enum) {
62326231 none,
src/arch/x86_64/CodeGen.zig+41-42
......@@ -82655,8 +82655,7 @@ fn restoreState(self: *CodeGen, state: State, deaths: []const Air.Inst.Index, co
8265582655
8265682656 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
8265782657 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
82658 if (opts.update_tracking)
82659 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
82658 if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
8266082659
8266182660 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
8266282661 stack.get(),
......@@ -83216,7 +83215,7 @@ fn airIntCast(self: *CodeGen, inst: Air.Inst.Index) !void {
8321683215 const dst_mcv = if ((if (src_mcv.getReg()) |src_reg| src_reg.class() == .general_purpose else src_abi_size > 8) and
8321783216 dst_int_info.bits <= src_storage_bits and
8321883217 std.math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
83219 std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
83218 std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
8322083219 self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
8322183220 const dst_mcv = try self.allocRegOrMem(inst, true);
8322283221 try self.genCopy(min_ty, dst_mcv, src_mcv, .{});
......@@ -84695,10 +84694,10 @@ fn genIntMulDivOpMir(self: *CodeGen, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCVa
8469584694 ._ => {
8469684695 const hi_reg: Register =
8469784696 switch (bit_size) {
84698 8 => .ah,
84699 16, 32, 64 => .edx,
84700 else => unreachable,
84701 };
84697 8 => .ah,
84698 16, 32, 64 => .edx,
84699 else => unreachable,
84700 };
8470284701 try self.asmRegisterRegister(.{ ._, .xor }, hi_reg, hi_reg);
8470384702 },
8470484703 .i_ => try self.asmOpOnly(.{ ._, switch (bit_size) {
......@@ -89019,9 +89018,9 @@ fn genShiftBinOpMir(
8901989018 .size = .fromSize(abi_size),
8902089019 .disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
8902189020 return self.fail("TODO genShiftBinOpMir between {s} and {s}", .{
89022 @tagName(lhs_mcv),
89023 @tagName(shift_mcv),
89024 }),
89021 @tagName(lhs_mcv),
89022 @tagName(shift_mcv),
89023 }),
8902589024 } },
8902689025 },
8902789026 .indirect => |reg_off| .{
......@@ -89761,17 +89760,17 @@ fn genBinOp(
8976189760
8976289761 const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
8976389762 switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
89764 .bool => false,
89765 .int => switch (air_tag) {
89766 .cmp_lt, .cmp_gte => true,
89767 else => false,
89768 },
89769 .float => switch (air_tag) {
89770 .cmp_gte, .cmp_gt => true,
89771 else => false,
89772 },
89773 else => unreachable,
89774 }) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
89763 .bool => false,
89764 .int => switch (air_tag) {
89765 .cmp_lt, .cmp_gte => true,
89766 else => false,
89767 },
89768 .float => switch (air_tag) {
89769 .cmp_gte, .cmp_gt => true,
89770 else => false,
89771 },
89772 else => unreachable,
89773 }) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
8977589774
8977689775 if (lhs_ty.isAbiInt(zcu)) for (ordered_air) |op_air| {
8977789776 switch (try self.resolveInst(op_air)) {
......@@ -91776,13 +91775,13 @@ fn genIntMulComplexOpMir(self: *CodeGen, dst_ty: Type, dst_mcv: MCValue, src_mcv
9177691775 .size = .fromSize(abi_size),
9177791776 .disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
9177891777 return self.asmRegisterRegister(
91779 .{ .i_, .mul },
91780 dst_alias,
91781 registerAlias(
91782 try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
91783 abi_size,
91778 .{ .i_, .mul },
91779 dst_alias,
91780 registerAlias(
91781 try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
91782 abi_size,
91783 ),
9178491784 ),
91785 ),
9178691785 } },
9178791786 },
9178891787 .indirect => |reg_off| .{
......@@ -94101,9 +94100,9 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
9410194100 std.mem.eql(u8, rest, "r,m") or std.mem.eql(u8, rest, "m,r"))
9410294101 self.register_manager.tryAllocReg(maybe_inst, abi.RegisterClass.gp) orelse
9410394102 if (output != .none)
94104 null
94105 else
94106 return self.fail("ran out of registers lowering inline asm", .{})
94103 null
94104 else
94105 return self.fail("ran out of registers lowering inline asm", .{})
9410794106 else if (std.mem.startsWith(u8, rest, "{") and std.mem.endsWith(u8, rest, "}"))
9410894107 parseRegName(rest["{".len .. rest.len - "}".len]) orelse
9410994108 return self.fail("invalid register constraint: '{s}'", .{constraint})
......@@ -96965,9 +96964,9 @@ fn airAtomicLoad(self: *CodeGen, inst: Air.Inst.Index) !void {
9696596964
9696696965 const dst_mcv =
9696796966 if (self.reuseOperand(inst, atomic_load.ptr, 0, ptr_mcv))
96968 ptr_mcv
96969 else
96970 try self.allocRegOrMem(inst, true);
96967 ptr_mcv
96968 else
96969 try self.allocRegOrMem(inst, true);
9697196970
9697296971 try self.load(dst_mcv, ptr_ty, ptr_mcv);
9697396972 return self.finishAir(inst, dst_mcv, .{ atomic_load.ptr, .none, .none });
......@@ -103712,9 +103711,9 @@ const Select = struct {
103712103711 if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .signed else false,
103713103712 .signed_int_or_full_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
103714103713 if (cg.intInfo(ty.childType(zcu))) |int_info| switch (int_info.signedness) {
103715 .signed => true,
103716 .unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
103717 } else false,
103714 .signed => true,
103715 .unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
103716 } else false,
103718103717 .unsigned_int_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
103719103718 if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .unsigned else false,
103720103719 .size => |size| @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu),
......@@ -103736,26 +103735,26 @@ const Select = struct {
103736103735 if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
103737103736 .scalar_signed_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
103738103737 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
103739 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103738 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103740103739 .scalar_unsigned_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
103741103740 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
103742 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103741 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103743103742 .multiple_scalar_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103744103743 if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
103745103744 .multiple_scalar_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103746103745 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
103747 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103746 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103748103747 .multiple_scalar_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103749103748 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
103750 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103749 of_is.is.bitSize(cg.target) >= int_info.bits else false,
103751103750 .multiple_scalar_exact_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103752103751 if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is == int_info.bits else false,
103753103752 .multiple_scalar_exact_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103754103753 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
103755 of_is.is == int_info.bits else false,
103754 of_is.is == int_info.bits else false,
103756103755 .multiple_scalar_exact_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
103757103756 if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
103758 of_is.is == int_info.bits else false,
103757 of_is.is == int_info.bits else false,
103759103758 .scalar_remainder_int => |of_is| if (cg.intInfo(ty.scalarType(zcu))) |int_info|
103760103759 of_is.is.bitSize(cg.target) >= (int_info.bits - 1) % of_is.of.bitSize(cg.target) + 1
103761103760 else
src/codegen.zig+1-1
......@@ -423,7 +423,7 @@ pub fn generateSymbol(
423423
424424 const padding = abi_size -
425425 (math.cast(usize, Type.fromInterned(vector_type.child).abiSize(zcu) * vector_type.len) orelse
426 return error.Overflow);
426 return error.Overflow);
427427 if (padding > 0) try code.appendNTimes(gpa, 0, padding);
428428 }
429429 },
src/codegen/c.zig+3-3
......@@ -1990,7 +1990,7 @@ pub const DeclGen = struct {
19901990 if (dest_bits <= 64 and src_bits <= 64) {
19911991 const needs_cast = src_int_info == null or
19921992 (toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
1993 dest_int_info.signedness != src_int_info.?.signedness);
1993 dest_int_info.signedness != src_int_info.?.signedness);
19941994 return !needs_cast and !src_is_ptr;
19951995 } else return false;
19961996 }
......@@ -2031,7 +2031,7 @@ pub const DeclGen = struct {
20312031 if (dest_bits <= 64 and src_bits <= 64) {
20322032 const needs_cast = src_int_info == null or
20332033 (toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
2034 dest_int_info.signedness != src_int_info.?.signedness);
2034 dest_int_info.signedness != src_int_info.?.signedness);
20352035
20362036 if (needs_cast) {
20372037 try w.writeByte('(');
......@@ -4348,7 +4348,7 @@ fn airEquality(
43484348 .aligned, .array, .vector, .fwd_decl, .function => unreachable,
43494349 .aggregate => |aggregate| if (aggregate.fields.len == 2 and
43504350 (aggregate.fields.at(0, ctype_pool).name.index == .is_null or
4351 aggregate.fields.at(1, ctype_pool).name.index == .is_null))
4351 aggregate.fields.at(1, ctype_pool).name.index == .is_null))
43524352 {
43534353 try f.writeCValueMember(writer, lhs, .{ .identifier = "is_null" });
43544354 try writer.writeAll(" || ");
src/codegen/c/Type.zig+34-35
......@@ -758,12 +758,12 @@ pub const Info = union(enum) {
758758 fn tag(pointer_info: Pointer) Pool.Tag {
759759 return @enumFromInt(@intFromEnum(Pool.Tag.pointer) +
760760 @as(u2, @bitCast(packed struct(u2) {
761 @"const": bool,
762 @"volatile": bool,
763 }{
764 .@"const" = pointer_info.@"const",
765 .@"volatile" = pointer_info.@"volatile",
766 })));
761 @"const": bool,
762 @"volatile": bool,
763 }{
764 .@"const" = pointer_info.@"const",
765 .@"volatile" = pointer_info.@"volatile",
766 })));
767767 }
768768 };
769769
......@@ -887,24 +887,24 @@ pub const Info = union(enum) {
887887 pool_adapter.eql(lhs_vector_info.elem_ctype, rhs_info.vector.elem_ctype),
888888 .fwd_decl => |lhs_fwd_decl_info| lhs_fwd_decl_info.tag == rhs_info.fwd_decl.tag and
889889 switch (lhs_fwd_decl_info.name) {
890 .anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
891 lhs_pool,
892 rhs_info.fwd_decl.name.anon,
893 rhs_pool,
894 pool_adapter,
895 ),
896 .index => |lhs_index| rhs_info.fwd_decl.name == .index and
897 lhs_index == rhs_info.fwd_decl.name.index,
898 },
890 .anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
891 lhs_pool,
892 rhs_info.fwd_decl.name.anon,
893 rhs_pool,
894 pool_adapter,
895 ),
896 .index => |lhs_index| rhs_info.fwd_decl.name == .index and
897 lhs_index == rhs_info.fwd_decl.name.index,
898 },
899899 .aggregate => |lhs_aggregate_info| lhs_aggregate_info.tag == rhs_info.aggregate.tag and
900900 lhs_aggregate_info.@"packed" == rhs_info.aggregate.@"packed" and
901901 switch (lhs_aggregate_info.name) {
902 .anon => |lhs_anon| rhs_info.aggregate.name == .anon and
903 lhs_anon.index == rhs_info.aggregate.name.anon.index and
904 lhs_anon.id == rhs_info.aggregate.name.anon.id,
905 .fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
906 pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
907 } and lhs_aggregate_info.fields.eqlAdapted(
902 .anon => |lhs_anon| rhs_info.aggregate.name == .anon and
903 lhs_anon.index == rhs_info.aggregate.name.anon.index and
904 lhs_anon.id == rhs_info.aggregate.name.anon.id,
905 .fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
906 pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
907 } and lhs_aggregate_info.fields.eqlAdapted(
908908 lhs_pool,
909909 rhs_info.aggregate.fields,
910910 rhs_pool,
......@@ -913,13 +913,12 @@ pub const Info = union(enum) {
913913 .function => |lhs_function_info| lhs_function_info.param_ctypes.len ==
914914 rhs_info.function.param_ctypes.len and
915915 pool_adapter.eql(lhs_function_info.return_ctype, rhs_info.function.return_ctype) and
916 for (0..lhs_function_info.param_ctypes.len) |param_index|
917 {
918 if (!pool_adapter.eql(
919 lhs_function_info.param_ctypes.at(param_index, lhs_pool),
920 rhs_info.function.param_ctypes.at(param_index, rhs_pool),
921 )) break false;
922 } else true,
916 for (0..lhs_function_info.param_ctypes.len) |param_index| {
917 if (!pool_adapter.eql(
918 lhs_function_info.param_ctypes.at(param_index, lhs_pool),
919 rhs_info.function.param_ctypes.at(param_index, rhs_pool),
920 )) break false;
921 } else true,
923922 };
924923 }
925924};
......@@ -2301,13 +2300,13 @@ pub const Pool = struct {
23012300 const return_type = Type.fromInterned(func_info.return_type);
23022301 const return_ctype: CType =
23032302 if (!ip.isNoReturn(func_info.return_type)) try pool.fromType(
2304 allocator,
2305 scratch,
2306 return_type,
2307 pt,
2308 mod,
2309 kind.asParameter(),
2310 ) else .void;
2303 allocator,
2304 scratch,
2305 return_type,
2306 pt,
2307 mod,
2308 kind.asParameter(),
2309 ) else .void;
23112310 for (0..func_info.param_types.len) |param_index| {
23122311 const param_type = Type.fromInterned(
23132312 func_info.param_types.get(ip)[param_index],
src/codegen/llvm.zig+55-56
......@@ -388,7 +388,7 @@ const DataLayoutBuilder = struct {
388388 self.target.cpu.arch != .riscv64 and
389389 self.target.cpu.arch != .loongarch64 and
390390 !(self.target.cpu.arch == .aarch64 and
391 (self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
391 (self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
392392 self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue;
393393 try writer.writeAll("-p");
394394 if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)});
......@@ -859,55 +859,54 @@ pub const Object = struct {
859859 builder.data_layout = try builder.fmt("{}", .{DataLayoutBuilder{ .target = target }});
860860
861861 const debug_compile_unit, const debug_enums_fwd_ref, const debug_globals_fwd_ref =
862 if (!builder.strip)
863 debug_info: {
864 // We fully resolve all paths at this point to avoid lack of
865 // source line info in stack traces or lack of debugging
866 // information which, if relative paths were used, would be
867 // very location dependent.
868 // TODO: the only concern I have with this is WASI as either host or target, should
869 // we leave the paths as relative then?
870 // TODO: This is totally wrong. In dwarf, paths are encoded as relative to
871 // a particular directory, and then the directory path is specified elsewhere.
872 // In the compiler frontend we have it stored correctly in this
873 // way already, but here we throw all that sweet information
874 // into the garbage can by converting into absolute paths. What
875 // a terrible tragedy.
876 const compile_unit_dir = blk: {
877 if (comp.zcu) |zcu| m: {
878 const d = try zcu.main_mod.root.joinString(arena, "");
879 if (d.len == 0) break :m;
880 if (std.fs.path.isAbsolute(d)) break :blk d;
881 break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
882 }
883 break :blk try std.process.getCwdAlloc(arena);
884 };
862 if (!builder.strip) debug_info: {
863 // We fully resolve all paths at this point to avoid lack of
864 // source line info in stack traces or lack of debugging
865 // information which, if relative paths were used, would be
866 // very location dependent.
867 // TODO: the only concern I have with this is WASI as either host or target, should
868 // we leave the paths as relative then?
869 // TODO: This is totally wrong. In dwarf, paths are encoded as relative to
870 // a particular directory, and then the directory path is specified elsewhere.
871 // In the compiler frontend we have it stored correctly in this
872 // way already, but here we throw all that sweet information
873 // into the garbage can by converting into absolute paths. What
874 // a terrible tragedy.
875 const compile_unit_dir = blk: {
876 if (comp.zcu) |zcu| m: {
877 const d = try zcu.main_mod.root.joinString(arena, "");
878 if (d.len == 0) break :m;
879 if (std.fs.path.isAbsolute(d)) break :blk d;
880 break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
881 }
882 break :blk try std.process.getCwdAlloc(arena);
883 };
885884
886 const debug_file = try builder.debugFile(
887 try builder.metadataString(comp.root_name),
888 try builder.metadataString(compile_unit_dir),
889 );
885 const debug_file = try builder.debugFile(
886 try builder.metadataString(comp.root_name),
887 try builder.metadataString(compile_unit_dir),
888 );
890889
891 const debug_enums_fwd_ref = try builder.debugForwardReference();
892 const debug_globals_fwd_ref = try builder.debugForwardReference();
893
894 const debug_compile_unit = try builder.debugCompileUnit(
895 debug_file,
896 // Don't use the version string here; LLVM misparses it when it
897 // includes the git revision.
898 try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
899 build_options.semver.major,
900 build_options.semver.minor,
901 build_options.semver.patch,
902 }),
903 debug_enums_fwd_ref,
904 debug_globals_fwd_ref,
905 .{ .optimized = comp.root_mod.optimize_mode != .Debug },
906 );
890 const debug_enums_fwd_ref = try builder.debugForwardReference();
891 const debug_globals_fwd_ref = try builder.debugForwardReference();
892
893 const debug_compile_unit = try builder.debugCompileUnit(
894 debug_file,
895 // Don't use the version string here; LLVM misparses it when it
896 // includes the git revision.
897 try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
898 build_options.semver.major,
899 build_options.semver.minor,
900 build_options.semver.patch,
901 }),
902 debug_enums_fwd_ref,
903 debug_globals_fwd_ref,
904 .{ .optimized = comp.root_mod.optimize_mode != .Debug },
905 );
907906
908 try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
909 break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
910 } else .{.none} ** 3;
907 try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
908 break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
909 } else .{.none} ** 3;
911910
912911 const obj = try arena.create(Object);
913912 obj.* = .{
......@@ -2759,9 +2758,9 @@ pub const Object = struct {
27592758
27602759 const full_fields: [2]Builder.Metadata =
27612760 if (layout.tag_align.compare(.gte, layout.payload_align))
2762 .{ debug_tag_type, debug_payload_type }
2763 else
2764 .{ debug_payload_type, debug_tag_type };
2761 .{ debug_tag_type, debug_payload_type }
2762 else
2763 .{ debug_payload_type, debug_tag_type };
27652764
27662765 const debug_tagged_union_type = try o.builder.debugStructType(
27672766 try o.builder.metadataString(name),
......@@ -4551,11 +4550,11 @@ pub const Object = struct {
45514550 // instruction is followed by a `wrap_optional`, it will return this value
45524551 // verbatim, and the result should test as non-null.
45534552 switch (zcu.getTarget().ptrBitWidth()) {
4554 16 => 0xaaaa,
4555 32 => 0xaaaaaaaa,
4556 64 => 0xaaaaaaaa_aaaaaaaa,
4557 else => unreachable,
4558 };
4553 16 => 0xaaaa,
4554 32 => 0xaaaaaaaa,
4555 64 => 0xaaaaaaaa_aaaaaaaa,
4556 else => unreachable,
4557 };
45594558 const llvm_usize = try o.lowerType(Type.usize);
45604559 const llvm_ptr_ty = try o.lowerType(ptr_ty);
45614560 return o.builder.castConst(.inttoptr, try o.builder.intConst(llvm_usize, int), llvm_ptr_ty);
......@@ -9544,7 +9543,7 @@ pub const FuncGen = struct {
95449543
95459544 if (llvm_dest_ty.isStruct(&o.builder) or
95469545 ((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
9547 operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
9546 operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
95489547 {
95499548 // Both our operand and our result are values, not pointers,
95509549 // but LLVM won't let us bitcast struct values or vectors with padding bits.
src/link/Coff.zig+35-35
......@@ -3821,38 +3821,38 @@ const msdos_stub: [120]u8 = .{
38213821 0x40, 0x00, // Absolute offset to relocation table. 64 matches the header size (all bytes before the MS-DOS stub program).
38223822 0x00, 0x00, // Overlay number. Zero means this is the main executable.
38233823}
3824// Reserved words.
3825++ .{ 0x00, 0x00 } ** 4
3826// OEM-related fields.
3827++ .{
3828 0x00, 0x00, // OEM identifier.
3829 0x00, 0x00, // OEM information.
3830}
3831// Reserved words.
3832++ .{ 0x00, 0x00 } ** 10
3833// Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
3834++ .{ 0x78, 0x00, 0x00, 0x00 }
3835// What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
3836++ .{
3837 // Set the value of the data segment to the same value as the code segment.
3838 0x0e, // push cs
3839 0x1f, // pop ds
3840 // Set the DX register to the address of the message.
3841 // If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
3842 0xba, 14, 0x00, // mov dx, 14
3843 // Set AH to the system call code for printing a message.
3844 0xb4, 0x09, // mov ah, 0x09
3845 // Perform the system call to print the message.
3846 0xcd, 0x21, // int 0x21
3847 // Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
3848 0xb8, 0x01, 0x4c, // mov ax, 0x4c01
3849 // Peform the system call to exit the program with exit code 1.
3850 0xcd, 0x21, // int 0x21
3851}
3852// Message to print.
3853++ "This program cannot be run in DOS mode.".*
3854// Message terminators.
3855++ .{
3856 '$', // We do not pass a length to the print system call; the string is terminated by this character.
3857 0x00, 0x00, // Terminating zero bytes.
3858};
3824 // Reserved words.
3825 ++ .{ 0x00, 0x00 } ** 4
3826 // OEM-related fields.
3827 ++ .{
3828 0x00, 0x00, // OEM identifier.
3829 0x00, 0x00, // OEM information.
3830 }
3831 // Reserved words.
3832 ++ .{ 0x00, 0x00 } ** 10
3833 // Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
3834 ++ .{ 0x78, 0x00, 0x00, 0x00 }
3835 // What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
3836 ++ .{
3837 // Set the value of the data segment to the same value as the code segment.
3838 0x0e, // push cs
3839 0x1f, // pop ds
3840 // Set the DX register to the address of the message.
3841 // If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
3842 0xba, 14, 0x00, // mov dx, 14
3843 // Set AH to the system call code for printing a message.
3844 0xb4, 0x09, // mov ah, 0x09
3845 // Perform the system call to print the message.
3846 0xcd, 0x21, // int 0x21
3847 // Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
3848 0xb8, 0x01, 0x4c, // mov ax, 0x4c01
3849 // Peform the system call to exit the program with exit code 1.
3850 0xcd, 0x21, // int 0x21
3851 }
3852 // Message to print.
3853 ++ "This program cannot be run in DOS mode.".*
3854 // Message terminators.
3855 ++ .{
3856 '$', // We do not pass a length to the print system call; the string is terminated by this character.
3857 0x00, 0x00, // Terminating zero bytes.
3858 };
src/link/Dwarf.zig+24-24
......@@ -1995,30 +1995,30 @@ pub const WipNav = struct {
19951995 errdefer _ = if (!decl_gop.found_existing) dwarf.decls.pop();
19961996 const was_generic_decl = decl_gop.found_existing and
19971997 switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, decl_gop.value_ptr.*)) {
1998 .null,
1999 .decl_alias,
2000 .decl_empty_enum,
2001 .decl_enum,
2002 .decl_namespace_struct,
2003 .decl_struct,
2004 .decl_packed_struct,
2005 .decl_union,
2006 .decl_var,
2007 .decl_const,
2008 .decl_const_runtime_bits,
2009 .decl_const_comptime_state,
2010 .decl_const_runtime_bits_comptime_state,
2011 .decl_empty_func,
2012 .decl_func,
2013 .decl_empty_func_generic,
2014 .decl_func_generic,
2015 => false,
2016 .generic_decl_var,
2017 .generic_decl_const,
2018 .generic_decl_func,
2019 => true,
2020 else => unreachable,
2021 };
1998 .null,
1999 .decl_alias,
2000 .decl_empty_enum,
2001 .decl_enum,
2002 .decl_namespace_struct,
2003 .decl_struct,
2004 .decl_packed_struct,
2005 .decl_union,
2006 .decl_var,
2007 .decl_const,
2008 .decl_const_runtime_bits,
2009 .decl_const_comptime_state,
2010 .decl_const_runtime_bits_comptime_state,
2011 .decl_empty_func,
2012 .decl_func,
2013 .decl_empty_func_generic,
2014 .decl_func_generic,
2015 => false,
2016 .generic_decl_var,
2017 .generic_decl_const,
2018 .generic_decl_func,
2019 => true,
2020 else => unreachable,
2021 };
20222022 if (parent_type.getCaptures(zcu).len == 0) {
20232023 if (was_generic_decl) try dwarf.freeCommonEntry(wip_nav.unit, decl_gop.value_ptr.*);
20242024 decl_gop.value_ptr.* = orig_entry;
src/link/Elf/Object.zig+5-5
......@@ -236,11 +236,11 @@ pub fn validateEFlags(
236236
237237 const fabi: riscv.Eflags.FloatAbi =
238238 if (std.Target.riscv.featureSetHas(features, .d))
239 .double
240 else if (std.Target.riscv.featureSetHas(features, .f))
241 .single
242 else
243 .soft;
239 .double
240 else if (std.Target.riscv.featureSetHas(features, .f))
241 .single
242 else
243 .soft;
244244
245245 if (flags.fabi != fabi) {
246246 any_errors = true;
src/link/Elf/relocatable.zig+11-11
......@@ -217,20 +217,20 @@ fn initSections(elf_file: *Elf) !void {
217217 if (elf_file.section_indexes.eh_frame == null) {
218218 elf_file.section_indexes.eh_frame = elf_file.sectionByName(".eh_frame") orelse
219219 try elf_file.addSection(.{
220 .name = try elf_file.insertShString(".eh_frame"),
221 .type = if (elf_file.getTarget().cpu.arch == .x86_64)
222 elf.SHT_X86_64_UNWIND
223 else
224 elf.SHT_PROGBITS,
225 .flags = elf.SHF_ALLOC,
226 .addralign = elf_file.ptrWidthBytes(),
227 });
220 .name = try elf_file.insertShString(".eh_frame"),
221 .type = if (elf_file.getTarget().cpu.arch == .x86_64)
222 elf.SHT_X86_64_UNWIND
223 else
224 elf.SHT_PROGBITS,
225 .flags = elf.SHF_ALLOC,
226 .addralign = elf_file.ptrWidthBytes(),
227 });
228228 }
229229 elf_file.section_indexes.eh_frame_rela = elf_file.sectionByName(".rela.eh_frame") orelse
230230 try elf_file.addRelaShdr(
231 try elf_file.insertShString(".rela.eh_frame"),
232 elf_file.section_indexes.eh_frame.?,
233 );
231 try elf_file.insertShString(".rela.eh_frame"),
232 elf_file.section_indexes.eh_frame.?,
233 );
234234 }
235235
236236 try initComdatGroups(elf_file);
src/link/Elf/synthetic_sections.zig+1-1
......@@ -551,7 +551,7 @@ pub const GotSection = struct {
551551 switch (entry.tag) {
552552 .got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or
553553 ((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and
554 !symbol.?.isAbs(elf_file)))
554 !symbol.?.isAbs(elf_file)))
555555 {
556556 num += 1;
557557 },
src/link/MachO.zig+8-8
......@@ -1617,14 +1617,14 @@ fn initOutputSections(self: *MachO) !void {
16171617 }
16181618 self.text_sect_index = self.getSectionByName("__TEXT", "__text") orelse
16191619 try self.addSection("__TEXT", "__text", .{
1620 .alignment = switch (self.getTarget().cpu.arch) {
1621 .x86_64 => 0,
1622 .aarch64 => 2,
1623 else => unreachable,
1624 },
1625 .flags = macho.S_REGULAR |
1626 macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
1627 });
1620 .alignment = switch (self.getTarget().cpu.arch) {
1621 .x86_64 => 0,
1622 .aarch64 => 2,
1623 else => unreachable,
1624 },
1625 .flags = macho.S_REGULAR |
1626 macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
1627 });
16281628 self.data_sect_index = self.getSectionByName("__DATA", "__data") orelse
16291629 try self.addSection("__DATA", "__data", .{});
16301630}
src/link/MachO/Atom.zig+4-4
......@@ -149,10 +149,10 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
149149 if (macho_file.base.isRelocatable()) {
150150 const osec = macho_file.getSectionByName(sect.segName(), sect.sectName()) orelse
151151 try macho_file.addSection(
152 sect.segName(),
153 sect.sectName(),
154 .{ .flags = sect.flags },
155 );
152 sect.segName(),
153 sect.sectName(),
154 .{ .flags = sect.flags },
155 );
156156 return osec;
157157 }
158158
src/link/MachO/ZigObject.zig+2-2
......@@ -1104,8 +1104,8 @@ fn createTlvDescriptor(
11041104
11051105 const sect_index = macho_file.getSectionByName("__DATA", "__thread_vars") orelse
11061106 try macho_file.addSection("__DATA", "__thread_vars", .{
1107 .flags = macho.S_THREAD_LOCAL_VARIABLES,
1108 });
1107 .flags = macho.S_THREAD_LOCAL_VARIABLES,
1108 });
11091109 sym.out_n_sect = sect_index;
11101110 atom.out_n_sect = sect_index;
11111111
src/link/MachO/dead_strip.zig+2-2
......@@ -102,8 +102,8 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
102102 const isec = atom.getInputSection(macho_file);
103103 if (isec.isDontDeadStripIfReferencesLive() and
104104 !(mem.eql(u8, isec.sectName(), "__eh_frame") or
105 mem.eql(u8, isec.sectName(), "__compact_unwind") or
106 isec.attrs() & macho.S_ATTR_DEBUG != 0) and
105 mem.eql(u8, isec.sectName(), "__compact_unwind") or
106 isec.attrs() & macho.S_ATTR_DEBUG != 0) and
107107 !atom.isAlive() and refersLive(atom, macho_file))
108108 {
109109 markLive(atom, macho_file);
src/main.zig+4-4
......@@ -5919,8 +5919,8 @@ pub const ClangArgIterator = struct {
59195919
59205920 self.arg_iterator_response_file =
59215921 initArgIteratorResponseFile(arena, resp_file_path) catch |err| {
5922 fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
5923 };
5922 fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
5923 };
59245924 // NOTE: The ArgIteratorResponseFile returns tokens from next() that are slices of an
59255925 // internal buffer. This internal buffer is arena allocated, so it is not cleaned up here.
59265926
......@@ -6233,8 +6233,8 @@ fn cmdAstCheck(
62336233 file.tree.?.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
62346234 const tree_bytes = @sizeOf(Ast) + file.tree.?.nodes.len *
62356235 (@sizeOf(Ast.Node.Tag) +
6236 @sizeOf(Ast.Node.Data) +
6237 @sizeOf(Ast.TokenIndex));
6236 @sizeOf(Ast.Node.Data) +
6237 @sizeOf(Ast.TokenIndex));
62386238 const instruction_bytes = file.zir.?.instructions.len *
62396239 // Here we don't use @sizeOf(Zir.Inst.Data) because it would include
62406240 // the debug safety tag but we want to measure release size.
src/translate_c.zig+14-15
......@@ -2570,9 +2570,9 @@ fn transInitListExprRecord(
25702570 // Unions and Structs are both represented as RecordDecl
25712571 const record_ty = ty.getAsRecordType() orelse
25722572 blk: {
2573 is_union_type = true;
2574 break :blk ty.getAsUnionType();
2575 } orelse unreachable;
2573 is_union_type = true;
2574 break :blk ty.getAsUnionType();
2575 } orelse unreachable;
25762576 const record_decl = record_ty.getDecl();
25772577 const record_def = record_decl.getDefinition() orelse
25782578 unreachable;
......@@ -4006,7 +4006,7 @@ fn transCPtrCast(
40064006 if (!src_ty.isArrayType() and ((src_child_type.isConstQualified() and
40074007 !child_type.isConstQualified()) or
40084008 (src_child_type.isVolatileQualified() and
4009 !child_type.isVolatileQualified())))
4009 !child_type.isVolatileQualified())))
40104010 {
40114011 return removeCVQualifiers(c, dst_type_node, expr);
40124012 } else {
......@@ -4092,8 +4092,8 @@ fn transFloatingLiteralQuad(c: *Context, expr: *const clang.FloatingLiteral, use
40924092 false;
40934093 break :fmt_decimal if (could_roundtrip) try c.arena.dupe(u8, temp_str) else null;
40944094 }
4095 // otherwise, fall back to the hexadecimal format
4096 orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
4095 // otherwise, fall back to the hexadecimal format
4096 orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
40974097
40984098 var node = try Tag.float_literal.create(c.arena, str);
40994099 if (is_negative) node = try Tag.negate.create(c.arena, node);
......@@ -5080,15 +5080,14 @@ fn finishTransFnProto(
50805080 const is_noalias = param_qt.isRestrictQualified();
50815081
50825082 const param_name: ?[]const u8 =
5083 if (fn_decl) |decl|
5084 blk: {
5085 const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
5086 const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
5087 if (param_name.len < 1)
5088 break :blk null;
5089
5090 break :blk param_name;
5091 } else null;
5083 if (fn_decl) |decl| blk: {
5084 const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
5085 const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
5086 if (param_name.len < 1)
5087 break :blk null;
5088
5089 break :blk param_name;
5090 } else null;
50925091 const type_node = try transQualType(c, scope, param_qt, source_loc);
50935092
50945093 fn_params.addOneAssumeCapacity().* = .{
test/behavior/export_builtin.zig+2-2
......@@ -59,8 +59,8 @@ test "exporting comptime-known value" {
5959 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
6060 if (builtin.zig_backend == .stage2_x86_64 and
6161 (builtin.target.ofmt != .elf and
62 builtin.target.ofmt != .macho and
63 builtin.target.ofmt != .coff)) return error.SkipZigTest;
62 builtin.target.ofmt != .macho and
63 builtin.target.ofmt != .coff)) return error.SkipZigTest;
6464 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
6565 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
6666 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
test/link/elf.zig+70-70
......@@ -475,7 +475,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
475475 const test_step = addTestStep(b, "comment-string", opts);
476476
477477 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
478 \\pub fn main() void {}
478 \\pub fn main() void {}
479479 });
480480
481481 const check = exe.checkObject();
......@@ -490,7 +490,7 @@ fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
490490 const test_step = addTestStep(b, "comment-string-static-lib", opts);
491491
492492 const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
493 \\export fn foo() void {}
493 \\export fn foo() void {}
494494 });
495495
496496 const check = lib.checkObject();
......@@ -861,23 +861,23 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
861861 const test_step = addTestStep(b, "emit-relocatable", opts);
862862
863863 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
864 \\const std = @import("std");
865 \\extern var bar: i32;
866 \\export fn foo() i32 {
867 \\ return bar;
868 \\}
869 \\export fn printFoo() void {
870 \\ std.debug.print("foo={d}\n", .{foo()});
871 \\}
864 \\const std = @import("std");
865 \\extern var bar: i32;
866 \\export fn foo() i32 {
867 \\ return bar;
868 \\}
869 \\export fn printFoo() void {
870 \\ std.debug.print("foo={d}\n", .{foo()});
871 \\}
872872 });
873873 a_o.linkLibC();
874874
875875 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
876 \\#include <stdio.h>
877 \\int bar = 42;
878 \\void printBar() {
879 \\ fprintf(stderr, "bar=%d\n", bar);
880 \\}
876 \\#include <stdio.h>
877 \\int bar = 42;
878 \\void printBar() {
879 \\ fprintf(stderr, "bar=%d\n", bar);
880 \\}
881881 });
882882 b_o.linkLibC();
883883
......@@ -886,13 +886,13 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
886886 c_o.addObject(b_o);
887887
888888 const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
889 \\const std = @import("std");
890 \\extern fn printFoo() void;
891 \\extern fn printBar() void;
892 \\pub fn main() void {
893 \\ printFoo();
894 \\ printBar();
895 \\}
889 \\const std = @import("std");
890 \\extern fn printFoo() void;
891 \\extern fn printBar() void;
892 \\pub fn main() void {
893 \\ printFoo();
894 \\ printBar();
895 \\}
896896 });
897897 exe.addObject(c_o);
898898 exe.linkLibC();
......@@ -1920,8 +1920,8 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
19201920 g_o.linkLibC();
19211921
19221922 const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
1923 \\#include <stdio.h>
1924 \\__attribute__((destructor)) void fini2() { printf("8"); }
1923 \\#include <stdio.h>
1924 \\__attribute__((destructor)) void fini2() { printf("8"); }
19251925 });
19261926 h_o.linkLibC();
19271927
......@@ -2495,23 +2495,23 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
24952495 const test_step = addTestStep(b, "merge-strings2", opts);
24962496
24972497 const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
2498 \\const std = @import("std");
2499 \\export fn foo() void {
2500 \\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
2501 \\ const slice = std.mem.sliceTo(&arr, 3);
2502 \\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
2503 \\}
2498 \\const std = @import("std");
2499 \\export fn foo() void {
2500 \\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
2501 \\ const slice = std.mem.sliceTo(&arr, 3);
2502 \\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
2503 \\}
25042504 });
25052505
25062506 const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
2507 \\const std = @import("std");
2508 \\extern fn foo() void;
2509 \\pub fn main() void {
2510 \\ foo();
2511 \\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
2512 \\ const slice = std.mem.sliceTo(&arr, 3);
2513 \\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
2514 \\}
2507 \\const std = @import("std");
2508 \\extern fn foo() void;
2509 \\pub fn main() void {
2510 \\ foo();
2511 \\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
2512 \\ const slice = std.mem.sliceTo(&arr, 3);
2513 \\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
2514 \\}
25152515 });
25162516
25172517 {
......@@ -2752,17 +2752,17 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
27522752 });
27532753 obj2.linkLibCpp();
27542754 const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
2755 \\#include <iostream>
2756 \\#include <stdexcept>
2757 \\extern int try_again();
2758 \\int main() {
2759 \\ try {
2760 \\ try_again();
2761 \\ } catch (const std::exception &e) {
2762 \\ std::cout << "exception=" << e.what();
2763 \\ }
2764 \\ return 0;
2765 \\}
2755 \\#include <iostream>
2756 \\#include <stdexcept>
2757 \\extern int try_again();
2758 \\int main() {
2759 \\ try {
2760 \\ try_again();
2761 \\ } catch (const std::exception &e) {
2762 \\ std::cout << "exception=" << e.what();
2763 \\ }
2764 \\ return 0;
2765 \\}
27662766 });
27672767 obj3.linkLibCpp();
27682768
......@@ -2864,15 +2864,15 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
28642864 const test_step = addTestStep(b, "relocatable-merge-strings", opts);
28652865
28662866 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2867 \\.section .rodata.str1.1,"aMS",@progbits,1
2868 \\val1:
2869 \\.ascii "Hello \0"
2870 \\.section .rodata.str1.1,"aMS",@progbits,1
2871 \\val5:
2872 \\.ascii "World \0"
2873 \\.section .rodata.str1.1,"aMS",@progbits,1
2874 \\val7:
2875 \\.ascii "Hello \0"
2867 \\.section .rodata.str1.1,"aMS",@progbits,1
2868 \\val1:
2869 \\.ascii "Hello \0"
2870 \\.section .rodata.str1.1,"aMS",@progbits,1
2871 \\val5:
2872 \\.ascii "World \0"
2873 \\.section .rodata.str1.1,"aMS",@progbits,1
2874 \\val7:
2875 \\.ascii "Hello \0"
28762876 });
28772877
28782878 const obj2 = addObject(b, opts, .{ .name = "b" });
......@@ -3030,18 +3030,18 @@ fn testThunks(b: *Build, opts: Options) *Step {
30303030 const test_step = addTestStep(b, "thunks", opts);
30313031
30323032 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3033 \\void foo();
3034 \\__attribute__((section(".bar"))) void bar() {
3035 \\ return foo();
3036 \\}
3037 \\__attribute__((section(".foo"))) void foo() {
3038 \\ return bar();
3039 \\}
3040 \\int main() {
3041 \\ foo();
3042 \\ bar();
3043 \\ return 0;
3044 \\}
3033 \\void foo();
3034 \\__attribute__((section(".bar"))) void bar() {
3035 \\ return foo();
3036 \\}
3037 \\__attribute__((section(".foo"))) void foo() {
3038 \\ return bar();
3039 \\}
3040 \\int main() {
3041 \\ foo();
3042 \\ bar();
3043 \\ return 0;
3044 \\}
30453045 });
30463046
30473047 const check = exe.checkObject();
test/link/macho.zig+816-816
......@@ -109,20 +109,20 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
109109 const test_step = addTestStep(b, "dead-strip", opts);
110110
111111 const obj = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
112 \\#include <stdio.h>
113 \\int two() { return 2; }
114 \\int live_var1 = 1;
115 \\int live_var2 = two();
116 \\int dead_var1 = 3;
117 \\int dead_var2 = 4;
118 \\void live_fn1() {}
119 \\void live_fn2() { live_fn1(); }
120 \\void dead_fn1() {}
121 \\void dead_fn2() { dead_fn1(); }
122 \\int main() {
123 \\ printf("%d %d\n", live_var1, live_var2);
124 \\ live_fn2();
125 \\}
112 \\#include <stdio.h>
113 \\int two() { return 2; }
114 \\int live_var1 = 1;
115 \\int live_var2 = two();
116 \\int dead_var1 = 3;
117 \\int dead_var2 = 4;
118 \\void live_fn1() {}
119 \\void live_fn2() { live_fn1(); }
120 \\void dead_fn1() {}
121 \\void dead_fn2() { dead_fn1(); }
122 \\int main() {
123 \\ printf("%d %d\n", live_var1, live_var2);
124 \\ live_fn2();
125 \\}
126126 });
127127
128128 {
......@@ -190,21 +190,21 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
190190 const test_step = addTestStep(b, "duplicate-definitions", opts);
191191
192192 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
193 \\var x: usize = 1;
194 \\export fn strong() void { x += 1; }
195 \\export fn weak() void { x += 1; }
193 \\var x: usize = 1;
194 \\export fn strong() void { x += 1; }
195 \\export fn weak() void { x += 1; }
196196 });
197197
198198 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
199 \\var x: usize = 1;
200 \\export fn strong() void { x += 1; }
201 \\comptime { @export(&weakImpl, .{ .name = "weak", .linkage = .weak }); }
202 \\fn weakImpl() callconv(.C) void { x += 1; }
203 \\extern fn weak() void;
204 \\pub fn main() void {
205 \\ weak();
206 \\ strong();
207 \\}
199 \\var x: usize = 1;
200 \\export fn strong() void { x += 1; }
201 \\comptime { @export(&weakImpl, .{ .name = "weak", .linkage = .weak }); }
202 \\fn weakImpl() callconv(.C) void { x += 1; }
203 \\extern fn weak() void;
204 \\pub fn main() void {
205 \\ weak();
206 \\ strong();
207 \\}
208208 });
209209 exe.addObject(obj);
210210
......@@ -221,16 +221,16 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
221221 const test_step = addTestStep(b, "dead-strip-dylibs", opts);
222222
223223 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
224 \\#include <objc/runtime.h>
225 \\int main() {
226 \\ if (objc_getClass("NSObject") == 0) {
227 \\ return -1;
228 \\ }
229 \\ if (objc_getClass("NSApplication") == 0) {
230 \\ return -2;
231 \\ }
232 \\ return 0;
233 \\}
224 \\#include <objc/runtime.h>
225 \\int main() {
226 \\ if (objc_getClass("NSObject") == 0) {
227 \\ return -1;
228 \\ }
229 \\ if (objc_getClass("NSApplication") == 0) {
230 \\ return -2;
231 \\ }
232 \\ return 0;
233 \\}
234234 });
235235
236236 {
......@@ -270,11 +270,11 @@ fn testDylib(b: *Build, opts: Options) *Step {
270270 const test_step = addTestStep(b, "dylib", opts);
271271
272272 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
273 \\#include<stdio.h>
274 \\char world[] = "world";
275 \\char* hello() {
276 \\ return "Hello";
277 \\}
273 \\#include<stdio.h>
274 \\char world[] = "world";
275 \\char* hello() {
276 \\ return "Hello";
277 \\}
278278 });
279279
280280 const check = dylib.checkObject();
......@@ -284,13 +284,13 @@ fn testDylib(b: *Build, opts: Options) *Step {
284284 test_step.dependOn(&check.step);
285285
286286 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
287 \\#include<stdio.h>
288 \\char* hello();
289 \\extern char world[];
290 \\int main() {
291 \\ printf("%s %s", hello(), world);
292 \\ return 0;
293 \\}
287 \\#include<stdio.h>
288 \\char* hello();
289 \\extern char world[];
290 \\int main() {
291 \\ printf("%s %s", hello(), world);
292 \\ return 0;
293 \\}
294294 });
295295 exe.root_module.linkSystemLibrary("a", .{});
296296 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
......@@ -345,10 +345,10 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
345345 const empty = addObject(b, opts, .{ .name = "empty", .c_source_bytes = "" });
346346
347347 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
348 \\#include <stdio.h>
349 \\int main() {
350 \\ printf("Hello world!");
351 \\}
348 \\#include <stdio.h>
349 \\int main() {
350 \\ printf("Hello world!");
351 \\}
352352 });
353353 exe.addObject(empty);
354354
......@@ -375,11 +375,11 @@ fn testEntryPoint(b: *Build, opts: Options) *Step {
375375 const test_step = addTestStep(b, "entry-point", opts);
376376
377377 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
378 \\#include<stdio.h>
379 \\int non_main() {
380 \\ printf("%d", 42);
381 \\ return 0;
382 \\}
378 \\#include<stdio.h>
379 \\int non_main() {
380 \\ printf("%d", 42);
381 \\ return 0;
382 \\}
383383 });
384384 exe.entry = .{ .symbol_name = "_non_main" };
385385
......@@ -597,10 +597,10 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
597597 const test_step = addTestStep(b, "header-weak-flags", opts);
598598
599599 const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
600 \\.globl _x
601 \\.weak_definition _x
602 \\_x:
603 \\ ret
600 \\.globl _x
601 \\.weak_definition _x
602 \\_x:
603 \\ ret
604604 });
605605
606606 const lib = addSharedLibrary(b, opts, .{ .name = "a" });
......@@ -659,11 +659,11 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
659659
660660 {
661661 const exe = addExecutable(b, opts, .{ .name = "main3", .asm_source_bytes =
662 \\.globl _main, _x
663 \\_x:
664 \\
665 \\_main:
666 \\ ret
662 \\.globl _main, _x
663 \\_x:
664 \\
665 \\_main:
666 \\ ret
667667 });
668668 exe.linkLibrary(lib);
669669
......@@ -684,11 +684,11 @@ fn testHelloC(b: *Build, opts: Options) *Step {
684684 const test_step = addTestStep(b, "hello-c", opts);
685685
686686 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
687 \\#include <stdio.h>
688 \\int main() {
689 \\ printf("Hello world!\n");
690 \\ return 0;
691 \\}
687 \\#include <stdio.h>
688 \\int main() {
689 \\ printf("Hello world!\n");
690 \\ return 0;
691 \\}
692692 });
693693
694694 const run = addRunArtifact(exe);
......@@ -708,10 +708,10 @@ fn testHelloZig(b: *Build, opts: Options) *Step {
708708 const test_step = addTestStep(b, "hello-zig", opts);
709709
710710 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
711 \\const std = @import("std");
712 \\pub fn main() void {
713 \\ std.io.getStdOut().writer().print("Hello world!\n", .{}) catch unreachable;
714 \\}
711 \\const std = @import("std");
712 \\pub fn main() void {
713 \\ std.io.getStdOut().writer().print("Hello world!\n", .{}) catch unreachable;
714 \\}
715715 });
716716
717717 const run = addRunArtifact(exe);
......@@ -729,10 +729,10 @@ fn testLargeBss(b: *Build, opts: Options) *Step {
729729 // maybe S_GB_ZEROFILL section is an answer to this but it doesn't seem supported by dyld
730730 // anymore. When I get some free time I will re-investigate this.
731731 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
732 \\char arr[0x1000000];
733 \\int main() {
734 \\ return arr[2000];
735 \\}
732 \\char arr[0x1000000];
733 \\int main() {
734 \\ return arr[2000];
735 \\}
736736 });
737737
738738 const run = addRunArtifact(exe);
......@@ -746,11 +746,11 @@ fn testLayout(b: *Build, opts: Options) *Step {
746746 const test_step = addTestStep(b, "layout", opts);
747747
748748 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
749 \\#include <stdio.h>
750 \\int main() {
751 \\ printf("Hello world!");
752 \\ return 0;
753 \\}
749 \\#include <stdio.h>
750 \\int main() {
751 \\ printf("Hello world!");
752 \\ return 0;
753 \\}
754754 });
755755
756756 const check = exe.checkObject();
......@@ -936,15 +936,15 @@ fn testLinksection(b: *Build, opts: Options) *Step {
936936 const test_step = addTestStep(b, "linksection", opts);
937937
938938 const obj = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
939 \\export var test_global: u32 linksection("__DATA,__TestGlobal") = undefined;
940 \\export fn testFn() linksection("__TEXT,__TestFn") callconv(.C) void {
941 \\ TestGenericFn("A").f();
942 \\}
943 \\fn TestGenericFn(comptime suffix: []const u8) type {
944 \\ return struct {
945 \\ fn f() linksection("__TEXT,__TestGenFn" ++ suffix) void {}
946 \\ };
947 \\}
939 \\export var test_global: u32 linksection("__DATA,__TestGlobal") = undefined;
940 \\export fn testFn() linksection("__TEXT,__TestFn") callconv(.C) void {
941 \\ TestGenericFn("A").f();
942 \\}
943 \\fn TestGenericFn(comptime suffix: []const u8) type {
944 \\ return struct {
945 \\ fn f() linksection("__TEXT,__TestGenFn" ++ suffix) void {}
946 \\ };
947 \\}
948948 });
949949
950950 const check = obj.checkObject();
......@@ -967,71 +967,71 @@ fn testMergeLiteralsX64(b: *Build, opts: Options) *Step {
967967 const test_step = addTestStep(b, "merge-literals-x64", opts);
968968
969969 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
970 \\.globl _q1
971 \\.globl _s1
972 \\
973 \\.align 4
974 \\_q1:
975 \\ lea L._q1(%rip), %rax
976 \\ mov (%rax), %xmm0
977 \\ ret
978 \\
979 \\.section __TEXT,__cstring,cstring_literals
980 \\l._s1:
981 \\ .asciz "hello"
982 \\
983 \\.section __TEXT,__literal8,8byte_literals
984 \\.align 8
985 \\L._q1:
986 \\ .double 1.2345
987 \\
988 \\.section __DATA,__data
989 \\.align 8
990 \\_s1:
991 \\ .quad l._s1
970 \\.globl _q1
971 \\.globl _s1
972 \\
973 \\.align 4
974 \\_q1:
975 \\ lea L._q1(%rip), %rax
976 \\ mov (%rax), %xmm0
977 \\ ret
978 \\
979 \\.section __TEXT,__cstring,cstring_literals
980 \\l._s1:
981 \\ .asciz "hello"
982 \\
983 \\.section __TEXT,__literal8,8byte_literals
984 \\.align 8
985 \\L._q1:
986 \\ .double 1.2345
987 \\
988 \\.section __DATA,__data
989 \\.align 8
990 \\_s1:
991 \\ .quad l._s1
992992 });
993993
994994 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
995 \\.globl _q2
996 \\.globl _s2
997 \\.globl _s3
998 \\
999 \\.align 4
1000 \\_q2:
1001 \\ lea L._q2(%rip), %rax
1002 \\ mov (%rax), %xmm0
1003 \\ ret
1004 \\
1005 \\.section __TEXT,__cstring,cstring_literals
1006 \\l._s2:
1007 \\ .asciz "hello"
1008 \\l._s3:
1009 \\ .asciz "world"
1010 \\
1011 \\.section __TEXT,__literal8,8byte_literals
1012 \\.align 8
1013 \\L._q2:
1014 \\ .double 1.2345
1015 \\
1016 \\.section __DATA,__data
1017 \\.align 8
1018 \\_s2:
1019 \\ .quad l._s2
1020 \\_s3:
1021 \\ .quad l._s3
995 \\.globl _q2
996 \\.globl _s2
997 \\.globl _s3
998 \\
999 \\.align 4
1000 \\_q2:
1001 \\ lea L._q2(%rip), %rax
1002 \\ mov (%rax), %xmm0
1003 \\ ret
1004 \\
1005 \\.section __TEXT,__cstring,cstring_literals
1006 \\l._s2:
1007 \\ .asciz "hello"
1008 \\l._s3:
1009 \\ .asciz "world"
1010 \\
1011 \\.section __TEXT,__literal8,8byte_literals
1012 \\.align 8
1013 \\L._q2:
1014 \\ .double 1.2345
1015 \\
1016 \\.section __DATA,__data
1017 \\.align 8
1018 \\_s2:
1019 \\ .quad l._s2
1020 \\_s3:
1021 \\ .quad l._s3
10221022 });
10231023
10241024 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1025 \\#include <stdio.h>
1026 \\extern double q1();
1027 \\extern double q2();
1028 \\extern const char* s1;
1029 \\extern const char* s2;
1030 \\extern const char* s3;
1031 \\int main() {
1032 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1033 \\ return 0;
1034 \\}
1025 \\#include <stdio.h>
1026 \\extern double q1();
1027 \\extern double q2();
1028 \\extern const char* s1;
1029 \\extern const char* s2;
1030 \\extern const char* s3;
1031 \\int main() {
1032 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1033 \\ return 0;
1034 \\}
10351035 });
10361036
10371037 const runWithChecks = struct {
......@@ -1083,71 +1083,71 @@ fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
10831083 const test_step = addTestStep(b, "merge-literals-arm64", opts);
10841084
10851085 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1086 \\.globl _q1
1087 \\.globl _s1
1088 \\
1089 \\.align 4
1090 \\_q1:
1091 \\ adrp x8, L._q1@PAGE
1092 \\ ldr d0, [x8, L._q1@PAGEOFF]
1093 \\ ret
1094 \\
1095 \\.section __TEXT,__cstring,cstring_literals
1096 \\l._s1:
1097 \\ .asciz "hello"
1098 \\
1099 \\.section __TEXT,__literal8,8byte_literals
1100 \\.align 8
1101 \\L._q1:
1102 \\ .double 1.2345
1103 \\
1104 \\.section __DATA,__data
1105 \\.align 8
1106 \\_s1:
1107 \\ .quad l._s1
1086 \\.globl _q1
1087 \\.globl _s1
1088 \\
1089 \\.align 4
1090 \\_q1:
1091 \\ adrp x8, L._q1@PAGE
1092 \\ ldr d0, [x8, L._q1@PAGEOFF]
1093 \\ ret
1094 \\
1095 \\.section __TEXT,__cstring,cstring_literals
1096 \\l._s1:
1097 \\ .asciz "hello"
1098 \\
1099 \\.section __TEXT,__literal8,8byte_literals
1100 \\.align 8
1101 \\L._q1:
1102 \\ .double 1.2345
1103 \\
1104 \\.section __DATA,__data
1105 \\.align 8
1106 \\_s1:
1107 \\ .quad l._s1
11081108 });
11091109
11101110 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1111 \\.globl _q2
1112 \\.globl _s2
1113 \\.globl _s3
1114 \\
1115 \\.align 4
1116 \\_q2:
1117 \\ adrp x8, L._q2@PAGE
1118 \\ ldr d0, [x8, L._q2@PAGEOFF]
1119 \\ ret
1120 \\
1121 \\.section __TEXT,__cstring,cstring_literals
1122 \\l._s2:
1123 \\ .asciz "hello"
1124 \\l._s3:
1125 \\ .asciz "world"
1126 \\
1127 \\.section __TEXT,__literal8,8byte_literals
1128 \\.align 8
1129 \\L._q2:
1130 \\ .double 1.2345
1131 \\
1132 \\.section __DATA,__data
1133 \\.align 8
1134 \\_s2:
1135 \\ .quad l._s2
1136 \\_s3:
1137 \\ .quad l._s3
1111 \\.globl _q2
1112 \\.globl _s2
1113 \\.globl _s3
1114 \\
1115 \\.align 4
1116 \\_q2:
1117 \\ adrp x8, L._q2@PAGE
1118 \\ ldr d0, [x8, L._q2@PAGEOFF]
1119 \\ ret
1120 \\
1121 \\.section __TEXT,__cstring,cstring_literals
1122 \\l._s2:
1123 \\ .asciz "hello"
1124 \\l._s3:
1125 \\ .asciz "world"
1126 \\
1127 \\.section __TEXT,__literal8,8byte_literals
1128 \\.align 8
1129 \\L._q2:
1130 \\ .double 1.2345
1131 \\
1132 \\.section __DATA,__data
1133 \\.align 8
1134 \\_s2:
1135 \\ .quad l._s2
1136 \\_s3:
1137 \\ .quad l._s3
11381138 });
11391139
11401140 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1141 \\#include <stdio.h>
1142 \\extern double q1();
1143 \\extern double q2();
1144 \\extern const char* s1;
1145 \\extern const char* s2;
1146 \\extern const char* s3;
1147 \\int main() {
1148 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1149 \\ return 0;
1150 \\}
1141 \\#include <stdio.h>
1142 \\extern double q1();
1143 \\extern double q2();
1144 \\extern const char* s1;
1145 \\extern const char* s2;
1146 \\extern const char* s3;
1147 \\int main() {
1148 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1149 \\ return 0;
1150 \\}
11511151 });
11521152
11531153 const runWithChecks = struct {
......@@ -1203,59 +1203,59 @@ fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
12031203 const test_step = addTestStep(b, "merge-literals-arm64-2", opts);
12041204
12051205 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1206 \\.globl _q1
1207 \\.globl _s1
1208 \\
1209 \\.align 4
1210 \\_q1:
1211 \\ adrp x0, L._q1@PAGE
1212 \\ ldr x0, [x0, L._q1@PAGEOFF]
1213 \\ ret
1214 \\
1215 \\.section __TEXT,__cstring,cstring_literals
1216 \\_s1:
1217 \\ .asciz "hello"
1218 \\
1219 \\.section __TEXT,__literal8,8byte_literals
1220 \\.align 8
1221 \\L._q1:
1222 \\ .double 1.2345
1206 \\.globl _q1
1207 \\.globl _s1
1208 \\
1209 \\.align 4
1210 \\_q1:
1211 \\ adrp x0, L._q1@PAGE
1212 \\ ldr x0, [x0, L._q1@PAGEOFF]
1213 \\ ret
1214 \\
1215 \\.section __TEXT,__cstring,cstring_literals
1216 \\_s1:
1217 \\ .asciz "hello"
1218 \\
1219 \\.section __TEXT,__literal8,8byte_literals
1220 \\.align 8
1221 \\L._q1:
1222 \\ .double 1.2345
12231223 });
12241224
12251225 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1226 \\.globl _q2
1227 \\.globl _s2
1228 \\.globl _s3
1229 \\
1230 \\.align 4
1231 \\_q2:
1232 \\ adrp x0, L._q2@PAGE
1233 \\ ldr x0, [x0, L._q2@PAGEOFF]
1234 \\ ret
1235 \\
1236 \\.section __TEXT,__cstring,cstring_literals
1237 \\_s2:
1238 \\ .asciz "hello"
1239 \\_s3:
1240 \\ .asciz "world"
1241 \\
1242 \\.section __TEXT,__literal8,8byte_literals
1243 \\.align 8
1244 \\L._q2:
1245 \\ .double 1.2345
1226 \\.globl _q2
1227 \\.globl _s2
1228 \\.globl _s3
1229 \\
1230 \\.align 4
1231 \\_q2:
1232 \\ adrp x0, L._q2@PAGE
1233 \\ ldr x0, [x0, L._q2@PAGEOFF]
1234 \\ ret
1235 \\
1236 \\.section __TEXT,__cstring,cstring_literals
1237 \\_s2:
1238 \\ .asciz "hello"
1239 \\_s3:
1240 \\ .asciz "world"
1241 \\
1242 \\.section __TEXT,__literal8,8byte_literals
1243 \\.align 8
1244 \\L._q2:
1245 \\ .double 1.2345
12461246 });
12471247
12481248 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1249 \\#include <stdio.h>
1250 \\extern double q1();
1251 \\extern double q2();
1252 \\extern const char* s1;
1253 \\extern const char* s2;
1254 \\extern const char* s3;
1255 \\int main() {
1256 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1257 \\ return 0;
1258 \\}
1249 \\#include <stdio.h>
1250 \\extern double q1();
1251 \\extern double q2();
1252 \\extern const char* s1;
1253 \\extern const char* s2;
1254 \\extern const char* s3;
1255 \\int main() {
1256 \\ printf("%s, %s, %s, %f, %f", s1, s2, s3, q1(), q2());
1257 \\ return 0;
1258 \\}
12591259 });
12601260
12611261 const exe = addExecutable(b, opts, .{ .name = "main1" });
......@@ -1277,43 +1277,43 @@ fn testMergeLiteralsAlignment(b: *Build, opts: Options) *Step {
12771277 const test_step = addTestStep(b, "merge-literals-alignment", opts);
12781278
12791279 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
1280 \\.globl _s1
1281 \\.globl _s2
1282 \\
1283 \\.section __TEXT,__cstring,cstring_literals
1284 \\.align 3
1285 \\_s1:
1286 \\ .asciz "str1"
1287 \\_s2:
1288 \\ .asciz "str2"
1280 \\.globl _s1
1281 \\.globl _s2
1282 \\
1283 \\.section __TEXT,__cstring,cstring_literals
1284 \\.align 3
1285 \\_s1:
1286 \\ .asciz "str1"
1287 \\_s2:
1288 \\ .asciz "str2"
12891289 });
12901290
12911291 const b_o = addObject(b, opts, .{ .name = "b", .asm_source_bytes =
1292 \\.globl _s3
1293 \\.globl _s4
1294 \\
1295 \\.section __TEXT,__cstring,cstring_literals
1296 \\.align 2
1297 \\_s3:
1298 \\ .asciz "str1"
1299 \\_s4:
1300 \\ .asciz "str2"
1292 \\.globl _s3
1293 \\.globl _s4
1294 \\
1295 \\.section __TEXT,__cstring,cstring_literals
1296 \\.align 2
1297 \\_s3:
1298 \\ .asciz "str1"
1299 \\_s4:
1300 \\ .asciz "str2"
13011301 });
13021302
13031303 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1304 \\#include <assert.h>
1305 \\#include <stdint.h>
1306 \\#include <stdio.h>
1307 \\extern const char* s1;
1308 \\extern const char* s2;
1309 \\extern const char* s3;
1310 \\extern const char* s4;
1311 \\int main() {
1312 \\ assert((uintptr_t)(&s1) % 8 == 0 && s1 == s3);
1313 \\ assert((uintptr_t)(&s2) % 8 == 0 && s2 == s4);
1314 \\ printf("%s%s%s%s", &s1, &s2, &s3, &s4);
1315 \\ return 0;
1316 \\}
1304 \\#include <assert.h>
1305 \\#include <stdint.h>
1306 \\#include <stdio.h>
1307 \\extern const char* s1;
1308 \\extern const char* s2;
1309 \\extern const char* s3;
1310 \\extern const char* s4;
1311 \\int main() {
1312 \\ assert((uintptr_t)(&s1) % 8 == 0 && s1 == s3);
1313 \\ assert((uintptr_t)(&s2) % 8 == 0 && s2 == s4);
1314 \\ printf("%s%s%s%s", &s1, &s2, &s3, &s4);
1315 \\ return 0;
1316 \\}
13171317 , .c_source_flags = &.{"-Wno-format"} });
13181318
13191319 const runWithChecks = struct {
......@@ -1356,39 +1356,39 @@ fn testMergeLiteralsObjc(b: *Build, opts: Options) *Step {
13561356 const test_step = addTestStep(b, "merge-literals-objc", opts);
13571357
13581358 const main_o = addObject(b, opts, .{ .name = "main", .objc_source_bytes =
1359 \\#import <Foundation/Foundation.h>;
1360 \\
1361 \\extern void foo();
1362 \\
1363 \\int main() {
1364 \\ NSString *thing = @"aaa";
1365 \\
1366 \\ SEL sel = @selector(lowercaseString);
1367 \\ NSString *lower = (([thing respondsToSelector:sel]) ? @"YES" : @"NO");
1368 \\ NSLog (@"Responds to lowercaseString: %@", lower);
1369 \\ if ([thing respondsToSelector:sel]) //(lower == @"YES")
1370 \\ NSLog(@"lowercaseString is: %@", [thing lowercaseString]);
1371 \\
1372 \\ foo();
1373 \\}
1359 \\#import <Foundation/Foundation.h>;
1360 \\
1361 \\extern void foo();
1362 \\
1363 \\int main() {
1364 \\ NSString *thing = @"aaa";
1365 \\
1366 \\ SEL sel = @selector(lowercaseString);
1367 \\ NSString *lower = (([thing respondsToSelector:sel]) ? @"YES" : @"NO");
1368 \\ NSLog (@"Responds to lowercaseString: %@", lower);
1369 \\ if ([thing respondsToSelector:sel]) //(lower == @"YES")
1370 \\ NSLog(@"lowercaseString is: %@", [thing lowercaseString]);
1371 \\
1372 \\ foo();
1373 \\}
13741374 });
13751375
13761376 const a_o = addObject(b, opts, .{ .name = "a", .objc_source_bytes =
1377 \\#import <Foundation/Foundation.h>;
1378 \\
1379 \\void foo() {
1380 \\ NSString *thing = @"aaa";
1381 \\ SEL sel = @selector(lowercaseString);
1382 \\ NSString *lower = (([thing respondsToSelector:sel]) ? @"YES" : @"NO");
1383 \\ NSLog (@"Responds to lowercaseString in foo(): %@", lower);
1384 \\ if ([thing respondsToSelector:sel]) //(lower == @"YES")
1385 \\ NSLog(@"lowercaseString in foo() is: %@", [thing lowercaseString]);
1386 \\ SEL sel2 = @selector(uppercaseString);
1387 \\ NSString *upper = (([thing respondsToSelector:sel2]) ? @"YES" : @"NO");
1388 \\ NSLog (@"Responds to uppercaseString in foo(): %@", upper);
1389 \\ if ([thing respondsToSelector:sel2]) //(upper == @"YES")
1390 \\ NSLog(@"uppercaseString in foo() is: %@", [thing uppercaseString]);
1391 \\}
1377 \\#import <Foundation/Foundation.h>;
1378 \\
1379 \\void foo() {
1380 \\ NSString *thing = @"aaa";
1381 \\ SEL sel = @selector(lowercaseString);
1382 \\ NSString *lower = (([thing respondsToSelector:sel]) ? @"YES" : @"NO");
1383 \\ NSLog (@"Responds to lowercaseString in foo(): %@", lower);
1384 \\ if ([thing respondsToSelector:sel]) //(lower == @"YES")
1385 \\ NSLog(@"lowercaseString in foo() is: %@", [thing lowercaseString]);
1386 \\ SEL sel2 = @selector(uppercaseString);
1387 \\ NSString *upper = (([thing respondsToSelector:sel2]) ? @"YES" : @"NO");
1388 \\ NSLog (@"Responds to uppercaseString in foo(): %@", upper);
1389 \\ if ([thing respondsToSelector:sel2]) //(upper == @"YES")
1390 \\ NSLog(@"uppercaseString in foo() is: %@", [thing uppercaseString]);
1391 \\}
13921392 });
13931393
13941394 const runWithChecks = struct {
......@@ -1459,12 +1459,12 @@ fn testNoDeadStrip(b: *Build, opts: Options) *Step {
14591459 const test_step = addTestStep(b, "no-dead-strip", opts);
14601460
14611461 const exe = addExecutable(b, opts, .{ .name = "name", .c_source_bytes =
1462 \\__attribute__((used)) int bogus1 = 0;
1463 \\int bogus2 = 0;
1464 \\int foo = 42;
1465 \\int main() {
1466 \\ return foo - 42;
1467 \\}
1462 \\__attribute__((used)) int bogus1 = 0;
1463 \\int bogus2 = 0;
1464 \\int foo = 42;
1465 \\int main() {
1466 \\ return foo - 42;
1467 \\}
14681468 });
14691469 exe.link_gc_sections = true;
14701470
......@@ -1543,11 +1543,11 @@ fn testObjc(b: *Build, opts: Options) *Step {
15431543 const test_step = addTestStep(b, "objc", opts);
15441544
15451545 const lib = addStaticLibrary(b, opts, .{ .name = "a", .objc_source_bytes =
1546 \\#import <Foundation/Foundation.h>
1547 \\@interface Foo : NSObject
1548 \\@end
1549 \\@implementation Foo
1550 \\@end
1546 \\#import <Foundation/Foundation.h>
1547 \\@interface Foo : NSObject
1548 \\@end
1549 \\@implementation Foo
1550 \\@end
15511551 });
15521552
15531553 {
......@@ -1600,32 +1600,32 @@ fn testObjcpp(b: *Build, opts: Options) *Step {
16001600 };
16011601
16021602 const foo_o = addObject(b, opts, .{ .name = "foo", .objcpp_source_bytes =
1603 \\#import "Foo.h"
1604 \\@implementation Foo
1605 \\- (NSString *)name
1606 \\{
1607 \\ NSString *str = [[NSString alloc] initWithFormat:@"Zig"];
1608 \\ return str;
1609 \\}
1610 \\@end
1603 \\#import "Foo.h"
1604 \\@implementation Foo
1605 \\- (NSString *)name
1606 \\{
1607 \\ NSString *str = [[NSString alloc] initWithFormat:@"Zig"];
1608 \\ return str;
1609 \\}
1610 \\@end
16111611 });
16121612 foo_o.root_module.addIncludePath(foo_h.dirname());
16131613 foo_o.linkLibCpp();
16141614
16151615 const exe = addExecutable(b, opts, .{ .name = "main", .objcpp_source_bytes =
1616 \\#import "Foo.h"
1617 \\#import <assert.h>
1618 \\#include <iostream>
1619 \\int main(int argc, char *argv[])
1620 \\{
1621 \\ @autoreleasepool {
1622 \\ Foo *foo = [[Foo alloc] init];
1623 \\ NSString *result = [foo name];
1624 \\ std::cout << "Hello from C++ and " << [result UTF8String];
1625 \\ assert([result isEqualToString:@"Zig"]);
1626 \\ return 0;
1627 \\ }
1628 \\}
1616 \\#import "Foo.h"
1617 \\#import <assert.h>
1618 \\#include <iostream>
1619 \\int main(int argc, char *argv[])
1620 \\{
1621 \\ @autoreleasepool {
1622 \\ Foo *foo = [[Foo alloc] init];
1623 \\ NSString *result = [foo name];
1624 \\ std::cout << "Hello from C++ and " << [result UTF8String];
1625 \\ assert([result isEqualToString:@"Zig"]);
1626 \\ return 0;
1627 \\ }
1628 \\}
16291629 });
16301630 exe.root_module.addIncludePath(foo_h.dirname());
16311631 exe.addObject(foo_o);
......@@ -1677,21 +1677,21 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
16771677 const test_step = addTestStep(b, "reexports-zig", opts);
16781678
16791679 const lib = addStaticLibrary(b, opts, .{ .name = "a", .zig_source_bytes =
1680 \\const x: i32 = 42;
1681 \\export fn foo() i32 {
1682 \\ return x;
1683 \\}
1684 \\comptime {
1685 \\ @export(&foo, .{ .name = "bar", .linkage = .strong });
1686 \\}
1680 \\const x: i32 = 42;
1681 \\export fn foo() i32 {
1682 \\ return x;
1683 \\}
1684 \\comptime {
1685 \\ @export(&foo, .{ .name = "bar", .linkage = .strong });
1686 \\}
16871687 });
16881688
16891689 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
1690 \\extern int foo();
1691 \\extern int bar();
1692 \\int main() {
1693 \\ return bar() - foo();
1694 \\}
1690 \\extern int foo();
1691 \\extern int bar();
1692 \\int main() {
1693 \\ return bar() - foo();
1694 \\}
16951695 });
16961696 exe.linkLibrary(lib);
16971697
......@@ -1706,32 +1706,32 @@ fn testRelocatable(b: *Build, opts: Options) *Step {
17061706 const test_step = addTestStep(b, "relocatable", opts);
17071707
17081708 const a_o = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
1709 \\#include <stdexcept>
1710 \\int try_me() {
1711 \\ throw std::runtime_error("Oh no!");
1712 \\}
1709 \\#include <stdexcept>
1710 \\int try_me() {
1711 \\ throw std::runtime_error("Oh no!");
1712 \\}
17131713 });
17141714 a_o.linkLibCpp();
17151715
17161716 const b_o = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
1717 \\extern int try_me();
1718 \\int try_again() {
1719 \\ return try_me();
1720 \\}
1717 \\extern int try_me();
1718 \\int try_again() {
1719 \\ return try_me();
1720 \\}
17211721 });
17221722
17231723 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
1724 \\#include <iostream>
1725 \\#include <stdexcept>
1726 \\extern int try_again();
1727 \\int main() {
1728 \\ try {
1729 \\ try_again();
1730 \\ } catch (const std::exception &e) {
1731 \\ std::cout << "exception=" << e.what();
1732 \\ }
1733 \\ return 0;
1734 \\}
1724 \\#include <iostream>
1725 \\#include <stdexcept>
1726 \\extern int try_again();
1727 \\int main() {
1728 \\ try {
1729 \\ try_again();
1730 \\ } catch (const std::exception &e) {
1731 \\ std::cout << "exception=" << e.what();
1732 \\ }
1733 \\ return 0;
1734 \\}
17351735 });
17361736 main_o.linkLibCpp();
17371737
......@@ -1774,34 +1774,34 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
17741774 const test_step = addTestStep(b, "relocatable-zig", opts);
17751775
17761776 const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
1777 \\const std = @import("std");
1778 \\export var foo: i32 = 0;
1779 \\export fn incrFoo() void {
1780 \\ foo += 1;
1781 \\ std.debug.print("incrFoo={d}\n", .{foo});
1782 \\}
1777 \\const std = @import("std");
1778 \\export var foo: i32 = 0;
1779 \\export fn incrFoo() void {
1780 \\ foo += 1;
1781 \\ std.debug.print("incrFoo={d}\n", .{foo});
1782 \\}
17831783 });
17841784
17851785 const b_o = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
1786 \\const std = @import("std");
1787 \\extern var foo: i32;
1788 \\export fn decrFoo() void {
1789 \\ foo -= 1;
1790 \\ std.debug.print("decrFoo={d}\n", .{foo});
1791 \\}
1786 \\const std = @import("std");
1787 \\extern var foo: i32;
1788 \\export fn decrFoo() void {
1789 \\ foo -= 1;
1790 \\ std.debug.print("decrFoo={d}\n", .{foo});
1791 \\}
17921792 });
17931793
17941794 const main_o = addObject(b, opts, .{ .name = "main", .zig_source_bytes =
1795 \\const std = @import("std");
1796 \\extern var foo: i32;
1797 \\extern fn incrFoo() void;
1798 \\extern fn decrFoo() void;
1799 \\pub fn main() void {
1800 \\ const init = foo;
1801 \\ incrFoo();
1802 \\ decrFoo();
1803 \\ if (init == foo) @panic("Oh no!");
1804 \\}
1795 \\const std = @import("std");
1796 \\extern var foo: i32;
1797 \\extern fn incrFoo() void;
1798 \\extern fn decrFoo() void;
1799 \\pub fn main() void {
1800 \\ const init = foo;
1801 \\ incrFoo();
1802 \\ decrFoo();
1803 \\ if (init == foo) @panic("Oh no!");
1804 \\}
18051805 });
18061806
18071807 const c_o = addObject(b, opts, .{ .name = "c" });
......@@ -1825,11 +1825,11 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18251825 const test_step = addTestStep(b, "search-strategy", opts);
18261826
18271827 const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes =
1828 \\#include<stdio.h>
1829 \\char world[] = "world";
1830 \\char* hello() {
1831 \\ return "Hello";
1832 \\}
1828 \\#include<stdio.h>
1829 \\char world[] = "world";
1830 \\char* hello() {
1831 \\ return "Hello";
1832 \\}
18331833 });
18341834
18351835 const liba = addStaticLibrary(b, opts, .{ .name = "a" });
......@@ -1839,13 +1839,13 @@ fn testSearchStrategy(b: *Build, opts: Options) *Step {
18391839 dylib.addObject(obj);
18401840
18411841 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
1842 \\#include<stdio.h>
1843 \\char* hello();
1844 \\extern char world[];
1845 \\int main() {
1846 \\ printf("%s %s", hello(), world);
1847 \\ return 0;
1848 \\}
1842 \\#include<stdio.h>
1843 \\char* hello();
1844 \\extern char world[];
1845 \\int main() {
1846 \\ printf("%s %s", hello(), world);
1847 \\ return 0;
1848 \\}
18491849 });
18501850
18511851 {
......@@ -1973,23 +1973,23 @@ fn testSectionBoundarySymbols2(b: *Build, opts: Options) *Step {
19731973 const test_step = addTestStep(b, "section-boundary-symbols-2", opts);
19741974
19751975 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
1976 \\#include <stdio.h>
1977 \\struct pair { int a; int b; };
1978 \\struct pair first __attribute__((section("__DATA,__pairs"))) = { 1, 2 };
1979 \\struct pair second __attribute__((section("__DATA,__pairs"))) = { 3, 4 };
1980 \\extern struct pair pairs_start __asm("section$start$__DATA$__pairs");
1981 \\extern struct pair pairs_end __asm("section$end$__DATA$__pairs");
1982 \\int main() {
1983 \\ printf("%d,%d\n", first.a, first.b);
1984 \\ printf("%d,%d\n", second.a, second.b);
1985 \\ struct pair* p;
1986 \\ for (p = &pairs_start; p < &pairs_end; p++) {
1987 \\ p->a = 0;
1988 \\ }
1989 \\ printf("%d,%d\n", first.a, first.b);
1990 \\ printf("%d,%d\n", second.a, second.b);
1991 \\ return 0;
1992 \\}
1976 \\#include <stdio.h>
1977 \\struct pair { int a; int b; };
1978 \\struct pair first __attribute__((section("__DATA,__pairs"))) = { 1, 2 };
1979 \\struct pair second __attribute__((section("__DATA,__pairs"))) = { 3, 4 };
1980 \\extern struct pair pairs_start __asm("section$start$__DATA$__pairs");
1981 \\extern struct pair pairs_end __asm("section$end$__DATA$__pairs");
1982 \\int main() {
1983 \\ printf("%d,%d\n", first.a, first.b);
1984 \\ printf("%d,%d\n", second.a, second.b);
1985 \\ struct pair* p;
1986 \\ for (p = &pairs_start; p < &pairs_end; p++) {
1987 \\ p->a = 0;
1988 \\ }
1989 \\ printf("%d,%d\n", first.a, first.b);
1990 \\ printf("%d,%d\n", second.a, second.b);
1991 \\ return 0;
1992 \\}
19931993 });
19941994
19951995 const run = b.addRunArtifact(exe);
......@@ -2010,24 +2010,24 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20102010 const test_step = addTestStep(b, "segment-boundary-symbols", opts);
20112011
20122012 const obj1 = addObject(b, opts, .{ .name = "a", .cpp_source_bytes =
2013 \\constexpr const char* MESSAGE __attribute__((used, section("__DATA_CONST_1,__message_ptr"))) = "codebase";
2013 \\constexpr const char* MESSAGE __attribute__((used, section("__DATA_CONST_1,__message_ptr"))) = "codebase";
20142014 });
20152015
20162016 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2017 \\#include <stdio.h>
2018 \\const char* interop();
2019 \\int main() {
2020 \\ printf("All your %s are belong to us.\n", interop());
2021 \\ return 0;
2022 \\}
2017 \\#include <stdio.h>
2018 \\const char* interop();
2019 \\int main() {
2020 \\ printf("All your %s are belong to us.\n", interop());
2021 \\ return 0;
2022 \\}
20232023 });
20242024
20252025 {
20262026 const obj2 = addObject(b, opts, .{ .name = "b", .cpp_source_bytes =
2027 \\extern const char* message_pointer __asm("segment$start$__DATA_CONST_1");
2028 \\extern "C" const char* interop() {
2029 \\ return message_pointer;
2030 \\}
2027 \\extern const char* message_pointer __asm("segment$start$__DATA_CONST_1");
2028 \\extern "C" const char* interop() {
2029 \\ return message_pointer;
2030 \\}
20312031 });
20322032
20332033 const exe = addExecutable(b, opts, .{ .name = "main" });
......@@ -2047,10 +2047,10 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
20472047
20482048 {
20492049 const obj2 = addObject(b, opts, .{ .name = "c", .cpp_source_bytes =
2050 \\extern const char* message_pointer __asm("segment$start$__DATA_1");
2051 \\extern "C" const char* interop() {
2052 \\ return message_pointer;
2053 \\}
2050 \\extern const char* message_pointer __asm("segment$start$__DATA_1");
2051 \\extern "C" const char* interop() {
2052 \\ return message_pointer;
2053 \\}
20542054 });
20552055
20562056 const exe = addExecutable(b, opts, .{ .name = "main2" });
......@@ -2078,27 +2078,27 @@ fn testSymbolStabs(b: *Build, opts: Options) *Step {
20782078 const test_step = addTestStep(b, "symbol-stabs", opts);
20792079
20802080 const a_o = addObject(b, opts, .{ .name = "a", .c_source_bytes =
2081 \\int foo = 42;
2082 \\int getFoo() {
2083 \\ return foo;
2084 \\}
2081 \\int foo = 42;
2082 \\int getFoo() {
2083 \\ return foo;
2084 \\}
20852085 });
20862086
20872087 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
2088 \\int bar = 24;
2089 \\int getBar() {
2090 \\ return bar;
2091 \\}
2088 \\int bar = 24;
2089 \\int getBar() {
2090 \\ return bar;
2091 \\}
20922092 });
20932093
20942094 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2095 \\#include <stdio.h>
2096 \\extern int getFoo();
2097 \\extern int getBar();
2098 \\int main() {
2099 \\ printf("foo=%d,bar=%d", getFoo(), getBar());
2100 \\ return 0;
2101 \\}
2095 \\#include <stdio.h>
2096 \\extern int getFoo();
2097 \\extern int getBar();
2098 \\int main() {
2099 \\ printf("foo=%d,bar=%d", getFoo(), getBar());
2100 \\ return 0;
2101 \\}
21022102 });
21032103
21042104 const exe = addExecutable(b, opts, .{ .name = "main" });
......@@ -2162,11 +2162,11 @@ fn testTbdv3(b: *Build, opts: Options) *Step {
21622162 };
21632163
21642164 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2165 \\#include <stdio.h>
2166 \\int getFoo();
2167 \\int main() {
2168 \\ return getFoo() - 42;
2169 \\}
2165 \\#include <stdio.h>
2166 \\int getFoo();
2167 \\int main() {
2168 \\ return getFoo() - 42;
2169 \\}
21702170 });
21712171 exe.root_module.linkSystemLibrary("a", .{});
21722172 exe.root_module.addLibraryPath(tbd.dirname());
......@@ -2209,18 +2209,18 @@ fn testThunks(b: *Build, opts: Options) *Step {
22092209 const test_step = addTestStep(b, "thunks", opts);
22102210
22112211 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2212 \\#include <stdio.h>
2213 \\void bar() {
2214 \\ printf("bar");
2215 \\}
2216 \\void foo() {
2217 \\ fprintf(stdout, "foo");
2218 \\}
2219 \\int main() {
2220 \\ foo();
2221 \\ bar();
2222 \\ return 0;
2223 \\}
2212 \\#include <stdio.h>
2213 \\void bar() {
2214 \\ printf("bar");
2215 \\}
2216 \\void foo() {
2217 \\ fprintf(stdout, "foo");
2218 \\}
2219 \\int main() {
2220 \\ foo();
2221 \\ bar();
2222 \\ return 0;
2223 \\}
22242224 });
22252225
22262226 const check = exe.checkObject();
......@@ -2241,24 +2241,24 @@ fn testTls(b: *Build, opts: Options) *Step {
22412241 const test_step = addTestStep(b, "tls", opts);
22422242
22432243 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
2244 \\_Thread_local int a;
2245 \\int getA() {
2246 \\ return a;
2247 \\}
2244 \\_Thread_local int a;
2245 \\int getA() {
2246 \\ return a;
2247 \\}
22482248 });
22492249
22502250 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2251 \\#include<stdio.h>
2252 \\extern _Thread_local int a;
2253 \\extern int getA();
2254 \\int getA2() {
2255 \\ return a;
2256 \\}
2257 \\int main() {
2258 \\ a = 2;
2259 \\ printf("%d %d %d", a, getA(), getA2());
2260 \\ return 0;
2261 \\}
2251 \\#include<stdio.h>
2252 \\extern _Thread_local int a;
2253 \\extern int getA();
2254 \\int getA2() {
2255 \\ return a;
2256 \\}
2257 \\int main() {
2258 \\ a = 2;
2259 \\ printf("%d %d %d", a, getA(), getA2());
2260 \\ return 0;
2261 \\}
22622262 });
22632263 exe.root_module.linkSystemLibrary("a", .{});
22642264 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
......@@ -2292,33 +2292,33 @@ fn testTlsPointers(b: *Build, opts: Options) *Step {
22922292 };
22932293
22942294 const bar_o = addObject(b, opts, .{ .name = "bar", .cpp_source_bytes =
2295 \\#include "foo.h"
2296 \\int bar() {
2297 \\ int v1 = Foo<int>::getVar();
2298 \\ return v1;
2299 \\}
2295 \\#include "foo.h"
2296 \\int bar() {
2297 \\ int v1 = Foo<int>::getVar();
2298 \\ return v1;
2299 \\}
23002300 });
23012301 bar_o.root_module.addIncludePath(foo_h.dirname());
23022302 bar_o.linkLibCpp();
23032303
23042304 const baz_o = addObject(b, opts, .{ .name = "baz", .cpp_source_bytes =
2305 \\#include "foo.h"
2306 \\int baz() {
2307 \\ int v1 = Foo<unsigned>::getVar();
2308 \\ return v1;
2309 \\}
2305 \\#include "foo.h"
2306 \\int baz() {
2307 \\ int v1 = Foo<unsigned>::getVar();
2308 \\ return v1;
2309 \\}
23102310 });
23112311 baz_o.root_module.addIncludePath(foo_h.dirname());
23122312 baz_o.linkLibCpp();
23132313
23142314 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
2315 \\extern int bar();
2316 \\extern int baz();
2317 \\int main() {
2318 \\ int v1 = bar();
2319 \\ int v2 = baz();
2320 \\ return v1 != v2;
2321 \\}
2315 \\extern int bar();
2316 \\extern int baz();
2317 \\int main() {
2318 \\ int v1 = bar();
2319 \\ int v2 = baz();
2320 \\ return v1 != v2;
2321 \\}
23222322 });
23232323 main_o.root_module.addIncludePath(foo_h.dirname());
23242324 main_o.linkLibCpp();
......@@ -2340,14 +2340,14 @@ fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
23402340 const test_step = addTestStep(b, "tls-large-tbss", opts);
23412341
23422342 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2343 \\#include <stdio.h>
2344 \\_Thread_local int x[0x8000];
2345 \\_Thread_local int y[0x8000];
2346 \\int main() {
2347 \\ x[0] = 3;
2348 \\ x[0x7fff] = 5;
2349 \\ printf("%d %d %d %d %d %d\n", x[0], x[1], x[0x7fff], y[0], y[1], y[0x7fff]);
2350 \\}
2343 \\#include <stdio.h>
2344 \\_Thread_local int x[0x8000];
2345 \\_Thread_local int y[0x8000];
2346 \\int main() {
2347 \\ x[0] = 3;
2348 \\ x[0x7fff] = 5;
2349 \\ printf("%d %d %d %d %d %d\n", x[0], x[1], x[0x7fff], y[0], y[1], y[0x7fff]);
2350 \\}
23512351 });
23522352
23532353 const run = addRunArtifact(exe);
......@@ -2361,15 +2361,15 @@ fn testTlsZig(b: *Build, opts: Options) *Step {
23612361 const test_step = addTestStep(b, "tls-zig", opts);
23622362
23632363 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2364 \\const std = @import("std");
2365 \\threadlocal var x: i32 = 0;
2366 \\threadlocal var y: i32 = -1;
2367 \\pub fn main() void {
2368 \\ std.io.getStdOut().writer().print("{d} {d}\n", .{x, y}) catch unreachable;
2369 \\ x -= 1;
2370 \\ y += 1;
2371 \\ std.io.getStdOut().writer().print("{d} {d}\n", .{x, y}) catch unreachable;
2372 \\}
2364 \\const std = @import("std");
2365 \\threadlocal var x: i32 = 0;
2366 \\threadlocal var y: i32 = -1;
2367 \\pub fn main() void {
2368 \\ std.io.getStdOut().writer().print("{d} {d}\n", .{x, y}) catch unreachable;
2369 \\ x -= 1;
2370 \\ y += 1;
2371 \\ std.io.getStdOut().writer().print("{d} {d}\n", .{x, y}) catch unreachable;
2372 \\}
23732373 });
23742374
23752375 const run = addRunArtifact(exe);
......@@ -2387,15 +2387,15 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
23872387 const test_step = addTestStep(b, "two-level-namespace", opts);
23882388
23892389 const liba = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
2390 \\#include <stdio.h>
2391 \\int foo = 1;
2392 \\int* ptr_to_foo = &foo;
2393 \\int getFoo() {
2394 \\ return foo;
2395 \\}
2396 \\void printInA() {
2397 \\ printf("liba: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2398 \\}
2390 \\#include <stdio.h>
2391 \\int foo = 1;
2392 \\int* ptr_to_foo = &foo;
2393 \\int getFoo() {
2394 \\ return foo;
2395 \\}
2396 \\void printInA() {
2397 \\ printf("liba: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2398 \\}
23992399 });
24002400
24012401 {
......@@ -2408,15 +2408,15 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24082408 }
24092409
24102410 const libb = addSharedLibrary(b, opts, .{ .name = "b", .c_source_bytes =
2411 \\#include <stdio.h>
2412 \\int foo = 2;
2413 \\int* ptr_to_foo = &foo;
2414 \\int getFoo() {
2415 \\ return foo;
2416 \\}
2417 \\void printInB() {
2418 \\ printf("libb: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2419 \\}
2411 \\#include <stdio.h>
2412 \\int foo = 2;
2413 \\int* ptr_to_foo = &foo;
2414 \\int getFoo() {
2415 \\ return foo;
2416 \\}
2417 \\void printInB() {
2418 \\ printf("libb: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2419 \\}
24202420 });
24212421
24222422 {
......@@ -2429,17 +2429,17 @@ fn testTwoLevelNamespace(b: *Build, opts: Options) *Step {
24292429 }
24302430
24312431 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2432 \\#include <stdio.h>
2433 \\int getFoo();
2434 \\extern int* ptr_to_foo;
2435 \\void printInA();
2436 \\void printInB();
2437 \\int main() {
2438 \\ printf("main: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2439 \\ printInA();
2440 \\ printInB();
2441 \\ return 0;
2442 \\}
2432 \\#include <stdio.h>
2433 \\int getFoo();
2434 \\extern int* ptr_to_foo;
2435 \\void printInA();
2436 \\void printInB();
2437 \\int main() {
2438 \\ printf("main: getFoo()=%d, ptr_to_foo=%d\n", getFoo(), *ptr_to_foo);
2439 \\ printInA();
2440 \\ printInB();
2441 \\ return 0;
2442 \\}
24432443 });
24442444
24452445 {
......@@ -2629,17 +2629,17 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
26292629 const test_step = addTestStep(b, "unresolved-error", opts);
26302630
26312631 const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
2632 \\extern fn foo() i32;
2633 \\export fn bar() i32 { return foo() + 1; }
2632 \\extern fn foo() i32;
2633 \\export fn bar() i32 { return foo() + 1; }
26342634 });
26352635
26362636 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2637 \\const std = @import("std");
2638 \\extern fn foo() i32;
2639 \\extern fn bar() i32;
2640 \\pub fn main() void {
2641 \\ std.debug.print("foo() + bar() = {d}", .{foo() + bar()});
2642 \\}
2637 \\const std = @import("std");
2638 \\extern fn foo() i32;
2639 \\extern fn bar() i32;
2640 \\pub fn main() void {
2641 \\ std.debug.print("foo() + bar() = {d}", .{foo() + bar()});
2642 \\}
26432643 });
26442644 exe.addObject(obj);
26452645
......@@ -2665,17 +2665,17 @@ fn testUnresolvedError2(b: *Build, opts: Options) *Step {
26652665 const test_step = addTestStep(b, "unresolved-error-2", opts);
26662666
26672667 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
2668 \\pub fn main() !void {
2669 \\ const msg_send_fn = @extern(
2670 \\ *const fn () callconv(.C) usize,
2671 \\ .{ .name = "objc_msgSend$initWithContentRect:styleMask:backing:defer:screen:" },
2672 \\ );
2673 \\ _ = @call(
2674 \\ .auto,
2675 \\ msg_send_fn,
2676 \\ .{},
2677 \\ );
2678 \\}
2668 \\pub fn main() !void {
2669 \\ const msg_send_fn = @extern(
2670 \\ *const fn () callconv(.C) usize,
2671 \\ .{ .name = "objc_msgSend$initWithContentRect:styleMask:backing:defer:screen:" },
2672 \\ );
2673 \\ _ = @call(
2674 \\ .auto,
2675 \\ msg_send_fn,
2676 \\ .{},
2677 \\ );
2678 \\}
26792679 });
26802680
26812681 expectLinkErrors(exe, test_step, .{ .exact = &.{
......@@ -2737,82 +2737,82 @@ fn testUnwindInfo(b: *Build, opts: Options) *Step {
27372737 };
27382738
27392739 const main_o = addObject(b, opts, .{ .name = "main", .cpp_source_bytes =
2740 \\#include "all.h"
2741 \\#include <cstdio>
2742 \\
2743 \\void fn_c() {
2744 \\ SimpleStringOwner c{ "cccccccccc" };
2745 \\}
2746 \\
2747 \\void fn_b() {
2748 \\ SimpleStringOwner b{ "b" };
2749 \\ fn_c();
2750 \\}
2751 \\
2752 \\int main() {
2753 \\ try {
2754 \\ SimpleStringOwner a{ "a" };
2755 \\ fn_b();
2756 \\ SimpleStringOwner d{ "d" };
2757 \\ } catch (const Error& e) {
2758 \\ printf("Error: %s\n", e.what());
2759 \\ } catch(const std::exception& e) {
2760 \\ printf("Exception: %s\n", e.what());
2761 \\ }
2762 \\ return 0;
2763 \\}
2740 \\#include "all.h"
2741 \\#include <cstdio>
2742 \\
2743 \\void fn_c() {
2744 \\ SimpleStringOwner c{ "cccccccccc" };
2745 \\}
2746 \\
2747 \\void fn_b() {
2748 \\ SimpleStringOwner b{ "b" };
2749 \\ fn_c();
2750 \\}
2751 \\
2752 \\int main() {
2753 \\ try {
2754 \\ SimpleStringOwner a{ "a" };
2755 \\ fn_b();
2756 \\ SimpleStringOwner d{ "d" };
2757 \\ } catch (const Error& e) {
2758 \\ printf("Error: %s\n", e.what());
2759 \\ } catch(const std::exception& e) {
2760 \\ printf("Exception: %s\n", e.what());
2761 \\ }
2762 \\ return 0;
2763 \\}
27642764 });
27652765 main_o.root_module.addIncludePath(all_h.dirname());
27662766 main_o.linkLibCpp();
27672767
27682768 const simple_string_o = addObject(b, opts, .{ .name = "simple_string", .cpp_source_bytes =
2769 \\#include "all.h"
2770 \\#include <cstdio>
2771 \\#include <cstring>
2772 \\
2773 \\SimpleString::SimpleString(size_t max_size)
2774 \\: max_size{ max_size }, length{} {
2775 \\ if (max_size == 0) {
2776 \\ throw Error{ "Max size must be at least 1." };
2777 \\ }
2778 \\ buffer = new char[max_size];
2779 \\ buffer[0] = 0;
2780 \\}
2781 \\
2782 \\SimpleString::~SimpleString() {
2783 \\ delete[] buffer;
2784 \\}
2785 \\
2786 \\void SimpleString::print(const char* tag) const {
2787 \\ printf("%s: %s", tag, buffer);
2788 \\}
2789 \\
2790 \\bool SimpleString::append_line(const char* x) {
2791 \\ const auto x_len = strlen(x);
2792 \\ if (x_len + length + 2 > max_size) return false;
2793 \\ std::strncpy(buffer + length, x, max_size - length);
2794 \\ length += x_len;
2795 \\ buffer[length++] = '\n';
2796 \\ buffer[length] = 0;
2797 \\ return true;
2798 \\}
2769 \\#include "all.h"
2770 \\#include <cstdio>
2771 \\#include <cstring>
2772 \\
2773 \\SimpleString::SimpleString(size_t max_size)
2774 \\: max_size{ max_size }, length{} {
2775 \\ if (max_size == 0) {
2776 \\ throw Error{ "Max size must be at least 1." };
2777 \\ }
2778 \\ buffer = new char[max_size];
2779 \\ buffer[0] = 0;
2780 \\}
2781 \\
2782 \\SimpleString::~SimpleString() {
2783 \\ delete[] buffer;
2784 \\}
2785 \\
2786 \\void SimpleString::print(const char* tag) const {
2787 \\ printf("%s: %s", tag, buffer);
2788 \\}
2789 \\
2790 \\bool SimpleString::append_line(const char* x) {
2791 \\ const auto x_len = strlen(x);
2792 \\ if (x_len + length + 2 > max_size) return false;
2793 \\ std::strncpy(buffer + length, x, max_size - length);
2794 \\ length += x_len;
2795 \\ buffer[length++] = '\n';
2796 \\ buffer[length] = 0;
2797 \\ return true;
2798 \\}
27992799 });
28002800 simple_string_o.root_module.addIncludePath(all_h.dirname());
28012801 simple_string_o.linkLibCpp();
28022802
28032803 const simple_string_owner_o = addObject(b, opts, .{ .name = "simple_string_owner", .cpp_source_bytes =
2804 \\#include "all.h"
2805 \\
2806 \\SimpleStringOwner::SimpleStringOwner(const char* x) : string{ 10 } {
2807 \\ if (!string.append_line(x)) {
2808 \\ throw Error{ "Not enough memory!" };
2809 \\ }
2810 \\ string.print("Constructed");
2811 \\}
2812 \\
2813 \\SimpleStringOwner::~SimpleStringOwner() {
2814 \\ string.print("About to destroy");
2815 \\}
2804 \\#include "all.h"
2805 \\
2806 \\SimpleStringOwner::SimpleStringOwner(const char* x) : string{ 10 } {
2807 \\ if (!string.append_line(x)) {
2808 \\ throw Error{ "Not enough memory!" };
2809 \\ }
2810 \\ string.print("Constructed");
2811 \\}
2812 \\
2813 \\SimpleStringOwner::~SimpleStringOwner() {
2814 \\ string.print("About to destroy");
2815 \\}
28162816 });
28172817 simple_string_owner_o.root_module.addIncludePath(all_h.dirname());
28182818 simple_string_owner_o.linkLibCpp();
......@@ -2848,52 +2848,52 @@ fn testUnwindInfoNoSubsectionsArm64(b: *Build, opts: Options) *Step {
28482848 const test_step = addTestStep(b, "unwind-info-no-subsections-arm64", opts);
28492849
28502850 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2851 \\.globl _foo
2852 \\.align 4
2853 \\_foo:
2854 \\ .cfi_startproc
2855 \\ stp x29, x30, [sp, #-32]!
2856 \\ .cfi_def_cfa_offset 32
2857 \\ .cfi_offset w30, -24
2858 \\ .cfi_offset w29, -32
2859 \\ mov x29, sp
2860 \\ .cfi_def_cfa w29, 32
2861 \\ bl _bar
2862 \\ ldp x29, x30, [sp], #32
2863 \\ .cfi_restore w29
2864 \\ .cfi_restore w30
2865 \\ .cfi_def_cfa_offset 0
2866 \\ ret
2867 \\ .cfi_endproc
2868 \\
2869 \\.globl _bar
2870 \\.align 4
2871 \\_bar:
2872 \\ .cfi_startproc
2873 \\ sub sp, sp, #32
2874 \\ .cfi_def_cfa_offset -32
2875 \\ stp x29, x30, [sp, #16]
2876 \\ .cfi_offset w30, -24
2877 \\ .cfi_offset w29, -32
2878 \\ mov x29, sp
2879 \\ .cfi_def_cfa w29, 32
2880 \\ mov w0, #4
2881 \\ ldp x29, x30, [sp, #16]
2882 \\ .cfi_restore w29
2883 \\ .cfi_restore w30
2884 \\ add sp, sp, #32
2885 \\ .cfi_def_cfa_offset 0
2886 \\ ret
2887 \\ .cfi_endproc
2851 \\.globl _foo
2852 \\.align 4
2853 \\_foo:
2854 \\ .cfi_startproc
2855 \\ stp x29, x30, [sp, #-32]!
2856 \\ .cfi_def_cfa_offset 32
2857 \\ .cfi_offset w30, -24
2858 \\ .cfi_offset w29, -32
2859 \\ mov x29, sp
2860 \\ .cfi_def_cfa w29, 32
2861 \\ bl _bar
2862 \\ ldp x29, x30, [sp], #32
2863 \\ .cfi_restore w29
2864 \\ .cfi_restore w30
2865 \\ .cfi_def_cfa_offset 0
2866 \\ ret
2867 \\ .cfi_endproc
2868 \\
2869 \\.globl _bar
2870 \\.align 4
2871 \\_bar:
2872 \\ .cfi_startproc
2873 \\ sub sp, sp, #32
2874 \\ .cfi_def_cfa_offset -32
2875 \\ stp x29, x30, [sp, #16]
2876 \\ .cfi_offset w30, -24
2877 \\ .cfi_offset w29, -32
2878 \\ mov x29, sp
2879 \\ .cfi_def_cfa w29, 32
2880 \\ mov w0, #4
2881 \\ ldp x29, x30, [sp, #16]
2882 \\ .cfi_restore w29
2883 \\ .cfi_restore w30
2884 \\ add sp, sp, #32
2885 \\ .cfi_def_cfa_offset 0
2886 \\ ret
2887 \\ .cfi_endproc
28882888 });
28892889
28902890 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2891 \\#include <stdio.h>
2892 \\int foo();
2893 \\int main() {
2894 \\ printf("%d\n", foo());
2895 \\ return 0;
2896 \\}
2891 \\#include <stdio.h>
2892 \\int foo();
2893 \\int main() {
2894 \\ printf("%d\n", foo());
2895 \\ return 0;
2896 \\}
28972897 });
28982898 exe.addObject(a_o);
28992899
......@@ -2908,44 +2908,44 @@ fn testUnwindInfoNoSubsectionsX64(b: *Build, opts: Options) *Step {
29082908 const test_step = addTestStep(b, "unwind-info-no-subsections-x64", opts);
29092909
29102910 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2911 \\.globl _foo
2912 \\_foo:
2913 \\ .cfi_startproc
2914 \\ push %rbp
2915 \\ .cfi_def_cfa_offset 8
2916 \\ .cfi_offset %rbp, -8
2917 \\ mov %rsp, %rbp
2918 \\ .cfi_def_cfa_register %rbp
2919 \\ call _bar
2920 \\ pop %rbp
2921 \\ .cfi_restore %rbp
2922 \\ .cfi_def_cfa_offset 0
2923 \\ ret
2924 \\ .cfi_endproc
2925 \\
2926 \\.globl _bar
2927 \\_bar:
2928 \\ .cfi_startproc
2929 \\ push %rbp
2930 \\ .cfi_def_cfa_offset 8
2931 \\ .cfi_offset %rbp, -8
2932 \\ mov %rsp, %rbp
2933 \\ .cfi_def_cfa_register %rbp
2934 \\ mov $4, %rax
2935 \\ pop %rbp
2936 \\ .cfi_restore %rbp
2937 \\ .cfi_def_cfa_offset 0
2938 \\ ret
2939 \\ .cfi_endproc
2911 \\.globl _foo
2912 \\_foo:
2913 \\ .cfi_startproc
2914 \\ push %rbp
2915 \\ .cfi_def_cfa_offset 8
2916 \\ .cfi_offset %rbp, -8
2917 \\ mov %rsp, %rbp
2918 \\ .cfi_def_cfa_register %rbp
2919 \\ call _bar
2920 \\ pop %rbp
2921 \\ .cfi_restore %rbp
2922 \\ .cfi_def_cfa_offset 0
2923 \\ ret
2924 \\ .cfi_endproc
2925 \\
2926 \\.globl _bar
2927 \\_bar:
2928 \\ .cfi_startproc
2929 \\ push %rbp
2930 \\ .cfi_def_cfa_offset 8
2931 \\ .cfi_offset %rbp, -8
2932 \\ mov %rsp, %rbp
2933 \\ .cfi_def_cfa_register %rbp
2934 \\ mov $4, %rax
2935 \\ pop %rbp
2936 \\ .cfi_restore %rbp
2937 \\ .cfi_def_cfa_offset 0
2938 \\ ret
2939 \\ .cfi_endproc
29402940 });
29412941
29422942 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
2943 \\#include <stdio.h>
2944 \\int foo();
2945 \\int main() {
2946 \\ printf("%d\n", foo());
2947 \\ return 0;
2948 \\}
2943 \\#include <stdio.h>
2944 \\int foo();
2945 \\int main() {
2946 \\ printf("%d\n", foo());
2947 \\ return 0;
2948 \\}
29492949 });
29502950 exe.addObject(a_o);
29512951
......@@ -2961,27 +2961,27 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
29612961 const test_step = addTestStep(b, "weak-bind", opts);
29622962
29632963 const lib = addSharedLibrary(b, opts, .{ .name = "foo", .asm_source_bytes =
2964 \\.globl _weak_dysym
2965 \\.weak_definition _weak_dysym
2966 \\_weak_dysym:
2967 \\ .quad 0x1234
2968 \\
2969 \\.globl _weak_dysym_for_gotpcrel
2970 \\.weak_definition _weak_dysym_for_gotpcrel
2971 \\_weak_dysym_for_gotpcrel:
2972 \\ .quad 0x1234
2973 \\
2974 \\.globl _weak_dysym_fn
2975 \\.weak_definition _weak_dysym_fn
2976 \\_weak_dysym_fn:
2977 \\ ret
2978 \\
2979 \\.section __DATA,__thread_vars,thread_local_variables
2980 \\
2981 \\.globl _weak_dysym_tlv
2982 \\.weak_definition _weak_dysym_tlv
2983 \\_weak_dysym_tlv:
2984 \\ .quad 0x1234
2964 \\.globl _weak_dysym
2965 \\.weak_definition _weak_dysym
2966 \\_weak_dysym:
2967 \\ .quad 0x1234
2968 \\
2969 \\.globl _weak_dysym_for_gotpcrel
2970 \\.weak_definition _weak_dysym_for_gotpcrel
2971 \\_weak_dysym_for_gotpcrel:
2972 \\ .quad 0x1234
2973 \\
2974 \\.globl _weak_dysym_fn
2975 \\.weak_definition _weak_dysym_fn
2976 \\_weak_dysym_fn:
2977 \\ ret
2978 \\
2979 \\.section __DATA,__thread_vars,thread_local_variables
2980 \\
2981 \\.globl _weak_dysym_tlv
2982 \\.weak_definition _weak_dysym_tlv
2983 \\_weak_dysym_tlv:
2984 \\ .quad 0x1234
29852985 });
29862986
29872987 {
......@@ -2995,61 +2995,61 @@ fn testWeakBind(b: *Build, opts: Options) *Step {
29952995 }
29962996
29972997 const exe = addExecutable(b, opts, .{ .name = "main", .asm_source_bytes =
2998 \\.globl _main, _weak_external, _weak_external_for_gotpcrel, _weak_external_fn
2999 \\.weak_definition _weak_external, _weak_external_for_gotpcrel, _weak_external_fn, _weak_internal, _weak_internal_for_gotpcrel, _weak_internal_fn
3000 \\
3001 \\_main:
3002 \\ mov _weak_dysym_for_gotpcrel@GOTPCREL(%rip), %rax
3003 \\ mov _weak_external_for_gotpcrel@GOTPCREL(%rip), %rax
3004 \\ mov _weak_internal_for_gotpcrel@GOTPCREL(%rip), %rax
3005 \\ mov _weak_tlv@TLVP(%rip), %rax
3006 \\ mov _weak_dysym_tlv@TLVP(%rip), %rax
3007 \\ mov _weak_internal_tlv@TLVP(%rip), %rax
3008 \\ callq _weak_dysym_fn
3009 \\ callq _weak_external_fn
3010 \\ callq _weak_internal_fn
3011 \\ mov $0, %rax
3012 \\ ret
3013 \\
3014 \\_weak_external:
3015 \\ .quad 0x1234
3016 \\
3017 \\_weak_external_for_gotpcrel:
3018 \\ .quad 0x1234
3019 \\
3020 \\_weak_external_fn:
3021 \\ ret
3022 \\
3023 \\_weak_internal:
3024 \\ .quad 0x1234
3025 \\
3026 \\_weak_internal_for_gotpcrel:
3027 \\ .quad 0x1234
3028 \\
3029 \\_weak_internal_fn:
3030 \\ ret
3031 \\
3032 \\.data
3033 \\ .quad _weak_dysym
3034 \\ .quad _weak_external + 2
3035 \\ .quad _weak_internal
3036 \\
3037 \\.tbss _weak_tlv$tlv$init, 4, 2
3038 \\.tbss _weak_internal_tlv$tlv$init, 4, 2
3039 \\
3040 \\.section __DATA,__thread_vars,thread_local_variables
3041 \\.globl _weak_tlv
3042 \\.weak_definition _weak_tlv, _weak_internal_tlv
3043 \\
3044 \\_weak_tlv:
3045 \\ .quad __tlv_bootstrap
3046 \\ .quad 0
3047 \\ .quad _weak_tlv$tlv$init
3048 \\
3049 \\_weak_internal_tlv:
3050 \\ .quad __tlv_bootstrap
3051 \\ .quad 0
3052 \\ .quad _weak_internal_tlv$tlv$init
2998 \\.globl _main, _weak_external, _weak_external_for_gotpcrel, _weak_external_fn
2999 \\.weak_definition _weak_external, _weak_external_for_gotpcrel, _weak_external_fn, _weak_internal, _weak_internal_for_gotpcrel, _weak_internal_fn
3000 \\
3001 \\_main:
3002 \\ mov _weak_dysym_for_gotpcrel@GOTPCREL(%rip), %rax
3003 \\ mov _weak_external_for_gotpcrel@GOTPCREL(%rip), %rax
3004 \\ mov _weak_internal_for_gotpcrel@GOTPCREL(%rip), %rax
3005 \\ mov _weak_tlv@TLVP(%rip), %rax
3006 \\ mov _weak_dysym_tlv@TLVP(%rip), %rax
3007 \\ mov _weak_internal_tlv@TLVP(%rip), %rax
3008 \\ callq _weak_dysym_fn
3009 \\ callq _weak_external_fn
3010 \\ callq _weak_internal_fn
3011 \\ mov $0, %rax
3012 \\ ret
3013 \\
3014 \\_weak_external:
3015 \\ .quad 0x1234
3016 \\
3017 \\_weak_external_for_gotpcrel:
3018 \\ .quad 0x1234
3019 \\
3020 \\_weak_external_fn:
3021 \\ ret
3022 \\
3023 \\_weak_internal:
3024 \\ .quad 0x1234
3025 \\
3026 \\_weak_internal_for_gotpcrel:
3027 \\ .quad 0x1234
3028 \\
3029 \\_weak_internal_fn:
3030 \\ ret
3031 \\
3032 \\.data
3033 \\ .quad _weak_dysym
3034 \\ .quad _weak_external + 2
3035 \\ .quad _weak_internal
3036 \\
3037 \\.tbss _weak_tlv$tlv$init, 4, 2
3038 \\.tbss _weak_internal_tlv$tlv$init, 4, 2
3039 \\
3040 \\.section __DATA,__thread_vars,thread_local_variables
3041 \\.globl _weak_tlv
3042 \\.weak_definition _weak_tlv, _weak_internal_tlv
3043 \\
3044 \\_weak_tlv:
3045 \\ .quad __tlv_bootstrap
3046 \\ .quad 0
3047 \\ .quad _weak_tlv$tlv$init
3048 \\
3049 \\_weak_internal_tlv:
3050 \\ .quad __tlv_bootstrap
3051 \\ .quad 0
3052 \\ .quad _weak_internal_tlv$tlv$init
30533053 });
30543054 exe.linkLibrary(lib);
30553055
......@@ -3111,23 +3111,23 @@ fn testWeakLibrary(b: *Build, opts: Options) *Step {
31113111 const test_step = addTestStep(b, "weak-library", opts);
31123112
31133113 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
3114 \\#include<stdio.h>
3115 \\int a = 42;
3116 \\const char* asStr() {
3117 \\ static char str[3];
3118 \\ sprintf(str, "%d", 42);
3119 \\ return str;
3120 \\}
3114 \\#include<stdio.h>
3115 \\int a = 42;
3116 \\const char* asStr() {
3117 \\ static char str[3];
3118 \\ sprintf(str, "%d", 42);
3119 \\ return str;
3120 \\}
31213121 });
31223122
31233123 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3124 \\#include<stdio.h>
3125 \\extern int a;
3126 \\extern const char* asStr();
3127 \\int main() {
3128 \\ printf("%d %s", a, asStr());
3129 \\ return 0;
3130 \\}
3124 \\#include<stdio.h>
3125 \\extern int a;
3126 \\extern const char* asStr();
3127 \\int main() {
3128 \\ printf("%d %s", a, asStr());
3129 \\ return 0;
3130 \\}
31313131 });
31323132 exe.root_module.linkSystemLibrary("a", .{ .weak = true });
31333133 exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory());
......@@ -3154,11 +3154,11 @@ fn testWeakRef(b: *Build, opts: Options) *Step {
31543154 const test_step = addTestStep(b, "weak-ref", opts);
31553155
31563156 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
3157 \\#include <stdio.h>
3158 \\#include <sys/_types/_fd_def.h>
3159 \\int main(int argc, char** argv) {
3160 \\ printf("__darwin_check_fd_set_overflow: %p\n", __darwin_check_fd_set_overflow);
3161 \\}
3157 \\#include <stdio.h>
3158 \\#include <sys/_types/_fd_def.h>
3159 \\int main(int argc, char** argv) {
3160 \\ printf("__darwin_check_fd_set_overflow: %p\n", __darwin_check_fd_set_overflow);
3161 \\}
31623162 });
31633163
31643164 const check = exe.checkObject();
tools/doctest.zig+1-1
......@@ -203,7 +203,7 @@ fn printOutput(
203203 if (mem.startsWith(u8, triple, "wasm32") or
204204 mem.startsWith(u8, triple, "riscv64-linux") or
205205 (mem.startsWith(u8, triple, "x86_64-linux") and
206 builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
206 builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
207207 {
208208 // skip execution
209209 break :code_block;
tools/fetch_them_macos_headers.zig+2-2
......@@ -99,8 +99,8 @@ pub fn main() anyerror!void {
9999
100100 const version = Version.parse(parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET) orelse
101101 fatal("don't know how to parse SDK version: {s}", .{
102 parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
103 });
102 parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
103 });
104104 const os_ver: OsVer = switch (version.major) {
105105 10 => .catalina,
106106 11 => .big_sur,
tools/update_clang_options.zig+1-1
......@@ -761,7 +761,7 @@ pub fn main() anyerror!void {
761761 if ((std.mem.startsWith(u8, name, "mno-") and
762762 llvm_to_zig_cpu_features.contains(name["mno-".len..])) or
763763 (std.mem.startsWith(u8, name, "m") and
764 llvm_to_zig_cpu_features.contains(name["m".len..])))
764 llvm_to_zig_cpu_features.contains(name["m".len..])))
765765 {
766766 try stdout.print("m(\"{s}\"),\n", .{name});
767767 } else {