Skip to content

Commit

Permalink
Auto merge of rust-lang#93523 - nagisa:branch-protection-revert-beta,…
Browse files Browse the repository at this point in the history
… 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`
  • Loading branch information
bors committed Feb 2, 2022
2 parents 28c8a34 + b9610ef commit 0426998
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 202 deletions.
30 changes: 1 addition & 29 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_middle::ty::layout::{
};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_session::config::{BranchProtection, CFGuard, CrateType, DebugInfo, PAuthKey, PacRet};
use rustc_session::config::{CFGuard, CrateType, DebugInfo};
use rustc_session::Session;
use rustc_span::source_map::Span;
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -242,34 +242,6 @@ pub unsafe fn create_module<'ll>(
}
}

if sess.target.arch == "aarch64" {
let BranchProtection { bti, pac_ret: pac } = sess.opts.debugging_opts.branch_protection;

llvm::LLVMRustAddModuleFlag(
llmod,
"branch-target-enforcement\0".as_ptr().cast(),
bti.into(),
);

llvm::LLVMRustAddModuleFlag(
llmod,
"sign-return-address\0".as_ptr().cast(),
pac.is_some().into(),
);
let pac_opts = pac.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
llvm::LLVMRustAddModuleFlag(
llmod,
"sign-return-address-all\0".as_ptr().cast(),
pac_opts.leaf.into(),
);
let is_bkey = if pac_opts.key == PAuthKey::A { false } else { true };
llvm::LLVMRustAddModuleFlag(
llmod,
"sign-return-address-with-bkey\0".as_ptr().cast(),
is_bkey.into(),
);
}

llmod
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ fn declare_raw_fn<'ll>(

attributes::default_optimisation_attrs(cx.tcx.sess, llfn);
attributes::non_lazy_bind(cx.sess(), llfn);

llfn
}

Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ use rustc_session::config::{build_configuration, build_session_options, to_crate
use rustc_session::config::{
rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes,
};
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
use rustc_session::config::{
BranchProtection, Externs, OutputType, OutputTypes, PAuthKey, PacRet, SymbolManglingVersion,
WasiExecModel,
Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
};
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
use rustc_session::lint::Level;
use rustc_session::search_paths::SearchPath;
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
Expand Down Expand Up @@ -719,10 +718,6 @@ fn test_debugging_options_tracking_hash() {
tracked!(asm_comments, true);
tracked!(assume_incomplete_release, true);
tracked!(binary_dep_depinfo, true);
tracked!(
branch_protection,
BranchProtection { bti: true, pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B }) }
);
tracked!(chalk, true);
tracked!(codegen_backend, Some("abc".to_string()));
tracked!(crate_attr, vec!["abc".to_string()]);
Expand Down
31 changes: 3 additions & 28 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,30 +891,6 @@ impl Passes {
}
}

#[derive(Clone, Copy, Hash, Debug, PartialEq)]
pub enum PAuthKey {
A,
B,
}

#[derive(Clone, Copy, Hash, Debug, PartialEq)]
pub struct PacRet {
pub leaf: bool,
pub key: PAuthKey,
}

#[derive(Clone, Copy, Hash, Debug, PartialEq)]
pub struct BranchProtection {
pub bti: bool,
pub pac_ret: Option<PacRet>,
}

impl Default for BranchProtection {
fn default() -> Self {
BranchProtection { bti: false, pac_ret: None }
}
}

pub const fn default_lib_output() -> CrateType {
CrateType::Rlib
}
Expand Down Expand Up @@ -2595,9 +2571,9 @@ impl PpMode {
crate mod dep_tracking {
use super::LdImpl;
use super::{
BranchProtection, CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage,
LinkerPluginLto, LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes,
SourceFileHashAlgorithm, SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
};
use crate::lint;
use crate::options::WasiExecModel;
Expand Down Expand Up @@ -2691,7 +2667,6 @@ crate mod dep_tracking {
OutputType,
RealFileName,
LocationDetail,
BranchProtection,
);

impl<T1, T2> DepTrackingHash for (T1, T2)
Expand Down
30 changes: 0 additions & 30 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,6 @@ mod desc {
pub const parse_gcc_ld: &str = "one of: no value, `lld`";
pub const parse_stack_protector: &str =
"one of (`none` (default), `basic`, `strong`, or `all`)";
pub const parse_branch_protection: &str =
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
}

mod parse {
Expand Down Expand Up @@ -967,32 +965,6 @@ mod parse {
}
true
}

crate fn parse_branch_protection(slot: &mut BranchProtection, v: Option<&str>) -> bool {
match v {
Some(s) => {
for opt in s.split(',') {
match opt {
"bti" => slot.bti = true,
"pac-ret" if slot.pac_ret.is_none() => {
slot.pac_ret = Some(PacRet { leaf: false, key: PAuthKey::A })
}
"leaf" => match slot.pac_ret.as_mut() {
Some(pac) => pac.leaf = true,
_ => return false,
},
"b-key" => match slot.pac_ret.as_mut() {
Some(pac) => pac.key = PAuthKey::B,
_ => return false,
},
_ => return false,
};
}
}
_ => return false,
}
true
}
}

options! {
Expand Down Expand Up @@ -1137,8 +1109,6 @@ options! {
(default: no)"),
borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
branch_protection: BranchProtection = (BranchProtection::default(), parse_branch_protection, [TRACKED],
"set options for branch target identification and pointer authentication on AArch64"),
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
"the codegen unit partitioning strategy to use"),
chalk: bool = (false, parse_bool, [TRACKED],
Expand Down
18 changes: 0 additions & 18 deletions src/doc/unstable-book/src/compiler-flags/branch-protection.md

This file was deleted.

22 changes: 0 additions & 22 deletions src/test/assembly/aarch64-pointer-auth.rs

This file was deleted.

41 changes: 0 additions & 41 deletions src/test/codegen/branch-protection.rs

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/run-make-fulldeps/pointer-auth-link-with-c/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/pointer-auth-link-with-c/test.c

This file was deleted.

8 changes: 0 additions & 8 deletions src/test/run-make-fulldeps/pointer-auth-link-with-c/test.rs

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0426998

Please sign in to comment.