Skip to content

Commit 0426998

Browse files
committed
Auto merge of rust-lang#93523 - nagisa:branch-protection-revert-beta, r=Mark-Simulacrum
beta: Revert -Zbranch-protection This reverts commit d331cb7, reversing changes made to 78fd0f6. This fixes rust-lang#92885 as discussed on Zulip[1]. [1] https://zulip-archive.rust-lang.org/stream/238009-t-compiler/meetings/topic/.5Bweekly.5D.202022-01-27.20.2354818.html#269588396 r? `@Mark-Simulacrum`
2 parents 28c8a34 + b9610ef commit 0426998

File tree

13 files changed

+6
-202
lines changed

13 files changed

+6
-202
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::ty::layout::{
2121
};
2222
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2323
use rustc_middle::{bug, span_bug};
24-
use rustc_session::config::{BranchProtection, CFGuard, CrateType, DebugInfo, PAuthKey, PacRet};
24+
use rustc_session::config::{CFGuard, CrateType, DebugInfo};
2525
use rustc_session::Session;
2626
use rustc_span::source_map::Span;
2727
use rustc_span::symbol::Symbol;
@@ -242,34 +242,6 @@ pub unsafe fn create_module<'ll>(
242242
}
243243
}
244244

245-
if sess.target.arch == "aarch64" {
246-
let BranchProtection { bti, pac_ret: pac } = sess.opts.debugging_opts.branch_protection;
247-
248-
llvm::LLVMRustAddModuleFlag(
249-
llmod,
250-
"branch-target-enforcement\0".as_ptr().cast(),
251-
bti.into(),
252-
);
253-
254-
llvm::LLVMRustAddModuleFlag(
255-
llmod,
256-
"sign-return-address\0".as_ptr().cast(),
257-
pac.is_some().into(),
258-
);
259-
let pac_opts = pac.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
260-
llvm::LLVMRustAddModuleFlag(
261-
llmod,
262-
"sign-return-address-all\0".as_ptr().cast(),
263-
pac_opts.leaf.into(),
264-
);
265-
let is_bkey = if pac_opts.key == PAuthKey::A { false } else { true };
266-
llvm::LLVMRustAddModuleFlag(
267-
llmod,
268-
"sign-return-address-with-bkey\0".as_ptr().cast(),
269-
is_bkey.into(),
270-
);
271-
}
272-
273245
llmod
274246
}
275247

compiler/rustc_codegen_llvm/src/declare.rs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ fn declare_raw_fn<'ll>(
4747

4848
attributes::default_optimisation_attrs(cx.tcx.sess, llfn);
4949
attributes::non_lazy_bind(cx.sess(), llfn);
50-
5150
llfn
5251
}
5352

compiler/rustc_interface/src/tests.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ use rustc_session::config::{build_configuration, build_session_options, to_crate
88
use rustc_session::config::{
99
rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes,
1010
};
11+
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
1112
use rustc_session::config::{
12-
BranchProtection, Externs, OutputType, OutputTypes, PAuthKey, PacRet, SymbolManglingVersion,
13-
WasiExecModel,
13+
Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
1414
};
15-
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
1615
use rustc_session::lint::Level;
1716
use rustc_session::search_paths::SearchPath;
1817
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
@@ -719,10 +718,6 @@ fn test_debugging_options_tracking_hash() {
719718
tracked!(asm_comments, true);
720719
tracked!(assume_incomplete_release, true);
721720
tracked!(binary_dep_depinfo, true);
722-
tracked!(
723-
branch_protection,
724-
BranchProtection { bti: true, pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B }) }
725-
);
726721
tracked!(chalk, true);
727722
tracked!(codegen_backend, Some("abc".to_string()));
728723
tracked!(crate_attr, vec!["abc".to_string()]);

compiler/rustc_session/src/config.rs

+3-28
Original file line numberDiff line numberDiff line change
@@ -891,30 +891,6 @@ impl Passes {
891891
}
892892
}
893893

894-
#[derive(Clone, Copy, Hash, Debug, PartialEq)]
895-
pub enum PAuthKey {
896-
A,
897-
B,
898-
}
899-
900-
#[derive(Clone, Copy, Hash, Debug, PartialEq)]
901-
pub struct PacRet {
902-
pub leaf: bool,
903-
pub key: PAuthKey,
904-
}
905-
906-
#[derive(Clone, Copy, Hash, Debug, PartialEq)]
907-
pub struct BranchProtection {
908-
pub bti: bool,
909-
pub pac_ret: Option<PacRet>,
910-
}
911-
912-
impl Default for BranchProtection {
913-
fn default() -> Self {
914-
BranchProtection { bti: false, pac_ret: None }
915-
}
916-
}
917-
918894
pub const fn default_lib_output() -> CrateType {
919895
CrateType::Rlib
920896
}
@@ -2595,9 +2571,9 @@ impl PpMode {
25952571
crate mod dep_tracking {
25962572
use super::LdImpl;
25972573
use super::{
2598-
BranchProtection, CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage,
2599-
LinkerPluginLto, LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes,
2600-
SourceFileHashAlgorithm, SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
2574+
CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
2575+
LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
2576+
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
26012577
};
26022578
use crate::lint;
26032579
use crate::options::WasiExecModel;
@@ -2691,7 +2667,6 @@ crate mod dep_tracking {
26912667
OutputType,
26922668
RealFileName,
26932669
LocationDetail,
2694-
BranchProtection,
26952670
);
26962671

26972672
impl<T1, T2> DepTrackingHash for (T1, T2)

compiler/rustc_session/src/options.rs

-30
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ mod desc {
417417
pub const parse_gcc_ld: &str = "one of: no value, `lld`";
418418
pub const parse_stack_protector: &str =
419419
"one of (`none` (default), `basic`, `strong`, or `all`)";
420-
pub const parse_branch_protection: &str =
421-
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
422420
}
423421

424422
mod parse {
@@ -967,32 +965,6 @@ mod parse {
967965
}
968966
true
969967
}
970-
971-
crate fn parse_branch_protection(slot: &mut BranchProtection, v: Option<&str>) -> bool {
972-
match v {
973-
Some(s) => {
974-
for opt in s.split(',') {
975-
match opt {
976-
"bti" => slot.bti = true,
977-
"pac-ret" if slot.pac_ret.is_none() => {
978-
slot.pac_ret = Some(PacRet { leaf: false, key: PAuthKey::A })
979-
}
980-
"leaf" => match slot.pac_ret.as_mut() {
981-
Some(pac) => pac.leaf = true,
982-
_ => return false,
983-
},
984-
"b-key" => match slot.pac_ret.as_mut() {
985-
Some(pac) => pac.key = PAuthKey::B,
986-
_ => return false,
987-
},
988-
_ => return false,
989-
};
990-
}
991-
}
992-
_ => return false,
993-
}
994-
true
995-
}
996968
}
997969

998970
options! {
@@ -1137,8 +1109,6 @@ options! {
11371109
(default: no)"),
11381110
borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
11391111
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
1140-
branch_protection: BranchProtection = (BranchProtection::default(), parse_branch_protection, [TRACKED],
1141-
"set options for branch target identification and pointer authentication on AArch64"),
11421112
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
11431113
"the codegen unit partitioning strategy to use"),
11441114
chalk: bool = (false, parse_bool, [TRACKED],

src/doc/unstable-book/src/compiler-flags/branch-protection.md

-18
This file was deleted.

src/test/assembly/aarch64-pointer-auth.rs

-22
This file was deleted.

src/test/codegen/branch-protection.rs

-41
This file was deleted.

src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile

-14
This file was deleted.

src/test/run-make-fulldeps/pointer-auth-link-with-c/test.c

-1
This file was deleted.

src/test/run-make-fulldeps/pointer-auth-link-with-c/test.rs

-8
This file was deleted.

src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.rs

-1
This file was deleted.

src/test/ui/invalid-compile-flags/branch-protection-missing-pac-ret.stderr

-2
This file was deleted.

0 commit comments

Comments
 (0)