Skip to content

Commit d1efe8c

Browse files
committed
configure external linkage if no linkage is explicitly set
1 parent c602377 commit d1efe8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
644644
}
645645

646646
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
647-
codegen_fn_attrs.inline = InlineAttr::Never;
647+
// naked functions are generated using an extern function and global assembly. To
648+
// make sure that these can be linked together by LLVM, the linkage should be external,
649+
// unless the user explicitly configured something else (in which case any linker errors
650+
// they encounter are their responsibility).
651+
codegen_fn_attrs.linkage = codegen_fn_attrs.linkage.or(Some(Linkage::External));
648652
}
649653

650654
// Weak lang items have the same semantics as "std internal" symbols in the

0 commit comments

Comments
 (0)