diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2026-02-04 08:59:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-04 08:59:23 +0000 |
| commit | 61f3d45fa7cf3993a42ad122d450f5629d704720 (patch) | |
| tree | 7b8783d43193c16e4ef393a175fede50a8fe52dd /src/llvm_backend_proc.cpp | |
| parent | 270df36468df8f89e1ac944205272469142c7a65 (diff) | |
| parent | b8276065f9296754d1e76e25d6661b7b5567e3e1 (diff) | |
Merge pull request #6227 from JesseRMeyer/lto-support
Fix LTO on Windows
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index e52e91f75..7897e17cd 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -289,6 +289,19 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i lb_set_linkage_from_entity_flags(p->module, p->value, entity->flags); + // With LTO on Windows, required procedures with external linkage need to be added to + // llvm.used to survive linker-level dead code elimination. This is necessary because + // LLVM may generate implicit calls to runtime builtins (e.g., __extendhfsf2 for f16 + // conversions) during instruction lowering, after the IR is finalized. + if (build_context.lto_kind != LTO_None && build_context.metrics.os == TargetOs_windows) { + if (entity->flags & EntityFlag_Require) { + LLVMLinkage linkage = LLVMGetLinkage(p->value); + if (linkage != LLVMInternalLinkage) { + lb_append_to_used(m, p->value); + } + } + } + if (m->debug_builder) { // Debug Information Type *bt = base_type(p->type); |