Skip to content
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

Make more of the test suite run on Mac Catalyst #125226

Merged
merged 3 commits into from
May 29, 2024
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 library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ fn metadata_access_times() {
assert_eq!(check!(a.modified()), check!(a.modified()));
assert_eq!(check!(b.accessed()), check!(b.modified()));

if cfg!(target_os = "macos") || cfg!(target_os = "windows") {
if cfg!(target_vendor = "apple") || cfg!(target_os = "windows") {
check!(a.created());
check!(b.created());
}
Expand Down
8 changes: 8 additions & 0 deletions library/std/src/sys/pal/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ mod imp {
}
}

// This is intentionally not enabled on iOS/tvOS/watchOS/visionOS, as it uses
// several symbols that might lead to rejections from the App Store, namely
// `sigaction`, `sigaltstack`, `sysctlbyname`, `mmap`, `munmap` and `mprotect`.
//
// This might be overly cautious, though it is also what Swift does (and they
// usually have fewer qualms about forwards compatibility, since the runtime
// is shipped with the OS):
// <https:/apple/swift/blob/swift-5.10-RELEASE/stdlib/public/runtime/CrashHandlerMacOS.cpp>
Comment on lines +494 to +501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And based on the exclusion notes on the stack-probes.rs test, we still emit binaries with __stack_chk_guard and such, right? And so do they? So it's less about whether the stack is protected and more about the error message.

Copy link
Contributor Author

@madsmtm madsmtm May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure Swift also emit stack probes (dubbed "stack protectors"), this is indeed only about the error message

#[cfg(not(any(
target_os = "linux",
target_os = "freebsd",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub fn dylib_path_var() -> &'static str {
if cfg!(target_os = "windows") {
"PATH"
} else if cfg!(target_os = "macos") {
} else if cfg!(target_vendor = "apple") {
"DYLD_LIBRARY_PATH"
} else if cfg!(target_os = "haiku") {
"LIBRARY_PATH"
Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-aarch64",
"ignore-aarch64-unknown-linux-gnu",
"ignore-android",
"ignore-apple",
"ignore-arm",
"ignore-avr",
"ignore-beta",
Expand Down Expand Up @@ -829,7 +830,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-x32",
"ignore-x86",
"ignore-x86_64",
"ignore-x86_64-apple-darwin",
"ignore-x86_64-unknown-linux-gnu",
"incremental",
"known-bug",
Expand Down Expand Up @@ -876,6 +876,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-32bit",
"only-64bit",
"only-aarch64",
"only-apple",
"only-arm",
"only-avr",
"only-beta",
Expand Down
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/header/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ pub(super) fn parse_cfg_name_directive<'a>(
message: "when the architecture is part of the Thumb family"
}

condition! {
name: "apple",
condition: config.target.contains("apple"),
message: "when the target vendor is Apple"
}

// Technically the locally built compiler uses the "dev" channel rather than the "nightly"
// channel, even though most people don't know or won't care about it. To avoid confusion, we
// treat the "dev" channel as the "nightly" channel when processing the directive.
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn get_lib_name(lib: &str, aux_type: AuxType) -> Option<String> {
AuxType::Lib => Some(format!("lib{}.rlib", lib)),
AuxType::Dylib => Some(if cfg!(windows) {
format!("{}.dll", lib)
} else if cfg!(target_os = "macos") {
} else if cfg!(target_vendor = "apple") {
format!("lib{}.dylib", lib)
} else {
format!("lib{}.so", lib)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl PathBufExt for PathBuf {
pub fn dylib_env_var() -> &'static str {
if cfg!(windows) {
"PATH"
} else if cfg!(target_os = "macos") {
} else if cfg!(target_vendor = "apple") {
"DYLD_LIBRARY_PATH"
} else if cfg!(target_os = "haiku") {
"LIBRARY_PATH"
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,6 @@ ui/issues/issue-33687.rs
ui/issues/issue-33770.rs
ui/issues/issue-3389.rs
ui/issues/issue-33941.rs
ui/issues/issue-33992.rs
ui/issues/issue-34047.rs
ui/issues/issue-34074.rs
ui/issues/issue-34209.rs
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: u32 = 900;
// FIXME: The following limits should be reduced eventually.

const ISSUES_ENTRY_LIMIT: u32 = 1676;
const ISSUES_ENTRY_LIMIT: u32 = 1674;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: all strong basic none missing
//@ assembly-output: emit-asm
//@ ignore-macos slightly different policy on stack protection of arrays
//@ ignore-apple slightly different policy on stack protection of arrays
//@ ignore-msvc stack check code uses different function names
//@ ignore-nvptx64 stack protector is not supported
//@ ignore-wasm32-bare
Expand All @@ -17,12 +17,9 @@
// See comments on https:/rust-lang/rust/issues/114903.

#![crate_type = "lib"]

#![allow(incomplete_features)]

#![feature(unsized_locals, unsized_fn_params)]


// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-array-pair-load-store-merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64
//@ ignore-sgx
//@ ignore-macos (manipulates rsp too)
//@ ignore-apple (manipulates rsp too)

// Depending on various codegen choices, this might end up copying
// a `<2 x i8>`, an `i16`, or two `i8`s.
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/x86_64-function-return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//@ [keep-thunk-extern] compile-flags: -Zfunction-return=keep -Zfunction-return=thunk-extern
//@ [thunk-extern-keep] compile-flags: -Zfunction-return=thunk-extern -Zfunction-return=keep
//@ only-x86_64
//@ ignore-x86_64-apple-darwin Symbol is called `___x86_return_thunk` (Darwin's extra underscore)
//@ ignore-apple Symbol is called `___x86_return_thunk` (Darwin's extra underscore)
//@ ignore-sgx Tests incompatible with LVI mitigations

#![crate_type = "lib"]
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/gdb_debug_script_load.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
//@ ignore-windows
//@ ignore-macos
//@ ignore-apple
//@ ignore-wasm
//@ ignore-emscripten

Expand Down
4 changes: 2 additions & 2 deletions tests/codegen/instrument-coverage/testprog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//@ [LINUX] filecheck-flags: -DINSTR_PROF_COVFUN=__llvm_covfun
//@ [LINUX] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat'

//@ [DARWIN] only-macos
//@ [DARWIN] only-apple
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_DATA=__DATA,__llvm_prf_data,regular,live_support
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_NAME=__DATA,__llvm_prf_names
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_CNTS=__DATA,__llvm_prf_cnts
Expand Down Expand Up @@ -49,7 +49,7 @@ where

pub fn wrap_with<F, T>(inner: T, should_wrap: bool, wrapper: F)
where
F: FnOnce(&T)
F: FnOnce(&T),
{
if should_wrap {
wrapper(&inner)
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/issues/issue-44056-macos-tls-align.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
//@ only-macos
//@ only-apple
//@ compile-flags: -O

#![crate_type = "rlib"]
Expand Down
5 changes: 2 additions & 3 deletions tests/codegen/mainsubprogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// before 4.0, formerly backported to the Rust LLVM fork.

//@ ignore-windows
//@ ignore-macos
//@ ignore-apple
//@ ignore-wasi

//@ compile-flags: -g -C no-prepopulate-passes

// CHECK-LABEL: @main
// CHECK: {{.*}}DISubprogram{{.*}}name: "main",{{.*}}DI{{(SP)?}}FlagMainSubprogram{{.*}}

pub fn main() {
}
pub fn main() {}
2 changes: 1 addition & 1 deletion tests/codegen/mainsubprogramstart.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ ignore-windows
//@ ignore-macos
//@ ignore-apple
//@ ignore-wasi wasi codegens the main symbol differently

//@ compile-flags: -g -C no-prepopulate-passes
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/pgo-counter-bias.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test that __llvm_profile_counter_bias does not get internalized by lto.

//@ ignore-macos -runtime-counter-relocation not honored on Mach-O
//@ ignore-apple -runtime-counter-relocation not honored on Mach-O
//@ compile-flags: -Cprofile-generate -Cllvm-args=-runtime-counter-relocation -Clto=fat
//@ needs-profiler-support
//@ no-prefer-dynamic
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/c-dynamic-dylib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ignore-cross-compile
include ../tools.mk

# ignore-macos
# ignore-apple
#
# This hits an assertion in the linker on older versions of osx apparently

Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/c-dynamic-rlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ignore-cross-compile
include ../tools.mk

# ignore-macos
# ignore-apple
#
# This hits an assertion in the linker on older versions of osx apparently

Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/emit-stack-sizes/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
include ../tools.mk

# ignore-windows
# ignore-macos
# ignore-apple
#
# This feature only works when the output object format is ELF so we ignore
# macOS and Windows
# Apple and Windows

# check that the .stack_sizes section is generated
all:
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/fpic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
include ../tools.mk

# ignore-windows
# ignore-macos
# ignore-apple

# Test for #39529.
# `-z text` causes ld to error if there are any non-PIC sections
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/link-framework/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# only-macos
# only-apple
#
# Check that linking to a framework actually makes it to the linker.

Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/macos-fat-archive/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# only-macos
# only-apple

include ../tools.mk

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ignore-cross-compile
# ignore-macos
# ignore-apple

include ../tools.mk

Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/used-cdylib-macos/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include ../tools.mk

# only-macos
# only-apple
#
# This checks that `#[used]` passes through to the linker on
# darwin. This is subject to change in the future, see
# Apple targets. This is subject to change in the future, see
# https:/rust-lang/rust/pull/93718 for discussion

all:
Expand Down
5 changes: 2 additions & 3 deletions tests/run-pass-valgrind/exit-flushes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ ignore-wasm32 no subprocess support
//@ ignore-sgx no processes
//@ ignore-macos this needs valgrind 3.11 or higher; see
//@ ignore-apple this needs valgrind 3.11 or higher; see
// https:/rust-lang/rust/pull/30365#issuecomment-165763679

use std::env;
Expand All @@ -11,8 +11,7 @@ fn main() {
print!("hello!");
exit(0);
} else {
let out = Command::new(env::args().next().unwrap()).arg("foo")
.output().unwrap();
let out = Command::new(env::args().next().unwrap()).arg("foo").output().unwrap();
assert!(out.status.success());
assert_eq!(String::from_utf8(out.stdout).unwrap(), "hello!");
assert_eq!(String::from_utf8(out.stderr).unwrap(), "");
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/abi/stack-probes-lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
//@ compile-flags: -C lto
//@ no-prefer-dynamic
//@ ignore-nto Crash analysis impossible at SIGSEGV in QNX Neutrino
//@ ignore-ios Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-tvos Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-watchos Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-visionos Stack probes are enabled, but the SIGSEGV handler isn't

include!("stack-probes.rs");
4 changes: 4 additions & 0 deletions tests/ui/abi/stack-probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
//@ ignore-sgx no processes
//@ ignore-fuchsia no exception handler registered for segfault
//@ ignore-nto Crash analysis impossible at SIGSEGV in QNX Neutrino
//@ ignore-ios Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-tvos Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-watchos Stack probes are enabled, but the SIGSEGV handler isn't
//@ ignore-visionos Stack probes are enabled, but the SIGSEGV handler isn't
madsmtm marked this conversation as resolved.
Show resolved Hide resolved

use std::env;
use std::mem::MaybeUninit;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/backtrace/apple-no-dsymutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//@ compile-flags:-Cstrip=none
//@ compile-flags:-g -Csplit-debuginfo=unpacked
//@ only-macos
//@ only-apple

use std::process::Command;
use std::str;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/deployment-target/macos-target.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ only-macos
//@ only-apple
//@ compile-flags: --print deployment-target
//@ normalize-stdout-test: "\d+\." -> "$$CURRENT_MAJOR_VERSION."
//@ normalize-stdout-test: "\d+" -> "$$CURRENT_MINOR_VERSION"
Expand Down
29 changes: 15 additions & 14 deletions tests/ui/intrinsics/intrinsic-alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ mod rusti {
}
}

#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_os = "vxworks",
target_os = "nto",
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_os = "vxworks",
target_os = "nto",
target_vendor = "apple",
))]
mod m {
#[cfg(target_arch = "x86")]
Expand Down
13 changes: 9 additions & 4 deletions tests/ui/issues/issue-45731.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
#![allow(unused_variables)]
//@ compile-flags:--test -g

#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
#[test]
fn simple_test() {
use std::{env, panic, fs};
use std::{env, fs, panic};

// Find our dSYM and replace the DWARF binary with an empty file
let mut dsym_path = env::current_exe().unwrap();
let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string();
assert!(dsym_path.pop()); // Pop executable
dsym_path.push(format!("{}.dSYM/Contents/Resources/DWARF/{0}", executable_name));
{
let file = fs::OpenOptions::new().read(false).write(true).truncate(true).create(false)
.open(&dsym_path).unwrap();
let file = fs::OpenOptions::new()
.read(false)
.write(true)
.truncate(true)
.create(false)
.open(&dsym_path)
.unwrap();
}

env::set_var("RUST_BACKTRACE", "1");
Expand Down
Loading
Loading