Skip to content

Commit 48fda61

Browse files
authored
Rollup merge of rust-lang#34461 - ubsan:master, r=steveklabnik
Fix ABI string docs in reference.md
2 parents 9316ae5 + 1e899fd commit 48fda61

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/doc/reference.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,14 +1653,43 @@ the Rust ABI and the foreign ABI.
16531653
A number of [attributes](#ffi-attributes) control the behavior of external blocks.
16541654

16551655
By default external blocks assume that the library they are calling uses the
1656-
standard C "cdecl" ABI. Other ABIs may be specified using an `abi` string, as
1657-
shown here:
1656+
standard C ABI on the specific platform. Other ABIs may be specified using an
1657+
`abi` string, as shown here:
16581658

16591659
```ignore
16601660
// Interface to the Windows API
16611661
extern "stdcall" { }
16621662
```
16631663

1664+
There are three ABI strings which are cross-platform, and which all compilers
1665+
are guaranteed to support:
1666+
1667+
* `extern "Rust"` -- The default ABI when you write a normal `fn foo()` in any
1668+
Rust code.
1669+
* `extern "C"` -- This is the same as `extern fn foo()`; whatever the default
1670+
your C compiler supports.
1671+
* `extern "system"` -- Usually the same as `extern "C"`, except on Win32, in
1672+
which case it's `"stdcall"`, or what you should use to link to the Windows API
1673+
itself
1674+
1675+
There are also some platform-specific ABI strings:
1676+
1677+
* `extern "cdecl"` -- The default for x86\_32 C code.
1678+
* `extern "stdcall"` -- The default for the Win32 API on x86\_32.
1679+
* `extern "win64"` -- The default for C code on x86\_64 Windows.
1680+
* `extern "aapcs"` -- The default for ARM.
1681+
* `extern "fastcall"` -- The `fastcall` ABI -- corresponds to MSVC's
1682+
`__fastcall` and GCC and clang's `__attribute__((fastcall))`
1683+
* `extern "vectorcall"` -- The `vectorcall` ABI -- corresponds to MSVC's
1684+
`__vectorcall` and clang's `__attribute__((vectorcall))`
1685+
1686+
Finally, there are some rustc-specific ABI strings:
1687+
1688+
* `extern "rust-intrinsic"` -- The ABI of rustc intrinsics.
1689+
* `extern "rust-call"` -- The ABI of the Fn::call trait functions.
1690+
* `extern "platform-intrinsic"` -- Specific platform intrinsics -- like, for
1691+
example, `sqrt` -- have this ABI. You should never have to deal with it.
1692+
16641693
The `link` attribute allows the name of the library to be specified. When
16651694
specified the compiler will attempt to link against the native library of the
16661695
specified name.

0 commit comments

Comments
 (0)