| author | |
| committer | |
| log | fb0ecdbe1accdb8521fa3539101941a880216292 |
| tree | a2dc611423aa94f323799164d8cd9a69153fd3af |
| parent | d892d3bbe782c7e5c5a5907c0afd37c3a3efa97f |
This new option sets a default libc paths file to be used for all
LibExeObjSteps. Setting LibExeObjStep.libc_file overrides this default.
This is required to allow users to cross compile projects linking system
libraries without needing to patch the build.zig.2 files changed, 11 insertions(+), 0 deletions(-)
lib/std/build.zig+4| ... | ... | @@ -58,6 +58,7 @@ pub const Builder = struct { |
| 58 | 58 | h_dir: []const u8, |
| 59 | 59 | install_path: []const u8, |
| 60 | 60 | search_prefixes: ArrayList([]const u8), |
| 61 | libc_file: ?[]const u8 = null, | |
| 61 | 62 | installed_files: ArrayList(InstalledFile), |
| 62 | 63 | build_root: []const u8, |
| 63 | 64 | cache_root: []const u8, |
| ... | ... | @@ -2474,6 +2475,9 @@ pub const LibExeObjStep = struct { |
| 2474 | 2475 | if (self.libc_file) |libc_file| { |
| 2475 | 2476 | try zig_args.append("--libc"); |
| 2476 | 2477 | try zig_args.append(libc_file.getPath(self.builder)); |
| 2478 | } else if (builder.libc_file) |libc_file| { | |
| 2479 | try zig_args.append("--libc"); | |
| 2480 | try zig_args.append(libc_file); | |
| 2477 | 2481 | } |
| 2478 | 2482 | |
| 2479 | 2483 | switch (self.build_mode) { |
lib/std/special/build_runner.zig+7| ... | ... | @@ -110,6 +110,12 @@ pub fn main() !void { |
| 110 | 110 | return usageAndErr(builder, false, stderr_stream); |
| 111 | 111 | }; |
| 112 | 112 | builder.addSearchPrefix(search_prefix); |
| 113 | } else if (mem.eql(u8, arg, "--libc")) { | |
| 114 | const libc_file = nextArg(args, &arg_idx) orelse { | |
| 115 | warn("Expected argument after --libc\n\n", .{}); | |
| 116 | return usageAndErr(builder, false, stderr_stream); | |
| 117 | }; | |
| 118 | builder.libc_file = libc_file; | |
| 113 | 119 | } else if (mem.eql(u8, arg, "--color")) { |
| 114 | 120 | const next_arg = nextArg(args, &arg_idx) orelse { |
| 115 | 121 | warn("expected [auto|on|off] after --color", .{}); |
| ... | ... | @@ -209,6 +215,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 209 | 215 | \\ --prefix-include-dir [path] Override default include directory path |
| 210 | 216 | \\ |
| 211 | 217 | \\ --search-prefix [path] Add a path to look for binaries, libraries, headers |
| 218 | \\ --libc [file] Provide a file which specifies libc paths | |
| 212 | 219 | \\ |
| 213 | 220 | \\ -h, --help Print this help and exit |
| 214 | 221 | \\ --verbose Print commands before executing them |