Lobsters | 📄 原文链接 | 2026-10-23 收录

macOS 上的 gcc 是三层套娃:从 /usr/bin/gcc 一路挖到 clang

来源:zoey-on-github.github.io — 2026-10-20

📋 概述

/usr/bin/gcc 在 macOS 上不是别名也不是脚本,而是一个真正的可执行文件。作者反汇编它,发现它把 c++、llvm-gcc、llvm-g++ 等名字特判成 clang 或 clang++,随后调用 libxcselect.dylib 里的 xcselect_invoke_xcrun,效果等同于 xcrun。用 xcrun --find gcc 定位到真正的 gcc,它同样只是个壳:再次 exec 到 xcrun 并调 clang。也就是说 Xcode 装的开发工具全是一条条指向 xcrun 的转接链。

🔑 核心要点

💡 金句

i naively assumed that it would just be shelling out to clang but it turns out the answer is more interesting than that.
← 返回 Lobsters 首页