diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-10-29 08:55:03 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-10-29 08:55:03 +0000 |
commit | d103c523469020573e7b5c4644a6e3e33619fdbd (patch) | |
tree | 0e329db1f6f731cc3567a90272fc2103411624de | |
parent | ea53d82652020ae4f56b2ab08649eb60509ed5e9 (diff) | |
parent | 62a02e767109ba97176b5e67175c4990cbed7bc1 (diff) | |
download | libloading-d103c523469020573e7b5c4644a6e3e33619fdbd.tar.gz |
Upgrade rust/crates/libloading to 0.6.5 am: 62a02e7671
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/libloading/+/1475561
Change-Id: I2a0aba1003564181c9b11e9b390508a03415271f
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/libloading.yml | 8 | ||||
-rw-r--r-- | Android.bp | 9 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | Cargo.toml.orig | 5 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | build.rs | 70 | ||||
-rw-r--r-- | src/changelog.rs | 12 | ||||
-rw-r--r-- | src/os/unix/consts.rs | 4 | ||||
-rw-r--r-- | src/os/unix/mod.rs | 25 | ||||
-rw-r--r-- | tests/functions.rs | 25 |
11 files changed, 64 insertions, 109 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index a289ae4..358bf1b 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "21c7cdb08ffc38ceb0b0f9e7038f88548c2ade94" + "sha1": "4ad1af8ae9d577562e5dc1280f222713a17e8cf2" } } diff --git a/.github/workflows/libloading.yml b/.github/workflows/libloading.yml index d315445..aa9b3f6 100644 --- a/.github/workflows/libloading.yml +++ b/.github/workflows/libloading.yml @@ -71,13 +71,15 @@ jobs: steps: - uses: actions/checkout@v2 - name: Add MSYS2 to the PATH - run: echo "::add-path::c:/msys64/bin" + run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append - name: Add 32-bit mingw-w64 to the PATH - run: echo "::add-path::c:/msys64/mingw32/bin" + run: echo "c:/msys64/mingw32/bin" | Out-File -FilePath $env:GITHUB_PATH -Append if: startsWith(matrix.rust_target, 'i686') - name: Add 64-bit mingw-w64 to the PATH - run: echo "::add-path::c:/msys64/mingw64/bin" + run: echo "c:/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append if: startsWith(matrix.rust_target, 'x86_64') + - name: Set TARGET variable + run: echo "TARGET=${{ matrix.rust_target}}" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install Rust nightly uses: actions-rs/toolchain@v1 with: @@ -5,17 +5,10 @@ rust_library_host { crate_name: "libloading", srcs: ["src/lib.rs"], edition: "2015", - flags: [ - "--cfg mtsafe_dlerror", - ], rustlibs: [ "libcfg_if", ], - // TODO: Cannot use libdl on Android host? - // shared_libs: [ - // "libdl", - // ], } // dependent_library ["feature_list"] -// cfg-if-0.1.10 +// cfg-if-1.0.0 @@ -12,9 +12,8 @@ [package] name = "libloading" -version = "0.6.3" +version = "0.6.5" authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"] -build = "build.rs" description = "A safer binding to platform’s dynamic library loading utilities" documentation = "https://docs.rs/libloading/" readme = "README.mkd" @@ -31,7 +30,7 @@ version = "0.2" [dev-dependencies.static_assertions] version = "1.1" [target."cfg(unix)".dependencies.cfg-if] -version = "0.1" +version = "1" [target."cfg(windows)".dependencies.winapi] version = "0.3" features = ["winerror", "errhandlingapi", "libloaderapi"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 1dfd507..23324db 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -3,7 +3,7 @@ name = "libloading" # When bumping # * Don’t forget to add an entry to `src/changelog.rs` # * If bumping a incompatible version, adjust documentation in `src/lib.rs` -version = "0.6.3" +version = "0.6.5" authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"] license = "ISC" repository = "https://github.com/nagisa/rust_libloading/" @@ -12,7 +12,6 @@ readme = "README.mkd" description = "A safer binding to platform’s dynamic library loading utilities" keywords = ["dlopen", "load", "shared", "dylib"] categories = ["api-bindings"] -build = "build.rs" [target.'cfg(windows)'.dependencies.winapi] version = "0.3" @@ -23,7 +22,7 @@ features = [ ] [target.'cfg(unix)'.dependencies.cfg-if] -version = "0.1" +version = "1" [dev-dependencies] libc = "0.2" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/libloading/libloading-0.6.3.crate" + value: "https://static.crates.io/crates/libloading/libloading-0.6.5.crate" } - version: "0.6.3" + version: "0.6.5" license_type: NOTICE last_upgrade_date { year: 2020 - month: 8 - day: 24 + month: 10 + day: 26 } } diff --git a/build.rs b/build.rs deleted file mode 100644 index e217f80..0000000 --- a/build.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::io::Write; -use std::env; - -fn dlerror_is_mtsafe(target_os: &str) { - match target_os { - // Confirmed MT-safe: - "linux" - | "android" - | "openbsd" - | "macos" - | "ios" - | "solaris" - | "illumos" - | "redox" - | "fuchsia" => { - println!("cargo:rustc-cfg=mtsafe_dlerror"); - } - // Confirmed not MT-safe: - "freebsd" - | "dragonfly" - | "netbsd" - | "bitrig" - | "haiku" => {} - // Unknown: - _ => {} - } -} - -fn link_libraries(target_os: &str) { - match target_os { - "linux" | "android" => println!("cargo:rustc-link-lib=dl"), - "freebsd" | "dragonfly" => println!("cargo:rustc-link-lib=c"), - // netbsd claims dl* will be available to any dynamically linked binary, but I haven’t - // found any libraries that have to be linked to on other platforms. - // What happens if the executable is not linked up dynamically? - "openbsd" | "bitrig" | "netbsd" | "macos" | "ios" => {} - "solaris" | "illumos" => {} - "haiku" => {} - "redox" => {} - "fuchsia" => {} - // dependencies come with winapi - "windows" => {} - tos => { - writeln!(::std::io::stderr(), - "Building for an unknown target_os=`{:?}`!\nPlease report an issue ", - tos).expect("could not report the error"); - ::std::process::exit(0xfc); - } - } -} - -fn main() { - match env::var("CARGO_CFG_TARGET_OS") { - Ok(target_os) => { - dlerror_is_mtsafe(&target_os); - link_libraries(&target_os); - } - Err(e) => { - writeln!(::std::io::stderr(), - "Unable to get target_os=`{}`!", e).expect("could not report the error"); - ::std::process::exit(0xfd); - } - } - - // For tests - println!( - "cargo:rustc-env=LIBLOADING_TEST_TARGET={}", - std::env::var("TARGET").expect("$TARGET is not set") - ); -} diff --git a/src/changelog.rs b/src/changelog.rs index 01c25ec..7d058b8 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -3,6 +3,17 @@ // TODO: for the next breaking release rename `Error::LoadLibraryW` to `Error::LoadLibraryExW`. // TODO: for the next breaking release use `RTLD_LAZY | RTLD_LOCAL` by default on unix. +/// Release 0.6.5 (2020-10-23) +/// +/// * Upgrade cfg-if 0.1 to 1.0 +pub mod r0_6_5 {} + +/// Release 0.6.4 (2020-10-10) +/// +/// * Remove use of `build.rs` making it easier to build `libloading` without cargo. It also +/// almost halves the build time of this crate. +pub mod r0_6_4 {} + /// Release 0.6.3 (2020-08-22) /// /// * Improve documentation, allowing to view all of the os-specific functionality from @@ -13,6 +24,7 @@ /// /// [`os::windows::Library::this`]: crate::os::windows::Library::this /// [`library_filename`]: crate::library_filename +pub mod r0_6_3 {} /// Release 0.6.2 (2020-05-06) /// diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs index 823155e..2c18f95 100644 --- a/src/os/unix/consts.rs +++ b/src/os/unix/consts.rs @@ -43,7 +43,7 @@ pub const RTLD_GLOBAL: c_int = posix::RTLD_GLOBAL; /// any other executable object file. This mode of operation is most appropriate for e.g. plugins. pub const RTLD_LOCAL: c_int = posix::RTLD_LOCAL; -#[cfg(docsrs)] +#[cfg(all(docsrs, not(unix)))] mod posix { use super::c_int; pub(super) const RTLD_LAZY: c_int = !0; @@ -52,7 +52,7 @@ mod posix { pub(super) const RTLD_LOCAL: c_int = !0; } -#[cfg(not(docsrs))] +#[cfg(any(not(docsrs), unix))] mod posix { extern crate cfg_if; use self::cfg_if::cfg_if; diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index 785c58f..71d2c5f 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -220,10 +220,25 @@ impl Library { /// care about, consider using the [`Library::get_singlethreaded`] call. #[inline(always)] pub unsafe fn get<T>(&self, symbol: &[u8]) -> Result<Symbol<T>, crate::Error> { - #[cfg(mtsafe_dlerror)] - { self.get_singlethreaded(symbol) } - #[cfg(not(mtsafe_dlerror))] - { self.get_impl(symbol, || Err(crate::Error::DlSymUnknown)) } + extern crate cfg_if; + cfg_if::cfg_if! { + // These targets are known to have MT-safe `dlerror`. + if #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "openbsd", + target_os = "macos", + target_os = "ios", + target_os = "solaris", + target_os = "illumos", + target_os = "redox", + target_os = "fuchsia" + ))] { + self.get_singlethreaded(symbol) + } else { + self.get_impl(symbol, || Err(crate::Error::DlSymUnknown)) + } + } } /// Get a pointer to function or static variable by symbol name. @@ -387,6 +402,8 @@ impl<T> fmt::Debug for Symbol<T> { } // Platform specific things +#[cfg_attr(any(target_os = "linux", target_os = "android"), link(name="dl"))] +#[cfg_attr(any(target_os = "freebsd", target_os = "dragonfly"), link(name="c"))] extern { fn dlopen(filename: *const raw::c_char, flags: raw::c_int) -> *mut raw::c_void; fn dlclose(handle: *mut raw::c_void) -> raw::c_int; diff --git a/tests/functions.rs b/tests/functions.rs index b642478..20ac3c1 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -4,24 +4,27 @@ extern crate winapi; extern crate libloading; use libloading::{Symbol, Library}; -const LIBPATH: &'static str = concat!(env!("OUT_DIR"), "/libtest_helpers.module"); +const LIBPATH: &'static str = "target/libtest_helpers.module"; fn make_helpers() { static ONCE: ::std::sync::Once = ::std::sync::Once::new(); ONCE.call_once(|| { - let rustc = option_env!("RUSTC").unwrap_or_else(|| { "rustc".into() }); + let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| { "rustc".into() }); let mut cmd = ::std::process::Command::new(rustc); cmd .arg("src/test_helpers.rs") .arg("-o") - .arg(LIBPATH) - .arg("--target") - .arg(env!("LIBLOADING_TEST_TARGET")) - .arg("-O"); - - cmd - .output() - .expect("could not compile the test helpers!"); + .arg(LIBPATH); + if let Some(target) = std::env::var_os("TARGET") { + cmd.arg("--target").arg(target); + } else { + eprintln!("WARNING: $TARGET NOT SPECIFIED! BUILDING HELPER MODULE FOR NATIVE TARGET."); + } + assert!(cmd + .status() + .expect("could not compile the test helpers!") + .success() + ); }); } @@ -67,7 +70,7 @@ fn test_0_no_0() { #[test] fn wrong_name_fails() { - Library::new(concat!(env!("OUT_DIR"), "/libtest_help")).err().unwrap(); + Library::new("target/this_location_is_definitely_non existent:^~").err().unwrap(); } #[test] |