# compiler: resolve library paths in the frontend · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/a08cc7d2ae3bd6e90f8d26ac13f2e0652687dc30)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: a08cc7d2ae3bd6e90f8d26ac13f2e0652687dc30

Requested commit: a08cc7d2ae3bd6e90f8d26ac13f2e0652687dc30

Commit: a08cc7d2ae3bd6e90f8d26ac13f2e0652687dc30

Tree: 85cd80a1276d31cb543ae2d4317b257e39bed146

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

````
compiler: resolve library paths in the frontend

search_strategy is no longer passed to Compilation at all; instead it is
used in the CLI code only.

When using Zig CLI mode, `-l` no longer has the ability to link
statically; use positional arguments for this.

The CLI has a small abstraction around library resolution handling which
is used to remove some code duplication regarding static libraries, as
well as handle the difference between zig cc CLI mode and zig CLI mode.

Thanks to this, system libraries are now included in the cache hash, and
thus changes to them will correctly cause cache misses.

In the future, lib_dirs should no longer be passed to Compilation at
all, because it is a frontend-only concept.

Previously, -search_paths_first and -search_dylibs_first were
Darwin-only arguments; they now work the same for all targets. Same
thing with --sysroot.

Improved the error reporting for failure to find a system library. An
example error now looks like this:

```
$ zig build-exe test.zig -lfoo -L. -L/a -target x86_64-macos --sysroot /home/andy/local
error: unable to find Dynamic system library 'foo' using strategy 'no_fallback'. search paths:
  ./libfoo.tbd
  ./libfoo.dylib
  ./libfoo.so
  /home/andy/local/a/libfoo.tbd
  /home/andy/local/a/libfoo.dylib
  /home/andy/local/a/libfoo.so
  /a/libfoo.tbd
  /a/libfoo.dylib
  /a/libfoo.so
```

closes #14963

````

## Parents

- [f887b0251822f75dc4a3e24ca5337cb681c1eb1f](https://git.cafe/gitcafe/zig/commit/f887b0251822f75dc4a3e24ca5337cb681c1eb1f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/a08cc7d2ae3bd6e90f8d26ac13f2e0652687dc30?format=markdown)
