Skip to content

Rename is_like_osx to is_like_darwin #138949

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
Apr 4, 2025
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 compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
.flat_map(|arg_abi| arg_abi.get_abi_param(fx.tcx).into_iter()),
);

if fx.tcx.sess.target.is_like_osx && fx.tcx.sess.target.arch == "aarch64" {
if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == "aarch64" {
// Add any padding arguments needed for Apple AArch64.
// There's no need to pad the argument list unless variadic arguments are actually being
// passed.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
data.set_align(alloc.align.bytes());

if let Some(section_name) = section_name {
let (segment_name, section_name) = if tcx.sess.target.is_like_osx {
let (segment_name, section_name) = if tcx.sess.target.is_like_darwin {
// See https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/MCSectionMachO.cpp
let mut parts = section_name.as_str().split(',');
let Some(segment_name) = parts.next() else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl DebugContext {
// FIXME this should be configurable
// macOS doesn't seem to support DWARF > 3
// 5 version is required for md5 file hash
version: if tcx.sess.target.is_like_osx {
version: if tcx.sess.target.is_like_darwin {
3
} else {
// FIXME change to version 5 once the gdb and lldb shipping with the latest debian
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
// will use load-unaligned instructions instead, and thus avoiding the crash.
//
// We could remove this hack whenever we decide to drop macOS 10.10 support.
if self.tcx.sess.target.options.is_like_osx {
if self.tcx.sess.target.options.is_like_darwin {
// The `inspect` method is okay here because we checked for provenance, and
// because we are doing this access to inspect the final interpreter state
// (not as part of the interpreter execution).
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data:
}

pub(crate) fn bitcode_section_name(cgcx: &CodegenContext<LlvmCodegenBackend>) -> &'static CStr {
if cgcx.target_is_like_osx {
if cgcx.target_is_like_darwin {
c"__LLVM,__bitcode"
} else if cgcx.target_is_like_aix {
c".ipa"
Expand Down Expand Up @@ -1077,7 +1077,7 @@ unsafe fn embed_bitcode(
// and COFF we emit the sections using module level inline assembly for that
// reason (see issue #90326 for historical background).
unsafe {
if cgcx.target_is_like_osx
if cgcx.target_is_like_darwin
|| cgcx.target_is_like_aix
|| cgcx.target_arch == "wasm32"
|| cgcx.target_arch == "wasm64"
Expand All @@ -1096,7 +1096,7 @@ unsafe fn embed_bitcode(
let llglobal =
llvm::add_global(llmod, common::val_ty(llconst), c"rustc.embedded.cmdline");
llvm::set_initializer(llglobal, llconst);
let section = if cgcx.target_is_like_osx {
let section = if cgcx.target_is_like_darwin {
c"__LLVM,__cmdline"
} else if cgcx.target_is_like_aix {
c".info"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl CodegenCx<'_, '_> {
}

// Match clang by only supporting COFF and ELF for now.
if self.tcx.sess.target.is_like_osx {
if self.tcx.sess.target.is_like_darwin {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
}
// macOS / iOS AArch64
"aarch64" if target.is_like_osx => {
"aarch64" if target.is_like_darwin => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
}
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ fn link_natively(
// On macOS the external `dsymutil` tool is used to create the packed
// debug information. Note that this will read debug information from
// the objects on the filesystem which we'll clean up later.
SplitDebuginfo::Packed if sess.target.is_like_osx => {
SplitDebuginfo::Packed if sess.target.is_like_darwin => {
let prog = Command::new("dsymutil").arg(out_filename).output();
match prog {
Ok(prog) => {
Expand Down Expand Up @@ -1043,7 +1043,7 @@ fn link_natively(

let strip = sess.opts.cg.strip;

if sess.target.is_like_osx {
if sess.target.is_like_darwin {
let stripcmd = "rust-objcopy";
match (strip, crate_type) {
(Strip::Debuginfo, _) => {
Expand Down Expand Up @@ -1241,7 +1241,7 @@ fn add_sanitizer_libraries(
// Everywhere else the runtimes are currently distributed as static
// libraries which should be linked to executables only.
if matches!(crate_type, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro)
&& !(sess.target.is_like_osx || sess.target.is_like_msvc)
&& !(sess.target.is_like_darwin || sess.target.is_like_msvc)
{
return;
}
Expand Down Expand Up @@ -1294,7 +1294,7 @@ fn link_sanitizer_runtime(
let channel =
option_env!("CFG_RELEASE_CHANNEL").map(|channel| format!("-{channel}")).unwrap_or_default();

if sess.target.is_like_osx {
if sess.target.is_like_darwin {
// On Apple platforms, the sanitizer is always built as a dylib, and
// LLVM will link to `@rpath/*.dylib`, so we need to specify an
// rpath to the library as well (the rpath should be absolute, see
Expand Down Expand Up @@ -2182,7 +2182,7 @@ fn add_rpath_args(
let rpath_config = RPathConfig {
libs: &*libs,
out_filename: out_filename.to_path_buf(),
is_like_osx: sess.target.is_like_osx,
is_like_darwin: sess.target.is_like_darwin,
linker_is_gnu: sess.target.linker_flavor.is_gnu(),
};
cmd.link_args(&rpath::get_rpath_linker_args(&rpath_config));
Expand Down Expand Up @@ -3044,7 +3044,7 @@ pub(crate) fn are_upstream_rust_objects_already_included(sess: &Session) -> bool
/// - The deployment target.
/// - The SDK version.
fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
if !sess.target.is_like_osx {
if !sess.target.is_like_darwin {
return;
}
let LinkerFlavor::Darwin(cc, _) = flavor else {
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<'a> GccLinker<'a> {
// * On OSX they have their own linker, not binutils'
// * For WebAssembly the only functional linker is LLD, which doesn't
// support hint flags
!self.sess.target.is_like_osx && !self.sess.target.is_like_wasm
!self.sess.target.is_like_darwin && !self.sess.target.is_like_wasm
}

// Some platforms take hints about whether a library is static or dynamic.
Expand Down Expand Up @@ -425,7 +425,7 @@ impl<'a> GccLinker<'a> {

fn build_dylib(&mut self, crate_type: CrateType, out_filename: &Path) {
// On mac we need to tell the linker to let this library be rpathed
if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
if self.is_cc() {
// `-dynamiclib` makes `cc` pass `-dylib` to the linker.
self.cc_arg("-dynamiclib");
Expand Down Expand Up @@ -470,7 +470,7 @@ impl<'a> GccLinker<'a> {

fn with_as_needed(&mut self, as_needed: bool, f: impl FnOnce(&mut Self)) {
if !as_needed {
if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
// FIXME(81490): ld64 doesn't support these flags but macOS 11
// has -needed-l{} / -needed_library {}
// but we have no way to detect that here.
Expand All @@ -485,7 +485,7 @@ impl<'a> GccLinker<'a> {
f(self);

if !as_needed {
if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
// See above FIXME comment
} else if self.is_gnu && !self.sess.target.is_like_windows {
self.link_arg("--as-needed");
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<'a> Linker for GccLinker<'a> {
let colon = if verbatim && self.is_gnu { ":" } else { "" };
if !whole_archive {
self.link_or_cc_arg(format!("-l{colon}{name}"));
} else if self.sess.target.is_like_osx {
} else if self.sess.target.is_like_darwin {
// -force_load is the macOS equivalent of --whole-archive, but it
// involves passing the full path to the library to link.
self.link_arg("-force_load");
Expand All @@ -634,7 +634,7 @@ impl<'a> Linker for GccLinker<'a> {
self.hint_static();
if !whole_archive {
self.link_or_cc_arg(path);
} else if self.sess.target.is_like_osx {
} else if self.sess.target.is_like_darwin {
self.link_arg("-force_load").link_arg(path);
} else {
self.link_arg("--whole-archive").link_arg(path).link_arg("--no-whole-archive");
Expand Down Expand Up @@ -669,7 +669,7 @@ impl<'a> Linker for GccLinker<'a> {
// -dead_strip can't be part of the pre_link_args because it's also used
// for partial linking when using multiple codegen units (-r). So we
// insert it here.
if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
self.link_arg("-dead_strip");

// If we're building a dylib, we don't use --gc-sections because LLVM
Expand Down Expand Up @@ -727,7 +727,7 @@ impl<'a> Linker for GccLinker<'a> {

fn debuginfo(&mut self, strip: Strip, _: &[PathBuf]) {
// MacOS linker doesn't support stripping symbols directly anymore.
if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
return;
}

Expand Down Expand Up @@ -794,7 +794,7 @@ impl<'a> Linker for GccLinker<'a> {

debug!("EXPORTED SYMBOLS:");

if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
// Write a plain, newline-separated list of symbols
let res: io::Result<()> = try {
let mut f = File::create_buffered(&path)?;
Expand Down Expand Up @@ -840,7 +840,7 @@ impl<'a> Linker for GccLinker<'a> {
}
}

if self.sess.target.is_like_osx {
if self.sess.target.is_like_darwin {
self.link_arg("-exported_symbols_list").link_arg(path);
} else if self.sess.target.is_like_solaris {
self.link_arg("-M").link_arg(path);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static

let mut file = write::Object::new(binary_format, architecture, endianness);
file.set_sub_architecture(sub_architecture);
if sess.target.is_like_osx {
if sess.target.is_like_darwin {
if macho_is_arm64e(&sess.target) {
file.set_macho_cpu_subtype(object::macho::CPU_SUBTYPE_ARM64E);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod write;
///
/// Certain optimizations also depend on the deployment target.
pub fn versioned_llvm_target(sess: &Session) -> Cow<'_, str> {
if sess.target.is_like_osx {
if sess.target.is_like_darwin {
apple::add_version_to_llvm_target(&sess.target.llvm_target, apple::deployment_target(sess))
.into()
} else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tracing::debug;
pub(super) struct RPathConfig<'a> {
pub libs: &'a [&'a Path],
pub out_filename: PathBuf,
pub is_like_osx: bool,
pub is_like_darwin: bool,
pub linker_is_gnu: bool,
}

Expand Down Expand Up @@ -63,7 +63,7 @@ fn get_rpaths_relative_to_output(config: &RPathConfig<'_>) -> Vec<OsString> {

fn get_rpath_relative_to_output(config: &RPathConfig<'_>, lib: &Path) -> OsString {
// Mac doesn't appear to support $ORIGIN
let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" };
let prefix = if config.is_like_darwin { "@loader_path" } else { "$ORIGIN" };

// Strip filenames
let lib = lib.parent().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/rpath/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn test_rpath_relative() {
if cfg!(target_os = "macos") {
let config = &mut RPathConfig {
libs: &[],
is_like_osx: true,
is_like_darwin: true,
linker_is_gnu: false,
out_filename: PathBuf::from("bin/rustc"),
};
Expand All @@ -38,7 +38,7 @@ fn test_rpath_relative() {
let config = &mut RPathConfig {
libs: &[],
out_filename: PathBuf::from("bin/rustc"),
is_like_osx: false,
is_like_darwin: false,
linker_is_gnu: true,
};
let res = get_rpath_relative_to_output(config, Path::new("lib/libstd.so"));
Expand All @@ -51,7 +51,7 @@ fn test_rpath_relative_issue_119571() {
let config = &mut RPathConfig {
libs: &[],
out_filename: PathBuf::from("rustc"),
is_like_osx: false,
is_like_darwin: false,
linker_is_gnu: true,
};
// Should not panic when out_filename only contains filename.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
pub is_pe_coff: bool,
pub target_can_use_split_dwarf: bool,
pub target_arch: String,
pub target_is_like_osx: bool,
pub target_is_like_darwin: bool,
pub target_is_like_aix: bool,
pub split_debuginfo: rustc_target::spec::SplitDebuginfo,
pub split_dwarf_kind: rustc_session::config::SplitDwarfKind,
Expand Down Expand Up @@ -1216,7 +1216,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
is_pe_coff: tcx.sess.target.is_like_windows,
target_can_use_split_dwarf: tcx.sess.target_can_use_split_dwarf(),
target_arch: tcx.sess.target.arch.to_string(),
target_is_like_osx: tcx.sess.target.is_like_osx,
target_is_like_darwin: tcx.sess.target.is_like_darwin,
target_is_like_aix: tcx.sess.target.is_like_aix,
split_debuginfo: tcx.sess.split_debuginfo(),
split_dwarf_kind: tcx.sess.opts.unstable_opts.split_dwarf_kind,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
// somewhat, and is subject to change in the future (which
// is a good thing, because this would ideally be a bit
// more firmed up).
let is_like_elf = !(tcx.sess.target.is_like_osx
let is_like_elf = !(tcx.sess.target.is_like_darwin
|| tcx.sess.target.is_like_windows
|| tcx.sess.target.is_like_wasm);
codegen_fn_attrs.flags |= if is_like_elf {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ fn print_crate_info(
}
}
DeploymentTarget => {
if sess.target.is_like_osx {
if sess.target.is_like_darwin {
println_info!(
"{}={}",
apple::deployment_target_env_var(&sess.target.os),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn walk_native_lib_search_dirs<R>(
|| sess.target.os == "linux"
|| sess.target.os == "fuchsia"
|| sess.target.is_like_aix
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
|| sess.target.is_like_darwin && !sess.opts.unstable_opts.sanitizer.is_empty()
{
f(&sess.target_tlib_path.dir, false)?;
}
Expand Down Expand Up @@ -258,7 +258,7 @@ impl<'tcx> Collector<'tcx> {
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
"dylib" => NativeLibKind::Dylib { as_needed: None },
"framework" => {
if !sess.target.is_like_osx {
if !sess.target.is_like_darwin {
sess.dcx().emit_err(errors::LinkFrameworkApple { span });
}
NativeLibKind::Framework { as_needed: None }
Expand Down Expand Up @@ -532,7 +532,7 @@ impl<'tcx> Collector<'tcx> {
let mut renames = FxHashSet::default();
for lib in &self.tcx.sess.opts.libs {
if let NativeLibKind::Framework { .. } = lib.kind
&& !self.tcx.sess.target.is_like_osx
&& !self.tcx.sess.target.is_like_darwin
{
// Cannot check this when parsing options because the target is not yet available.
self.tcx.dcx().emit_err(errors::LibFrameworkApple);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/asm/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(crate) fn target_reserves_x18(target: &Target, target_features: &FxIndexSet<
target.os == "android"
|| target.os == "fuchsia"
|| target.env == "ohos"
|| target.is_like_osx
|| target.is_like_darwin
|| target.is_like_windows
|| target_features.contains(&sym::reserve_x18)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/asm/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl ArmInlineAsmRegClass {

// This uses the same logic as useR7AsFramePointer in LLVM
fn frame_pointer_is_r7(target_features: &FxIndexSet<Symbol>, target: &Target) -> bool {
target.is_like_osx || (!target.is_like_windows && target_features.contains(&sym::thumb_mode))
target.is_like_darwin || (!target.is_like_windows && target_features.contains(&sym::thumb_mode))
}

fn frame_pointer_r11(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
}
},
"aarch64" | "arm64ec" => {
let kind = if cx.target_spec().is_like_osx {
let kind = if cx.target_spec().is_like_darwin {
aarch64::AbiKind::DarwinPCS
} else if cx.target_spec().is_like_windows {
aarch64::AbiKind::Win64
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
let byval_align = if arg.layout.align.abi < align_4 {
// (1.)
align_4
} else if t.is_like_osx && contains_vector(cx, arg.layout) {
} else if t.is_like_darwin && contains_vector(cx, arg.layout) {
// (3.)
align_16
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub(crate) fn base(
function_sections: false,
dynamic_linking: true,
families: cvs!["unix"],
is_like_osx: true,
is_like_darwin: true,
binary_format: BinaryFormat::MachO,
// LLVM notes that macOS 10.11+ and iOS 9+ default
// to v4, so we do the same.
Expand Down
Loading
Loading