diff options
| author | bors <bors@rust-lang.org> | 2021-12-12 17:28:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-12 17:28:52 +0000 |
| commit | 6bda5b331cfe7e04e1fe348c58a928fc2b650f4f (patch) | |
| tree | fa337d4fa5d7143dfe8fc6aed1b3c77fd287af74 /src/test | |
| parent | 753e569c9c2a4e3ef394ef7abd0802bf57f66bce (diff) | |
| parent | 923f939791a08d3f58566b0fc755381de031f43e (diff) | |
Auto merge of #90716 - euclio:libloading, r=cjgillot
replace dynamic library module with libloading This PR deletes the `rustc_metadata::dynamic_lib` module in favor of the popular and better tested [`libloading` crate](https://github.com/nagisa/rust_libloading/). We don't benefit from `libloading`'s symbol lifetimes since we end up leaking the loaded library in all cases, but the call-sites look much nicer by improving error handling and abstracting away some transmutes. We also can remove `rustc_metadata`'s direct dependencies on `libc` and `winapi`. This PR also adds an exception for `libloading` (and its license) to tidy, so this will need sign-off from the compiler team.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-make-fulldeps/extern-fn-reachable/Makefile | 20 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/extern-fn-reachable/main.rs | 18 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/Makefile b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile index 79a9a3c640f..9231a2b3574 100644 --- a/src/test/run-make-fulldeps/extern-fn-reachable/Makefile +++ b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile @@ -1,9 +1,25 @@ -include ../tools.mk +# ignore-windows-msvc + +NM=nm -D + +ifeq ($(UNAME),Darwin) +NM=nm -gU +endif + +ifdef IS_WINDOWS +NM=nm -g +endif + # This overrides the LD_LIBRARY_PATH for RUN TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) all: $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic - $(RUSTC) main.rs -C prefer-dynamic - $(call RUN,main) + + [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun1)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun2)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun3)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun4)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun5)" -eq "1" ] diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/main.rs b/src/test/run-make-fulldeps/extern-fn-reachable/main.rs deleted file mode 100644 index c1de6477585..00000000000 --- a/src/test/run-make-fulldeps/extern-fn-reachable/main.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(rustc_private)] - -extern crate rustc_metadata; - -use rustc_metadata::dynamic_lib::DynamicLibrary; -use std::path::Path; - -pub fn main() { - unsafe { - let path = Path::new("libdylib.so"); - let a = DynamicLibrary::open(&path).unwrap(); - assert!(a.symbol::<isize>("fun1").is_ok()); - assert!(a.symbol::<isize>("fun2").is_ok()); - assert!(a.symbol::<isize>("fun3").is_ok()); - assert!(a.symbol::<isize>("fun4").is_ok()); - assert!(a.symbol::<isize>("fun5").is_ok()); - } -} |
