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

Add docs for raw-dylib to unstable book #87315

Merged
merged 3 commits into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/doc/unstable-book/src/language-features/raw-dylib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# `raw_dylib`

The tracking issue for this feature is: [#58713]

[#58713]: https://github.com/rust-lang/rust/issues/58713

------------------------

The `raw_dylib` feature allows you to link against the implementations of functions in an `extern`
block without, on Windows, linking against an import library.

```rust,ignore (partial-example)
#![feature(raw_dylib)]

#[link(name="library", kind="raw-dylib")]
extern {
fn extern_function(x: i32);
}

fn main() {
unsafe {
extern_function(14);
}
}
```

## Limitations

Currently, this feature is only supported on `-windows-msvc` targets. Non-Windows platforms don't have import
libraries, and an incompatibility between LLVM and the BFD linker means that it is not currently supported on
`-windows-gnu` targets.

On the `i686-pc-windows-msvc` target, this feature supports only the `cdecl`, `stdcall`, `system`, and `fastcall`
calling conventions.