aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig7
-rw-r--r--src/main.zig10
2 files changed, 14 insertions, 3 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 11b3328e0e..98f4012a26 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -165,6 +165,7 @@ last_update_was_cache_hit: bool = false,
c_source_files: []const CSourceFile,
rc_source_files: []const RcSourceFile,
+global_cc_argv: []const []const u8,
cache_parent: *Cache,
/// Path to own executable for invoking `zig clang`.
self_exe_path: ?[]const u8,
@@ -1120,6 +1121,7 @@ pub const CreateOptions = struct {
/// (Windows) PDB output path
pdb_out_path: ?[]const u8 = null,
error_limit: ?Compilation.Module.ErrorInt = null,
+ global_cc_argv: []const []const u8 = &.{},
pub const Entry = link.File.OpenOptions.Entry;
};
@@ -1515,6 +1517,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
.wasi_emulated_libs = options.wasi_emulated_libs,
.force_undefined_symbols = options.force_undefined_symbols,
.link_eh_frame_hdr = link_eh_frame_hdr,
+ .global_cc_argv = options.global_cc_argv,
};
// Prevent some footguns by making the "any" fields of config reflect
@@ -2527,6 +2530,8 @@ fn addNonIncrementalStuffToCacheManifest(
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_llvm_ir);
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_llvm_bc);
+ man.hash.addListOfBytes(comp.global_cc_argv);
+
const opts = comp.cache_use.whole.lf_open_opts;
try man.addOptionalFile(opts.linker_script);
@@ -3941,6 +3946,7 @@ pub fn obtainCObjectCacheManifest(
// that apply both to @cImport and compiling C objects. No linking stuff here!
// Also nothing that applies only to compiling .zig code.
cache_helpers.addModule(&man.hash, owner_mod);
+ man.hash.addListOfBytes(comp.global_cc_argv);
man.hash.add(comp.config.link_libcpp);
// When libc_installation is null it means that Zig generated this dir list
@@ -5411,6 +5417,7 @@ pub fn addCCArgs(
}
}
+ try argv.appendSlice(comp.global_cc_argv);
try argv.appendSlice(mod.cc_argv);
}
diff --git a/src/main.zig b/src/main.zig
index 091e4b2668..4442234bd2 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -3244,6 +3244,10 @@ fn buildOutputType(
.pdb_out_path = pdb_out_path,
.error_limit = error_limit,
.native_system_include_paths = create_module.native_system_include_paths,
+ // Any leftover C compilation args (such as -I) apply globally rather
+ // than to any particular module. This feature can greatly reduce CLI
+ // noise when --search-prefix and --mod are combined.
+ .global_cc_argv = try cc_argv.toOwnedSlice(arena),
}) catch |err| switch (err) {
error.LibCUnavailable => {
const triple_name = try target.zigTriple(arena);
@@ -3421,9 +3425,9 @@ const CreateModule = struct {
c_source_files: std.ArrayListUnmanaged(Compilation.CSourceFile),
rc_source_files: std.ArrayListUnmanaged(Compilation.RcSourceFile),
- // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
- // This array is populated by zig cc frontend and then has to be converted to zig-style
- // CPU features.
+ /// e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
+ /// This array is populated by zig cc frontend and then has to be converted to zig-style
+ /// CPU features.
llvm_m_args: std.ArrayListUnmanaged([]const u8),
sysroot: ?[]const u8,
lib_dirs: std.ArrayListUnmanaged([]const u8),