夜雨聆风学习资料网

ARTICLE · 1426576

罗塞塔:MacOS转译中的过去,现在和未来

罗塞塔:MacOS转译中的过去,现在和未来
    这是一块花岗闪长岩石碑的残存部分。整块石碑原刻有托勒密五世的一份诏书,现存可见碑文分别以三种不同文字记录了诏书的同一段落:
       埃及草书(32行)、埃及象形文字(14行)以及希腊文(54行)。

公元前196年藏品尺寸:高112.3厘米,宽75.7厘米,厚28.4厘米

藏品来源:英王乔治三世捐赠  入藏日期:1802年  馆藏编号:EA24

  在前托勒密时期(公元前332年之前),埃及的诏书都是以象形文字(圣书体)书写并由国王颁布的。但到了公元4世纪末,这种文字已经被完全废弃,读写知识也已失传。
  因此罗塞塔石碑上由祭司们以三种文字书写的诏书表明了自从托勒密时期以来时局以及书写系统所发生的巨大变化。国王的诏书现在变成由祭司们负责誊写和颁发,而后者也是当时唯一掌握圣书体的人群了。  这通诏书列举了当时的国王托勒密五世为神庙所作的善行,因此也间接显示出神职人员当时所获的供养。
  1799年,拿破仑军队在埃及el-Rashid镇(即罗塞塔)附近进行要塞地基扩大工程时发现了这块石碑。随着拿破仑战败,罗塞塔石碑也根据亚历山卓协约成,和其他法军获取的埃及文物一道,成为了英王的财产。
        罗塞塔石碑的出土不仅引发了英法两国对石碑的明争暗抢,还引发了另一场两国破译碑文的巅峰对决。英法双方各派出皇家研究院教授托马斯·杨和小有名气的东方学教授让-弗朗索瓦·商博良出战。
      杨从数学角度出发,试图把希腊语中出现频率较高的文字对接到象形文字中,然而他失败了;商博良则从古埃及俗体文字的读音出发在象形文字中寻找异同点。

      最终商博良在1822年给出了罗塞塔石碑的全文翻译,成为这场巅峰对决的获胜者。

   罗塞塔碑的发现为已失传了 1400多年的埃及古文字的解读带来了曙光。在石碑刚被发现不久后的十九世纪初,学者们就开始从碑文上已知的希腊文着手,试图解读与之相对应的埃及象形文字了。  英国物理学者汤玛斯•杨(Thomas Young),首先指出了罗塞塔碑文上有些象形文字示意了王名“托勒密”的读音。
托马斯·杨是一位兴趣广泛的物理学家、医生和语言学家。他首先将研究重点放在了世俗体的部分,通过与希腊文比对,成功识别出了对应“国王”和“托勒密”的词组。 随后,他转向了更具挑战性的圣书体。他注意到,在圣书体铭文中,有一些符号被一个椭圆形的圈(Cartouche,即王名圈)框起来。他大胆猜测,这些王名圈里圈起来的,应该是国王的名字。这是一个决定性的突破!通过比对希腊文中的“Ptolemaios”(托勒密),他成功地将圈内的一系列象形符号与希腊字母的发音对应起来。 杨的发现证明了,圣书体并非纯粹的表意文字,其中至少有一部分符号是用来表音的。然而,他错误地认为,这种表音功能可能只适用于拼写外国统治者(如希腊的托勒密)的名字。这位伟大的科学家在真理的门前徘徊,却未能推开最后一扇门。
      其后,法国学者商博良(Jean-François Champollion)进一步认识到象形文字其实是记录了埃及语的读音。商博良的工作为我们以后对古埃及语言和文化的认识奠定了基础。
真正完成破译伟业的,是法国人商博良。他从小就对埃及充满了痴迷,并为此学习了包括科普特语在内的多种古代语言。他坚信,作为古埃及语最后演变形式的科普特语,将是解开圣书体之谜的关键。 商博良在杨的研究基础上,获得了更多来自埃及的铭文拓片。他拿到了另一个著名的王名圈,其中包含的符号他推测是“Cleopatra”(克利奥帕特拉)的名字。通过将“Ptolemaios”和“Cleopatra”两个名字中的共有字母(P, T, O, L)所对应的符号进行比对,他验证并扩展了杨的字母表。 真正的“尤里卡时刻”发生在1822年9月14日。商博良正在研究一份来自阿布辛贝神庙的铭文,看到了一个他从未见过的王名圈。圈内开头的符号是一个太阳(在科普特语中读作“Ra”),后面跟着两个他已经认识的符号,发音为“mes”和“ses”。他将它们组合在一起:“Ra-mes-ses”。拉美西斯!这是一位纯正的古埃及法老的名字! 这个发现彻底推翻了“表音符号只用于拼写外来名字”的错误假设。商博良激动地冲出自己的公寓,跑到他哥哥的办公室,大喊一声“Je tiens l'affaire!”(我成功了!),然后便因过度兴奋而昏了过去。 商博良最终揭示了古埃及圣书体系统的全部秘密:它是一种精妙的复合系统,同时包含了表音符号、表意符号和部首(限定符号)。这三大类符号相互配合,共同构成了复杂而准确的文字体系。
罗塞塔石碑(Rosetta Stone),这块看似平平无奇的黑色花岗闪长岩石板,是人类文明史上最著名的“解码器”之一。它并非一部史诗,也非一部法典,而是一份公元前196年的国王敕令。其貌不扬的外表下,蕴藏着解开古埃及文明千年之谜的钥匙。石碑上用三种不同的文字——古埃及神圣的圣书体(Hieroglyphs)、世俗的埃及草书(Demotic)和当时统治者使用的古希腊文(Ancient Greek)——刻写了相同的内容。正是这“三语对照”的独特形式,让它在沉睡了近一千四百年后,成为了一座跨越时空的语言。
桥梁,使早已被遗忘的埃及象形文字重获新生,让一个伟大的古代文明得以向现代世界再次讲述自己的故事。

故事回到6年前:
Apple在2020年推出了搭载 M1 自研芯片的 MacBook Air、Mac mini 以及 13 英寸 MacBook Pro。其中,苹果 M1 芯片与此前 Mac 采用的芯片最大不同是基于 ARM 架构,而过去是英特尔芯片的 x86 架构。

由于 M1 芯片底层架构和过去不同,由此带来的应用生态兼容性问题是首先需要解决的,为此苹果也开启了为期两年的 Mac 过渡计划。具体来说,苹果借助的是 macOS 11 Big Sur 系统以及其内置的 Universal 2、Rosetta 2 和 Virtualizaion 三种技术来解决问题。

不过话虽如此,回顾当时可能还是有人会犹豫,是否真的可以解决 M1 芯片 Mac 的软件兼容性问题吗?特别是原来在 x86 架构上的应用,开发者还没有及时做适配,能在 Mac 上很好地运行吗?还值得升级吗?

历史证明,Rosetta2确实是一项优秀的转译技术。


    在 macOS 27上,Apple对 Intel 架构 Mac 正是将画上句号,而 Rosetta 2 应用转换功能也将进入淘汰阶段,这标志着 Intel Mac 支持将结束。

现在可以明确的是:macOS 27 将成为最后一个支持 Intel Mac 的 macOS 版本。从之后开始,所有新版本系统都将仅支持 Apple Silicon 机型。

当然macOS Tahoe 安全更新将持续至 2028 年

苹果将为 macOS Tahoe 提供安全更新直至 2028 年秋季,即该版本被 macOS 27 取代后的两年。这也是 macOS 系统惯常的支持周期——主版本发布后的第 一年包含功能和安全更新,接下来的两年则仅限于安全补丁,不再新增功能。

(苹果惯用的“蜜罐策略”,先给蜜后逐步收紧放自己的糖🍬)

苹果正在逐步淘汰 Rosetta 2 转译层。未来,大多数依赖 Rosetta 2 的应用将无法在 macOS 28 中运行。

Rosetta 2 功能将被限制

苹果计划逐步削减 Rosetta 2 的适用范围。

Rosetta 是苹果在 Intel 过渡到 Apple Silicon 期间推出的Intel 到 Arm 应用转换技术,能让基于 Intel 架构的应用在 Apple Silicon 设备上运行。

在 macOS 27 中,Rosetta 2 仍将作为通用的应用转换工具存在。但此后,它将仅限于运行某些特定类型的应用,主要是依赖 Intel 专属库、且开发者已停止维护的老旧游戏。

开发者希望他们的应用继续在后续版本的 macOS 上运行,就必须将应用迁移为 Apple Silicon 原生版本,或开发同时兼容两种架构的“通用应用”。


蜜罐策略

苹果早在 2000 年代中期从 PowerPC 转向 Intel 时,也曾采用类似策略。最初的 Rosetta 技术曾在 Mac OS X 10.4、10.5 和 10.6 中提供支持,但在 2011 年发布的 10.7 中被完全移除,距首款 Intel Mac 推出约五年。

虽然苹果停止对 Intel Mac 的支持是早晚的事,但某些机型的“被淘汰速度”比其他机型更快。尽管大部分 Intel Mac 在 2020 至 2021 年就被 Apple Silicon 机型替代,但苹果仍持续销售 2019 年的 Intel Mac Pro 和部分 2018 年的 Intel Mac mini 直至 2023 年。

这意味着,2023 年仍花高价购买 Mac Pro 的用户,最多也只获得 三个 macOS 主版本更新,以及五年安全更新;而 2018 年的 Mac mini 更惨,甚至无法升级到 macOS Tahoe——macOS 15 Sequoia 就是它的“终点”。

随着 macOS 向 Apple Silicon 全面转型,苹果显然在为打造更统一、更高效的生态系统做准备。这也标志着 Intel Mac 时代的彻底落幕。

运行以下指令强制安装Rosetta:

installRosetta(completionHandler:)

Starts the installation of Rosetta.  

macOS 13.0+

class func installRosetta(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
class func installRosetta() async throws

Parameters 

  • completionHandler
  • The completion handler the framework invokes after the request finishes processing.

Discussion

The completion handler returns an error object that contains information about a problem, or nilif the installation completed successfully.

这一招,如今来到Mac OS 26版本,苹果逐步将剔除Rosetta 2 功能,过去依赖于蓝厂inter X86 架构的应用成为历史。谁知道会不会再来Rosetta 3呢?或者转译更加开源的RISC-V呢?(历史真是像个轮子)


macOS 27 新特性

在WWDC26中,新添加AI内置是亮点,另外还加入这些功能:

Foundation Models 框架

Foundation Models 框架是一套原生 Swift API,可让你直接访问驱动 Apple 智能的同款设备端模型。现在,你可以使用任何语言模型,包括 Apple Foundation Models、Claude 和 Gemini 等云端模型,或任何其他符合 Language Model 协议的供应商提供的模型。

多模态提示词让你能够同时传递图像和文本,使你的 App 可以对视觉内容进行推理;OCR 和条形码读取器等 Vision 框架工具也可供你的模型直接调用,全部在设备端完成。Dynamic Profiles 让你能够动态切换模型、工具和指令,使你的 App 行为可在连续会话中灵活调整。

如果你已加入 App Store Small Business Program,且你的 App 在 App Store 的首次下载总量少于 200 万次,你就可以免费访问在私有云计算上运行的下一代 Apple Foundation Models。借助全新 Evaluations 框架,你可以在各种动态条件下验证 AI 功能是否正常运行,弥补单元测试难以覆盖的场景。

App Intents 框架

通过 App Intents 框架,Siri 现在能与你 App 中更多用户操作进行连接,让你的内容和操作可通过自然语言访问。
实体架构将你 App 的内容贡献到 Spotlight 语义索引,使 Siri 可以将其呈现并归因到你的 App。意图架构让用户能够自然地对该内容采取行动,无需定义特定短语,当 Siri 的语言理解能力扩展或延伸到新语言和地区方言时,也无需更改代码。
全新 View Annotations API 让你能够将视图映射到实体,使用户可以通过对话引用并操控屏幕上的内容。App Intents Testing 框架则让你能够通过真实的系统路径验证整个集成方案,无需 UI 自动化,从而及早发现问题并自信地发布。
Core AI
全新框架 Core AI 直接内置在操作系统中,专为 Apple 芯片而设计,堪称将你自己的模型引入设备端运行的理想框架,另外还有配套的支持工具和技术助你一臂之力。通过内存安全的现代 Swift API,你能够直接在设备端载入、专门定制并运行 AI 模型,兼顾用户数据的隐私保护和你 App 的灵敏响应,完全消除对服务器的依赖和词元成本。模型会根据所运行的硬件自动完成优化,还支持提前编译,方便实现快速载入。精细的推理内存控制、无需拷贝的数据路径以及有状态的执行情况,共同为你带来在所有 Apple 平台上运行各类模型的强大性能,从紧凑型视觉模型到大规模生成式 AI,都不在话下。
     借助新推出的各种工具,你的 App 将能呈现更出彩的视觉体验,并顺畅地与 SwiftUI、UIKit 和 WidgetKit 搭配使用。焕然一新的材质、精心优化的字体,以及全面更新的标签页栏和导航栏,既能统一各个 Apple 平台的设计风格,又能完美保留你 App 的独有特质。利用 SwiftUI,你现在可以构建能直接访问磁盘的高性能文档类 App、重新排列列表和网格内容,还可惰性载入子视图来预取内容,实现丝滑的滚动体验。UIKit 添加了完美适配 iPhone 镜像的新布局,小组件现在还可通过 App Intents 和动态风格进行自定。
游戏与媒体

游戏移植工具包 4 推出开源智能体编码技能,将 Metal 和 Apple 游戏开发的最佳做法统统融入移植流程的每一步,助你在 Apple 平台上更快地发布游戏。如果你的 App 涉及音频或媒体播放,则可利用 Music Understanding 框架,在设备端实现六个维度的音频分析。还可使用 NowPlaying 框架,将你 App 的媒体播放接入锁定屏幕、控制中心、灵动岛和 CarPlay 车载。此外,Core Image RAW 处理 API 推出第 9 版,可呈现更高的清晰度和更有质感的颜色,为你显著提升画质。

适用于 Safari 浏览器的 WebKit

适用于 Safari 浏览器 27 的 WebKit 带来 1000 多项浏览器引擎改进,以及全新的网页平台功能。Grid Lanes 和 Customizable Select 为布局和表格控制解锁更多可能,而 HTML 元素和沉浸式环境则可将沉浸式空间内容原生融入网页。

Spatial Preview 框架

Mac 虚拟显示器彻底改变了你的工作空间,让广阔、私密又便携的显示屏触手可及,方便你随时随地通过这一显示屏在 Mac 上大展身手。今年,全新的 macOS Spatial Preview 框架进一步增强了这项功能,让你能直接使用 Apple Vision Pro 预览 Mac 中的空间内容,还能通过同播共享与他人顺畅协作。 

Spatial Preview 框架可将你的 Mac App 接入 visionOS 上的“快速查看”,这样你的用户就能在 Apple Vision Pro 上快速地预览并更新空间照片、Apple 沉浸视频,以及经过实时 USD 编辑的 3D 内容。你可以在 3D 场景周围自由移动、优化内容放置、调整光效和材质覆盖,并使用注释分享反馈——所有操作都在空间环境中完成。


Create virtual machines and run macOS and Linux-based operating systems

虚拟化框架提供高级API,用于在苹果芯片和基于英特尔的Mac电脑上创建和管理虚拟机(VM)。使用此框架在您定义的自定义环境中启动和运行 macOS 或基于 Linux 的操作系统。该框架支持虚拟I/O设备(VIRTIO)规范,该规范定义了许多设备类型的标准接口,包括网络、套接字、串行端口、存储、熵和内存气球设备。

要设置虚拟机,请配置VZVirtual。如果您要创建 macOS 来宾,也请配置 VZMac,然后添加要向来宾操作系统公开的设备。然后,使用您的配置数据创建一个VZVirtual对象,并使用该VM对象启动、暂停和恢复VM环境。要与来宾进行交互,您使用VZVirtual对象创建VZVirtual,以显示窗口中的图形内容并与之交互。

Running macOS in a virtual machine on Apple silicon 

Install and run macOS in a virtual machine using the Virtualization framework.

Overview

In macOS 13 and later on Mac computers with Apple silicon chips, the Virtualization framework supports apps using Intel binary translation in ARM Linux virtual machines (VMs). Until macOS 26, this capability was part of Rosetta, which allows apps built for Intel-based Mac computers to run seamlessly on Apple silicon. macOS 27 directly integrates support for Intel binary translation, without needing to install Rosetta. If your app has a minimum deployment target of macOS 27, continue with Create the Directory Share.

Test for Rosetta on macOS 26 and earlier

Before trying to install, run, or activate Rosetta, your app should check to ensure that the capability is available in the version of macOS running on the host computer. The availabilityclass method returns a value from the VZLinuxRosettaAvailabilityenumeration that describes whether the current host supports Rosetta or if the capability is already installed on the host Mac. The example below shows the process for checking for Rosetta availability:

import Virtualizationlet supportForIntelApps = VZLinuxRosettaDirectoryShare.availabilityswitch supportForIntelApps {case notSupported:    // Alert the user the capability isn't available; offer     // continuation options according to your app's requirements.case notInstalled:    // Ask the user for permission to install Rosetta, and     // start the installation process if they grant permission.case installed:    break // Ready to go.}

Install Rosetta on macOS 26 and earlier

In macOS 26 and earlier, you need to install Rosetta to allow apps built for Intel-based Mac computers to run on Apple silicon. Installing Rosetta is a one-time process per computer that requires someone to grant permission for the system to install Rosetta. If someone has already installed Rosetta, the system activates it for use under the Virtualization framework; if Rosetta isn’t installed, the framework downloads the installer from the network and performs the installation. The installer interactively prompts a person for authorization, and your app needs to handle any of the possible error conditions that could occur during the authorization, download, and installation process. The example below shows how to start the installation:

do {    try await VZLinuxRosettaDirectoryShare.installRosetta()    // Success: The system installs Rosetta on the host system.} catch let error {    switch error.code {    case networkError:        // A network error prevented the download from completing successfully.    case outOfDiskSpace:        // Not enough disk space on the system volume to complete the installation.    case userCancelled:        // The user cancelled the installation.    case notSupported:        // Rosetta isn't supported on the host Mac or macOS version.    default:        break // A non installer-related error occurred.    }}

Create the Directory Share

With Intel binary translation support enabled, your app needs to configure an appropriate directory share in the Linux guest to enable translation capabilities. The shared directory must have a tag that uniquely identifies the share and that you validate using validateTag(_:)to ensure it conforms to the length and format for file system tags:

let tag = "EXAMPLE_TAG"  let configuration = VZVirtualMachineConfiguration()do {    try let validationError = VZVirtioFileSystemDeviceConfiguration.validateTag(tag)    let rosettaDirectoryShare = tryVZLinuxRosettaDirectoryShare()    let fileSystemDevice = VZVirtioFileSystemDeviceConfiguration(tag: tag)    fileSystemDevice.share = rosettaDirectoryShare    configuration.directorySharingDevices = [ fileSystemDevice ]} catch VZError.invalidVirtualMachineConfiguration {    // Intel binary support is not present on this device.}

Mount the shared directory and register Rosetta

In order to use Intel binary translation in the Linux guest, a person must mount the Rosetta share in the guest VM and install Rosetta as the application the system uses to run x86_64 binaries using the following process:

  1. Install the update-binfmts command, if necessary. The command is part of the binfmt-support package in most Linux distributions; installation methods vary by distribution. Additionally, in order to run this command, someone must be able to use the sudocommand, which requires adding their username to the system’s /etc/sudoersfile.

  2. Create a directory as a mount point.

  3. Mount the VirtioFS file system tag to the mount point. This is the file system tag the app uses to identify the share and must be the same as the tag someone specifies on the command line demonstrated here.

  4. Check if the mounted directory has the Rosetta runtime. You should see rosettain the mounted directory.

  5. Register the Rosetta runtime binary as the handler for x86_64 ELF format executable files using the update-binfmtscommand. The magicparameter describes the first 20 bytes of the ELF header for x86_64 binaries. The Linux kernel performs a bitwise logical ANDwith the first 20 bytes of a binary a user attempts to run with the maskvalue. If it matches the magicvalue, the kernel uses the registered handler as the interpreter for that binary. If the system can’t find a handler for the specified binary, it reports an error.

The example below lists the commands, with the exception of the update-binfmtscommand installation, required to enable Intel binary translation in the Linux guest:

When using Rosetta in macOS 13, set the preserveoption to no.

% mkdir /tmp/mountpoint% sudo mount -t virtiofs EXAMPLE_TAG /tmp/mountpoint% ls /tmp/mountpoint rosetta% sudo /usr/sbin/update-binfmts --install rosetta /tmp/mountpoint/rosetta \    --magic "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" \    --mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \    --credentials yes --preserve yes --fix-binary yes

Ensure Shared Libraries are Available for Dynamically Linked Apps

Rosetta can run statically linked x86_64 binaries without additional configuration. Binaries that are dynamically linked and that depend on shared libraries require the installation of the shared libraries, or library hierarchies, in the Linux guest in paths that are accessible to both the user account and to Rosetta.

Configure Rosetta’s ahead of time (AOT) caching options

In macOS 14 and later, Rosetta supports options that allow you control the ahead of time (AOT) cache characteristics; this can improve the performance of some X86 workloads.

There are two modes of operation for AOT caching: The first is communication using a Unix Domain Socket where the Virtualization framework shares a file that represents the socket between the Rosetta daemon and Rosetta runtime through a symlink or bind-mount. The second is communication through an abstract socket where the framework defines a shared name rather than a shared file. 

You enable these options after you create the Rosetta directory share by setting one of the VZLinuxRosettaDirectoryShare.CachingOptionsusing setCachingOptions(_:). This example shows how to configure Rosetta’s caching options in a new virtual machine configuration using a UnixDomain Socket though a shared ,named file:

    let configuration = VZVirtualMachineConfiguration()    do {        let rosettaDirectoryShare = tryVZLinuxRosettaDirectoryShare()        try rosettaDirectoryShare.setCachingOptions(cachingOptions: .unixSocket("/valid/path/rosetta.sock"))        let fileSystemDevice = VZVirtioFileSystemDeviceConfiguration(tag: "example-tag")        fileSystemDevice.share = rosettaDirectoryShare        configuration.directorySharingDevices = [ fileSystemDevice ]    } catch VZError.invalidVirtualMachineConfiguration {        // Rosetta for Linux is unavailable or failed to initialize Rosetta caching options.        // If Rosetta for Linux is unavailable, clients may install the resources or proceed without them.        // If Rosetta caching options failed to initialize, clients may gracefully fail or proceed without caching.    }

The following example shows how to configure Rosetta’s caching options in a new virtual machine configuration using an abstract socket:

let configuration = VZVirtualMachineConfiguration()    do {        let rosettaDirectoryShare = tryVZLinuxRosettaDirectoryShare()        try rosettaDirectoryShare.setCachingOptions(.abstractSocket("abstractSocketName"))        let fileSystemDevice = VZVirtioFileSystemDeviceConfiguration(tag: "example-tag")        fileSystemDevice.share = rosettaDirectoryShare        configuration.directorySharingDevices = [ fileSystemDevice ]    } catch VZError.invalidVirtualMachineConfiguration {        // Rosetta for Linux is unavailable or failed to initialize Rosetta caching options.        // If Rosetta for Linux is unavailable, clients may install the resources or proceed without them.        // If Rosetta caching options failed to initialize, clients may gracefully fail or proceed without caching.    }    

The system defers app termination until the saveMachineStateTo(url:completionHandler:)method completes.

回首页,搜索你想要的文档

在首页搜索框输入关键词,快速定位资料

文库首页搜索指引 立即搜索

相关学习资料