| ... | ... | @@ -773,13 +773,26 @@ pub fn buildSharedObjects(comp: *Compilation) !void { |
| 773 | 773 | const hit = try cache.hit(); |
| 774 | 774 | const digest = cache.final(); |
| 775 | 775 | const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest }); |
| 776 | | if (!hit) { |
| 777 | | var o_directory: Compilation.Directory = .{ |
| 778 | | .handle = try comp.zig_cache_directory.handle.makeOpenPath(o_sub_path, .{}), |
| 779 | | .path = try path.join(arena, &[_][]const u8{ comp.zig_cache_directory.path.?, o_sub_path }), |
| 776 | |
| 777 | // Even if we get a hit, it doesn't guarantee that we finished the job last time. |
| 778 | // We use the presence of an "ok" file to determine if it is a true hit. |
| 779 | |
| 780 | var o_directory: Compilation.Directory = .{ |
| 781 | .handle = try comp.zig_cache_directory.handle.makeOpenPath(o_sub_path, .{}), |
| 782 | .path = try path.join(arena, &[_][]const u8{ comp.zig_cache_directory.path.?, o_sub_path }), |
| 783 | }; |
| 784 | defer o_directory.handle.close(); |
| 785 | |
| 786 | const ok_basename = "ok"; |
| 787 | const actual_hit = if (hit) blk: { |
| 788 | o_directory.handle.access(ok_basename, .{}) catch |err| switch (err) { |
| 789 | error.FileNotFound => break :blk false, |
| 790 | else => |e| return e, |
| 780 | 791 | }; |
| 781 | | defer o_directory.handle.close(); |
| 792 | break :blk true; |
| 793 | } else false; |
| 782 | 794 | |
| 795 | if (!actual_hit) { |
| 783 | 796 | const metadata = try loadMetaData(comp.gpa, comp.zig_lib_directory.handle); |
| 784 | 797 | defer metadata.destroy(comp.gpa); |
| 785 | 798 | |
| ... | ... | @@ -869,16 +882,16 @@ pub fn buildSharedObjects(comp: *Compilation) !void { |
| 869 | 882 | const want_two_ats = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index; |
| 870 | 883 | const at_sign_str = "@@"[0 .. @boolToInt(want_two_ats) + @as(usize, 1)]; |
| 871 | 884 | if (ver.patch == 0) { |
| 872 | | try zig_body.writer().print(" \\\\ .symver {s}, {s}{s}GLIBC_{d}.{d}\n", .{ |
| 885 | try zig_body.writer().print(" \\\\.symver {s}, {s}{s}GLIBC_{d}.{d}\n", .{ |
| 873 | 886 | stub_name, sym_name, at_sign_str, ver.major, ver.minor, |
| 874 | 887 | }); |
| 875 | 888 | } else { |
| 876 | | try zig_body.writer().print(" \\\\ .symver {s}, {s}{s}GLIBC_{d}.{d}.{d}\n", .{ |
| 889 | try zig_body.writer().print(" \\\\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}\n", .{ |
| 877 | 890 | stub_name, sym_name, at_sign_str, ver.major, ver.minor, ver.patch, |
| 878 | 891 | }); |
| 879 | 892 | } |
| 880 | 893 | // Hide the stub to keep the symbol table clean |
| 881 | | try zig_body.writer().print(" \\\\ .hidden {s}\n", .{stub_name}); |
| 894 | try zig_body.writer().print(" \\\\.hidden {s}\n", .{stub_name}); |
| 882 | 895 | } |
| 883 | 896 | } |
| 884 | 897 | } |
| ... | ... | @@ -896,9 +909,13 @@ pub fn buildSharedObjects(comp: *Compilation) !void { |
| 896 | 909 | |
| 897 | 910 | try buildSharedLib(comp, arena, comp.zig_cache_directory, o_directory, zig_file_basename, lib); |
| 898 | 911 | } |
| 899 | | cache.writeManifest() catch |err| { |
| 900 | | std.log.warn("glibc shared objects: failed to write cache manifest: {}", .{@errorName(err)}); |
| 901 | | }; |
| 912 | // No need to write the manifest because there are no file inputs associated with this cache hash. |
| 913 | // However we do need to write the ok file now. |
| 914 | if (o_directory.handle.createFile(ok_basename, .{})) |file| { |
| 915 | file.close(); |
| 916 | } else |err| { |
| 917 | std.log.warn("glibc shared objects: failed to mark completion: {}", .{@errorName(err)}); |
| 918 | } |
| 902 | 919 | } |
| 903 | 920 | |
| 904 | 921 | assert(comp.glibc_so_files == null); |
| ... | ... | @@ -935,7 +952,7 @@ fn buildSharedLib( |
| 935 | 952 | .zig_lib_directory = comp.zig_lib_directory, |
| 936 | 953 | .target = comp.getTarget(), |
| 937 | 954 | .root_name = lib.name, |
| 938 | | .root_pkg = null, |
| 955 | .root_pkg = root_pkg, |
| 939 | 956 | .output_mode = .Lib, |
| 940 | 957 | .link_mode = .Dynamic, |
| 941 | 958 | .rand = comp.rand, |
| ... | ... | @@ -971,7 +988,7 @@ fn updateSubCompilation(sub_compilation: *Compilation) !void { |
| 971 | 988 | |
| 972 | 989 | if (errors.list.len != 0) { |
| 973 | 990 | for (errors.list) |full_err_msg| { |
| 974 | | std.log.err("{}:{}:{}: error: {}\n", .{ |
| 991 | std.log.err("{}:{}:{}: {}\n", .{ |
| 975 | 992 | full_err_msg.src_path, |
| 976 | 993 | full_err_msg.line + 1, |
| 977 | 994 | full_err_msg.column + 1, |