about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJamie Cunliffe <Jamie.Cunliffe@arm.com>2021-12-01 15:56:59 +0000
committerJamie Cunliffe <Jamie.Cunliffe@arm.com>2021-12-01 15:56:59 +0000
commit984ca4689dbceea29bbfcf54c4743b45fccf7ad1 (patch)
tree50e979ae7eed117e44f6bce9a82003fe0270f51c /src
parent837cc1687f7c0d35a4e90a2f6bee377b5a2ecfd5 (diff)
downloadrust-984ca4689dbceea29bbfcf54c4743b45fccf7ad1.tar.gz
rust-984ca4689dbceea29bbfcf54c4743b45fccf7ad1.zip
Review comments
- Changed the separator from '+' to ','.
- Moved the branch protection options from -C to -Z.
- Additional test for incorrect branch-protection option.
- Remove LLVM < 12 code.
- Style fixes.

Co-authored-by: James McGregor <james.mcgregor2@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/doc/rustc/src/codegen-options/index.md23
-rw-r--r--src/doc/unstable-book/src/compiler-flags/branch-protection.md18
-rw-r--r--src/test/assembly/aarch64-pointer-auth.rs2
-rw-r--r--src/test/codegen/branch-protection.rs8
-rw-r--r--src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile6
-rw-r--r--src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs1
-rw-r--r--src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.stderr2
7 files changed, 29 insertions, 31 deletions
diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index 484242d86fe..0201b88417a 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -7,29 +7,6 @@ a version of this list for your exact compiler by running `rustc -C help`.
 
 This option is deprecated and does nothing.
 
-## branch-protection
-
-This option lets you enable branch authentication instructions on AArch64.
-This option is ignored for non-AArch64 architectures.
-It takes some combination of the following values, separated by a `+`.
-
-- `pac-ret` - Enable pointer authentication for non-leaf functions.
-- `leaf` - Enable pointer authentication for all functions, including leaf functions.
-- `b-key` - Sign return addresses with key B, instead of the default key A.
-- `bti` - Enable branch target identification.
-
-`leaf` and `b-key` are only valid if `pac-ret` was previously specified.
-For example, `-C branch-protection=bti+pac-ret+leaf` is valid, but
-`-C branch-protection=bti+leaf+pac-ret` is not.
-
-Repeated values are ignored.
-For example, `-C branch-protection=pac-ret+leaf+pac-ret` is equivalent to
-`-C branch-protection=pac-ret+leaf`.
-
-Rust's standard library does not ship with BTI or pointer authentication enabled by default. \
-In Cargo projects the standard library can be recompiled with pointer authentication using the nightly
-[build-std](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std) feature.
-
 ## code-model
 
 This option lets you choose which code model to use. \
diff --git a/src/doc/unstable-book/src/compiler-flags/branch-protection.md b/src/doc/unstable-book/src/compiler-flags/branch-protection.md
new file mode 100644
index 00000000000..85403748e1d
--- /dev/null
+++ b/src/doc/unstable-book/src/compiler-flags/branch-protection.md
@@ -0,0 +1,18 @@
+# `branch-protection`
+
+This option lets you enable branch authentication instructions on AArch64.
+This option is ignored for non-AArch64 architectures.
+It takes some combination of the following values, separated by a `,`.
+
+- `pac-ret` - Enable pointer authentication for non-leaf functions.
+- `leaf` - Enable pointer authentication for all functions, including leaf functions.
+- `b-key` - Sign return addresses with key B, instead of the default key A.
+- `bti` - Enable branch target identification.
+
+`leaf` and `b-key` are only valid if `pac-ret` was previously specified.
+For example, `-Z branch-protection=bti,pac-ret,leaf` is valid, but
+`-Z branch-protection=bti,leaf,pac-ret` is not.
+
+Rust's standard library does not ship with BTI or pointer authentication enabled by default.
+In Cargo projects the standard library can be recompiled with pointer authentication using the nightly
+[build-std](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std) feature.
diff --git a/src/test/assembly/aarch64-pointer-auth.rs b/src/test/assembly/aarch64-pointer-auth.rs
index e778e67e1b3..27e289086b9 100644
--- a/src/test/assembly/aarch64-pointer-auth.rs
+++ b/src/test/assembly/aarch64-pointer-auth.rs
@@ -3,7 +3,7 @@
 // min-llvm-version: 10.0.1
 // assembly-output: emit-asm
 // compile-flags: --target aarch64-unknown-linux-gnu
-// compile-flags: -C branch-protection=pac-ret+leaf
+// compile-flags: -Z branch-protection=pac-ret,leaf
 // needs-llvm-components: aarch64
 
 #![feature(no_core, lang_items)]
diff --git a/src/test/codegen/branch-protection.rs b/src/test/codegen/branch-protection.rs
index 79706cdf070..106c9b148ee 100644
--- a/src/test/codegen/branch-protection.rs
+++ b/src/test/codegen/branch-protection.rs
@@ -3,10 +3,10 @@
 // revisions: bti pac-ret leaf b-key
 // min-llvm-version: 12.0.0
 // needs-llvm-components: aarch64
-// [bti] compile-flags: -C branch-protection=bti
-// [pac-ret] compile-flags: -C branch-protection=pac-ret
-// [leaf] compile-flags: -C branch-protection=pac-ret+leaf
-// [b-key] compile-flags: -C branch-protection=pac-ret+b-key
+// [bti] compile-flags: -Z branch-protection=bti
+// [pac-ret] compile-flags: -Z branch-protection=pac-ret
+// [leaf] compile-flags: -Z branch-protection=pac-ret,leaf
+// [b-key] compile-flags: -Z branch-protection=pac-ret,b-key
 // compile-flags: --target aarch64-unknown-linux-gnu
 
 #![crate_type = "lib"]
diff --git a/src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile b/src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile
index 36d0f0e5a19..d0e22cfef4c 100644
--- a/src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile
+++ b/src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile
@@ -5,10 +5,10 @@
 all:
 	$(COMPILE_OBJ) $(TMPDIR)/test.o test.c
 	$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
-	$(RUSTC) -C branch-protection=bti+pac-ret+leaf test.rs
+	$(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
 	$(call RUN,test)
 
 	$(COMPILE_OBJ) $(TMPDIR)/test.o test.c -mbranch-protection=bti+pac-ret+leaf
 	$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
-	$(RUSTC) -C branch-protection=bti+pac-ret+leaf test.rs
-	$(call RUN,test)
\ No newline at end of file
+	$(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
+	$(call RUN,test)
diff --git a/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs b/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs
new file mode 100644
index 00000000000..4f39d223a2e
--- /dev/null
+++ b/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs
@@ -0,0 +1 @@
+// compile-flags: -Z branch-protection=leaf
diff --git a/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.stderr b/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.stderr
new file mode 100644
index 00000000000..5528d2a0729
--- /dev/null
+++ b/src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.stderr
@@ -0,0 +1,2 @@
+error: incorrect value `leaf` for debugging option `branch-protection` - a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf` was expected
+