[英]what does `arch -x86_64 zsh` on m1 mac do internally?
我在嘗試找到安裝舊版本 npm 包的解決方法時遇到了這個命令,這些包在 m1 mac (darwin arm64) 之前出現
我知道這將嘗試啟動具有x86_64
架構的 zsh session。 (盡管再次運行arch
會給我i386
,我認為它在某種程度上與x86_64
兼容。)
但據我所知,架構在硬件中被定義為處理器芯片。 要模擬不同的架構,您需要一些更重的軟件,例如 virtualbox 或 qemu。
那么arch -x86_64 zsh
到底做了什么? 它真的模擬了不同的架構嗎?
我嘗試閱讀man arch
的內容,但對我來說實在是太多了。
...
DESCRIPTION
The arch command with no arguments, displays the machine's architecture type.
The other use of the arch command is to run a selected architecture of a universal binary. A universal
binary contains code that can run on different architectures. By default, the operating system will select
the architecture that most closely matches the processor type. A 64-bit architecture is preferred over a
32-bit architecture on a 64-bit processor, while only 32-bit architectures can run on a 32-bit processor.
When the most natural architecture is unavailable, the operating system will try to pick another
architecture. On 64-bit processors, a 32-bit architecture is tried. Otherwise, no architecture is run, and
an error results.
The arch command can be used to alter the operating system's normal selection order. The most common use is
to select the 32-bit architecture on a 64-bit processor, even if a 64-bit architecture is available.
The arch_name argument must be one of the currently supported architectures:
i386 32-bit intel
x86_64 64-bit intel
x86_64h 64-bit intel (haswell)
arm64 64-bit arm
arm64e 64-bit arm (Apple Silicon)
...
通用二進制文件包含多個單獨的二進制文件。 在執行時,選擇最兼容的二進制文件來實際執行。
arch
命令通過顯式選擇要運行的命令來簡單地覆蓋此自動選擇。 能否在當前平台上運行選中的可執行文件是另一回事。
如果你把通用二進制想象成一張 hash 表,那么arch
只是查找操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.