mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
008be2d7b6
This ensures that rustc will not attempt to link against a cdylib as if it is a rust dylib when an rlib for the same crate is available. Previously rustc didn't actually check if any further formats of a crate which has been loaded are of the same version and if they are actually valid. This caused a cdylib to be interpreted as rust dylib as soon as the corresponding rlib was loaded. As cdylibs don't export any rust symbols, linking would fail if rustc decides to link against the cdylib rather than the rlib. Two crates depended on the previous behavior by separately compiling a test crate as both rlib and dylib. These have been changed to capture their original spirit to the best of my ability while still working when rustc verifies that all crates are in sync. It is unlikely that build systems depend on the current behavior and in any case we are taking a lot of measures to ensure that any change to either the source or the compilation options (including crate type) results in rustc rejecting it as incompatible. We merely didn't do this check here for now obsolete perf reasons.
9 lines
351 B
Makefile
9 lines
351 B
Makefile
# ignore-cross-compile
|
|
include ../tools.mk
|
|
|
|
all:
|
|
$(RUSTC) rlib.rs --crate-type=rlib --crate-type=dylib
|
|
$(RUSTC) dylib.rs # no -Cprefer-dynamic so statically linking librlib.rlib
|
|
$(call REMOVE_DYLIBS,rlib) # remove librlib.so to test that prog.rs doesn't get confused about the removed dylib version of librlib
|
|
$(RUSTC) prog.rs && exit 1 || exit 0
|