From 37f56907189ee9c5ef123571c93031e0d920dcef Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Tue, 15 Sep 2026 11:51:11 -0700 Subject: [PATCH 1/3] Rename Target::OS's OSX to MacOS, deprecate the old name Halide's Target::OS used the increasingly-out-of-date "osx" string and enum name for macOS. Rename the canonical name to MacOS/"macos" everywhere internally, while keeping OSX/"osx" working as a deprecated alias: the enum still defines OSX (marked [[deprecated]]) equal to MacOS, and target string parsing still accepts "osx" but emits a user_warning and prints "macos" back out. Co-Authored-By: Claude Sonnet 5 --- cmake/HalideGeneratorHelpers.cmake | 6 ++-- cmake/HalideTargetHelpers.cmake | 2 +- doc/HalideCMakePackage.md | 2 +- packaging/CMakeLists.txt | 2 +- .../halide/src/halide_/PyEnums.cpp | 32 +++++++++++++------ .../halide/test/correctness/target.py | 8 ++--- .../tutorial/lesson_12_using_the_gpu.py | 2 +- .../tutorial/lesson_19_wrapper_funcs.py | 2 +- src/CPlusPlusMangle.cpp | 8 ++--- src/CodeGen_ARM.cpp | 8 ++--- src/LLVM_Runtime_Linker.cpp | 16 +++++----- src/Target.cpp | 12 ++++--- src/Target.h | 3 +- src/autoschedulers/adams2019/CMakeLists.txt | 8 ++--- .../anderson2021/CMakeLists.txt | 8 ++--- test/correctness/cplusplus_mangle.cpp | 4 +-- test/correctness/gpu_allocation_cache.cpp | 2 +- test/correctness/gpu_dynamic_shared.cpp | 2 +- test/correctness/gpu_reuse_shared_memory.cpp | 2 +- test/correctness/gpu_specialize.cpp | 2 +- .../correctness/metal_precompiled_shaders.cpp | 2 +- test/correctness/simd_op_check_arm.cpp | 2 +- test/correctness/simd_op_check_sve2.cpp | 4 +-- test/correctness/target.cpp | 13 ++++++++ test/correctness/target_query.cpp | 6 ++-- test/correctness/vector_cast.cpp | 2 +- test/correctness/widening_reduction.cpp | 2 +- test/error/metal_threads_too_large.cpp | 2 +- test/performance/fast_inverse.cpp | 2 +- tutorial/lesson_12_using_the_gpu.cpp | 2 +- tutorial/lesson_19_wrapper_funcs.cpp | 2 +- 31 files changed, 100 insertions(+), 70 deletions(-) diff --git a/cmake/HalideGeneratorHelpers.cmake b/cmake/HalideGeneratorHelpers.cmake index 6f8920dacedb..6df083b67c0a 100644 --- a/cmake/HalideGeneratorHelpers.cmake +++ b/cmake/HalideGeneratorHelpers.cmake @@ -559,9 +559,9 @@ endfunction() function(_Halide_set_osx_arch TARGET TRIPLE) if (APPLE) - if (TRIPLE STREQUAL "arm-64-osx") + if (TRIPLE STREQUAL "arm-64-macos" OR TRIPLE STREQUAL "arm-64-osx") set_property(TARGET "${TARGET}" PROPERTY OSX_ARCHITECTURES "arm64") - elseif (TRIPLE STREQUAL "x86-64-osx") + elseif (TRIPLE STREQUAL "x86-64-macos" OR TRIPLE STREQUAL "x86-64-osx") set_property(TARGET "${TARGET}" PROPERTY OSX_ARCHITECTURES "x86_64") else () message(FATAL_ERROR "Could not set OSX_ARCHITECTURES for ${TRIPLE}") @@ -694,7 +694,7 @@ function(add_halide_library TARGET) set(features_args FEATURES) foreach (arch IN ITEMS x86 arm powerpc hexagon wasm riscv) foreach (bits IN ITEMS 32 64) - foreach (os IN ITEMS linux windows osx android ios qurt noos fuchsia wasmrt) + foreach (os IN ITEMS linux windows macos osx android ios qurt noos fuchsia wasmrt) list(APPEND features_args "FEATURES[${arch}-${bits}-${os}]") endforeach () endforeach () diff --git a/cmake/HalideTargetHelpers.cmake b/cmake/HalideTargetHelpers.cmake index 79b594b5af45..9dd2bab92a1c 100644 --- a/cmake/HalideTargetHelpers.cmake +++ b/cmake/HalideTargetHelpers.cmake @@ -13,7 +13,7 @@ function(_Halide_target_arch_os OUT_ARCH OUT_OS raw_arch raw_os) list(TRANSFORM arch REPLACE "^aarch(64)?$" "arm") string(TOLOWER "${raw_os}" os) - list(TRANSFORM os REPLACE "^darwin$" "osx") + list(TRANSFORM os REPLACE "^darwin$" "macos") list(TRANSFORM os REPLACE "^emscripten$" "wasmrt") # Fix up emscripten usage diff --git a/doc/HalideCMakePackage.md b/doc/HalideCMakePackage.md index a854ea15843f..c770b6439d8a 100644 --- a/doc/HalideCMakePackage.md +++ b/doc/HalideCMakePackage.md @@ -431,7 +431,7 @@ add_halide_library( FROM triple = -- arch = x86 | arm | powerpc | hexagon | wasm | riscv bits = 32 | 64 -os = linux | windows | osx | android | ios | qurt | noos | fuchsia | wasmrt +os = linux | windows | macos | android | ios | qurt | noos | fuchsia | wasmrt extra-output = ASSEMBLY | BITCODE | COMPILER_LOG | C_SOURCE | FEATURIZATION | HLPIPE | LLVM_ASSEMBLY | PYTHON_EXTENSION | PYTORCH_WRAPPER diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 70c4612dbe2c..68300b07ac2d 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -367,7 +367,7 @@ if (NOT CPACK_PACKAGE_FILE_NAME) set(arch_tag "${Halide_CMAKE_TARGET}") list(REMOVE_DUPLICATES arch_tag) list(SORT arch_tag) - if (arch_tag MATCHES "arm-64-osx;x86-64-osx") + if (arch_tag MATCHES "arm-64-macos;x86-64-macos") set(arch_tag "universal2") endif () string(REPLACE ";" "_" arch_tag "${arch_tag}") diff --git a/python_bindings/halide/src/halide_/PyEnums.cpp b/python_bindings/halide/src/halide_/PyEnums.cpp index a8705d71bca7..703cd3bdf2ee 100644 --- a/python_bindings/halide/src/halide_/PyEnums.cpp +++ b/python_bindings/halide/src/halide_/PyEnums.cpp @@ -94,16 +94,28 @@ void define_enums(py::module &m) { #pragma GCC diagnostic pop #endif - py::enum_(m, "TargetOS") - .value("OSUnknown", Target::OS::OSUnknown) - .value("Linux", Target::OS::Linux) - .value("Windows", Target::OS::Windows) - .value("OSX", Target::OS::OSX) - .value("Android", Target::OS::Android) - .value("IOS", Target::OS::IOS) - .value("QuRT", Target::OS::QuRT) - .value("NoOS", Target::OS::NoOS) - .value("wasmrt", Target::OS::WebAssemblyRuntime); + auto target_os = + py::enum_(m, "TargetOS") + .value("OSUnknown", Target::OS::OSUnknown) + .value("Linux", Target::OS::Linux) + .value("Windows", Target::OS::Windows) + .value("MacOS", Target::OS::MacOS) + .value("Android", Target::OS::Android) + .value("IOS", Target::OS::IOS) + .value("QuRT", Target::OS::QuRT) + .value("NoOS", Target::OS::NoOS) + .value("wasmrt", Target::OS::WebAssemblyRuntime); + + // OSX is deprecated in C++ (identical to MacOS), but the Python binding + // is kept for one release for backwards compatibility. +#if defined(__clang__) || defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + target_os.value("OSX", Target::OS::OSX); +#if defined(__clang__) || defined(__GNUC__) +#pragma GCC diagnostic pop +#endif py::enum_(m, "TargetArch") .value("ArchUnknown", Target::Arch::ArchUnknown) diff --git a/python_bindings/halide/test/correctness/target.py b/python_bindings/halide/test/correctness/target.py index a7031c2cd7d1..ea01672b5f59 100644 --- a/python_bindings/halide/test/correctness/target.py +++ b/python_bindings/halide/test/correctness/target.py @@ -153,14 +153,14 @@ def test_target(): assert not t2.supports_device_api(hl.DeviceAPI.CUDA) # supports_type (deprecated version) - t1 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal]) - t2 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64) + t1 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal]) + t2 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64) assert not t1.supports_type(hl.Float(64)) assert t2.supports_type(hl.Float(64)) # supports_type (preferred version) - t1 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal]) - t2 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64) + t1 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal]) + t2 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64) assert not t1.supports_type(hl.Float(64), hl.DeviceAPI.Metal) assert not t2.supports_type(hl.Float(64), hl.DeviceAPI.Metal) diff --git a/python_bindings/halide/tutorial/lesson_12_using_the_gpu.py b/python_bindings/halide/tutorial/lesson_12_using_the_gpu.py index 3dfca6b13ce2..213c14b1ba41 100755 --- a/python_bindings/halide/tutorial/lesson_12_using_the_gpu.py +++ b/python_bindings/halide/tutorial/lesson_12_using_the_gpu.py @@ -280,7 +280,7 @@ def find_gpu_target(): # D3D12Compute support is only available on 64-bit systems at present. features_to_try.append(hl.TargetFeature.D3D12Compute) features_to_try.append(hl.TargetFeature.OpenCL) - elif target.os == hl.TargetOS.OSX: + elif target.os == hl.TargetOS.MacOS: features_to_try.append(hl.TargetFeature.Metal) else: features_to_try.append(hl.TargetFeature.OpenCL) diff --git a/python_bindings/halide/tutorial/lesson_19_wrapper_funcs.py b/python_bindings/halide/tutorial/lesson_19_wrapper_funcs.py index 8d0256ea7c28..25084305fade 100755 --- a/python_bindings/halide/tutorial/lesson_19_wrapper_funcs.py +++ b/python_bindings/halide/tutorial/lesson_19_wrapper_funcs.py @@ -280,7 +280,7 @@ def main(): # Select an appropriate GPU API, as we did in lesson 12. target = hl.get_host_target() - if target.os == hl.TargetOS.OSX: + if target.os == hl.TargetOS.MacOS: target = target.with_feature(hl.TargetFeature.Metal) else: target = target.with_feature(hl.TargetFeature.OpenCL) diff --git a/src/CPlusPlusMangle.cpp b/src/CPlusPlusMangle.cpp index d56175185a66..31a87d053310 100644 --- a/src/CPlusPlusMangle.cpp +++ b/src/CPlusPlusMangle.cpp @@ -346,7 +346,7 @@ std::string simple_type_to_mangle_char(const std::string &type_name, const Targe } else if (type_name == "uint32_t") { return "j"; } else if (type_name == "int64_t") { - if (target.os == Target::OSX || + if (target.os == Target::MacOS || target.os == Target::IOS || target.bits == 32) { return "x"; @@ -354,7 +354,7 @@ std::string simple_type_to_mangle_char(const std::string &type_name, const Targe return "l"; } } else if (type_name == "uint64_t") { - if (target.os == Target::OSX || + if (target.os == Target::MacOS || target.os == Target::IOS || target.bits == 32) { return "y"; @@ -539,7 +539,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr return "i"; } case 64: - if (target.os == Target::OSX || + if (target.os == Target::MacOS || target.os == Target::IOS || target.bits == 32) { return "x"; @@ -565,7 +565,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr return "j"; } case 64: - if (target.os == Target::OSX || + if (target.os == Target::MacOS || target.os == Target::IOS || target.bits == 32) { return "y"; diff --git a/src/CodeGen_ARM.cpp b/src/CodeGen_ARM.cpp index 4fbf5c4a088d..123b8b7205ff 100644 --- a/src/CodeGen_ARM.cpp +++ b/src/CodeGen_ARM.cpp @@ -1199,7 +1199,7 @@ void CodeGen_ARM::compile_func(const LoweredFunc &f, internal_assert(llvm_func); bool is_streaming_task = (f.attributes & LoweredFunc::Attribute::SME_STREAMING_TASK) && target.has_feature(Target::SME2); - if (target.os != Target::IOS && target.os != Target::OSX) { + if (target.os != Target::IOS && target.os != Target::MacOS) { // Substitute in strided loads to get vld2/3/4 emission. We don't do it // on Apple silicon, because doing a dense load and then shuffling is // actually faster. @@ -2032,7 +2032,7 @@ void CodeGen_ARM::visit(const Shuffle *op) { // load. int stride = op->slice_stride(); const Load *load = op->vectors[0].as(); - if (target.os != Target::IOS && target.os != Target::OSX && + if (target.os != Target::IOS && target.os != Target::MacOS && load && op->vectors.size() == 1 && op->is_slice() && @@ -2932,7 +2932,7 @@ string CodeGen_ARM::mcpu_target() const { } else { if (target.os == Target::IOS) { return "apple-a7"; - } else if (target.os == Target::OSX) { + } else if (target.os == Target::MacOS) { return "apple-m1"; } else if (target.has_feature(Target::SVE2)) { return "cortex-x1"; @@ -3011,7 +3011,7 @@ string CodeGen_ARM::mattrs() const { if (target.has_feature(Target::SME2)) { attrs.emplace_back("+sme2"); } - if (target.os == Target::IOS || target.os == Target::OSX) { + if (target.os == Target::IOS || target.os == Target::MacOS) { attrs.emplace_back("+reserve-x18"); } } diff --git a/src/LLVM_Runtime_Linker.cpp b/src/LLVM_Runtime_Linker.cpp index dc612a15ddd7..40a06f32b8e2 100644 --- a/src/LLVM_Runtime_Linker.cpp +++ b/src/LLVM_Runtime_Linker.cpp @@ -353,7 +353,7 @@ namespace { llvm::DataLayout get_data_layout_for_target(Target target) { if (target.arch == Target::X86) { if (target.bits == 32) { - if (target.os == Target::OSX) { + if (target.os == Target::MacOS) { return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:128-n8:16:32-S128"); } else if (target.os == Target::IOS) { return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:128-n8:16:32-S128"); @@ -369,7 +369,7 @@ llvm::DataLayout get_data_layout_for_target(Target target) { return llvm::DataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128"); } } else { // 64-bit - if (target.os == Target::OSX) { + if (target.os == Target::MacOS) { return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"); } else if (target.os == Target::IOS) { return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"); @@ -391,7 +391,7 @@ llvm::DataLayout get_data_layout_for_target(Target target) { } else { // 64-bit if (target.os == Target::IOS) { return llvm::DataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32"); - } else if (target.os == Target::OSX) { + } else if (target.os == Target::MacOS) { return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"); } else if (target.os == Target::Windows) { return llvm::DataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32"); @@ -469,7 +469,7 @@ llvm::Triple get_triple_for_target(const Target &target) { if (target.os == Target::Linux) { triple.setOS(llvm::Triple::Linux); triple.setEnvironment(llvm::Triple::GNU); - } else if (target.os == Target::OSX) { + } else if (target.os == Target::MacOS) { triple.setVendor(llvm::Triple::Apple); triple.setOS(llvm::Triple::MacOSX); } else if (target.os == Target::Windows) { @@ -527,7 +527,7 @@ llvm::Triple get_triple_for_target(const Target &target) { } } else if (target.os == Target::Fuchsia) { triple.setOS(llvm::Triple::Fuchsia); - } else if (target.os == Target::OSX) { + } else if (target.os == Target::MacOS) { triple.setVendor(llvm::Triple::Apple); triple.setOS(llvm::Triple::MacOSX); triple.setArchName("arm64"); @@ -676,7 +676,7 @@ void link_modules(std::vector> &modules, Target t, // Comdats are left in for other platforms as they are required // for certain things on Windows and they are useful in general in // ELF based formats. - if (t.os == Target::IOS || t.os == Target::OSX) { + if (t.os == Target::IOS || t.os == Target::MacOS) { for (auto &global_obj : modules[0]->global_objects()) { global_obj.setComdat(nullptr); } @@ -1016,7 +1016,7 @@ std::unique_ptr get_initial_module_for_target(Target t, llvm::LLVM modules.push_back(get_initmod_fake_thread_pool(c, bits_64, debug)); } modules.push_back(get_initmod_fake_get_symbol(c, bits_64, debug)); - } else if (t.os == Target::OSX) { + } else if (t.os == Target::MacOS) { add_allocator(); modules.push_back(get_initmod_posix_error_handler(c, bits_64, debug)); modules.push_back(get_initmod_posix_print(c, bits_64, debug)); @@ -1280,7 +1280,7 @@ std::unique_ptr get_initial_module_for_target(Target t, llvm::LLVM if (t.arch == Target::ARM) { if (t.os == Target::Android || t.os == Target::Linux) { modules.push_back(get_initmod_linux_arm_cpu_features(c, bits_64, debug)); - } else if (t.os == Target::OSX || t.os == Target::IOS) { + } else if (t.os == Target::MacOS || t.os == Target::IOS) { modules.push_back(get_initmod_osx_arm_cpu_features(c, bits_64, debug)); } else if (t.bits == 64 && t.os == Target::Windows) { modules.push_back(get_initmod_windows_aarch64_cpu_features_arm(c, bits_64, debug)); diff --git a/src/Target.cpp b/src/Target.cpp index b5c445833c8a..f259235ff172 100644 --- a/src/Target.cpp +++ b/src/Target.cpp @@ -231,7 +231,7 @@ Target calculate_host_target() { os = Target::Windows; #endif #ifdef __APPLE__ - os = Target::OSX; + os = Target::MacOS; #endif bool use_64_bits = (sizeof(size_t) == 8); @@ -456,7 +456,8 @@ const std::map os_name_map = { {"os_unknown", Target::OSUnknown}, {"linux", Target::Linux}, {"windows", Target::Windows}, - {"osx", Target::OSX}, + {"macos", Target::MacOS}, + {"osx", Target::MacOS}, // Deprecated alias for macos. {"android", Target::Android}, {"ios", Target::IOS}, {"qurt", Target::QuRT}, @@ -468,6 +469,9 @@ bool lookup_os(const std::string &tok, Target::OS &result) { auto os_iter = os_name_map.find(tok); if (os_iter != os_name_map.end()) { result = os_iter->second; + if (tok == "osx") { + user_warning << "\"osx\" is a deprecated alias for \"macos\" in Halide target strings and will be removed in a future release.\n"; + } return true; } return false; @@ -1248,7 +1252,7 @@ void Target::set_implied_features() { set_feature(AVX512_SapphireRapids); } } - if (arch == ARM && os == OSX) { + if (arch == ARM && os == MacOS) { // Apple silicon implements at least the ARM v8.4-A spec. set_feature(ARMv84a); } @@ -1285,7 +1289,7 @@ void Target::unset_implied_features() { set_feature(AVX2, false); } } - if (arch == ARM && os == OSX) { + if (arch == ARM && os == MacOS) { set_feature(ARMv84a, false); } } diff --git a/src/Target.h b/src/Target.h index f8434644ae33..00076819197b 100644 --- a/src/Target.h +++ b/src/Target.h @@ -24,7 +24,8 @@ struct Target { OSUnknown = 0, Linux, Windows, - OSX, + MacOS, + OSX [[deprecated("Use Target::MacOS instead.")]] = MacOS, Android, IOS, QuRT, diff --git a/src/autoschedulers/adams2019/CMakeLists.txt b/src/autoschedulers/adams2019/CMakeLists.txt index 88fcac946d92..f6d06da584d7 100644 --- a/src/autoschedulers/adams2019/CMakeLists.txt +++ b/src/autoschedulers/adams2019/CMakeLists.txt @@ -27,8 +27,8 @@ add_halide_library( FROM adams2019_cost_model.generator GENERATOR cost_model FUNCTION_NAME cost_model - FEATURES[x86-64-osx] avx2 sse41 - FEATURES[arm-64-osx] arm_dot_prod-arm_fp16 + FEATURES[x86-64-macos] avx2 sse41 + FEATURES[arm-64-macos] arm_dot_prod-arm_fp16 ) add_halide_library( @@ -36,8 +36,8 @@ add_halide_library( FROM adams2019_cost_model.generator GENERATOR train_cost_model FUNCTION_NAME train_cost_model - FEATURES[x86-64-osx] avx2 sse41 - FEATURES[arm-64-osx] arm_dot_prod-arm_fp16 + FEATURES[x86-64-macos] avx2 sse41 + FEATURES[arm-64-macos] arm_dot_prod-arm_fp16 USE_RUNTIME adams2019_cost_model.runtime ) diff --git a/src/autoschedulers/anderson2021/CMakeLists.txt b/src/autoschedulers/anderson2021/CMakeLists.txt index c4a84cc4dcc4..49ef45658831 100644 --- a/src/autoschedulers/anderson2021/CMakeLists.txt +++ b/src/autoschedulers/anderson2021/CMakeLists.txt @@ -26,16 +26,16 @@ add_halide_library( FROM anderson2021_cost_model.generator GENERATOR cost_model FUNCTION_NAME cost_model - FEATURES[x86-64-osx] avx2 sse41 - FEATURES[arm-64-osx] arm_dot_prod-arm_fp16 + FEATURES[x86-64-macos] avx2 sse41 + FEATURES[arm-64-macos] arm_dot_prod-arm_fp16 ) add_halide_library( anderson2021_train_cost_model FROM anderson2021_cost_model.generator GENERATOR train_cost_model FUNCTION_NAME train_cost_model - FEATURES[x86-64-osx] avx2 sse41 - FEATURES[arm-64-osx] arm_dot_prod-arm_fp16 + FEATURES[x86-64-macos] avx2 sse41 + FEATURES[arm-64-macos] arm_dot_prod-arm_fp16 USE_RUNTIME anderson2021_cost_model.runtime ) diff --git a/test/correctness/cplusplus_mangle.cpp b/test/correctness/cplusplus_mangle.cpp index cdbeec6f020d..66d355d7f39a 100644 --- a/test/correctness/cplusplus_mangle.cpp +++ b/test/correctness/cplusplus_mangle.cpp @@ -326,8 +326,8 @@ int main() { Target targets[kTestTargetCount]{ Target(Target::Linux, Target::X86, 32), Target(Target::Linux, Target::X86, 64), - Target(Target::OSX, Target::X86, 32), - Target(Target::OSX, Target::X86, 64), + Target(Target::MacOS, Target::X86, 32), + Target(Target::MacOS, Target::X86, 64), Target(Target::IOS, Target::ARM, 32), Target(Target::IOS, Target::ARM, 64), Target(Target::Windows, Target::X86, 32), diff --git a/test/correctness/gpu_allocation_cache.cpp b/test/correctness/gpu_allocation_cache.cpp index 1581f8c8a8b0..857314cdd6fd 100644 --- a/test/correctness/gpu_allocation_cache.cpp +++ b/test/correctness/gpu_allocation_cache.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) { printf("[SKIP-WITH-ISSUE-5000] Allocation cache not yet implemented for D3D12Compute.\n"); return 0; } - if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::OSX)) { + if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::MacOS)) { printf("[SKIP] Skipping test for Vulkan on iOS/OSX (MoltenVK only allows 30 buffers to be allocated)!\n"); return 0; } diff --git a/test/correctness/gpu_dynamic_shared.cpp b/test/correctness/gpu_dynamic_shared.cpp index f98636ea8905..86d17bbaaa23 100644 --- a/test/correctness/gpu_dynamic_shared.cpp +++ b/test/correctness/gpu_dynamic_shared.cpp @@ -19,7 +19,7 @@ int main(int argc, char **argv) { printf("[SKIP] Vulkan %d.%d is less than required 1.3.\n", major, minor); return 0; } - if ((t.os == Target::IOS) || (t.os == Target::OSX)) { + if ((t.os == Target::IOS) || (t.os == Target::MacOS)) { printf("[SKIP] Skipping test for Vulkan on iOS/OSX (MoltenVK doesn't support dynamic LocalSizeId yet)!\n"); return 0; } diff --git a/test/correctness/gpu_reuse_shared_memory.cpp b/test/correctness/gpu_reuse_shared_memory.cpp index 8b0e8b7f9b90..3969b62d00de 100644 --- a/test/correctness/gpu_reuse_shared_memory.cpp +++ b/test/correctness/gpu_reuse_shared_memory.cpp @@ -259,7 +259,7 @@ int main(int argc, char **argv) { } printf("Running dynamic shared test\n"); - if (t.has_feature(Target::Vulkan) && ((t.os == Target::IOS) || t.os == Target::OSX)) { + if (t.has_feature(Target::Vulkan) && ((t.os == Target::IOS) || t.os == Target::MacOS)) { printf("Skipping test for Vulkan on iOS/OSX (MoltenVK doesn't support dynamic sizes for shared memory)!\n"); } else { if (dynamic_shared_test(memory_type) != 0) { diff --git a/test/correctness/gpu_specialize.cpp b/test/correctness/gpu_specialize.cpp index 9cae395a0082..21e32b81b785 100644 --- a/test/correctness/gpu_specialize.cpp +++ b/test/correctness/gpu_specialize.cpp @@ -9,7 +9,7 @@ int main(int argc, char **argv) { printf("[SKIP] No GPU target enabled.\n"); return 0; } - if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::OSX)) { + if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::MacOS)) { printf("[SKIP] Skipping test for Vulkan on iOS/OSX (MoltenVK doesn't support dynamically allocated shared mem)!\n"); return 0; } diff --git a/test/correctness/metal_precompiled_shaders.cpp b/test/correctness/metal_precompiled_shaders.cpp index da1e76423f21..3836d1758bfc 100644 --- a/test/correctness/metal_precompiled_shaders.cpp +++ b/test/correctness/metal_precompiled_shaders.cpp @@ -8,7 +8,7 @@ int main(int argc, char **argv) { // This test only runs on macOS with Metal support Target t = get_jit_target_from_environment(); - if (t.os != Target::OSX || !t.has_feature(Target::Metal)) { + if (t.os != Target::MacOS || !t.has_feature(Target::Metal)) { printf("[SKIP] This test only runs on macOS with Metal support\n"); return 0; } diff --git a/test/correctness/simd_op_check_arm.cpp b/test/correctness/simd_op_check_arm.cpp index a5e879622682..4a2c6f4d62d1 100644 --- a/test/correctness/simd_op_check_arm.cpp +++ b/test/correctness/simd_op_check_arm.cpp @@ -324,7 +324,7 @@ class SimdOpCheckARM : public SimdOpCheckTest { check(arm32 ? "vld1.32" : "ldr", 2 * w, in_f32(x + y)); } - if (target.os != Target::IOS && target.os != Target::OSX) { + if (target.os != Target::IOS && target.os != Target::MacOS) { // VLD* are not profitable on Apple silicon // Even on non-Apple silicon, LLVM occasionally decides it's diff --git a/test/correctness/simd_op_check_sve2.cpp b/test/correctness/simd_op_check_sve2.cpp index a497e617ddd2..db6a15eef171 100644 --- a/test/correctness/simd_op_check_sve2.cpp +++ b/test/correctness/simd_op_check_sve2.cpp @@ -678,7 +678,7 @@ class SimdOpCheckArmSve : public SimdOpCheckTest { add_arm64("finite", is_vector ? sel_op("", "fcmge", "fcmeq") : "", is_inf(f_1)); } - if (bits == 16 && target.os != Target::IOS && target.os != Target::OSX) { + if (bits == 16 && target.os != Target::IOS && target.os != Target::MacOS) { // Actually, the following ops are not vectorized because SIMD instruction is unavailable. // The purpose of the test is just to confirm no error. // In case the target has FP16 feature, native type conversion between fp16 and fp32 should be generated @@ -725,7 +725,7 @@ class SimdOpCheckArmSve : public SimdOpCheckTest { // which makes it prone to false-positive detection as we only search strings line-by-line. // LDn - Structured Load strided elements - if (target.os != Target::IOS && target.os != Target::OSX && + if (target.os != Target::IOS && target.os != Target::MacOS && Halide::Internal::get_llvm_version() >= 220) { for (int stride = 2; stride <= 4; ++stride) { diff --git a/test/correctness/target.cpp b/test/correctness/target.cpp index 77c39df0b4bc..d7ffc7ff6c1b 100644 --- a/test/correctness/target.cpp +++ b/test/correctness/target.cpp @@ -49,6 +49,19 @@ int main(int argc, char **argv) { return 1; } + // "osx" is a deprecated alias for "macos": it should still parse, but + // should print back out as "macos". + t1 = Target("x86-64-osx"); + ts = t1.to_string(); + if (ts != "x86-64-macos") { + printf("osx alias to_string failure: %s\n", ts.c_str()); + return 1; + } + if (t1.os != Target::MacOS || t1 != Target("x86-64-macos")) { + printf("osx alias parse failure: %s\n", ts.c_str()); + return 1; + } + // Full specification round-trip, crazy features t1 = Target(Target::Android, Target::ARM, 32, {Target::JIT, Target::CUDA, Target::OpenCL, diff --git a/test/correctness/target_query.cpp b/test/correctness/target_query.cpp index c3bfb9e8f123..a4b6bcf7bccf 100644 --- a/test/correctness/target_query.cpp +++ b/test/correctness/target_query.cpp @@ -6,7 +6,7 @@ using namespace Halide; int main(int argc, char **argv) { // For simplicity, only run this test on hosts that we can predict. Target t = get_host_target(); - if (t.arch != Target::X86 || t.bits != 64 || t.os != Target::OSX) { + if (t.arch != Target::X86 || t.bits != 64 || t.os != Target::MacOS) { printf("[SKIP] This test only runs on x86-64-osx.\n"); return 0; } @@ -14,14 +14,14 @@ int main(int argc, char **argv) { t = t.with_feature(Target::Debug); // Full specification round-trip, crazy features - Target t1 = Target(Target::OSX, Target::X86, 64, + Target t1 = Target(Target::MacOS, Target::X86, 64, {Target::CUDA, Target::Debug}); Expr is_arm = target_arch_is(Target::ARM); Expr is_x86 = target_arch_is(Target::X86); Expr bits = target_bits(); Expr is_android = target_os_is(Target::Android); - Expr is_osx = target_os_is(Target::OSX); + Expr is_osx = target_os_is(Target::MacOS); Expr vec = target_natural_vector_size(); Expr has_cuda = target_has_feature(Target::CUDA); Expr has_vulkan = target_has_feature(Target::Vulkan); diff --git a/test/correctness/vector_cast.cpp b/test/correctness/vector_cast.cpp index 575d97842176..66fd4c84f9e1 100644 --- a/test/correctness/vector_cast.cpp +++ b/test/correctness/vector_cast.cpp @@ -32,7 +32,7 @@ bool is_type_supported(int vec_width, const Target &target) { } if (target.has_feature(Target::Vulkan)) { if (type_of() == Float(64)) { - if ((target.os == Target::OSX || target.os == Target::IOS)) { + if ((target.os == Target::MacOS || target.os == Target::IOS)) { return false; // MoltenVK doesn't support Float64 } } diff --git a/test/correctness/widening_reduction.cpp b/test/correctness/widening_reduction.cpp index 43b79486e03a..fd01792df7be 100644 --- a/test/correctness/widening_reduction.cpp +++ b/test/correctness/widening_reduction.cpp @@ -9,7 +9,7 @@ using namespace Halide::Internal; int main(int arch, char **argv) { Halide::Target target = get_jit_target_from_environment(); - if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::OSX)) { + if (target.has_feature(Target::Vulkan) && ((target.os == Target::IOS) || target.os == Target::MacOS)) { printf("[SKIP] Skipping test for Vulkan on iOS/OSX (MoltenVK fails to convert max/min intrinsics correctly)!\n"); return 0; } diff --git a/test/error/metal_threads_too_large.cpp b/test/error/metal_threads_too_large.cpp index 130f0ba8c7b1..a8a0be6f6872 100644 --- a/test/error/metal_threads_too_large.cpp +++ b/test/error/metal_threads_too_large.cpp @@ -4,7 +4,7 @@ using namespace Halide; int main(int argc, char **argv) { - if (get_jit_target_from_environment().os != Target::OSX) { + if (get_jit_target_from_environment().os != Target::MacOS) { printf("[SKIP] error/metal_threads_too_large ignored for non-OSX targets\n"); _halide_user_assert(0); } diff --git a/test/performance/fast_inverse.cpp b/test/performance/fast_inverse.cpp index fff3d325223e..d49fe7632286 100644 --- a/test/performance/fast_inverse.cpp +++ b/test/performance/fast_inverse.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) { } if (target.arch == Target::ARM && - target.os == Target::OSX) { + target.os == Target::MacOS) { // vrecpe, vrecps, fmul have inverse throughputs of 1, 0.25, 0.25 // respectively, while fdiv has inverse throughput of 1. printf("[SKIP] Apple M1 chips have division performance roughly on par with the reciprocal instruction\n"); diff --git a/tutorial/lesson_12_using_the_gpu.cpp b/tutorial/lesson_12_using_the_gpu.cpp index 72827c73fa1f..c79858bfa4b2 100644 --- a/tutorial/lesson_12_using_the_gpu.cpp +++ b/tutorial/lesson_12_using_the_gpu.cpp @@ -289,7 +289,7 @@ Target find_gpu_target() { features_to_try.push_back(Target::D3D12Compute); } features_to_try.push_back(Target::OpenCL); - } else if (target.os == Target::OSX) { + } else if (target.os == Target::MacOS) { features_to_try.push_back(Target::Metal); } else { features_to_try.push_back(Target::OpenCL); diff --git a/tutorial/lesson_19_wrapper_funcs.cpp b/tutorial/lesson_19_wrapper_funcs.cpp index d56e6159c910..860b23ec3e70 100644 --- a/tutorial/lesson_19_wrapper_funcs.cpp +++ b/tutorial/lesson_19_wrapper_funcs.cpp @@ -286,7 +286,7 @@ int main() { // Select an appropriate GPU API, as we did in lesson 12 Target target = get_host_target(); - if (target.os == Target::OSX) { + if (target.os == Target::MacOS) { target.set_feature(Target::Metal); } else { target.set_feature(Target::OpenCL); From 2ca5114d9d0f51c7bc423b88e1c82133f112625d Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Tue, 15 Sep 2026 12:28:11 -0700 Subject: [PATCH 2/3] Emit a Python DeprecationWarning for TargetOS.OSX Wrap the pybind11-registered TargetOS.OSX class attribute with a descriptor in halide/__init__.py so accessing it raises a DeprecationWarning pointing at TargetOS.MacOS, matching the C++-side [[deprecated]] attribute on Target::OSX. Co-Authored-By: Claude Sonnet 5 --- python_bindings/halide/src/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python_bindings/halide/src/__init__.py b/python_bindings/halide/src/__init__.py index f071cb82c9cf..24267e63d812 100644 --- a/python_bindings/halide/src/__init__.py +++ b/python_bindings/halide/src/__init__.py @@ -1,3 +1,4 @@ +import warnings from pathlib import Path # halide-bin owns library discovery and loads its bundled libHalide before the @@ -10,6 +11,24 @@ from . import runtime as runtime from .halide_ import * # noqa: F403 + +class _DeprecatedEnumValue: + """Descriptor that returns a replacement enum value, after warning.""" + + def __init__(self, replacement, message): + self._replacement = replacement + self._message = message + + def __get__(self, obj, owner): + warnings.warn(self._message, DeprecationWarning, stacklevel=2) + return self._replacement + + +# TargetOS.OSX is deprecated in favor of TargetOS.MacOS; accessing it warns. +TargetOS.OSX = _DeprecatedEnumValue( + TargetOS.MacOS, "TargetOS.OSX is deprecated; use TargetOS.MacOS instead." +) + # The implicit-argument placeholders are deliberately imported explicitly; # `from .halide_ import *` skips them because they begin with an underscore. from .halide_ import _, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9 # noqa: F401 From 3771224b5b230967c3f9ab4d526bd8b7c66fcd40 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Wed, 16 Sep 2026 10:37:13 -0700 Subject: [PATCH 3/3] Fix ruff errors in the OSX-deprecation shim Move the deprecation shim below the module imports (E402) and name TargetOS explicitly rather than relying on the star import (F405). Co-Authored-By: Claude Opus 4.8 --- python_bindings/halide/src/__init__.py | 38 ++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/python_bindings/halide/src/__init__.py b/python_bindings/halide/src/__init__.py index 24267e63d812..bc89c59c2e6f 100644 --- a/python_bindings/halide/src/__init__.py +++ b/python_bindings/halide/src/__init__.py @@ -11,23 +11,9 @@ from . import runtime as runtime from .halide_ import * # noqa: F403 - -class _DeprecatedEnumValue: - """Descriptor that returns a replacement enum value, after warning.""" - - def __init__(self, replacement, message): - self._replacement = replacement - self._message = message - - def __get__(self, obj, owner): - warnings.warn(self._message, DeprecationWarning, stacklevel=2) - return self._replacement - - -# TargetOS.OSX is deprecated in favor of TargetOS.MacOS; accessing it warns. -TargetOS.OSX = _DeprecatedEnumValue( - TargetOS.MacOS, "TargetOS.OSX is deprecated; use TargetOS.MacOS instead." -) +# TargetOS comes from the star import above; name it explicitly so the +# deprecation shim below doesn't trip ruff's F405. +from .halide_ import TargetOS # The implicit-argument placeholders are deliberately imported explicitly; # `from .halide_ import *` skips them because they begin with an underscore. @@ -52,5 +38,23 @@ def __get__(self, obj, owner): ) +class _DeprecatedEnumValue: + """Descriptor that returns a replacement enum value, after warning.""" + + def __init__(self, replacement, message): + self._replacement = replacement + self._message = message + + def __get__(self, obj, owner): + warnings.warn(self._message, DeprecationWarning, stacklevel=2) + return self._replacement + + +# TargetOS.OSX is deprecated in favor of TargetOS.MacOS; accessing it warns. +TargetOS.OSX = _DeprecatedEnumValue( + TargetOS.MacOS, "TargetOS.OSX is deprecated; use TargetOS.MacOS instead." +) + + def install_dir(): return str(Path(__file__).resolve().parent)