Skip to content

Commit d21f9b7

Browse files
committed
targeted revert of PR rust-lang#64324 (just undo change to dylib generics export).
Includes the anticipated fallout to run-make-fulldeps test suite from this change. (We need to reopen issue 64319 as part of landing this.)
1 parent d3d28a4 commit d21f9b7

File tree

7 files changed

+18
-92
lines changed

7 files changed

+18
-92
lines changed

src/librustc/ty/context.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,14 @@ impl<'tcx> TyCtxt<'tcx> {
15141514
CrateType::Executable |
15151515
CrateType::Staticlib |
15161516
CrateType::ProcMacro |
1517-
CrateType::Dylib |
15181517
CrateType::Cdylib => false,
1518+
1519+
// FIXME rust-lang/rust#64319, rust-lang/rust#64872:
1520+
// We want to block export of generics from dylibs,
1521+
// but we must fix rust-lang/rust#65890 before we can
1522+
// do that robustly.
1523+
CrateType::Dylib => true,
1524+
15191525
CrateType::Rlib => true,
15201526
}
15211527
})

src/librustc_codegen_ssa/back/linker.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc::middle::dependency_format::Linkage;
1414
use rustc::session::Session;
1515
use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
1616
LinkerPluginLto, Lto};
17-
use rustc::middle::exported_symbols::ExportedSymbol;
1817
use rustc::ty::TyCtxt;
1918
use rustc_target::spec::{LinkerFlavor, LldFlavor};
2019
use rustc_serialize::{json, Encoder};
@@ -1112,20 +1111,10 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
11121111
continue;
11131112
}
11141113

1115-
// Do not export generic symbols from upstream crates in linked
1116-
// artifact (notably the `dylib` crate type). The main reason
1117-
// for this is that `symbol_name` is actually wrong for generic
1118-
// symbols because it guesses the name we'd give them locally
1119-
// rather than the name it has upstream (depending on
1120-
// `share_generics` settings and such).
1121-
//
1122-
// To fix that issue we just say that linked artifacts, aka
1123-
// `dylib`s, never export generic symbols and they aren't
1124-
// available to downstream crates. (the not available part is
1125-
// handled elsewhere).
1126-
if let ExportedSymbol::Generic(..) = symbol {
1127-
continue;
1128-
}
1114+
// FIXME rust-lang/rust#64319, rust-lang/rust#64872:
1115+
// We want to block export of generics from dylibs,
1116+
// but we must fix rust-lang/rust#65890 before we can
1117+
// do that robustly.
11291118

11301119
symbols.push(symbol.symbol_name(tcx).to_string());
11311120
}

src/librustc_metadata/cstore_impl.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc::ty::query::QueryConfig;
99
use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind};
1010
use rustc::middle::exported_symbols::ExportedSymbol;
1111
use rustc::middle::stability::DeprecationEntry;
12-
use rustc::middle::dependency_format::Linkage;
1312
use rustc::hir::def;
1413
use rustc::hir;
1514
use rustc::session::{CrateDisambiguator, Session};
@@ -235,26 +234,11 @@ provide! { <'tcx> tcx, def_id, other, cdata,
235234
used_crate_source => { Lrc::new(cdata.source.clone()) }
236235

237236
exported_symbols => {
238-
let mut syms = cdata.exported_symbols(tcx);
239-
240-
// When linked into a dylib crates don't export their generic symbols,
241-
// so if that's happening then we can't load upstream monomorphizations
242-
// from this crate.
243-
let formats = tcx.dependency_formats(LOCAL_CRATE);
244-
let remove_generics = formats.iter().any(|(_ty, list)| {
245-
match list.get(def_id.krate.as_usize() - 1) {
246-
Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
247-
_ => false,
248-
}
249-
});
250-
if remove_generics {
251-
syms.retain(|(sym, _threshold)| {
252-
match sym {
253-
ExportedSymbol::Generic(..) => false,
254-
_ => return true,
255-
}
256-
});
257-
}
237+
let syms = cdata.exported_symbols(tcx);
238+
239+
// FIXME rust-lang/rust#64319, rust-lang/rust#64872: We want
240+
// to block export of generics from dylibs, but we must fix
241+
// rust-lang/rust#65890 before we can do that robustly.
258242

259243
Arc::new(syms)
260244
}

src/test/run-make-fulldeps/issue-64319/Makefile

-39
This file was deleted.

src/test/run-make-fulldeps/issue-64319/bar.rs

-5
This file was deleted.

src/test/run-make-fulldeps/issue-64319/foo.rs

-9
This file was deleted.

src/test/run-make-fulldeps/symbol-visibility/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ all:
7979
# Check that a Rust dylib exports its monomorphic functions, including generics this time
8080
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
8181
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
82-
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
82+
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
8383

8484
# Check that a Rust dylib exports the monomorphic functions from its dependencies
8585
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
8686
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
87-
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
87+
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
8888

8989
# Check that an executable does not export any dynamic symbols
9090
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]

0 commit comments

Comments
 (0)