Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for std::dynamic_lib #27810

Closed
alexcrichton opened this issue Aug 13, 2015 · 13 comments · Fixed by #29254
Closed

Tracking issue for std::dynamic_lib #27810

alexcrichton opened this issue Aug 13, 2015 · 13 comments · Fixed by #29254
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Milestone

Comments

@alexcrichton
Copy link
Member

This is a tracking issue for the unstable dynamic_lib feature of the standard library. This module should probably just be made private to the standard library and the compiler rather than being exported for now. A future RFC could decide whether it should be a module in the standard library or not.

@alexcrichton alexcrichton added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. B-unstable Blocker: Implemented in the nightly compiler and unstable. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 13, 2015
@nagisa
Copy link
Member

nagisa commented Aug 13, 2015

dlopen bindings in some form is a very useful thing to have, but I personally care little whether it is stabilised in stdlib or moved out into an external crate.

@alexcrichton
Copy link
Member Author

Yeah if we remove from the standard library I'd definitely at least want an external crate with this functionality. That being said the standard library does indeed use this as an implementation detail for various aspects, so that may be a good indicator that it should be in libstd to begin with.

@nagisa
Copy link
Member

nagisa commented Aug 14, 2015

I so far found a several problems with the API exposed currently:

Some of the exposed methods are not cross-platform or might not do what’s intended. Most notably the methods dealing with search pathes… On Windows it doesn’t use AddDllDirectory/SetDllDirectory and manipulates environment instead. Man pages claim that on unix LD_LIBRARY_PATH may not be accounted for in some reasons and as far as I interpret the text (didn’t test, though) only the value of the variable as it was during process initialisation is used.

dlsym returns *mut void, and GetProcAddress returns FARPROC. *mut void is a regular pointer and FARPROC is a function pointer. While POSIX-compiliance requires *mut T and function pointers be interchangeable, I couldn’t find anything of a sort for Windows. That is, on POSIX-compiliant systems you can dlsym functions and statics and whatnot, while on Windows only function pointers can be safely retrieved.

Publicly exposed create_path and envvar methods make no sense. Instead of &Path, P: AsRef<Path> should be taken and symbols are not utf-8 therefore &str in symbol is a no-go.

Finally, I feel like there should be a simple way to prevent using symbols after the library is dropped, by e.g. returning &'library mut T? I’m experimenting with that.

@durka
Copy link
Contributor

durka commented Aug 31, 2015

FWIW there is a crate which is just a copy of the unstable API from libstd, and if the crates.io download count is to be believed it has rather widespread usage.

@sfackler
Copy link
Member

It seems like we should probably be deprecating and removing the in-tree version of this. The API's pretty bad right now and improvements should probably be prototyped out of tree.

@nagisa
Copy link
Member

nagisa commented Sep 17, 2015

I’m experimenting with various options on my free time: libloading

@alexcrichton
Copy link
Member Author

This issue is now entering its cycle-long FCP for deprecation in 1.5

@alexcrichton alexcrichton added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed I-nominated labels Sep 24, 2015
@diwic
Copy link
Contributor

diwic commented Sep 25, 2015

There is also the shared_library crate.

Would be good to offer an recommended alternative in the compiler message.

@durka
Copy link
Contributor

durka commented Sep 25, 2015

Really seems like a systems language should have this in std. (I realize we
need to experiment to find the right API.)
On Sep 25, 2015 3:28 AM, "diwic" notifications@github.com wrote:

There is also the shared_library https://crates.io/crates/shared_library
crate.

Would be good to offer an recommended alternative in the compiler message.


Reply to this email directly or view it on GitHub
#27810 (comment).

@steveklabnik steveklabnik added this to the 1.5 milestone Oct 1, 2015
@Manishearth Manishearth removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Oct 2, 2015
@retep998
Copy link
Member

While POSIX-compiliance requires *mut T and function pointers be interchangeable, I couldn’t find anything of a sort for Windows. That is, on POSIX-compiliant systems you can dlsym functions and statics and whatnot, while on Windows only function pointers can be safely retrieved.

For Win32 and Win64, all normal pointers are interchangeable, so both function and data pointers can be retrieved fine. Far and near only mattered in the times of Win16.

@alexcrichton
Copy link
Member Author

The libs team discussed this today and the decision was to deprecate.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 25, 2015
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:

Stabilized APIs:

* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
   is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
  but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`

Deprecated APIs

* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`

Closes rust-lang#27706
Closes rust-lang#27725
cc rust-lang#27726 (align not stabilized yet)
Closes rust-lang#27734
Closes rust-lang#27737
Closes rust-lang#27742
Closes rust-lang#27743
Closes rust-lang#27772
Closes rust-lang#27774
Closes rust-lang#27777
Closes rust-lang#27781
cc rust-lang#27788 (a few remaining methods though)
Closes rust-lang#27790
Closes rust-lang#27793
Closes rust-lang#27796
Closes rust-lang#27810
cc rust-lang#28147 (not all parts stabilized)
bors added a commit that referenced this issue Oct 25, 2015
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:

Stabilized APIs:

* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
   is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
  but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`

Deprecated APIs

* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`

Closes #27706
Closes #27725
cc #27726 (align not stabilized yet)
Closes #27734
Closes #27737
Closes #27742
Closes #27743
Closes #27772
Closes #27774
Closes #27777
Closes #27781
cc #27788 (a few remaining methods though)
Closes #27790
Closes #27793
Closes #27796
Closes #27810
cc #28147 (not all parts stabilized)
@perlun
Copy link

perlun commented Jan 21, 2019

For reference - std::dynamic_lib seems to be officially gone now; at least, its documentation which was originally available here is gone. Just for the sake of completeness, does anyone know in which Rust version it was dropped? (Or if it isn't, where are the docs now?)

@sfackler
Copy link
Member

It was deprecated in 1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants