diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-01-22 23:36:30 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-01-23 18:18:07 -0700 |
| commit | 0d4b6ac7417d1094ac972981b0241444ce2380ba (patch) | |
| tree | 52afdf98a47470a20067188fcd7b6a85dff61675 /src/codegen/llvm | |
| parent | ab4f3aee3da8f2658c019c05de2cce991d010f01 (diff) | |
| download | zig-0d4b6ac7417d1094ac972981b0241444ce2380ba.tar.gz zig-0d4b6ac7417d1094ac972981b0241444ce2380ba.zip | |
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
Diffstat (limited to 'src/codegen/llvm')
| -rw-r--r-- | src/codegen/llvm/bindings.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index 8774260a08..6474957b1c 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -243,7 +243,13 @@ pub const TargetMachine = opaque { extern fn LLVMDisposeTargetMachine(T: *const TargetMachine) void; pub const emitToFile = LLVMTargetMachineEmitToFile; - extern fn LLVMTargetMachineEmitToFile(*const TargetMachine, M: *const Module, Filename: [*:0]const u8, codegen: CodeGenFileType, ErrorMessage: *[*:0]const u8) LLVMBool; + extern fn LLVMTargetMachineEmitToFile( + *const TargetMachine, + M: *const Module, + Filename: [*:0]const u8, + codegen: CodeGenFileType, + ErrorMessage: *[*:0]const u8, + ) LLVMBool; }; pub const CodeMode = extern enum { |
