Skip to content

TRPL: FFI, "Linking" section: meaning of propagation is unclear #25586

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

Closed
mkpankov opened this issue May 18, 2015 · 0 comments
Closed

TRPL: FFI, "Linking" section: meaning of propagation is unclear #25586

mkpankov opened this issue May 18, 2015 · 0 comments

Comments

@mkpankov
Copy link
Contributor

This is the link
http://doc.rust-lang.org/stable/book/ffi.html

To quote:

The different kind values are meant to differentiate how the native library participates in linkage. From a linkage perspective, the rust compiler creates two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary). Native dynamic libraries and frameworks are propagated to the final artifact boundary, while static libraries are not propagated at all.

A few examples of how this model can be used are:

    A native build dependency. Sometimes some C/C++ glue is needed when writing some rust code, but distribution of the C/C++ code in a library format is just a burden. In this case, the code will be archived into libfoo.a and then the rust crate would declare a dependency via #[link(name = "foo", kind = "static")].

    Regardless of the flavor of output for the crate, the native static library will be included in the output, meaning that distribution of the native static library is not necessary.

    A normal dynamic dependency. Common system libraries (like readline) are available on a large number of systems, and often a static copy of these libraries cannot be found. When this dependency is included in a rust crate, partial targets (like rlibs) will not link to the library, but when the rlib is included in a final target (like a binary), the native library will be linked in.

I understand "propagation" meaning "required linking of this artifact will attach further and further towards the final artifacts".

The top sentence says "static libs are not propagated", but the following explanation (A native build dependency) makes it look like static libs are always propagated, on the contrary.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 9, 2015
After talking with @graydon on #rust-internals, this is hopefully clarifying.

Fixes rust-lang#25586
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 9, 2015
After talking with @graydon on #rust-internals, this is hopefully clarifying.

Fixes rust-lang#25586

@mkpankov, what do you think?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants