Skip to content

Replace target.target with target #1583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
06a079c43efb062e335e6e6c9dabd3c750619980
b5c9e2448c9ace53ad5c11585803894651b18b0a
4 changes: 2 additions & 2 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
/// if this is not the case.
fn assert_target_os(&self, target_os: &str, name: &str) {
assert_eq!(
self.eval_context_ref().tcx.sess.target.target.target_os,
self.eval_context_ref().tcx.sess.target.target_os,
target_os,
"`{}` is only available on the `{}` target OS",
name,
Expand Down Expand Up @@ -430,7 +430,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
fn set_last_error_from_io_error(&mut self, e: std::io::Error) -> InterpResult<'tcx> {
use std::io::ErrorKind::*;
let this = self.eval_context_mut();
let target = &this.tcx.sess.target.target;
let target = &this.tcx.sess.target;
let target_os = &target.target_os;
let last_error = if target.options.target_family == Some("unix".to_owned()) {
this.eval_libc(match e.kind() {
Expand Down
2 changes: 1 addition & 1 deletion src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl MemoryExtra {
pub fn init_extern_statics<'tcx, 'mir>(
this: &mut MiriEvalContext<'mir, 'tcx>,
) -> InterpResult<'tcx> {
match this.tcx.sess.target.target.target_os.as_str() {
match this.tcx.sess.target.target_os.as_str() {
"linux" => {
// "__cxa_thread_atexit_impl"
// This should be all-zero, pointer-sized.
Expand Down
12 changes: 6 additions & 6 deletions src/shims/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'tcx> EnvVars<'tcx> {
ecx: &mut InterpCx<'mir, 'tcx, Evaluator<'mir, 'tcx>>,
mut excluded_env_vars: Vec<String>,
) -> InterpResult<'tcx> {
let target_os = ecx.tcx.sess.target.target.target_os.as_str();
let target_os = ecx.tcx.sess.target.target_os.as_str();
if target_os == "windows" {
// Temporary hack: Exclude `TERM` var to avoid terminfo trying to open the termcap file.
// Can be removed once https://github.com/rust-lang/miri/issues/1013 is resolved.
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mi
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
fn getenv(&mut self, name_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, Scalar<Tag>> {
let this = self.eval_context_mut();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
assert!(target_os == "linux" || target_os == "macos", "`getenv` is only available for the UNIX target family");

let name_ptr = this.read_scalar(name_op)?.check_init()?;
Expand Down Expand Up @@ -185,7 +185,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
value_op: OpTy<'tcx, Tag>,
) -> InterpResult<'tcx, i32> {
let mut this = self.eval_context_mut();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
assert!(target_os == "linux" || target_os == "macos", "`setenv` is only available for the UNIX target family");

let name_ptr = this.read_scalar(name_op)?.check_init()?;
Expand Down Expand Up @@ -258,7 +258,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx

fn unsetenv(&mut self, name_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
assert!(target_os == "linux" || target_os == "macos", "`unsetenv` is only available for the UNIX target family");

let name_ptr = this.read_scalar(name_op)?.check_init()?;
Expand Down Expand Up @@ -290,7 +290,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
size_op: OpTy<'tcx, Tag>,
) -> InterpResult<'tcx, Scalar<Tag>> {
let this = self.eval_context_mut();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
assert!(target_os == "linux" || target_os == "macos", "`getcwd` is only available for the UNIX target family");

this.check_no_isolation("`getcwd`")?;
Expand Down Expand Up @@ -336,7 +336,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx

fn chdir(&mut self, path_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
assert!(target_os == "linux" || target_os == "macos", "`getcwd` is only available for the UNIX target family");

this.check_no_isolation("`chdir`")?;
Expand Down
6 changes: 3 additions & 3 deletions src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
fn min_align(&self, size: u64, kind: MiriMemoryKind) -> Align {
let this = self.eval_context_ref();
// List taken from `libstd/sys_common/alloc.rs`.
let min_align = match this.tcx.sess.target.target.arch.as_str() {
let min_align = match this.tcx.sess.target.arch.as_str() {
"x86" | "arm" | "mips" | "powerpc" | "powerpc64" | "asmjs" | "wasm32" => 8,
"x86_64" | "aarch64" | "mips64" | "s390x" | "sparc64" => 16,
arch => bug!("Unsupported target architecture: {}", arch),
Expand Down Expand Up @@ -480,13 +480,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
}

// Architecture-specific shims
"llvm.x86.sse2.pause" if this.tcx.sess.target.target.arch == "x86" || this.tcx.sess.target.target.arch == "x86_64" => {
"llvm.x86.sse2.pause" if this.tcx.sess.target.arch == "x86" || this.tcx.sess.target.arch == "x86_64" => {
let &[] = check_arg_count(args)?;
this.yield_active_thread();
}

// Platform-specific shims
_ => match this.tcx.sess.target.target.target_os.as_str() {
_ => match this.tcx.sess.target.target_os.as_str() {
"linux" | "macos" => return shims::posix::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
"windows" => return shims::windows::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
target => throw_unsup_format!("the target `{}` is not supported", target),
Expand Down
2 changes: 1 addition & 1 deletion src/shims/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
direction: PathConversion,
) -> Cow<'a, OsStr> {
let this = self.eval_context_ref();
let target_os = &this.tcx.sess.target.target.target_os;
let target_os = &this.tcx.sess.target.target_os;
#[cfg(windows)]
return if target_os == "windows" {
// Windows-on-Windows, all fine.
Expand Down
4 changes: 2 additions & 2 deletions src/shims/posix/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.read_scalar(handle)?.to_machine_usize(this)?;
let symbol = this.read_scalar(symbol)?.check_init()?;
let symbol_name = this.memory.read_c_str(symbol)?;
if let Some(dlsym) = Dlsym::from_str(symbol_name, &this.tcx.sess.target.target.target_os)? {
if let Some(dlsym) = Dlsym::from_str(symbol_name, &this.tcx.sess.target.target_os)? {
let ptr = this.memory.create_fn_alloc(FnVal::Other(dlsym));
this.write_scalar(Scalar::from(ptr), dest)?;
} else {
Expand Down Expand Up @@ -452,7 +452,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx

// Platform-specific shims
_ => {
match this.tcx.sess.target.target.target_os.as_str() {
match this.tcx.sess.target.target_os.as_str() {
"linux" => return shims::posix::linux::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
"macos" => return shims::posix::macos::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
_ => unreachable!(),
Expand Down
4 changes: 2 additions & 2 deletions src/shims/posix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
},
None => return this.handle_not_found(),
}
} else if this.tcx.sess.target.target.target_os == "macos"
} else if this.tcx.sess.target.target_os == "macos"
&& cmd == this.eval_libc_i32("F_FULLFSYNC")?
{
let &[_, _] = check_arg_count(args)?;
Expand Down Expand Up @@ -989,7 +989,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
this.check_no_isolation("`mkdir`")?;

#[cfg_attr(not(unix), allow(unused_variables))]
let mode = if this.tcx.sess.target.target.target_os == "macos" {
let mode = if this.tcx.sess.target.target_os == "macos" {
u32::from(this.read_scalar(mode_op)?.check_init()?.to_u16()?)
} else {
this.read_scalar(mode_op)?.to_u32()?
Expand Down
2 changes: 1 addition & 1 deletion src/shims/posix/linux/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let (_dest, _ret) = ret.expect("we don't support any diverging dlsym");
assert!(this.tcx.sess.target.target.target_os == "linux");
assert!(this.tcx.sess.target.target_os == "linux");

match dlsym {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shims/posix/macos/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let (dest, ret) = ret.expect("we don't support any diverging dlsym");
assert!(this.tcx.sess.target.target.target_os == "macos");
assert!(this.tcx.sess.target.target_os == "macos");

match dlsym {
Dlsym::getentropy => {
Expand Down
2 changes: 1 addition & 1 deletion src/shims/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// This is the first time we got asked to schedule a destructor. The
// Windows schedule destructor function must be called exactly once,
// this is why it is in this block.
if this.tcx.sess.target.target.target_os == "windows" {
if this.tcx.sess.target.target_os == "windows" {
// On Windows, we signal that the thread quit by starting the
// relevant function, reenabling the thread, and going back to
// the scheduler.
Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/dlsym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let (dest, ret) = ret.expect("we don't support any diverging dlsym");
assert!(this.tcx.sess.target.target.target_os == "windows");
assert!(this.tcx.sess.target.target_os == "windows");

match dlsym {
Dlsym::AcquireSRWLockExclusive => {
Expand Down
2 changes: 1 addition & 1 deletion src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let &[hModule, lpProcName] = check_arg_count(args)?;
this.read_scalar(hModule)?.to_machine_isize(this)?;
let name = this.memory.read_c_str(this.read_scalar(lpProcName)?.check_init()?)?;
if let Some(dlsym) = Dlsym::from_str(name, &this.tcx.sess.target.target.target_os)? {
if let Some(dlsym) = Dlsym::from_str(name, &this.tcx.sess.target.target_os)? {
let ptr = this.memory.create_fn_alloc(FnVal::Other(dlsym));
this.write_scalar(Scalar::from(ptr), dest)?;
} else {
Expand Down