V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Harry1993
V2EX  ›  Apple

Apple M1 Compatibility

  •  
  •   Harry1993 · 2020-11-24 11:53:28 +08:00 · 2848 次点击
    这是一个创建于 1220 天前的主题,其中的信息可能已经有所发展或是发生改变。

    TLDR:Apple M1 下用 macports 能實現大部分 command line tools 的 native execution (不用 rosetta2 )。

    剛從 Apple Store 拿到 MacBook Air 乞丐版,第一件事安裝 macports 。驚訝地發現 macports 已經是 arm64-native 了,而且 macports 下的大部分 packages 也都在 arm64 架構 pre-compiled 過了,直接可以安裝。那些尚未 pre-compiled 的可以在本地 compile 。結果就是,command line tools 基本都適配 Apple M1 。

    結論:常見的 command line tools 對 Apple M1 的適配得不錯。

    附錄:我用 macports 安裝 mutt 和 tmux 的日誌。我們會看到,除了 mutt 以外,其他 packages 都是直接安裝,而 mutt 需要本地 build 。

    >> sudo port install tmux mutt
    Password:
    --->  Computing dependencies for tmux
    The following dependencies will be installed:  libevent
    Continue? [Y/n]: Y
    --->  Fetching archive for libevent
    --->  Attempting to fetch libevent-2.1.12_0.darwin_20.arm64.tbz2 from https://packages.macports.org/libevent
    --->  Attempting to fetch libevent-2.1.12_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/libevent
    --->  Installing libevent @2.1.12_0
    --->  Activating libevent @2.1.12_0
    --->  Cleaning libevent
    --->  Fetching archive for tmux
    --->  Attempting to fetch tmux-3.1c_0.darwin_20.arm64.tbz2 from https://packages.macports.org/tmux
    --->  Attempting to fetch tmux-3.1c_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/tmux
    --->  Installing tmux @3.1c_0
    --->  Activating tmux @3.1c_0
    --->  Cleaning tmux
    --->  Computing dependencies for mutt
    The following dependencies will be installed:
     curl-ca-bundle
     gnutls
     libidn2
     libtasn1
     libunistring
     nettle
     p11-kit
    Continue? [Y/n]: Y
    --->  Fetching archive for curl-ca-bundle
    --->  Attempting to fetch curl-ca-bundle-7.73.0_0.darwin_20.noarch.tbz2 from https://packages.macports.org/curl-ca-bundle
    --->  Attempting to fetch curl-ca-bundle-7.73.0_0.darwin_20.noarch.tbz2.rmd160 from https://packages.macports.org/curl-ca-bundle
    --->  Installing curl-ca-bundle @7.73.0_0
    --->  Activating curl-ca-bundle @7.73.0_0
    --->  Cleaning curl-ca-bundle
    --->  Fetching archive for libunistring
    --->  Attempting to fetch libunistring-0.9.10_0.darwin_20.arm64.tbz2 from https://packages.macports.org/libunistring
    --->  Attempting to fetch libunistring-0.9.10_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/libunistring
    --->  Installing libunistring @0.9.10_0
    --->  Activating libunistring @0.9.10_0
    --->  Cleaning libunistring
    --->  Fetching archive for libidn2
    --->  Attempting to fetch libidn2-2.3.0_0.darwin_20.arm64.tbz2 from https://packages.macports.org/libidn2
    --->  Attempting to fetch libidn2-2.3.0_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/libidn2
    --->  Installing libidn2 @2.3.0_0
    --->  Activating libidn2 @2.3.0_0
    --->  Cleaning libidn2
    --->  Fetching archive for libtasn1
    --->  Attempting to fetch libtasn1-4.16.0_0.darwin_20.arm64.tbz2 from https://packages.macports.org/libtasn1
    --->  Attempting to fetch libtasn1-4.16.0_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/libtasn1
    --->  Installing libtasn1 @4.16.0_0
    --->  Activating libtasn1 @4.16.0_0
    --->  Cleaning libtasn1
    --->  Fetching archive for nettle
    --->  Attempting to fetch nettle-3.6_0.darwin_20.arm64.tbz2 from https://packages.macports.org/nettle
    --->  Attempting to fetch nettle-3.6_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/nettle
    --->  Installing nettle @3.6_0
    --->  Activating nettle @3.6_0
    --->  Cleaning nettle
    --->  Fetching archive for p11-kit
    --->  Attempting to fetch p11-kit-0.23.21_0.darwin_20.arm64.tbz2 from https://packages.macports.org/p11-kit
    --->  Attempting to fetch p11-kit-0.23.21_0.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/p11-kit
    --->  Installing p11-kit @0.23.21_0
    --->  Activating p11-kit @0.23.21_0
    --->  Cleaning p11-kit
    --->  Fetching archive for gnutls
    --->  Attempting to fetch gnutls-3.6.15_0+doc.darwin_20.arm64.tbz2 from https://packages.macports.org/gnutls
    --->  Attempting to fetch gnutls-3.6.15_0+doc.darwin_20.arm64.tbz2.rmd160 from https://packages.macports.org/gnutls
    --->  Installing gnutls @3.6.15_0+doc
    --->  Activating gnutls @3.6.15_0+doc
    --->  Cleaning gnutls
    --->  Fetching archive for mutt
    --->  Attempting to fetch mutt-2.0.0_0+gnutls+idn+imap+pop+smtp.darwin_20.arm64.tbz2 from https://packages.macports.org/mutt
    --->  Attempting to fetch mutt-2.0.0_0+gnutls+idn+imap+pop+smtp.darwin_20.arm64.tbz2 from https://ywg.ca.packages.macports.org/mirror/macports/packages/mutt/mutt
    --->  Attempting to fetch mutt-2.0.0_0+gnutls+idn+imap+pop+smtp.darwin_20.arm64.tbz2 from https://mse.uk.packages.macports.org/mutt
    --->  Fetching distfiles for mutt
    --->  Attempting to fetch mutt-2.0.0.tar.gz from https://bitbucket.org/mutt/mutt/downloads/
    --->  Verifying checksums for mutt
    --->  Extracting mutt
    --->  Configuring mutt
    --->  Building mutt
    --->  Staging mutt into destroot
    --->  Installing mutt @2.0.0_0+gnutls+idn+imap+pop+smtp
    --->  Activating mutt @2.0.0_0+gnutls+idn+imap+pop+smtp
    --->  Cleaning mutt
    --->  Updating database of binaries
    --->  Scanning binaries for linking errors
    --->  No broken files found.
    --->  No broken ports found.
    --->  Some of the ports you installed have notes:
      tmux has the following notes:
        If you want integration with system pasteboard consider installing port tmux-pasteboard as well
    >>
    
    13 条回复    2020-12-14 02:11:42 +08:00
    czhu
        1
    czhu  
       2020-11-24 12:04:31 +08:00
    👍 那 brew 怎么还不支持 M1 说还要好几个月
    Harry1993
        2
    Harry1993  
    OP
       2020-11-24 12:07:40 +08:00
    @czhu 對呀,我就是因為這個原因轉投 macports 的,竟然發現它其實還挺好用。
    czhu
        3
    czhu  
       2020-11-24 12:09:16 +08:00
    @Harry1993 有 brew 那样的 cask 支持吗?
    当年我记得 macports 的毛病是什么都要自己编译 特别占空间 而且每次升级都慢
    Harry1993
        4
    Harry1993  
    OP
       2020-11-24 12:12:34 +08:00   ❤️ 1
    @czhu 我的 iterm2 就是用 macports 裝的:port install iterm2 。spotlight 也能自動找到。
    估計現在 macports 優化好了吧。現在大部分 app 都可以直接安裝,不需要本地編譯。
    czhu
        5
    czhu  
       2020-11-24 12:28:55 +08:00
    @Harry1993 👍👍
    dependency 呢?是尽量用系统的还是装一套自己的
    原来是装一套自己的环境和系统互不影响 但这样就很占空间了
    ryh
        6
    ryh  
       2020-11-24 13:40:52 +08:00
    自从 macports 被 rvm 默认安装,而 macports 还自动建了用户名和用户组 我就对它没有好感(强盗逻辑啊)
    看了下 https://packages.macports.org/?C=M;O=D 11 月 22 日以后更新了不少,但绝对没超过它所以 packages 的 20%
    AkideLiu
        7
    AkideLiu  
       2020-11-25 00:01:40 +08:00 via iPhone
    macports 很棒我用 brew
    Binboy
        8
    Binboy  
       2020-12-12 11:05:03 +08:00
    brew 对 M1 的支持迟迟还没来,尝试下
    sinxccc
        9
    sinxccc  
       2020-12-14 01:13:33 +08:00
    @czhu 现在 macOS 系统的方向是 base system 尽量可能小而且 read only 。系统给提供的库已经非常少,而且并不推荐第三方软件使用了。

    现在即使是 homebrew,需要在包管理器内部解决的依赖也是越来越多,homebrew 使用 keg only 来解决跟系统包重复的问题。从这个角度的话,macports 选择的方向没有什么问题。

    Homebrew 的 Apple Silicon 进度的话,我自己的尝试,到今天( 2020-12-13 )为止,如果你按照推荐安装在 /opt/homebrew 下的话,很多包也已经有了 arm64 的 bottled,剩下的自己编译也基本可以。剩下还有问题的只有 go 和 rust 的依赖,这个只能等上游发布新版本了。

    不过 Homebrew 这次的操作有点迷,如果它坚持 arm64 只能安装在 /opt/homebrew 的话,无异于放弃了一直以来宣传的无缝便利(因为所有的包在 /usr/local 下)。
    sinxccc
        10
    sinxccc  
       2020-12-14 01:18:04 +08:00
    @Harry1993 类似 cask 的支持在 macports 里其实是没有的,你看到的 iTerm2 也是 macports 自己编译的版本。换句话说,只有开源的 app 才有收录进 aqua 下的可能。
    Harry1993
        11
    Harry1993  
    OP
       2020-12-14 01:38:44 +08:00
    @sinxccc 我有個疑問,我自己 build 了 go (參照 https://gist.github.com/Dids/dbe6356377e2a0b0dc8eacb0101dc3a7 ),我如何能告訴 homebrew 或者 macports 去哪裡找到本地的 go,於是他們在安裝(依賴 go 的) ports 不用另外再去安裝 go (通常是失敗的)?

    python38,openjdk 也有同樣的問題:我自己有一套 arm64-native 的環境,如何讓 homebrew 或者 macports 找到並依賴他們?
    sinxccc
        12
    sinxccc  
       2020-12-14 01:58:09 +08:00
    @Harry1993 抱歉,我不知道有什么正常一点的方法,因为依赖关系是写在它们包的定义文件里的——macports 的 Portfile 、homebrew 的 formula 。

    我能想到可行的 hack 只有在安装之前手工编辑一下包定义文件,去掉对 go 的依赖,然后确保自己编译的 go 在 PATH 里。等安装好再复原包定义文件。
    czhu
        13
    czhu  
       2020-12-14 02:11:42 +08:00
    @sinxccc 非常感谢
    macports 10 年前用过体验一般 homebrew 一出 耳目一新
    最近几年 homebrew 风评逐渐下降 这次升级 M1 看来是一次洗牌 风水轮流转又要重投 macports 的怀抱了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1532 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:09 · PVG 01:09 · LAX 10:09 · JFK 13:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.