# add LTO support · gitcafe/zig

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

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

Visibility: public

Requested revision: 0d4b6ac7417d1094ac972981b0241444ce2380ba

Requested commit: 0d4b6ac7417d1094ac972981b0241444ce2380ba

Commit: 0d4b6ac7417d1094ac972981b0241444ce2380ba

Tree: 52afdf98a47470a20067188fcd7b6a85dff61675

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
add LTO support

The CLI gains -flto and -fno-lto options to override the default.
However, the cool thing about this is that the defaults are great! In
general when you use build-exe in release mode, Zig will enable LTO if
it would work and it would help.

zig cc supports detecting and honoring the -flto and -fno-lto flags as
well. The linkWithLld functions are improved to all be the same with
regards to copying the artifact instead of trying to pass single objects
through LLD with -r. There is possibly a future improvement here as
well; see the respective TODOs.

stage1 is updated to support outputting LLVM bitcode instead of machine
code when lto is enabled. This allows LLVM to optimize across the Zig and
C/C++ code boundary.

closes #2845

```

## Parents

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

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