# stage2: support LLD \-O flags on ELF · gitcafe/zig

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

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

Visibility: public

Requested revision: 20cc7af8e6e47ba209ab0d462826f40516c86b9d

Requested commit: 20cc7af8e6e47ba209ab0d462826f40516c86b9d

Commit: 20cc7af8e6e47ba209ab0d462826f40516c86b9d

Tree: 865fcfffdc31cf0b7220d41198266f0627b2d118

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: support LLD -O flags on ELF

In 7e23b3245a9bf6e002009e6c18c10a9995671afa I made -O flags to the
linker emit a warning that the argument does nothing. That was not
correct however; LLD does have some logic that does different things
depending on -O0, -O1, and -O2. It defaults to -O1, and it does less
optimizations with -O0 and more with -O2.

With this commit, e.g. `-Wl,-O1` is supported by the `zig cc` frontend,
and by default we pass `-O0` to LLD in debug mode, and `-O3` in release
modes.

I also fixed a bug in the LLD ELF linker line which was incorrectly
passing `-O` flags instead of `--lto-O` flags for LTO.

```

## Parents

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

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