diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-18 15:20:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 15:20:51 -0700 |
| commit | 0e332e9e3c4a33458cac1801f59c2d0a3ca28484 (patch) | |
| tree | 47466b9f29e0272a3aa750d65a9820bbbaae2b76 /src/librustc_codegen_ssa | |
| parent | bf59152c01d9ffc4ceeb982e26b3df2354ebede6 (diff) | |
| parent | e8e0a0e4e220533db31bc6a572ed9f1b99b31289 (diff) | |
| download | rust-0e332e9e3c4a33458cac1801f59c2d0a3ca28484.tar.gz rust-0e332e9e3c4a33458cac1801f59c2d0a3ca28484.zip | |
Rollup merge of #73034 - doctorn:nomangle-inline-linkage, r=matthewjasper
Export `#[inline]` fns with extern indicators
In ancient history (#36280) we stopped `#[inline]` fns being codegened if they weren't used. However,
- #72944
- #72463
observe that when writing something like
```rust
#![crate_type = "cdylib"]
#[no_mangle]
#[inline]
pub extern "C" fn foo() {
// ...
}
```
we really _do_ want `foo` to be codegened. This change makes this the case.
Resolves #72944, resolves #72463 (and maybe some more)
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/back/symbol_export.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 970d13b30c0..98f7da8361c 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -89,10 +89,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap< | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) => { let def_id = tcx.hir().local_def_id(hir_id); let generics = tcx.generics_of(def_id); - if !generics.requires_monomorphization(tcx) && - // Functions marked with #[inline] are only ever codegened - // with "internal" linkage and are never exported. - !Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx) + if !generics.requires_monomorphization(tcx) + // Functions marked with #[inline] are codegened with "internal" + // linkage and are not exported unless marked with an extern + // inidicator + && (!Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx) + || tcx.codegen_fn_attrs(def_id.to_def_id()).contains_extern_indicator()) { Some(def_id) } else { |
