zig 为什么可以成为比 C 更好的编译器? #73
jinzhongjia
started this conversation in
观点交流
Replies: 1 comment 3 replies
-
你这个是哪里得到的结论, |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
实际上,zig 本身实现了一个 C 的编译器,当然不仅仅如此,zig 还提供了一个比较 magic 的东西—— glibc-abi-tool,这是一个收集每个版本的 glibc 的 .abilist 文件的存储库,还包含一个将它们组合成一个数据集的工具。
所以,zig 本身所谓的 “ships with libc” 并不准确,它的确分发 libc,但它只携带每个版本的符号库,仅依赖这个符号库,zig 就可以实现在没有 libc 的情况下仍然正确地进行动态链接!
由于这种特性,这导致 zig 尽管携带了 40 个 libc,却仍然能保持 45MB(linux-x86-64)左右的大小,作为对比 llvm 分发的 clang 完整的工具链的大小多达好几百 M。
关于更多的细节,你可以参考以下链接:
process_headers tool
Updating libc
hacker news
与 C 交互
Beta Was this translation helpful? Give feedback.
All reactions