diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-10-16 12:57:16 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-10-23 16:27:38 -0700 |
| commit | 76569035187ac86778802007b41382bfda42a7ee (patch) | |
| tree | 4cbb8775687d07e3162c1cfe659ecaf74bae4cb3 /src | |
| parent | 861df93768ed007ce6f5e6928fc3af8c5860f551 (diff) | |
| download | zig-76569035187ac86778802007b41382bfda42a7ee.tar.gz zig-76569035187ac86778802007b41382bfda42a7ee.zip | |
CLI: fix detection of link inputs
Diffstat (limited to 'src')
| -rw-r--r-- | src/link.zig | 7 | ||||
| -rw-r--r-- | src/main.zig | 23 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/link.zig b/src/link.zig index d78600783e..7cde28d683 100644 --- a/src/link.zig +++ b/src/link.zig @@ -1392,13 +1392,6 @@ pub const UnresolvedInput = union(enum) { /// Put exactly this string in the dynamic section, no rpath. dso_exact: Input.DsoExact, - ///// Relocatable. - //object: Input.Object, - ///// Static library. - //archive: Input.Object, - ///// Windows resource file. - //winres: Path, - pub const NameQuery = struct { name: []const u8, query: Query, diff --git a/src/main.zig b/src/main.zig index 39be246b1d..d3da2180f5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2721,7 +2721,7 @@ fn buildOutputType( }, } if (create_module.c_source_files.items.len == 0 and - !link.anyObjectInputs(create_module.link_inputs.items) and + !anyObjectLinkInputs(create_module.cli_link_inputs.items) and root_src_file == null) { // For example `zig cc` and no args should print the "no input files" message. @@ -2763,9 +2763,13 @@ fn buildOutputType( if (create_module.c_source_files.items.len >= 1) break :b create_module.c_source_files.items[0].src_path; - for (create_module.link_inputs.items) |link_input| { - if (link_input.path()) |path| break :b path.sub_path; - } + for (create_module.cli_link_inputs.items) |unresolved_link_input| switch (unresolved_link_input) { + .path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) { + .object, .static_library, .res => break :b pq.path.sub_path, + else => continue, + }, + else => continue, + }; if (emit_bin == .yes) break :b emit_bin.yes; @@ -7491,3 +7495,14 @@ fn handleModArg( c_source_files_owner_index.* = create_module.c_source_files.items.len; rc_source_files_owner_index.* = create_module.rc_source_files.items.len; } + +fn anyObjectLinkInputs(link_inputs: []const link.UnresolvedInput) bool { + for (link_inputs) |link_input| switch (link_input) { + .path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) { + .object, .static_library, .res => return true, + else => continue, + }, + else => continue, + }; + return false; +} |
