从根源分析,调试,定位和解决MacOS ld: unsupported tapi file type ‘!tapi-tbd‘ in YAML file

ops/2025/1/26 15:05:50/

    你要是遇到同样错误,找一圈都没有解决,建议认真读一下本文,这个应该是最终极的解决办法,从原理上剖析了产生的原因,同时给出来了调试和定位的办法。

    maccos使用brew安装了一个gcc14, 结果编译一个最简单的程序都报错,如下:

gcc-14 test.c -o t
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status

        查了网上是说libSystem.tbd和ld不一致引起的。现在不知道ld是调用了哪份,当前系统一堆不同版本的。

      一般的解决办法如下:

      

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

        但是我试了并没有用,同时使用clang编译是正常的,说明这个CommandLineTools没有问题的。

       没有办法了,只好自己来分析一下了。

        首先使用 dtruss跟踪一下系统api调用,发现ld应该是posix_spawn调用了。如下:

sudo dtruss gcc-14 test.c -o t
Password:
SYSCALL(args) 		 = returnopen("/dev/dtracehelper\0", 0x2, 0x0)		 = 3 0
ioctl(0x3, 0x80086804, 0x7FFEEF6B3560)		 = 0 0
close(0x3)		 = 0 0
mprotect(0x1006EF000, 0x48000, 0x1)		 = 0 0
access("/AppleInternal/XBS/.isChrooted\0", 0x0, 0x0)		 = -1 Err#2
bsdthread_register(0x7FFF2034746C, 0x7FFF20347458, 0x2000)		 = 1073742047 0
shm_open(0x7FFF2021DF66, 0x0, 0x2021CC3A)		 = 3 0
fstat64(0x3, 0x7FFEEF6B23D0, 0x0)		 = 0 0
mmap(0x0, 0x1000, 0x1, 0x40001, 0x3, 0x0)		 = 0x1007DD000 0
close(0x3)		 = 0 0
ioctl(0x2, 0x4004667A, 0x7FFEEF6B2494)		 = 0 0
mprotect(0x1007E3000, 0x1000, 0x0)		 = 0 0
mprotect(0x1007F2000, 0x1000, 0x0)		 = 0 0
mprotect(0x1007F3000, 0x1000, 0x0)		 = 0 0
mprotect(0x100802000, 0x1000, 0x0)		 = 0 0
mprotect(0x100803000, 0x1000, 0x0)		 = 0 0
mprotect(0x100812000, 0x1000, 0x0)		 = 0 0
mprotect(0x1007DE000, 0x90, 0x1)		 = 0 0
mprotect(0x100813000, 0x1000, 0x1)		 = 0 0
mprotect(0x1007DE000, 0x90, 0x3)		 = 0 0
mprotect(0x1007DE000, 0x90, 0x1)		 = 0 0
issetugid(0x0, 0x0, 0x0)		 = 0 0
getpid(0x0, 0x0, 0x0)		 = 86951 0
stat64("/AppleInternal\0", 0x7FFEEF6B29C0, 0x0)		 = -1 Err#2
csops_audittoken(0x153A7, 0x7, 0x7FFEEF6B24F0)		 = -1 Err#22
proc_info(0x2, 0x153A7, 0xD)		 = 64 0
csops_audittoken(0x153A7, 0x7, 0x7FFEEF6B25E0)		 = -1 Err#22
sysctlbyname(kern.system_version_compat, 0x1A, 0x0, 0x0, 0x7FFEEF6B2A7C)		 = 0 0
ioctl(0x2, 0x4004667A, 0x7FFEEF6B4594)		 = 0 0
ioctl(0x2, 0x4004667A, 0x7FFEEF6B45A4)		 = 0 0
ioctl(0x2, 0x4004667A, 0x7FFEEF6B4594)		 = 0 0
sysctl([CTL_KERN, 2, 0, 0, 0, 0] (2), 0x7FFEEF6B45D0, 0x7FFEEF6B45C0, 0x0, 0x0)		 = 0 0
sigaction(0x2, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0x2, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0x1, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0x1, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0xF, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0xF, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0xD, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0xD, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
sigaction(0x14, 0x7FFEEF6B45D8, 0x7FFEEF6B4600)		 = 0 0
getrlimit(0x1003, 0x7FFEEF6B4600, 0x0)		 = 0 0
setrlimit(0x1003, 0x7FFEEF6B4600, 0x0)		 = 0 0
access("/Volumes/10136/flutter/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/cuda/lib/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/cuda/extras/CUPTI/lib/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/anaconda3/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/anaconda3/condabin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/Volumes/data/Codes/android-ndk-r10e/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/Applications/Cocos/frameworks/cocos2d-x-3.5/tools/cocos2d-console/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/bin/gcc-14\0", 0x1, 0x0)		 = 0 0
stat64("/usr/local/bin/gcc-14\0", 0x7FFEEF6B4440, 0x0)		 = 0 0
stat64("/\0", 0x7FFEEF6B1D68, 0x0)		 = 0 0
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/bin\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/bin/gcc-14\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
readlink("/usr/local/bin/gcc-14\0", 0x7FFEEF6B2AB0, 0x400)		 = 33 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin/gcc-14\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
access("/Volumes/10136/flutter/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/cuda/lib/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/cuda/extras/CUPTI/lib/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/anaconda3/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/anaconda3/condabin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/Volumes/data/Codes/android-ndk-r10e/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/Applications/Cocos/frameworks/cocos2d-x-3.5/tools/cocos2d-console/bin/gcc-14\0", 0x1, 0x0)		 = -1 Err#2
access("/usr/local/bin/gcc-14\0", 0x1, 0x0)		 = 0 0
stat64("/usr/local/bin/gcc-14\0", 0x7FFEEF6B4440, 0x0)		 = 0 0
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/bin\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/bin/gcc-14\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
readlink("/usr/local/bin/gcc-14\0", 0x7FFEEF6B2AB0, 0x400)		 = 33 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin/gcc-14\0", 0x7FFF202A1644, 0x7FFEEF6B36B0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/\0", 0x1, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/\0", 0x1, 0x0)		 = 0 0
open_nocancel(".\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x7FFEEF6B1D20, 0x0)		 = 0 0
fcntl_nocancel(0x3, 0x32, 0x7FFEEF6B40E0)		 = 0 0
close_nocancel(0x3)		 = 0 0
stat64("/Volumes/evo2T/src/paq8px/mybuild\0", 0x7FFEEF6B1C90, 0x0)		 = 0 0
stat64("/Volumes/evo2T/src/paq8px/mybuild\0", 0x7FFEEF6B2338, 0x0)		 = 0 0
getattrlist("/Volumes/evo2T/src/paq8px/mybuild/test.c\0", 0x7FFF202A1644, 0x7FFEEF6B3C80)		 = 0 0
open_nocancel(".\0", 0x0, 0x0)		 = 3 0
fstat64(0x3, 0x7FFEEF6B1D20, 0x0)		 = 0 0
fcntl_nocancel(0x3, 0x32, 0x7FFEEF6B40E0)		 = 0 0
close_nocancel(0x3)		 = 0 0
stat64("/Volumes/evo2T/src/paq8px/mybuild\0", 0x7FFEEF6B1C90, 0x0)		 = 0 0
stat64("/Volumes/evo2T/src/paq8px/mybuild\0", 0x7FFEEF6B2338, 0x0)		 = 0 0
getattrlist("/Volumes/evo2T/src/paq8px/mybuild/t\0", 0x7FFF202A1644, 0x7FFEEF6B3C80)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/\0", 0x1, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/\0", 0x1, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/specs\0", 0x4, 0x0)		 = -1 Err#2
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/specs\0", 0x4, 0x0)		 = -1 Err#2
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/x86_64-apple-darwin20/14/specs\0", 0x4, 0x0)		 = -1 Err#2
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/specs\0", 0x4, 0x0)	 = -1 Err#2
access("/usr/local/opt/gcc/lib/gcc/current/gcc/x86_64-apple-darwin20/specs\0", 0x4, 0x0)		 = -1 Err#2
access("/usr/local/Cellar/gcc/14.2.0_1/bin/\0", 0x1, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/lto-wrapper\0", 0x7FFEEF6B4450, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/lto-wrapper\0", 0x1, 0x0)		 = 0 0
access("/var/tmp/\0", 0x7, 0x0)		 = 0 0
stat64("/var/tmp/\0", 0x7FFEEF6B3630, 0x0)		 = 0 0
getentropy(0x7FFEEF6B3070, 0x20, 0x0)		 = 0 0
getentropy(0x7FFEEF6B30C0, 0x40, 0x0)		 = 0 0
fstatat64(0xFFFFFFFFFFFFFFFE, 0x7FA4C6C04200, 0x7FFEEF6B31B0)		 = 0 0
openat_nocancel(0xFFFFFFFFFFFFFFFE, 0x7FA4C6C04200, 0xA02)		 = 3 0
close(0x3)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/cc1\0", 0x7FFEEF6B34B0, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/cc1\0", 0x1, 0x0)		 = 0 0
posix_spawn(0x7FFEEF6B355C, 0x7FA4C6C05D20, 0x7FFEEF6B3480)		 = 0 0
wait4(0x153A9, 0x7FA4C6C05850, 0x0)		 = 86953 0
fstatat64(0xFFFFFFFFFFFFFFFE, 0x7FA4C6D04080, 0x7FFEEF6B2E90)		 = 0 0
openat_nocancel(0xFFFFFFFFFFFFFFFE, 0x7FA4C6D04080, 0xA02)		 = 3 0
close(0x3)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/as\0", 0x7FFEEF6B42C0, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/as\0", 0x7FFEEF6B42C0, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/bin/x86_64-apple-darwin20/14/as\0", 0x7FFEEF6B42C0, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/bin/as\0", 0x7FFEEF6B42C0, 0x0)		 = -1 Err#2
posix_spawn(0x7FFEEF6B436C, 0x7FFEEF6B3F10, 0x7FFEEF6B38B0)		 = -1 Err#2
posix_spawn(0x7FFEEF6B436C, 0x7FFEEF6B3F10, 0x7FFEEF6B38B0)		 = -1 Err#2
posix_spawn(0x7FFEEF6B436C, 0x7FFEEF6B3F10, 0x7FFEEF6B38B0)		 = -1 Err#2
posix_spawn(0x7FFEEF6B436C, 0x7FFEEF6B3F10, 0x7FFEEF6B38B0)		 = 0 0
stat64("/usr/local/anaconda3/bin/as\0", 0x7FFEEF6B3E40, 0x0)		 = 0 0
wait4(0x153AD, 0x7FA4C6E04090, 0x0)		 = 86957 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2\0", 0x7FFEEF6B4450, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2\0", 0x1, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B4430, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/.\0", 0x7FFEEF6B4430, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/bin/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B4430, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/bin/.\0", 0x7FFEEF6B4430, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B4430, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/.\0", 0x7FFEEF6B4430, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B4430, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/.\0", 0x7FFEEF6B4430, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B4430, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../.\0", 0x7FFEEF6B4430, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B3470, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/.\0", 0x7FFEEF6B3470, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B3470, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/.\0", 0x7FFEEF6B3470, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B3470, 0x0)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../.\0", 0x7FFEEF6B3470, 0x0)		 = 0 0
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B2CB0, 0x0)		 = 0 0
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/.\0", 0x7FFEEF6B2CB0, 0x0)		 = 0 0
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B2CB0, 0x0)		 = -1 Err#2
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../../../../x86_64-apple-darwin20/lib/.\0", 0x7FFEEF6B2CB0, 0x0)		 = -1 Err#2
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = -1 Err#2
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../lib/gcc/current/gcc/x86_64-apple-darwin20/14/../../../x86_64-apple-darwin20/14/.\0", 0x7FFEEF6B2CB0, 0x0)		 = -1 Err#2
getattrlist("/usr\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/bin\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
getattrlist("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/x86_64-apple-darwin20/14\0", 0x7FFF202A1644, 0x7FFEEF6B2500)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/lib/gcc/current/.\0", 0x7FFEEF6B2CB0, 0x0)		 = 0 0
stat64("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2\0", 0x7FFEEF6B43A0, 0x0)		 = 0 0
access("/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2\0", 0x1, 0x0)		 = 0 0
posix_spawn(0x7FFEEF6B444C, 0x7FA4C6D049B0, 0x7FFEEF6B4370)		 = 0 0
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
wait4(0x153B4, 0x7FA4C6D05AF0, 0x0)		 = 86964 0
stat64("/var/tmp//ccJ8HKNk.o\0", 0x7FFEEF6B45A0, 0x0)		 = 0 0
unlink("/var/tmp//ccJ8HKNk.o\0", 0x0, 0x0)		 = 0 0
stat64("/var/tmp//ccDAFOTi.s\0", 0x7FFEEF6B45A0, 0x0)		 = 0 0
unlink("/var/tmp//ccDAFOTi.s\0", 0x0, 0x0)		 = 0 0

系统apiposix_spawn的参数没有打印出来,不知道为什么, lldb跟一下。

sudo lldb gcc-14
Password:^
SyntaxError: invalid syntax
(lldb) target create "gcc-14"
Current executable set to 'gcc-14' (x86_64).
(lldb) b posix_spawn
Breakpoint 1: where = libsystem_kernel.dylib`posix_spawn, address = 0x00007fff202de1e9
(lldb) r test.c -o t
Process 87222 launched: '/usr/local/bin/gcc-14' (x86_64)
Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) p (char*)$rsi
(char *) $0 = 0x00000001005063c0 "/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/cc1"
(lldb) command add 1
invalid command 'command add'.
(lldb) breakpoint command add 1 
Enter your debugger command(s).  Type 'DONE' to end.
> p (char*)$rsi 
(lldb) c
Process 87222 resuming
(lldb)  p (char*)$rsi
(char *) $1 = 0x00007ffeefbfeea0 "/Volumes/10136/flutter/bin/as"Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) c
Process 87222 resuming
(lldb)  p (char*)$rsi
(char *) $2 = 0x00007ffeefbfeea0 "/usr/local/cuda/lib/as"Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) c
Process 87222 resuming
(lldb)  p (char*)$rsi
(char *) $3 = 0x00007ffeefbfeea0 "/usr/local/cuda/extras/CUPTI/lib/as"Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) c
Process 87222 resuming
(lldb)  p (char*)$rsi
(char *) $4 = 0x00007ffeefbfeea0 "/usr/local/anaconda3/bin/as"Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) c
Process 87222 resuming
(lldb)  p (char*)$rsi
(char *) $5 = 0x0000000100704b90 "/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2"Process 87222 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1frame #0: 0x00007fff2031c1e9 libsystem_kernel.dylib`posix_spawn
libsystem_kernel.dylib`posix_spawn:
->  0x7fff2031c1e9 <+0>: pushq  %rbp0x7fff2031c1ea <+1>: movq   %rsp, %rbp0x7fff2031c1ed <+4>: pushq  %r150x7fff2031c1ef <+6>: pushq  %r14
Target 0: (gcc-14) stopped.
(lldb) c
Process 87222 resuming
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
Process 87222 exited with status = 1 (0x00000001) 

发现是最后一个apiposix_spawn是调用/usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2

运行一下 它加一个-debug参数

 /usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2    -debug  
//...去掉一堆
Looking for 'gcc'
collect2 version 14.2.0
ld_file_name        = /usr/local/anaconda3/bin/ld
c_file_name         = /usr/bin/gcc
nm_file_name        = /usr/local/anaconda3/bin/nm
strip_file_name     = /usr/local/anaconda3/bin/strip
c_file              = a.out.cdtor.c
o_file              = a.out.cdtor.o

看起来是使用了 /usr/local/anaconda3/bin/ld 我晕。

这个一堆都使用了这个目录下的,先临时屏蔽一下,

mv  /usr/local/anaconda3/bin  /usr/local/anaconda3/bin.bak

再执行

 /usr/local/Cellar/gcc/14.2.0_1/bin/../libexec/gcc/x86_64-apple-darwin20/14/collect2    -debug  
//...
Looking for 'gcc'
collect2 version 14.2.0
ld_file_name        = /usr/bin/ld
c_file_name         = /usr/bin/gcc
nm_file_name        = /usr/bin/nm
strip_file_name     = /usr/bin/strip
c_file              = a.out.cdtor.c
o_file              = a.out.cdtor.o/usr/bin/ld
ld: warning: platform not specified
ld: warning: -arch not specified
ld: warning: No platform min-version specified on command line
ld: no object files specified
collect2: error: ld returned 1 exit status

看起来好了,再试试编译

$  gcc-14 test.c -o t && ./t
Hello Cruel World!

完美解决!!

这个anaconda的ld和系统的是不匹配的,但是它为了penv把这个替换了,结果collect2使用了它设置的工具链的ld. 然后引起这个问题。

这个python连gcc也搞乱了,真是服,自己乱就好了。为什么祸害别人?

本文希望可以帮到需要的人,要是遇到这个的,可能原因不大一样,但是这个文章把debug和定位的方法和原理都告诉大家了,祝大好运!


http://www.ppmy.cn/ops/152843.html

相关文章

低代码系统-钉、微表单控件对比

组件对比 微搭 宜搭 数据列表 单行文本 数据详情 多行文本 表单容器 数值 数据表格 评分 普通容器 单选 网格布局 复选 卡片 日期 轮播容器 日期区间 布局组件 成员 滚动容器 图片上传 弹窗 附件 TAB栏 子表单 菜单导航 下拉单选 宫格导航 下拉复…

低代码系统-氚云、宜搭控件对比

上一篇我们对比了宜搭和微搭&#xff0c;可以发现&#xff0c;两个产品的定位完全不一样&#xff0c;虽然都借助了平台的资源和能力&#xff0c;但很明显&#xff0c;微搭在集成腾讯平台上&#xff0c;更加具有针对性和特性。可以说是一个以腾讯微平台的企业级应用服务平台&…

基于python+Django+mysql鲜花水果销售商城网站系统设计与实现

博主介绍&#xff1a;黄菊华老师《Vue.js入门与商城开发实战》《微信小程序商城开发》图书作者&#xff0c;CSDN博客专家&#xff0c;在线教育专家&#xff0c;CSDN钻石讲师&#xff1b;专注大学生毕业设计教育、辅导。 所有项目都配有从入门到精通的基础知识视频课程&#xff…

LetsWave脑电数据简单ERP分析matlab(一)

LetsWave是基于matlab的一款工具包&#xff0c;类似eeglab&#xff0c;也可以对数据进行预处理。习惯使用eeglab做数据预处理的&#xff0c;可以先在eeglab中做预处理&#xff0c;然后可以保存为*.set格式&#xff0c;最后在letswave中画图。 letswave下载地址&#xff1a;htt…

文本文件打印类库(C#)

写了一个打印文本文件的类库&#xff0c;功能包括&#xff1a;打印预览、打印。打印时可以选择打印机&#xff0c;可以指定页码范围。调用方法非常简单&#xff1a; TextFilePrinter p new TextFilePrinter(tbxFileName.Text); p.View(); // 打印预览 p.Print(); // 打印文件…

No.36 学习 | Python 函数:从基础到实战

最近我在学 Python 编程&#xff0c;今天可算是狠狠钻研了一把 Python 里的函数&#xff0c;感觉脑袋里的知识又充实了不少&#xff0c;赶紧来记一记。 一、Python函数基础概念 &#xff08;一&#xff09;pass语句&#xff1a;代码块的“占位符” 在编写代码时&#xff0c;有…

Scrapy之一个item包含多级页面的处理方案

目标 在实际开发过程中&#xff0c;我们所需要的数据往往需要通过多个页面的数据汇总得到&#xff0c;通过列表获取到的数据只有简单的介绍。站在Scrapy框架的角度来看&#xff0c;实际上就是考虑如何处理一个item包含多级页面数据的问题。本文将以获取叶子猪网站的手游排行榜及…

专业130+总分410+西安交通大学815/869原909信号与系统考研电子信息与通信工程。真题,大纲,参考书。

read-normal-img 考研成功上岸西安交通大学&#xff0c;总分410&#xff0c;专业课815/909-现在的869信号与系统&#xff08;含DSP&#xff09;130&#xff0c;总结一下自己的复习经历&#xff0c;希望给大家有些帮助。 专业课&#xff1a;815/869原909信号与系统和dsp 教材&…