about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2024-12-18 22:03:07 +0100
committerFolkert de Vries <folkert@folkertdev.nl>2025-01-10 22:53:54 +0100
commit47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd (patch)
treebe340fec403359a7cfcc5cb06b61f555e7b0788b /src
parenta52085d9f6a6e596b0cbad4502cddf86bc878028 (diff)
downloadrust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.tar.gz
rust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.zip
add `-Zmin-function-alignment`
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/compiler-flags/min-function-alignment.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/min-function-alignment.md b/src/doc/unstable-book/src/compiler-flags/min-function-alignment.md
new file mode 100644
index 00000000000..b7a3aa71fc4
--- /dev/null
+++ b/src/doc/unstable-book/src/compiler-flags/min-function-alignment.md
@@ -0,0 +1,24 @@
+# `min-function-alignment`
+
+The tracking issue for this feature is: https://github.com/rust-lang/rust/issues/82232.
+
+------------------------
+
+The `-Zmin-function-alignment=<align>` flag specifies the minimum alignment of functions for which code is generated.
+The `align` value must be a power of 2, other values are rejected.
+
+Note that `-Zbuild-std` (or similar) is required to apply this minimum alignment to standard library functions.
+By default, these functions come precompiled and their alignments won't respect the `min-function-alignment` flag.
+
+This flag is equivalent to:
+
+- `-fmin-function-alignment` for [GCC](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fmin-function-alignment_003dn)
+- `-falign-functions` for [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-falign-functions)
+
+The specified alignment is a minimum. A higher alignment can be specified for specific functions by using the [`repr(align(...))`](https://github.com/rust-lang/rust/issues/82232) feature and annotating the function with a `#[repr(align(<align>))]` attribute. The attribute's value is ignored when it is lower than the value passed to `min-function-alignment`.
+
+There are two additional edge cases for this flag:
+
+- targets have a minimum alignment for functions (e.g. on x86_64 the lowest that LLVM generates is 16 bytes).
+    A `min-function-alignment` value lower than the target's minimum has no effect.
+- the maximum alignment supported by rust (and LLVM) is `2^29`. Trying to set a higher value results in an error.