# stage2: default dynamic libraries to be linked as needed · gitcafe/zig

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

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

Visibility: public

Requested revision: 4e5a88b28882eda156a46ecc7f70887a7bc0b49b

Requested commit: 4e5a88b28882eda156a46ecc7f70887a7bc0b49b

Commit: 4e5a88b28882eda156a46ecc7f70887a7bc0b49b

Tree: 1ccdc54fdb432ff72692e9f10f4f0640ef6869cd

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: default dynamic libraries to be linked as needed

After this change, the default for dynamic libraries (`-l` or
`--library`) is to only link them if they end up being actually used.

With the Zig CLI, the new options `-needed-l` or `--needed-library` can
be used to force link against a dynamic library.

With `zig cc`, this behavior can be overridden with `-Wl,--no-as-needed`
(and restored with `-Wl,--as-needed`).

Closes #10164

```

## Parents

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

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