authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-01 18:42:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-03 09:52:14-07:00
log89c605d140bf295e052cdded4e2c453f7a143d6f
tree70d8e402129b7925a7bfe3c6bbd0125cfec52506
parenta1e21ceec8ecb475f96c5e83ee9f8d59ceecc82d

CLI: add --ambiguous-static-library

I hate this, gonna revert it in the next commit

1 files changed, 15 insertions(+), 2 deletions(-)

src/main.zig+15-2
...@@ -477,9 +477,15 @@ const usage_build_generic =...@@ -477,9 +477,15 @@ const usage_build_generic =
477 \\ -l[lib], --library [lib] Link against system library (only if actually used)477 \\ -l[lib], --library [lib] Link against system library (only if actually used)
478 \\ -needed-l[lib], Link against system library (even if unused)478 \\ -needed-l[lib], Link against system library (even if unused)
479 \\ --needed-library [lib]479 \\ --needed-library [lib]
480 \\ --ambiguous-static-library [l] Link against system library, checking for a
481 \\ static lib in each search path, then checking
482 \\ for a dynamic lib in each search path. Use of
483 \\ this CLI option is a code smell.
480 \\ -L[d], --library-directory [d] Add a directory to the library search path484 \\ -L[d], --library-directory [d] Add a directory to the library search path
481 \\ -search_paths_first Search each library search path for dynamic libs then static libs485 \\ -search_paths_first For each library search path, check for dynamic
482 \\ -search_dylibs_first Search for dynamic libs in each library search path, then static libs.486 \\ lib then static lib before proceeding to next path.
487 \\ -search_dylibs_first Search for dynamic libs in all library search
488 \\ paths, then static libs.
483 \\ -T[script], --script [script] Use a custom linker script489 \\ -T[script], --script [script] Use a custom linker script
484 \\ --version-script [path] Provide a version .map file490 \\ --version-script [path] Provide a version .map file
485 \\ --dynamic-linker [path] Set the dynamic interpreter path (usually ld.so)491 \\ --dynamic-linker [path] Set the dynamic interpreter path (usually ld.so)
...@@ -1155,6 +1161,13 @@ fn buildOutputType(...@@ -1155,6 +1161,13 @@ fn buildOutputType(
1155 .preferred_mode = lib_preferred_mode orelse .Dynamic,1161 .preferred_mode = lib_preferred_mode orelse .Dynamic,
1156 .search_strategy = lib_search_strategy orelse .no_fallback,1162 .search_strategy = lib_search_strategy orelse .no_fallback,
1157 });1163 });
1164 } else if (mem.eql(u8, arg, "--ambiguous-static-library")) {
1165 try system_libs.put(args_iter.nextOrFatal(), .{
1166 .needed = false,
1167 .weak = false,
1168 .preferred_mode = lib_preferred_mode orelse .Static,
1169 .search_strategy = lib_search_strategy orelse .mode_first,
1170 });
1158 } else if (mem.eql(u8, arg, "-D")) {1171 } else if (mem.eql(u8, arg, "-D")) {
1159 try clang_argv.append(arg);1172 try clang_argv.append(arg);
1160 try clang_argv.append(args_iter.nextOrFatal());1173 try clang_argv.append(args_iter.nextOrFatal());