about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/ty/context.rs8
-rw-r--r--src/librustc_codegen_ssa/back/linker.rs19
-rw-r--r--src/librustc_metadata/cstore_impl.rs26
-rw-r--r--src/test/run-make-fulldeps/issue-64319/Makefile39
-rw-r--r--src/test/run-make-fulldeps/issue-64319/bar.rs5
-rw-r--r--src/test/run-make-fulldeps/issue-64319/foo.rs9
-rw-r--r--src/test/run-make-fulldeps/symbol-visibility/Makefile4
7 files changed, 18 insertions, 92 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index bdf9b2d7f3f..8d8974c6cbb 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -1514,8 +1514,14 @@ impl<'tcx> TyCtxt<'tcx> {
                 CrateType::Executable |
                 CrateType::Staticlib  |
                 CrateType::ProcMacro  |
-                CrateType::Dylib      |
                 CrateType::Cdylib     => false,
+
+                // FIXME rust-lang/rust#64319, rust-lang/rust#64872:
+                // We want to block export of generics from dylibs,
+                // but we must fix rust-lang/rust#65890 before we can
+                // do that robustly.
+                CrateType::Dylib      => true,
+
                 CrateType::Rlib       => true,
             }
         })
diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs
index ff87f0b1547..999cc406585 100644
--- a/src/librustc_codegen_ssa/back/linker.rs
+++ b/src/librustc_codegen_ssa/back/linker.rs
@@ -14,7 +14,6 @@ use rustc::middle::dependency_format::Linkage;
 use rustc::session::Session;
 use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
                              LinkerPluginLto, Lto};
-use rustc::middle::exported_symbols::ExportedSymbol;
 use rustc::ty::TyCtxt;
 use rustc_target::spec::{LinkerFlavor, LldFlavor};
 use rustc_serialize::{json, Encoder};
@@ -1112,20 +1111,10 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
                     continue;
                 }
 
-                // Do not export generic symbols from upstream crates in linked
-                // artifact (notably the `dylib` crate type). The main reason
-                // for this is that `symbol_name` is actually wrong for generic
-                // symbols because it guesses the name we'd give them locally
-                // rather than the name it has upstream (depending on
-                // `share_generics` settings and such).
-                //
-                // To fix that issue we just say that linked artifacts, aka
-                // `dylib`s, never export generic symbols and they aren't
-                // available to downstream crates. (the not available part is
-                // handled elsewhere).
-                if let ExportedSymbol::Generic(..) = symbol {
-                    continue;
-                }
+                // FIXME rust-lang/rust#64319, rust-lang/rust#64872:
+                // We want to block export of generics from dylibs,
+                // but we must fix rust-lang/rust#65890 before we can
+                // do that robustly.
 
                 symbols.push(symbol.symbol_name(tcx).to_string());
             }
diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs
index d942a19194a..5e5c94b0314 100644
--- a/src/librustc_metadata/cstore_impl.rs
+++ b/src/librustc_metadata/cstore_impl.rs
@@ -9,7 +9,6 @@ use rustc::ty::query::QueryConfig;
 use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind};
 use rustc::middle::exported_symbols::ExportedSymbol;
 use rustc::middle::stability::DeprecationEntry;
-use rustc::middle::dependency_format::Linkage;
 use rustc::hir::def;
 use rustc::hir;
 use rustc::session::{CrateDisambiguator, Session};
@@ -235,26 +234,11 @@ provide! { <'tcx> tcx, def_id, other, cdata,
     used_crate_source => { Lrc::new(cdata.source.clone()) }
 
     exported_symbols => {
-        let mut syms = cdata.exported_symbols(tcx);
-
-        // When linked into a dylib crates don't export their generic symbols,
-        // so if that's happening then we can't load upstream monomorphizations
-        // from this crate.
-        let formats = tcx.dependency_formats(LOCAL_CRATE);
-        let remove_generics = formats.iter().any(|(_ty, list)| {
-            match list.get(def_id.krate.as_usize() - 1) {
-                Some(Linkage::IncludedFromDylib) | Some(Linkage::Dynamic) => true,
-                _ => false,
-            }
-        });
-        if remove_generics {
-            syms.retain(|(sym, _threshold)| {
-                match sym {
-                    ExportedSymbol::Generic(..) => false,
-                    _ => return true,
-                }
-            });
-        }
+        let syms = cdata.exported_symbols(tcx);
+
+        // FIXME rust-lang/rust#64319, rust-lang/rust#64872: We want
+        // to block export of generics from dylibs, but we must fix
+        // rust-lang/rust#65890 before we can do that robustly.
 
         Arc::new(syms)
     }
diff --git a/src/test/run-make-fulldeps/issue-64319/Makefile b/src/test/run-make-fulldeps/issue-64319/Makefile
deleted file mode 100644
index b2c6b8b3cbb..00000000000
--- a/src/test/run-make-fulldeps/issue-64319/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
--include ../tools.mk
-
-# Different optimization levels imply different values for `-Zshare-generics`,
-# so try out a whole bunch of combinations to make sure everything is compatible
-all:
-	# First up, try some defaults
-	$(RUSTC) --crate-type rlib foo.rs
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=3
-
-	# Next try mixing up some things explicitly
-	$(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
-	$(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
-	$(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
-	$(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
-
-	# Now combine a whole bunch of options together
-	$(RUSTC) --crate-type rlib foo.rs
-	$(RUSTC) --crate-type dylib bar.rs
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=1
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=2
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=3
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=s
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=yes
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=z
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=no
-	$(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=yes
diff --git a/src/test/run-make-fulldeps/issue-64319/bar.rs b/src/test/run-make-fulldeps/issue-64319/bar.rs
deleted file mode 100644
index 3895c0b6cdb..00000000000
--- a/src/test/run-make-fulldeps/issue-64319/bar.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-extern crate foo;
-
-pub fn bar() {
-    foo::foo();
-}
diff --git a/src/test/run-make-fulldeps/issue-64319/foo.rs b/src/test/run-make-fulldeps/issue-64319/foo.rs
deleted file mode 100644
index c54a238e9ad..00000000000
--- a/src/test/run-make-fulldeps/issue-64319/foo.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-pub fn foo() {
-    bar::<usize>();
-}
-
-pub fn bar<T>() {
-    baz();
-}
-
-fn baz() {}
diff --git a/src/test/run-make-fulldeps/symbol-visibility/Makefile b/src/test/run-make-fulldeps/symbol-visibility/Makefile
index 840fe801a95..7901866015b 100644
--- a/src/test/run-make-fulldeps/symbol-visibility/Makefile
+++ b/src/test/run-make-fulldeps/symbol-visibility/Makefile
@@ -79,12 +79,12 @@ all:
 	# Check that a Rust dylib exports its monomorphic functions, including generics this time
 	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
 	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
-	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
+	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
 
 	# Check that a Rust dylib exports the monomorphic functions from its dependencies
 	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
 	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
-	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
+	[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
 
 	# Check that an executable does not export any dynamic symbols
 	[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]