Skip to content

Commit d39dcd6

Browse files
committed
zig build: add setLibCFile API
1 parent 38ba412 commit d39dcd6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

std/build.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ pub const LibExeObjStep = struct {
10531053
installed_path: ?[]const u8,
10541054
install_step: ?*InstallArtifactStep,
10551055

1056+
libc_file: ?[]const u8,
1057+
10561058
const LinkObject = union(enum) {
10571059
StaticPath: []const u8,
10581060
OtherStep: *LibExeObjStep,
@@ -1146,6 +1148,7 @@ pub const LibExeObjStep = struct {
11461148
.single_threaded = false,
11471149
.installed_path = null,
11481150
.install_step = null,
1151+
.libc_file = null,
11491152
};
11501153
self.computeOutFileNames();
11511154
return self;
@@ -1321,6 +1324,10 @@ pub const LibExeObjStep = struct {
13211324
self.disable_gen_h = value;
13221325
}
13231326

1327+
pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {
1328+
self.libc_file = libc_file;
1329+
}
1330+
13241331
/// Unless setOutputDir was called, this function must be called only in
13251332
/// the make step, from a step that has declared a dependency on this one.
13261333
/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
@@ -1525,6 +1532,11 @@ pub const LibExeObjStep = struct {
15251532
try zig_args.append("--single-threaded");
15261533
}
15271534

1535+
if (self.libc_file) |libc_file| {
1536+
try zig_args.append("--libc");
1537+
try zig_args.append(builder.pathFromRoot(libc_file));
1538+
}
1539+
15281540
switch (self.build_mode) {
15291541
builtin.Mode.Debug => {},
15301542
builtin.Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,

0 commit comments

Comments
 (0)