update update_glibc and process_headers to latest zig
parent
69de1a51cd
commit
9605e5363b
|
@ -15,6 +15,7 @@ const Arch = std.Target.Cpu.Arch;
|
||||||
const Abi = std.Target.Abi;
|
const Abi = std.Target.Abi;
|
||||||
const OsTag = std.Target.Os.Tag;
|
const OsTag = std.Target.Os.Tag;
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
|
const Sha256 = std.crypto.hash.sha2.Sha256;
|
||||||
|
|
||||||
const LibCTarget = struct {
|
const LibCTarget = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
|
@ -313,7 +314,7 @@ pub fn main() !void {
|
||||||
var max_bytes_saved: usize = 0;
|
var max_bytes_saved: usize = 0;
|
||||||
var total_bytes: usize = 0;
|
var total_bytes: usize = 0;
|
||||||
|
|
||||||
var hasher = std.crypto.hash.sha2.Sha256.init(.{});
|
var hasher = Sha256.init(.{});
|
||||||
|
|
||||||
for (libc_targets) |libc_target| {
|
for (libc_targets) |libc_target| {
|
||||||
const dest_target = DestTarget{
|
const dest_target = DestTarget{
|
||||||
|
@ -359,7 +360,7 @@ pub fn main() !void {
|
||||||
const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
|
const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
|
||||||
total_bytes += raw_bytes.len;
|
total_bytes += raw_bytes.len;
|
||||||
const hash = try allocator.alloc(u8, 32);
|
const hash = try allocator.alloc(u8, 32);
|
||||||
hasher.reset();
|
hasher = Sha256.init(.{});
|
||||||
hasher.update(rel_path);
|
hasher.update(rel_path);
|
||||||
hasher.update(trimmed);
|
hasher.update(trimmed);
|
||||||
hasher.final(hash);
|
hasher.final(hash);
|
||||||
|
|
|
@ -148,12 +148,12 @@ pub fn main() !void {
|
||||||
for (abi_lists) |*abi_list| {
|
for (abi_lists) |*abi_list| {
|
||||||
const target_funcs_gop = try target_functions.getOrPut(@ptrToInt(abi_list));
|
const target_funcs_gop = try target_functions.getOrPut(@ptrToInt(abi_list));
|
||||||
if (!target_funcs_gop.found_existing) {
|
if (!target_funcs_gop.found_existing) {
|
||||||
target_funcs_gop.kv.value = FunctionSet{
|
target_funcs_gop.entry.value = FunctionSet{
|
||||||
.list = std.ArrayList(VersionedFn).init(allocator),
|
.list = std.ArrayList(VersionedFn).init(allocator),
|
||||||
.fn_vers_list = FnVersionList.init(allocator),
|
.fn_vers_list = FnVersionList.init(allocator),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const fn_set = &target_funcs_gop.kv.value.list;
|
const fn_set = &target_funcs_gop.entry.value.list;
|
||||||
|
|
||||||
for (lib_names) |lib_name, lib_name_index| {
|
for (lib_names) |lib_name, lib_name_index| {
|
||||||
const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
|
const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
|
||||||
|
@ -203,11 +203,11 @@ pub fn main() !void {
|
||||||
_ = try global_ver_set.put(ver, undefined);
|
_ = try global_ver_set.put(ver, undefined);
|
||||||
const gop = try global_fn_set.getOrPut(name);
|
const gop = try global_fn_set.getOrPut(name);
|
||||||
if (gop.found_existing) {
|
if (gop.found_existing) {
|
||||||
if (!std.mem.eql(u8, gop.kv.value.lib, "c")) {
|
if (!std.mem.eql(u8, gop.entry.value.lib, "c")) {
|
||||||
gop.kv.value.lib = lib_name;
|
gop.entry.value.lib = lib_name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gop.kv.value = Function{
|
gop.entry.value = Function{
|
||||||
.name = name,
|
.name = name,
|
||||||
.lib = lib_name,
|
.lib = lib_name,
|
||||||
.index = undefined,
|
.index = undefined,
|
||||||
|
@ -224,14 +224,14 @@ pub fn main() !void {
|
||||||
const global_fn_list = blk: {
|
const global_fn_list = blk: {
|
||||||
var list = std.ArrayList([]const u8).init(allocator);
|
var list = std.ArrayList([]const u8).init(allocator);
|
||||||
var it = global_fn_set.iterator();
|
var it = global_fn_set.iterator();
|
||||||
while (it.next()) |kv| try list.append(kv.key);
|
while (it.next()) |entry| try list.append(entry.key);
|
||||||
std.sort.sort([]const u8, list.span(), {}, strCmpLessThan);
|
std.sort.sort([]const u8, list.span(), {}, strCmpLessThan);
|
||||||
break :blk list.span();
|
break :blk list.span();
|
||||||
};
|
};
|
||||||
const global_ver_list = blk: {
|
const global_ver_list = blk: {
|
||||||
var list = std.ArrayList([]const u8).init(allocator);
|
var list = std.ArrayList([]const u8).init(allocator);
|
||||||
var it = global_ver_set.iterator();
|
var it = global_ver_set.iterator();
|
||||||
while (it.next()) |kv| try list.append(kv.key);
|
while (it.next()) |entry| try list.append(entry.key);
|
||||||
std.sort.sort([]const u8, list.span(), {}, versionLessThan);
|
std.sort.sort([]const u8, list.span(), {}, versionLessThan);
|
||||||
break :blk list.span();
|
break :blk list.span();
|
||||||
};
|
};
|
||||||
|
@ -254,9 +254,9 @@ pub fn main() !void {
|
||||||
var buffered = std.io.bufferedOutStream(fns_txt_file.outStream());
|
var buffered = std.io.bufferedOutStream(fns_txt_file.outStream());
|
||||||
const fns_txt = buffered.outStream();
|
const fns_txt = buffered.outStream();
|
||||||
for (global_fn_list) |name, i| {
|
for (global_fn_list) |name, i| {
|
||||||
const kv = global_fn_set.get(name).?;
|
const entry = global_fn_set.getEntry(name).?;
|
||||||
kv.value.index = i;
|
entry.value.index = i;
|
||||||
try fns_txt.print("{} {}\n", .{ name, kv.value.lib });
|
try fns_txt.print("{} {}\n", .{ name, entry.value.lib });
|
||||||
}
|
}
|
||||||
try buffered.flush();
|
try buffered.flush();
|
||||||
}
|
}
|
||||||
|
@ -264,16 +264,16 @@ pub fn main() !void {
|
||||||
// Now the mapping of version and function to integer index is complete.
|
// Now the mapping of version and function to integer index is complete.
|
||||||
// Here we create a mapping of function name to list of versions.
|
// Here we create a mapping of function name to list of versions.
|
||||||
for (abi_lists) |*abi_list, abi_index| {
|
for (abi_lists) |*abi_list, abi_index| {
|
||||||
const kv = target_functions.get(@ptrToInt(abi_list)).?;
|
const entry = target_functions.getEntry(@ptrToInt(abi_list)).?;
|
||||||
const fn_vers_list = &kv.value.fn_vers_list;
|
const fn_vers_list = &entry.value.fn_vers_list;
|
||||||
for (kv.value.list.span()) |*ver_fn| {
|
for (entry.value.list.span()) |*ver_fn| {
|
||||||
const gop = try fn_vers_list.getOrPut(ver_fn.name);
|
const gop = try fn_vers_list.getOrPut(ver_fn.name);
|
||||||
if (!gop.found_existing) {
|
if (!gop.found_existing) {
|
||||||
gop.kv.value = std.ArrayList(usize).init(allocator);
|
gop.entry.value = std.ArrayList(usize).init(allocator);
|
||||||
}
|
}
|
||||||
const ver_index = global_ver_set.get(ver_fn.ver).?.value;
|
const ver_index = global_ver_set.getEntry(ver_fn.ver).?.value;
|
||||||
if (std.mem.indexOfScalar(usize, gop.kv.value.span(), ver_index) == null) {
|
if (std.mem.indexOfScalar(usize, gop.entry.value.span(), ver_index) == null) {
|
||||||
try gop.kv.value.append(ver_index);
|
try gop.entry.value.append(ver_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
// first iterate over the abi lists
|
// first iterate over the abi lists
|
||||||
for (abi_lists) |*abi_list, abi_index| {
|
for (abi_lists) |*abi_list, abi_index| {
|
||||||
const fn_vers_list = &target_functions.get(@ptrToInt(abi_list)).?.value.fn_vers_list;
|
const fn_vers_list = &target_functions.getEntry(@ptrToInt(abi_list)).?.value.fn_vers_list;
|
||||||
for (abi_list.targets) |target, it_i| {
|
for (abi_list.targets) |target, it_i| {
|
||||||
if (it_i != 0) try abilist_txt.writeByte(' ');
|
if (it_i != 0) try abilist_txt.writeByte(' ');
|
||||||
try abilist_txt.print("{}-linux-{}", .{ @tagName(target.arch), @tagName(target.abi) });
|
try abilist_txt.print("{}-linux-{}", .{ @tagName(target.arch), @tagName(target.abi) });
|
||||||
|
@ -295,11 +295,11 @@ pub fn main() !void {
|
||||||
try abilist_txt.writeByte('\n');
|
try abilist_txt.writeByte('\n');
|
||||||
// next, each line implicitly corresponds to a function
|
// next, each line implicitly corresponds to a function
|
||||||
for (global_fn_list) |name| {
|
for (global_fn_list) |name| {
|
||||||
const kv = fn_vers_list.get(name) orelse {
|
const entry = fn_vers_list.getEntry(name) orelse {
|
||||||
try abilist_txt.writeByte('\n');
|
try abilist_txt.writeByte('\n');
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
for (kv.value.span()) |ver_index, it_i| {
|
for (entry.value.span()) |ver_index, it_i| {
|
||||||
if (it_i != 0) try abilist_txt.writeByte(' ');
|
if (it_i != 0) try abilist_txt.writeByte(' ');
|
||||||
try abilist_txt.print("{d}", .{ver_index});
|
try abilist_txt.print("{d}", .{ver_index});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue