zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3ed6379192ceffdc1b85cd83c16e87cd477e2043 (tree)
parent 2f538f30fda59d259b2d3c890a7ade6d35085da0
Author: LemonBoy <thatlemon@gmail.com>
Date:   Tue, 25 May 2021 19:41:41 +0200

stage1: Store target info in the LLVM module

This is needed to let LLVM (or, better, libLTO) produce code using the
target options specified by the user.

Fix #8803

Diffstat:
Msrc/stage1/codegen.cpp | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp @@ -589,6 +589,13 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { // use the ABI alignment, which is fine. } + if (g->zig_target->llvm_cpu_name != nullptr) { + ZigLLVMAddFunctionAttr(llvm_fn, "target-cpu", g->zig_target->llvm_cpu_name); + } + if (g->zig_target->llvm_cpu_features != nullptr) { + ZigLLVMAddFunctionAttr(llvm_fn, "target-features", g->zig_target->llvm_cpu_features); + } + if (is_async) { addLLVMArgAttr(llvm_fn, 0, "nonnull"); } else {