aboutsummaryrefslogtreecommitdiff
path: root/src/libs/glibc.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/glibc.zig')
-rw-r--r--src/libs/glibc.zig48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig
index 5d1c6f420b..541cf5d168 100644
--- a/src/libs/glibc.zig
+++ b/src/libs/glibc.zig
@@ -365,7 +365,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
const s = path.sep_str;
var result = std.ArrayList(u8).init(arena);
- try result.appendSlice(comp.zig_lib_directory.path.?);
+ try result.appendSlice(comp.dirs.zig_lib.path orelse ".");
try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
if (is_sparc) {
if (is_64) {
@@ -439,7 +439,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([
}
if (opt_nptl) |nptl| {
try args.append("-I");
- try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
+ try args.append(try path.join(arena, &.{ comp.dirs.zig_lib.path orelse ".", lib_libc_glibc ++ "sysdeps", nptl }));
}
try args.append("-I");
@@ -459,11 +459,11 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([
try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
try args.append("-I");
- try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
+ try args.append(try path.join(arena, &[_][]const u8{ comp.dirs.zig_lib.path orelse ".", lib_libc ++ "glibc" }));
try args.append("-I");
try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{
- comp.zig_lib_directory.path.?, @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi),
+ comp.dirs.zig_lib.path orelse ".", @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi),
}));
try args.append("-I");
@@ -472,7 +472,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([
const arch_name = std.zig.target.osArchName(target);
try args.append("-I");
try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
- comp.zig_lib_directory.path.?, arch_name,
+ comp.dirs.zig_lib.path orelse ".", arch_name,
}));
try args.append("-I");
@@ -626,15 +626,11 @@ fn add_include_dirs_arch(
}
}
-fn path_from_lib(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
- return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
-}
-
const lib_libc = "libc" ++ path.sep_str;
const lib_libc_glibc = lib_libc ++ "glibc" ++ path.sep_str;
fn lib_path(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
- return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
+ return path.join(arena, &.{ comp.dirs.zig_lib.path orelse ".", sub_path });
}
pub const BuiltSharedObjects = struct {
@@ -678,11 +674,11 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
// Use the global cache directory.
var cache: Cache = .{
.gpa = gpa,
- .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
+ .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath("h", .{}),
};
cache.addPrefix(.{ .path = null, .handle = fs.cwd() });
- cache.addPrefix(comp.zig_lib_directory);
- cache.addPrefix(comp.global_cache_directory);
+ cache.addPrefix(comp.dirs.zig_lib);
+ cache.addPrefix(comp.dirs.global_cache);
defer cache.manifest_dir.close();
var man = cache.obtain();
@@ -692,7 +688,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
man.hash.add(target.abi);
man.hash.add(target_version);
- const full_abilists_path = try comp.zig_lib_directory.join(arena, &.{abilists_path});
+ const full_abilists_path = try comp.dirs.zig_lib.join(arena, &.{abilists_path});
const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);
if (try man.hit()) {
@@ -701,7 +697,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
return queueSharedObjects(comp, .{
.lock = man.toOwnedLock(),
.dir_path = .{
- .root_dir = comp.global_cache_directory,
+ .root_dir = comp.dirs.global_cache,
.sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
},
});
@@ -710,9 +706,9 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
const digest = man.final();
const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
- var o_directory: Compilation.Directory = .{
- .handle = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{}),
- .path = try comp.global_cache_directory.join(arena, &.{o_sub_path}),
+ var o_directory: Cache.Directory = .{
+ .handle = try comp.dirs.global_cache.handle.makeOpenPath(o_sub_path, .{}),
+ .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),
};
defer o_directory.handle.close();
@@ -1112,7 +1108,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
- try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
+ try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
}
man.writeManifest() catch |err| {
@@ -1122,7 +1118,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
return queueSharedObjects(comp, .{
.lock = man.toOwnedLock(),
.dir_path = .{
- .root_dir = comp.global_cache_directory,
+ .root_dir = comp.dirs.global_cache,
.sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
},
});
@@ -1174,8 +1170,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
fn buildSharedLib(
comp: *Compilation,
arena: Allocator,
- zig_cache_directory: Compilation.Directory,
- bin_directory: Compilation.Directory,
+ bin_directory: Cache.Directory,
asm_file_basename: []const u8,
lib: Lib,
prog_node: std.Progress.Node,
@@ -1208,9 +1203,8 @@ fn buildSharedLib(
});
const root_mod = try Module.create(arena, .{
- .global_cache_directory = comp.global_cache_directory,
.paths = .{
- .root = .{ .root_dir = comp.zig_lib_directory },
+ .root = .zig_lib_root,
.root_src_path = "",
},
.fully_qualified_name = "root",
@@ -1230,8 +1224,6 @@ fn buildSharedLib(
.global = config,
.cc_argv = &.{},
.parent = null,
- .builtin_mod = null,
- .builtin_modules = null, // there is only one module in this compilation
});
const c_source_files = [1]Compilation.CSourceFile{
@@ -1242,9 +1234,7 @@ fn buildSharedLib(
};
const sub_compilation = try Compilation.create(comp.gpa, arena, .{
- .local_cache_directory = zig_cache_directory,
- .global_cache_directory = comp.global_cache_directory,
- .zig_lib_directory = comp.zig_lib_directory,
+ .dirs = comp.dirs.withoutLocalCache(),
.thread_pool = comp.thread_pool,
.self_exe_path = comp.self_exe_path,
.cache_mode = .incremental,