diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-03-21 16:54:53 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-04-04 21:54:59 -0700 |
| commit | 9c462b84c8e15c3b33229a2604b273fc58acf60a (patch) | |
| tree | c6684ad6b089132ba4ec37c1bca7d6a7e738d30f /src/libstd/sys/unix/weak.rs | |
| parent | 3ec71b033a81f2a7d7c24db265d1e1c2c437339a (diff) | |
| download | rust-9c462b84c8e15c3b33229a2604b273fc58acf60a.tar.gz rust-9c462b84c8e15c3b33229a2604b273fc58acf60a.zip | |
std: Fix linking against `signal` on Android
Currently the minimum supported Android version of the standard library is API level 18 (android-18). Back in those days [1] the `signal` function was just an inline wrapper around `bsd_signal`, but starting in API level android-20 the `signal` symbols was introduced [2]. Finally, in android-21 the API `bsd_signal` was removed [3]. Basically this means that if we want to be binary compatible with multiple Android releases (oldest being 18 and newest being 21) then we need to check for both symbols and not actually link against either. This was first discovered in rust-lang/libc#236 with a fix proposed in rust-lang/libc#237. I suspect that we'll want to accept rust-lang/libc#237 so Rust crates at large continue to be compatible with newer releases of Android and crates, like the standard library, that want to opt into older support can continue to do so via similar means. Closes rust-lang/libc#236 [1]: https://chromium.googlesource.com/android_tools/+/20ee6d20/ndk/platforms/android-18/arch-arm/usr/include/signal.h [2]: https://chromium.googlesource.com/android_tools/+/fbd420/ndk_experimental/platforms/android-20/arch-arm/usr/include/signal.h [3]: https://chromium.googlesource.com/android_tools/+/20ee6d/ndk/platforms/android-21/arch-arm/usr/include/signal.h
Diffstat (limited to 'src/libstd/sys/unix/weak.rs')
| -rw-r--r-- | src/libstd/sys/unix/weak.rs | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/libstd/sys/unix/weak.rs b/src/libstd/sys/unix/weak.rs index e6f85c08d12..99ab8741159 100644 --- a/src/libstd/sys/unix/weak.rs +++ b/src/libstd/sys/unix/weak.rs @@ -75,11 +75,5 @@ unsafe fn fetch(name: &str) -> usize { Ok(cstr) => cstr, Err(..) => return 0, }; - let lib = libc::dlopen(0 as *const _, libc::RTLD_LAZY); - if lib.is_null() { - return 0 - } - let ret = libc::dlsym(lib, name.as_ptr()) as usize; - libc::dlclose(lib); - return ret + libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr()) as usize } |
