-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix ABI string docs in reference.md #34461
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1631,14 +1631,43 @@ the Rust ABI and the foreign ABI. | |
A number of [attributes](#ffi-attributes) control the behavior of external blocks. | ||
|
||
By default external blocks assume that the library they are calling uses the | ||
standard C "cdecl" ABI. Other ABIs may be specified using an `abi` string, as | ||
shown here: | ||
standard C ABI on the specific platform. Other ABIs may be specified using an | ||
`abi` string, as shown here: | ||
|
||
```ignore | ||
// Interface to the Windows API | ||
extern "stdcall" { } | ||
``` | ||
|
||
There are three ABI strings which are cross-platform, and which all compilers | ||
are guaranteed to support: | ||
|
||
* `extern "Rust"` -- The default ABI when you write a normal `fn foo()` in any | ||
Rust code. | ||
* `extern "C"` -- This is the same as `extern fn foo()`; whatever the default | ||
your C compiler supports. | ||
* `extern "system"` -- Usually the same as `extern "C"`, except on Win32, in | ||
which case it's `"stdcall"`, or what you should use to link to the Windows API | ||
itself | ||
|
||
There are also some platform-specific ABI strings: | ||
|
||
* `extern "cdecl"` -- The default for x86\_32 C code. | ||
* `extern "stdcall"` -- The default for the Win32 API on x86\_32. | ||
* `extern "win64"` -- The default for C code on x86\_64 Windows. | ||
* `extern "aapcs"` -- The default for ARM. | ||
* `extern "fastcall"` -- The `fastcall` ABI -- corresponds to MSVC's | ||
`__fastcall` and GCC and clang's `__attribute__((fastcall))` | ||
* `extern "vectorcall"` -- The `vectorcall` ABI -- corresponds to MSVC's | ||
`__vectorcall` and clang's `__attribute__((vectorcall))` | ||
|
||
Finally, there are some rustc-specific ABI strings: | ||
|
||
* `extern "rust-intrinsic"` -- The ABI of rustc intrinsics. | ||
* `extern "rust-call"` -- The ABI of the Fn::call trait functions. | ||
* `extern "platform-intrinsic"` -- Specific platform intrinsics -- like, for | ||
example, `sqrt` -- have this ABI. You should never have to deal with it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
The `link` attribute allows the name of the library to be specified. When | ||
specified the compiler will attempt to link against the native library of the | ||
specified name. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the fact that there are no other rust compilers, it seems like we should just say "which are cross-platform". This wording suggests that other compilers exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They do? They're not finished, but they exist. (mrustc, grustc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrustc is the main one I know of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikomatsakis and the rest of @rust-lang/lang , are we comfortable saying that all compilers are guaranteed to support this? It feels like a strange thing to "guarantee".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a requirement, not a guarantee - i.e., "which all compilers must support:"