about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-05-06 13:30:51 +0200
committerGitHub <noreply@github.com>2021-05-06 13:30:51 +0200
commit5dcdeb81e16c9debbf142f8e31d635b0c1149255 (patch)
tree63da563f51628bed1ffe0642538edb2f781d59a1 /src/doc
parent1d99508b52499c9efd213738e71927458c1d394e (diff)
parentdb555e1284dd37f4f3c76474aabfca09140a7ab3 (diff)
downloadrust-5dcdeb81e16c9debbf142f8e31d635b0c1149255.tar.gz
rust-5dcdeb81e16c9debbf142f8e31d635b0c1149255.zip
Rollup merge of #83507 - luqmana:native-link-modifiers, r=petrochenkov
Implement RFC 2951: Native link modifiers

A first attempt at implementing https://github.com/rust-lang/rfcs/pull/2951 / https://github.com/rust-lang/compiler-team/issues/356.

Tracking Issue: https://github.com/rust-lang/rust/issues/81490

Introduces feature flags for the general syntax (`native_link_modifiers`) and each modifier (`native_link_modifiers_{as_needed,bundle,verbatim,whole_archive}`).

r? `@petrochenkov`
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/native-link-modifiers-as-needed.md18
-rw-r--r--src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md19
-rw-r--r--src/doc/unstable-book/src/language-features/native-link-modifiers-verbatim.md20
-rw-r--r--src/doc/unstable-book/src/language-features/native-link-modifiers-whole-archive.md18
-rw-r--r--src/doc/unstable-book/src/language-features/native-link-modifiers.md11
5 files changed, 86 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers-as-needed.md b/src/doc/unstable-book/src/language-features/native-link-modifiers-as-needed.md
new file mode 100644
index 00000000000..1757673612c
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/native-link-modifiers-as-needed.md
@@ -0,0 +1,18 @@
+# `native_link_modifiers_as_needed`
+
+The tracking issue for this feature is: [#81490]
+
+[#81490]: https://github.com/rust-lang/rust/issues/81490
+
+------------------------
+
+The `native_link_modifiers_as_needed` feature allows you to use the `as-needed` modifier.
+
+`as-needed` is only compatible with the `dynamic` and `framework` linking kinds. Using any other kind will result in a compiler error.
+
+`+as-needed` means that the library will be actually linked only if it satisfies some undefined symbols at the point at which it is specified on the command line, making it similar to static libraries in this regard.
+
+This modifier translates to `--as-needed` for ld-like linkers, and to `-dead_strip_dylibs` / `-needed_library` / `-needed_framework` for ld64.
+The modifier does nothing for linkers that don't support it (e.g. `link.exe`).
+
+The default for this modifier is unclear, some targets currently specify it as `+as-needed`, some do not. We may want to try making `+as-needed` a default for all targets.
diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md b/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md
new file mode 100644
index 00000000000..ac192cff13a
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md
@@ -0,0 +1,19 @@
+# `native_link_modifiers_bundle`
+
+The tracking issue for this feature is: [#81490]
+
+[#81490]: https://github.com/rust-lang/rust/issues/81490
+
+------------------------
+
+The `native_link_modifiers_bundle` feature allows you to use the `bundle` modifier.
+
+Only compatible with the `static` linking kind. Using any other kind will result in a compiler error.
+
+`+bundle` means objects from the static library are bundled into the produced crate (a rlib, for example) and are used from this crate later during linking of the final binary.
+
+`-bundle` means the static library is included into the produced rlib "by name" and object files from it are included only during linking of the final binary, the file search by that name is also performed during final linking.
+
+This modifier is supposed to supersede the `static-nobundle` linking kind defined by [RFC 1717](https://github.com/rust-lang/rfcs/pull/1717).
+
+The default for this modifier is currently `+bundle`, but it could be changed later on some future edition boundary.
diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers-verbatim.md b/src/doc/unstable-book/src/language-features/native-link-modifiers-verbatim.md
new file mode 100644
index 00000000000..02bd87e5095
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/native-link-modifiers-verbatim.md
@@ -0,0 +1,20 @@
+# `native_link_modifiers_verbatim`
+
+The tracking issue for this feature is: [#81490]
+
+[#81490]: https://github.com/rust-lang/rust/issues/81490
+
+------------------------
+
+The `native_link_modifiers_verbatim` feature allows you to use the `verbatim` modifier.
+
+`+verbatim` means that rustc itself won't add any target-specified library prefixes or suffixes (like `lib` or `.a`) to the library name, and will try its best to ask for the same thing from the linker.
+
+For `ld`-like linkers rustc will use the `-l:filename` syntax (note the colon) when passing the library, so the linker won't add any prefixes or suffixes as well.
+See [`-l namespec`](https://sourceware.org/binutils/docs/ld/Options.html) in ld documentation for more details.
+For linkers not supporting any verbatim modifiers (e.g. `link.exe` or `ld64`) the library name will be passed as is.
+
+The default for this modifier is `-verbatim`.
+
+This RFC changes the behavior of `raw-dylib` linking kind specified by [RFC 2627](https://github.com/rust-lang/rfcs/pull/2627). The `.dll` suffix (or other target-specified suffixes for other targets) is now added automatically.
+If your DLL doesn't have the `.dll` suffix, it can be specified with `+verbatim`.
diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers-whole-archive.md b/src/doc/unstable-book/src/language-features/native-link-modifiers-whole-archive.md
new file mode 100644
index 00000000000..4961e88cad1
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/native-link-modifiers-whole-archive.md
@@ -0,0 +1,18 @@
+# `native_link_modifiers_whole_archive`
+
+The tracking issue for this feature is: [#81490]
+
+[#81490]: https://github.com/rust-lang/rust/issues/81490
+
+------------------------
+
+The `native_link_modifiers_whole_archive` feature allows you to use the `whole-archive` modifier.
+
+Only compatible with the `static` linking kind. Using any other kind will result in a compiler error.
+
+`+whole-archive` means that the static library is linked as a whole archive without throwing any object files away.
+
+This modifier translates to `--whole-archive` for `ld`-like linkers, to `/WHOLEARCHIVE` for `link.exe`, and to `-force_load` for `ld64`.
+The modifier does nothing for linkers that don't support it.
+
+The default for this modifier is `-whole-archive`.
diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers.md b/src/doc/unstable-book/src/language-features/native-link-modifiers.md
new file mode 100644
index 00000000000..fc8b5754621
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/native-link-modifiers.md
@@ -0,0 +1,11 @@
+# `native_link_modifiers`
+
+The tracking issue for this feature is: [#81490]
+
+[#81490]: https://github.com/rust-lang/rust/issues/81490
+
+------------------------
+
+The `native_link_modifiers` feature allows you to use the `modifiers` syntax with the `#[link(..)]` attribute.
+
+Modifiers are specified as a comma-delimited string with each modifier prefixed with either a `+` or `-` to indicate that the modifier is enabled or disabled, respectively. The last boolean value specified for a given modifier wins.