make: *** No rule to make target `sqlite_cfg.h', needed by `.target_source'

前置条件

  • macOS Sonoma (14.4.1) 
  • MacBook Pro 2023-Apple M2 Pro (4能效核、8性能核、32GB内存、2TB磁盘)
  • Homebrew (4.2.18 或更高版本)
  • Xcode Version 15.3 (15E204a)
  • DevEco Studio NEXT Developer Preview2 4.1.3.700

错误信息

源代码编译 sqlite3

# https://github.com/clemensg/sqlite3pod
$ wget https://www.sqlite.org/2024/sqlite-src-3450100.zip

$ unzip sqlite-src-3450100.zip

$ cd sqlite-src-3450100

$ ./configure

$ make

或者使用 pod 安装 sqlite3 报错:

$ pod try sqlite3
Updating spec repositories

Trying sqlite3
[!] /opt/homebrew/bin/bash -c 
set -e
cd sqlite-src-3450100
./configure
make sqlite3.c sqlite3.h sqlite3ext.h

checking build system type... arm-apple-darwin23.4.0
checking host system type... arm-apple-darwin23.4.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /opt/homebrew/bin/ggrep
checking for egrep... /opt/homebrew/bin/ggrep -E
checking for fgrep... /opt/homebrew/bin/ggrep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... no
checking for -exported_symbols_list linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin23.4.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for intptr_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uintptr_t... yes
checking for sys/types.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for stdint.h... (cached) yes
checking for inttypes.h... (cached) yes
checking malloc.h usability... no
checking malloc.h presence... no
checking for malloc.h... no
checking for fdatasync... yes
checking for gmtime_r... yes
checking for isnan... yes
checking for localtime_r... yes
checking for localtime_s... no
checking for malloc_usable_size... no
checking for strchrnul... no
checking for usleep... yes
checking for utime... yes
checking for pread... yes
checking for pread64... no
checking for pwrite... yes
checking for pwrite64... no
checking for tclsh8.7... no
checking for tclsh8.6... tclsh8.6
configure: Version set to 3.45
configure: Release set to 3.45.1
checking for WASI SDK directory... no
checking whether to support threadsafe operation... yes
checking for library containing pthread_create... none required
checking for library containing pthread_mutexattr_init... none required
checking whether to support shared library linked as release mode or not... no
checking whether to use an in-ram database for temporary tables... no
checking if executables have the .exe suffix... unknown
checking for Tcl configuration... found /opt/homebrew/Cellar/tcl-tk/8.6.14/lib/tclConfig.sh
checking for existence of /opt/homebrew/Cellar/tcl-tk/8.6.14/lib/tclConfig.sh... loading
checking for library containing readline... -ledit
not using linenoise
checking for library containing fdatasync... none required
checking build type... release
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for library containing deflate... -lz
checking for library containing dlopen... none required
checking whether to support math functions... yes
checking for library containing ceil... none required
checking whether to support JSON functions... yes
checking whether to support MEMSYS5... no
checking whether to support MEMSYS3... no
checking whether to support FTS3... no
checking whether to support FTS4... no
checking whether to support FTS5... no
checking whether to support LIMIT on UPDATE and DELETE statements... no
checking whether to support GEOPOLY... no
checking whether to support RTREE... no
checking whether to support SESSION... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: creating sqlite_cfg.h
config.status: sqlite_cfg.h is unchanged
config.status: executing libtool commands
gcc  -g -O2 -o mkkeywordhash -DSQLITE_ENABLE_MATH_FUNCTIONS  /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/mkkeywordhash.c
./mkkeywordhash >keywordhash.h
gcc  -g -O2 -o lemon /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/lemon.c
cp /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/lempar.c .
cp /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/src/parse.y .
./lemon -DSQLITE_ENABLE_MATH_FUNCTIONS  -S parse.y
sh /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/cktclsh.sh 8.4 tclsh8.6
touch has_tclsh84
cat parse.h /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/src/vdbe.c | tclsh8.6 /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/mkopcodeh.tcl >opcodes.h
tclsh8.6 /private/var/folders/z8/_cvsdvbd4x51vm4szw5xkw0w0000gn/T/CocoaPods/Try/sqlite3/sqlite-src-3450100/tool/mkopcodec.tcl opcodes.h >opcodes.c
make: *** No rule to make target `sqlite_cfg.h', needed by `.target_source'.  Stop.

观察源代码目录,也确实没有 sqlite_cfg.h 文件生成。

继续阅读make: *** No rule to make target `sqlite_cfg.h', needed by `.target_source'

Flutter: Xcode error “Unable to boot the Simulator“

使用 flutter、Android Studio ,通过iOS模拟器运行项目,一直一切正常。

某次重启后无法启动模拟器,报错信息如下:

 "Unable to boot the simulator".

解决方法,亲测有效:

macOS 14.4.1以及更高版本:
进入 “系统设置”→“通用”→“存储空间”→“开发者” 删除 “XCode 缓存” 。

在 macOS 13 及更高版本上:
进入 “系统设置”→“常规”→“存储”→“开发人员”
删除“开发者缓存”

在 macOS 12 及更低版本上:
转到“关于本机”→“存储”→“管理”→“开发人员”

参考链接


Flutter: XCode error “Unable to boot the Simulator

Linux使用SMB给macOS做无线Time Machine备份

前要:

一直以来使用外置硬盘给Mac做Time Machine备份盘,但是存在若干不够方便的地方,如:

  • 磁盘需要格式化为APFS格式,虽然APFS的“卷共享容器空间”的机制可以很方便的让Time Machine卷和其他资料卷共用空间,而不是像传统的分盘让空间分隔,还要考虑空间分配问题。但APFS格式只在macOS设备间方便使用
  • 虽然在不连接磁盘的情况下,内置存储也会保留24小时内到每小时快照,但总是需要刻意记起找出插入硬盘进行备份的操作

正好最近使用旧电脑刷了Ubuntu用作NAS使用,于是想了解关于如何配置无线Time Machine

无线Time Machine的共享协议选择:

最开始找到的教程是使用AFP的开源实现netatalk让Linux支持AFP共享协议,然后作为Time Machine盘。但发现netatalk最近曝出过严重漏洞项目本身在GitHub也只有0.2K Star的关注。主观感觉其稳定性是存在疑问的。

后来发现,并不一定是AFP协议的共享才能做Time Machine备份盘;Samba只要进行一些配置就能做Time Machine备份用了

在 Mac 上可以与时间机器配合使用的磁盘类型

在Apple官方文档中说明有写到

【提示】如果可以选择 SMB 或 AFP,请使用 SMB 来备份到外置备份磁盘。

目前Apple官方也是更推荐使用SMB协议来作为无线Time Machine备份的

Linux上Samba的配置

首先需要安装avahi和samba,关于其安装和配置和samba用户的设置管理这里不再赘述,不同的Linux发行版安装方式会有一些差异,可以自行搜索。

个人的 /etc/samba/smb.conf 内容如下

[global]
   workgroup = WORKGROUP
   server string = %h server (Samba, Ubuntu)
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = never
   usershare allow guests = no
   security = user
   public = no
   writable = yes
   guest ok = no

   vfs objects = catia fruit streams_xattr
   min protocol = SMB3_11
   smb encrypt = required
   ea support = yes
   fruit:metadata = stream
   fruit:model = MacSamba
   fruit:posix_rename = yes
   fruit:veto_appledouble = no
   fruit:wipe_intentionally_left_blank_rfork = yes
   fruit:delete_empty_adfiles = yes
   fruit:aapl = yes
[samba_WD]
   #comment = mydisk
   #available = yes
   #browseable = yes
   path = /media/xiaoming/WD
   vaild user = xiaoming
   create mask = 0755
[samba_xiaoming]
   #comment = xiaominghome
   #available = yes
   #browseable = yes
   path = /home/xiaoming/Documents
   vaild user = xiaoming
   create mask = 0755
[myTimeMachine]
   path = /media/xiaoming/WD/tmbackup
   valid users = xiaoming
   fruit:time machine = yes
   #fruit:time machine max size = 500G

其中,与 Time Machine 的启用相关的关键部分为:

[global]
   vfs objects = catia fruit streams_xattr
   min protocol = SMB3_11
   smb encrypt = required
   ea support = yes
   fruit:metadata = stream
   fruit:model = MacSamba
   fruit:posix_rename = yes
   fruit:veto_appledouble = no
   fruit:wipe_intentionally_left_blank_rfork = yes
   fruit:delete_empty_adfiles = yes
   fruit:aapl = yes
[myTimeMachine]
   path = /media/xiaoming/WD/tmbackup
   valid users = xiaoming
   fruit:time machine = yes
   #fruit:time machine max size = 500G

因为个人这里是只配合自己的Mac使用的,所以配置文件尽量确保了安全性和与macOS设备的兼容性,比如在global中把最小连接协议设置为SMB3_11,强制启用了传输加密,和很多更加兼容macOS的fruit选项。请根据个人需求修改。

配置可参考

Configure Samba to Work Better with Mac OS X

最后使用systemctl restart smbd另配置生效即可。

备份盘的选择:

上述配置文件中,/media/xiaoming/WD是外置硬盘在fstab中设置挂载的路径,而Time Machine备份的目录则放在了该目录的./tmbackup下。登陆用户我设置为“xiaoming”,并确保这两个目录都具有用户“xiaoming”的权限读写。后续在使用SMB访问时,才能正常读写文件

特别提示:如果你的外置磁盘并非ext4这样的适合Linux使用的格式,而是如exFAT这种,会出现问题。像exFAT是不兼容在Linux上的文件用户分组的。个人测试,exFAT磁盘中所有文件所属只能为root:root。且使用sudo chown -R xiaoming:xiaoming也无法更改权限。建议备份磁盘文件后,格式化为ext4这种适合Linux使用的格式

macOS上的配置:

打开访达,边栏上应该能直接看到服务器,点击后点上面的“连接身份...”,再点“注册用户”,输入用户和密码,勾选“在我的钥匙串中记住此密码”,点连接,随后会显示出多个共享,多选连接即可。

如果边栏没有,则需按command+K来手动连接,输入smb://xiaomingnas.local。这里xiaomingnas.local中的xiaomingnas是主机的hostname,通常avahi的mDNS服务会使用<hostname>.local作为域名。点连接,后续步骤与上述相同。

随后在Mac的系统设置-通用-时间机器,点+号,就能选择设置的Time Machine进行备份了。然后根据提示设置登录用户名,时间机器的加密密码即可。

无线备份受限于网络传输速度,首次备份可能需要数小时才能完成,可耐心等待。

Time Machine默认设置了速度限制,以保障网络和磁盘可正常使用,首次备份可以在Mac上暂时解除该限制

#解除限制
$ sudo sysctl debug.lowpri_throttle_enabled=0

#恢复速度限制:
$ sudo sysctl debug.lowpri_throttle_enabled=1

#查看状态
$ sysctl -n debug.lowpri_throttle_enabled

用外置磁盘和无线共享设置Time Machine的区别:

使用外置磁盘备份,点击边栏上的卷后,可以看到目录形式展示的每次的备份,并直接查看其中的目录文件。还可以方便地多选备份进行删除,来腾出空间占用

而使用SMB共享作为备份盘。这会在共享路径下生成一个类似“小明的MacBook Air.sparsebundle”目录。大致结构如下

$ tree -L 2
.
└── 小明的MacBook Air.sparsebundle
    ├── bands
    ├── com.apple.TimeMachine.MachineID.bckup
    ├── com.apple.TimeMachine.MachineID.plist
    ├── com.apple.TimeMachine.Results.plist
    ├── com.apple.TimeMachine.SnapshotHistory.plist
    ├── Info.bckup
    ├── Info.plist
    ├── lock
    ├── mapped
    └── token

其中bands目录中会有大量固定大小为67MB的二进制文件,这些便是备份的数据。

Apple官方对sparsebundle的解释的大致意思是,它是一个以二进制形式存储的,可按需收缩和扩大的可扩展文件。

在 Mac 上使用“磁盘工具”创建磁盘映像

这样看用SMB共享设置Time Machine实际上更加灵活,相比之下不挑磁盘格式,且备份在Linux上的磁盘中仅作为某个路径下的某个目录存在,而不像使用外置磁盘备份一样单独占据一个APFS卷。

但其不能像外置磁盘一样,可以任意多选删除备份来腾出空间。但可以设置fruit:time machine max size来限制备份大小,这样达到空间临界点时macOS就会自动删除最旧的备份来腾出空间。当然,磁盘备份同样也可以在添加APFS卷时,通过设置“配额大小”来限制Time Machine过度膨胀(但设置完毕后不易变更)

实际使用的体验:

无线备份的速度慢于磁盘备份,这取决于你的局域网环境。不过备份过程同样是完全无感的,和有线备份一样,即使是合盖休眠情况下也会自动创建备份。

Time Machine是可以同时备份到多个位置的,因此可以同时使用磁盘备份和无线备份,这样数据安全性也更好。如果再配合zerotier异地组网,设置一个异地的NAS作为无线Time Machine,那么你就得到了一个符合“3-2-1原则”的,完全无感、自动化、无需干涉的备份系统。且Time Machine本身也有加密,无惧因备份介质遗失导致数据泄漏的风险。

考虑到传输速度,无线的Time Machine用于找回过去的文件没有问题,但不太适合做整机恢复,如果是换机这种操作,还是建议使用磁盘备份节省时间。

更建议使用 docker-timemachine 镜像进行配置,可以在搜索 docker-timemachine 然后进行配置。

参考链接


Linux使用SMB给macOS做无线Time Machine备份

macOS Sonoma 14.3.1 安装包Apple官网下载集合

macOS Sonoma Final Full Installer

macOS Sonoma Final Version Build App Avail Date
InstallAssistant.pkg 14.3.1 23D60   YES 2/08
InstallAssistant.pkg 14.3 23D56   YES 1/22
InstallAssistant.pkg 14.2.1 23C71   YES 12/19
InstallAssistant.pkg 14.2 23C64   YES 12/11
InstallAssistant.pkg 14.1.2 23B92   YES 11/30
InstallAssistant.pkg 14.1.2 23B2091 M3 only YES 11/30
^ For M3 Macs ONLY
InstallAssistant.pkg 14.1.1 23B81 19.1.02 YES 11/07
InstallAssistant.pkg 14.1.1 23B2082 M3 only YES 11/07
^ For M3 Macs ONLY
InstallAssistant.pkg 14.1 23B74 19.1.01 YES 10/25
InstallAssistant.pkg 14.1 23B2077 M3 only YES 11/01
^ For M3 Macs ONLY
InstallAssistant.pkg 14.0 22A344 19.0.02 YES 9/26

参考链接


MacBook Pro 2023-Apple M2 Pro使用Fn按键作为标准功能键

在按下某个功能键的同时按住功能 (Fn)/地球键。例如,同时按下 Fn 和 F12(扬声器图标)可执行分配给 F12 键的操作,而不是提高扬声器的音量1。如果你的键盘没有 Fn 键,请尝试在按下某个功能键的同时按住 Control 键。

更改按键的默认行为

如果你要更改顶行按键以使它们在无需按住 Fn 键的情况下用作标准功能键,请按照以下步骤操作,具体取决于你使用的 macOS 版本

macOS Ventura
  1. 选取苹果菜单  >“系统设置”。

  2. 点按边栏中的“键盘”。

  3. 点按右侧的“键盘快捷键”按钮。

  4. 点按边栏中的“功能键”。

  5. 打开“将 F1、F2 等键用作标准功能键”2

更低版本的 macOS
  1. 选取苹果菜单  >“系统偏好设置”。

  2. 点按“键盘”。

  3. 选择“将 F1、F2 等键用作标准功能键”2

参考链接


使用按键作为标准功能键

M1 CPU 那么多的核,macOS 是怎样管理的?

1984 年 1 月,Apple 开始设计、开发和销售个人电脑系列产品 Macintosh。在这近 40 年时间里,Apple 浓墨重彩地书写了许多科技史上的里程碑,其中就包括了三个非常重要的时间点——1994 年从摩托罗拉 68000 架构迁移至 PowerPC 平台、 2005 年从 PowerPC 平台迁移至英特尔 x86 平台、2020 年从英特尔 x86 平台迁移至 Apple Silicon。

2020 年 11 月 11 日 Apple 在加州 Cupertino 正式发布了 M1 芯片,不仅是 Apple 自己首款基于 ARM 架构的用于个人电脑的自研处理器,而且其强大的性能也让当时苦「牙膏厂」久已的 Geeker 们也感到异常亢奋。

不过,看得见的风光总是与看不到的努力分不开的。作为专为 Mac 设计、优化的芯片,系统到底是怎么将程序调度在 M 系列处理器上的。

继续阅读M1 CPU 那么多的核,macOS 是怎样管理的?

Box64 running on M1 with Asahi

The Asahi project has now released a first alpha version, so I tried that on a MacBookPro. Asahi is a full linux distribution that can be installed on mac with an M1 processor, it installs alongside your current macOS. It’s an alpha release so many things are missing for now, including 3D hardware acceleration, but on the other hand, for an alpha release, many things are already working, and working fine!

After a (quite) long installation process, I got linux running on that mac. Note that I add to restart the installation process, as the mac went to sleep mode during “root expension” and that actually froze the installation. I needed to break, remove all the create partitions (a risky process) to be able to start again.

Now, the M1 processor is very fast ARM64 processor, but it only supports 64bits operations. No ARM32 there, so no box86. Also, the Asahi readme mentions that the Pagesize is 16K, instead of the standard 4K. That breaks a few things on the way. Fortunatly, I had already encountered a system with 16K pagesize (Loongarch64 systems), so there is some supporting code on box64 already for it. And after enabling it (plus some compilation options), box64, with dynarec, was running!

To try things, I wanted to install a simple linux game. Remember that there is no Hardware acceleration yet, so I choose WorldOfGoo, with its simple graphics (it’s still an OpenGL game). Launching the install didn’t work, as by default, the setup tries to run x86 code (32bits, so needing box86 not available here). To work around that, I created a simple uname script that spoofs the setup into thinking this is an x86_64 system:

the file simply contains

#!/bin/bash

if [ "$1" == "-m" ];then
 echo x86_64
 exit 0
fi

/bin/uname "$@"

And I created an x86_64 folder in my home directory to put some pc stuffs (and that uname script)

Then I launched the setup as PATH=~/x86_64:$PATH ./WorldOfGoo.Linux.153.sh et voilà, the setup launched… But as text only… Ok, gtk2 libs are not installed. So sudo pacman -S gtk2 and try again…

继续阅读Box64 running on M1 with Asahi

macOS Ventura(13.6)/macOS Sonoma(14.0)编译Android 10.0/Android 11.0源码过程总结(MacBook Pro 2023-Apple M2 Pro)

前置条件


  • macOS Ventura(13.6)/macOS Sonoma(14.0) MacBook Pro 2023-Apple M2 Pro (4能效核、8性能核、32GB内存、2TB磁盘)
  • Homebrew (4.0.28 或更高版本)
  • Xcode Version 15.0 (15A240d)
  • Android Studio Giraffe | 2022.3.1 Patch 1

从Intel版本MacBook Pro迁移到MacBook Pro 2023(Apple M2 Pro)的设备,参考 从Intel版本MacBook Pro 2013迁移到MacBook Pro 2023(Apple M2 Pro)后HomeBrew报错"Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)" 重新安装 Homebrew

根据 Google 官方文档,2021年6月22日之后的Android系统版本不支持在macOS系统上构建,我们在 Applic SiliconmacOS 系统是不能直接成功构建后续版本的,但是之前的版本可以在修改编译配置后成功编译。

尝试过使用 Podman Desktop / Docker 方式进行编译、也尝试过借助 OrbStackLima 这些纯虚拟机通过安装 ubuntu 22.04 系统镜像的方式进行编译,结果都在执行 lunch 命令的时候长时间卡住,观察系统进程发现名为 nsjail 进程的 CPU 占用持续卡住在 100% 上无法继续编译,并且由于 Docker 或者虚拟机文件系统是 Linux 文件系统,而宿主机的文件系统是 AppleFS 文件系统,导致需要进行文件转换,中间的转换性能代价非常高,性能很差。

通过 UTM 虚拟机,使用 MacOS 提供的虚拟机执行编译的话,性能会更好。但是目前测试发现存在严重的文件系统缺陷,编译/大量文件复制过程中,经常出现文件系统损坏,导致编译失败。

需要在 M2 上使用UTM 虚拟机编译的,可以参考 macOS Sonoma(14.1.1)通过UTM虚拟机编译Android 11.0源码过程总结(MacBook Pro 2023-Apple M2 Pro) 通过 UTM 虚拟机借助 Rosetta 2 的方式进行编译。目前测试来看,性能勉强能用。

另外,我们需要安装 Rosetta 2 支持运行部分 x86_64 应用。注意  Rosetta 2 只支持 64 位应用,不支持 32 位应用。 参考 Does Rosetta 2 support 32-bit Intel apps?

继续阅读macOS Ventura(13.6)/macOS Sonoma(14.0)编译Android 10.0/Android 11.0源码过程总结(MacBook Pro 2023-Apple M2 Pro)

从Intel版本MacBook Pro 2013迁移到MacBook Pro 2023(Apple M2 Pro)后HomeBrew报错"Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)"

通过 TimeMachineIntel 版本 MacBook Pro 2013 迁移到 MacBook Pro 2023(Apple M2 Pro)HomeBrew 报错,如下:

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

该报错的原因是 HomeBrew 修改了 Apple ARM 版本的设备上的默认目录,默认目录从 /usr/local 调整到了 /opt/homebrew

由于大量的路径被硬编码到了代码中,结果就导致各种运行、安装异常。

我们能做的就是,重新在 /opt/homebrew目录下安装一遍。

# 导出环境配置,和已经通过brew安装的应用列表,为后续重新安装这些应用进行准备
$ brew bundle dump

# 执行完成后,当前目录下生成的 Brewfile 就是我们已经安装的应用列表,后续可以执行这个脚本进行恢复安装

# 卸载已经安装的 HomeBrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

# 移除整个 /usr/local 目录,此处谨慎操作,只有确保没有与homebrew无关的应用没有安装到这个目录下才能执行删除操作
# sudo rm -rf /usr/local

# 重新安装 HomeBrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 把路径增加到环境变量中,比如 .bashrc

$ export PATH="/opt/homebrew/bin:$PATH"

# 重新配置HomeBrew 并安装之前的软件
$ brew bundle --file=Brewfile

参考链接