authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-16 12:57:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-23 16:27:38-07:00
log76569035187ac86778802007b41382bfda42a7ee
tree4cbb8775687d07e3162c1cfe659ecaf74bae4cb3
parent861df93768ed007ce6f5e6928fc3af8c5860f551

CLI: fix detection of link inputs


2 files changed, 19 insertions(+), 11 deletions(-)

src/link.zig-7
...@@ -1392,13 +1392,6 @@ pub const UnresolvedInput = union(enum) {...@@ -1392,13 +1392,6 @@ pub const UnresolvedInput = union(enum) {
1392 /// Put exactly this string in the dynamic section, no rpath.1392 /// Put exactly this string in the dynamic section, no rpath.
1393 dso_exact: Input.DsoExact,1393 dso_exact: Input.DsoExact,
13941394
1395 ///// Relocatable.
1396 //object: Input.Object,
1397 ///// Static library.
1398 //archive: Input.Object,
1399 ///// Windows resource file.
1400 //winres: Path,
1401
1402 pub const NameQuery = struct {1395 pub const NameQuery = struct {
1403 name: []const u8,1396 name: []const u8,
1404 query: Query,1397 query: Query,
src/main.zig+19-4
...@@ -2721,7 +2721,7 @@ fn buildOutputType(...@@ -2721,7 +2721,7 @@ fn buildOutputType(
2721 },2721 },
2722 }2722 }
2723 if (create_module.c_source_files.items.len == 0 and2723 if (create_module.c_source_files.items.len == 0 and
2724 !link.anyObjectInputs(create_module.link_inputs.items) and2724 !anyObjectLinkInputs(create_module.cli_link_inputs.items) and
2725 root_src_file == null)2725 root_src_file == null)
2726 {2726 {
2727 // For example `zig cc` and no args should print the "no input files" message.2727 // For example `zig cc` and no args should print the "no input files" message.
...@@ -2763,9 +2763,13 @@ fn buildOutputType(...@@ -2763,9 +2763,13 @@ fn buildOutputType(
2763 if (create_module.c_source_files.items.len >= 1)2763 if (create_module.c_source_files.items.len >= 1)
2764 break :b create_module.c_source_files.items[0].src_path;2764 break :b create_module.c_source_files.items[0].src_path;
27652765
2766 for (create_module.link_inputs.items) |link_input| {2766 for (create_module.cli_link_inputs.items) |unresolved_link_input| switch (unresolved_link_input) {
2767 if (link_input.path()) |path| break :b path.sub_path;2767 .path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) {
2768 }2768 .object, .static_library, .res => break :b pq.path.sub_path,
2769 else => continue,
2770 },
2771 else => continue,
2772 };
27692773
2770 if (emit_bin == .yes)2774 if (emit_bin == .yes)
2771 break :b emit_bin.yes;2775 break :b emit_bin.yes;
...@@ -7491,3 +7495,14 @@ fn handleModArg(...@@ -7491,3 +7495,14 @@ fn handleModArg(
7491 c_source_files_owner_index.* = create_module.c_source_files.items.len;7495 c_source_files_owner_index.* = create_module.c_source_files.items.len;
7492 rc_source_files_owner_index.* = create_module.rc_source_files.items.len;7496 rc_source_files_owner_index.* = create_module.rc_source_files.items.len;
7493}7497}
7498
7499fn anyObjectLinkInputs(link_inputs: []const link.UnresolvedInput) bool {
7500 for (link_inputs) |link_input| switch (link_input) {
7501 .path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) {
7502 .object, .static_library, .res => return true,
7503 else => continue,
7504 },
7505 else => continue,
7506 };
7507 return false;
7508}