about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-03-03 22:45:58 +0000
committerbors <bors@rust-lang.org>2023-03-03 22:45:58 +0000
commit70adb4e5b4c8f8bde4ade0edcb0435ff7bf31281 (patch)
treeb80e2d5c0f5cd3c5e90d193fde662e1b400fbcdd /src/doc
parent44cfafe2fafe816395d3acc434663a45d5178c41 (diff)
parent7a228ce9a64e20804b60c89b561ef97507425d95 (diff)
downloadrust-70adb4e5b4c8f8bde4ade0edcb0435ff7bf31281.tar.gz
rust-70adb4e5b4c8f8bde4ade0edcb0435ff7bf31281.zip
Auto merge of #108709 - matthiaskrgr:rollup-j2tjbyx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104549 (add -Zexport-executable-symbols to unstable book)
 - #108292 (Label opaque type for 'captures lifetime' error message)
 - #108540 (Add `Atomic*::from_ptr`)
 - #108634 (Add link to component dashboard)
 - #108647 (Remove dead pgo.sh file)
 - #108678 (Use `Option::as_slice` where applicable)
 - #108681 (Improve comments in `needs_process_obligation`.)
 - #108688 (Match unmatched backticks in library/)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/rustc/src/platform-support.md2
-rw-r--r--src/doc/unstable-book/src/compiler-flags/export-executable-symbols.md43
2 files changed, 45 insertions, 0 deletions
diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md
index b2ce2bd529b..9eafa27e2b7 100644
--- a/src/doc/rustc/src/platform-support.md
+++ b/src/doc/rustc/src/platform-support.md
@@ -13,6 +13,8 @@ for targets at each tier, see the [Target Tier Policy](target-tier-policy.md).
 Targets are identified by their "target triple" which is the string to inform
 the compiler what kind of output should be produced.
 
+Component availability is tracked [here](https://rust-lang.github.io/rustup-components-history/).
+
 ## Tier 1 with Host Tools
 
 Tier 1 targets can be thought of as "guaranteed to work". The Rust project
diff --git a/src/doc/unstable-book/src/compiler-flags/export-executable-symbols.md b/src/doc/unstable-book/src/compiler-flags/export-executable-symbols.md
new file mode 100644
index 00000000000..c7f10afaccc
--- /dev/null
+++ b/src/doc/unstable-book/src/compiler-flags/export-executable-symbols.md
@@ -0,0 +1,43 @@
+# `export-executable-symbols`
+
+The tracking issue for this feature is: [#84161](https://github.com/rust-lang/rust/issues/84161).
+
+------------------------
+
+The `-Zexport-executable-symbols` compiler flag makes `rustc` export symbols from executables. The resulting binary is runnable, but can also be used as a dynamic library. This is useful for interoperating with programs written in other languages, in particular languages with a runtime like Java or Lua.
+
+For example on windows:
+```rust
+#[no_mangle]
+fn my_function() -> usize {
+    return 42;
+}
+
+fn main() {
+    println!("Hello, world!");
+}
+```
+
+A standard `cargo build` will produce a `.exe` without an export directory. When the `export-executable-symbols` flag is added
+
+```Bash
+export RUSTFLAGS="-Zexport-executable-symbols"
+cargo build
+```
+
+the binary has an export directory with the functions:
+
+```plain
+The Export Tables (interpreted .edata section contents)
+
+...
+
+[Ordinal/Name Pointer] Table
+    [   0] my_function
+    [   1] main
+```
+(the output of `objdump -x` on the binary)
+
+Please note that the `#[no_mangle]` attribute is required. Without it, the symbol is not exported.
+
+The equivalent of this flag in C and C++ compilers is the `__declspec(dllexport)` annotation or the `-rdynamic` linker flag.