From 3542dcad33f5e2021caeb897857b7cc3a57f2c23 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 11 Jan 2022 18:41:26 +0100 Subject: [PATCH] zig cc: integration with sysroot arg (#10568) 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. --- src/clang_options_data.zig | 4 ++-- src/main.zig | 4 ++++ tools/update_clang_options.zig | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/clang_options_data.zig b/src/clang_options_data.zig index 3c4c084976..85ff809761 100644 --- a/src/clang_options_data.zig +++ b/src/clang_options_data.zig @@ -1983,7 +1983,7 @@ flagpsl("MT"), .{ .name = "sysroot", .syntax = .separate, - .zig_equivalent = .other, + .zig_equivalent = .sysroot, .pd1 = false, .pd2 = true, .psl = false, @@ -5970,7 +5970,7 @@ jspd1("undefined"), .{ .name = "sysroot=", .syntax = .joined, - .zig_equivalent = .other, + .zig_equivalent = .sysroot, .pd1 = false, .pd2 = true, .psl = false, diff --git a/src/main.zig b/src/main.zig index 61b4ebb7e9..b532151654 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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. @@ -4115,6 +4118,7 @@ pub const ClangArgIterator = struct { strip, exec_model, emit_llvm, + sysroot, }; const Args = struct { diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index 7360f96560..73b1bbd284 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -412,6 +412,10 @@ const known_options = [_]KnownOpt{ .name = "emit-llvm", .ident = "emit_llvm", }, + .{ + .name = "sysroot", + .ident = "sysroot", + }, }; const blacklisted_options = [_][]const u8{};