diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-06-25 22:37:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-25 22:37:46 +0200 |
| commit | 7a85dc6935ffaf1828cdc75c2602fb232217f7b3 (patch) | |
| tree | 4b18151af1320b2801054a5dc0e1765a541ddc62 /lib | |
| parent | 73f77f30804f3a512fbb35caad3d87ff2778ecc0 (diff) | |
| parent | f9171bf54295df0bd8f4dbe1ab9698e5940ba445 (diff) | |
| download | zig-7a85dc6935ffaf1828cdc75c2602fb232217f7b3.tar.gz zig-7a85dc6935ffaf1828cdc75c2602fb232217f7b3.zip | |
Merge pull request #9202 from ifreund/sysroot
stage2: add --sysroot link option
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/build.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/build_runner.zig | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig index 8626d660f0..36a71d5061 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -57,6 +57,7 @@ pub const Builder = struct { exe_dir: []const u8, h_dir: []const u8, install_path: []const u8, + sysroot: ?[]const u8 = null, search_prefixes: ArrayList([]const u8), libc_file: ?[]const u8 = null, installed_files: ArrayList(InstalledFile), @@ -2701,6 +2702,10 @@ pub const LibExeObjStep = struct { } } + if (builder.sysroot) |sysroot| { + try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot }); + } + for (builder.search_prefixes.items) |search_prefix| { try zig_args.append("-L"); try zig_args.append(try fs.path.join(builder.allocator, &[_][]const u8{ diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 510dd578c3..7530fae4f0 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -104,6 +104,12 @@ pub fn main() !void { warn("Expected argument after {s}\n\n", .{arg}); return usageAndErr(builder, false, stderr_stream); }; + } else if (mem.eql(u8, arg, "--sysroot")) { + const sysroot = nextArg(args, &arg_idx) orelse { + warn("Expected argument after --sysroot\n\n", .{}); + return usageAndErr(builder, false, stderr_stream); + }; + builder.sysroot = sysroot; } else if (mem.eql(u8, arg, "--search-prefix")) { const search_prefix = nextArg(args, &arg_idx) orelse { warn("Expected argument after --search-prefix\n\n", .{}); @@ -214,6 +220,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void \\ --prefix-exe-dir [path] Override default executable directory path \\ --prefix-include-dir [path] Override default include directory path \\ + \\ --sysroot [path] Set the system root directory (usually /) \\ --search-prefix [path] Add a path to look for binaries, libraries, headers \\ --libc [file] Provide a file which specifies libc paths \\ |
