Skip to content

Commit

Permalink
zig cc: integration with sysroot arg (#10568)
Browse files Browse the repository at this point in the history
Prior to this change, even if the use specified the sysroot on the
compiler line like so

```
zig cc --sysroot=/path/to/sdk
```

it would only be used as a prefix to include paths and not as a prefix
for `zig ld` linker.
  • Loading branch information
kubkon authored and andrewrk committed Jan 12, 2022
1 parent 9b97edb commit 3542dca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/clang_options_data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ flagpsl("MT"),
.{
.name = "sysroot",
.syntax = .separate,
.zig_equivalent = .other,
.zig_equivalent = .sysroot,
.pd1 = false,
.pd2 = true,
.psl = false,
Expand Down Expand Up @@ -5970,7 +5970,7 @@ jspd1("undefined"),
.{
.name = "sysroot=",
.syntax = .joined,
.zig_equivalent = .other,
.zig_equivalent = .sysroot,
.pd1 = false,
.pd2 = true,
.psl = false,
Expand Down
4 changes: 4 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,9 @@ fn buildOutputType(
fatal("expected [command|reactor] for -mexec-mode=[value], found '{s}'", .{it.only_arg});
};
},
.sysroot => {
sysroot = it.only_arg;
},
}
}
// Parse linker args.
Expand Down Expand Up @@ -4115,6 +4118,7 @@ pub const ClangArgIterator = struct {
strip,
exec_model,
emit_llvm,
sysroot,
};

const Args = struct {
Expand Down
4 changes: 4 additions & 0 deletions tools/update_clang_options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ const known_options = [_]KnownOpt{
.name = "emit-llvm",
.ident = "emit_llvm",
},
.{
.name = "sysroot",
.ident = "sysroot",
},
};

const blacklisted_options = [_][]const u8{};
Expand Down

0 comments on commit 3542dca

Please sign in to comment.