aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-19 15:03:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:20 -0700
commit8944dea23fb554290a4b54ca40b0594f6e3f77a9 (patch)
tree9ce6e53249296cac235346f7e26fbc0f6a87fc11 /src/Compilation.zig
parentdb2ca2ca0005b73e1a7df42de77a06c5506f3aaf (diff)
downloadzig-8944dea23fb554290a4b54ca40b0594f6e3f77a9.tar.gz
zig-8944dea23fb554290a4b54ca40b0594f6e3f77a9.zip
CLI: fix regressed logic for any_dyn_libs
This value needs access to the fully resolved set of system libraries, which required restructuring a bunch of CLI logic.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index fa674e28fa..f825d8c930 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -86,6 +86,7 @@ skip_linker_dependencies: bool,
no_builtin: bool,
function_sections: bool,
data_sections: bool,
+native_system_include_paths: []const []const u8,
c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{},
win32_resource_table: if (build_options.only_core_functionality) void else std.AutoArrayHashMapUnmanaged(*Win32Resource, void) =
@@ -1065,6 +1066,7 @@ pub const InitOptions = struct {
version: ?std.SemanticVersion = null,
compatibility_version: ?std.SemanticVersion = null,
libc_installation: ?*const LibCInstallation = null,
+ native_system_include_paths: []const []const u8 = &.{},
clang_preprocessor_mode: ClangPreprocessorMode = .no,
/// This is for stage1 and should be deleted upon completion of self-hosting.
color: Color = .auto,
@@ -1508,6 +1510,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.job_queued_update_builtin_zig = have_zcu,
.function_sections = options.function_sections,
.data_sections = options.data_sections,
+ .native_system_include_paths = options.native_system_include_paths,
};
const lf_open_opts: link.File.OpenOptions = .{
@@ -5296,6 +5299,14 @@ pub fn addCCArgs(
try argv.append("-ffreestanding");
}
+ if (mod.resolved_target.is_native_os and mod.resolved_target.is_native_abi) {
+ try argv.ensureUnusedCapacity(comp.native_system_include_paths.len * 2);
+ for (comp.native_system_include_paths) |include_path| {
+ argv.appendAssumeCapacity("-isystem");
+ argv.appendAssumeCapacity(include_path);
+ }
+ }
+
try argv.appendSlice(mod.cc_argv);
}