LLVM

C++ 中的 main 定义

| Development | #C++ | #C | #Programming | #Linkage | #GCC | #LLVM

新的 C++ 标准中 不允许给 main 指定 linkage-specification 了。

当然,考虑到原本 main() 也是 C 运行环境在开始运行程序的时候调用的, 而 C 运行环境自然也预期 C linkage,即不按照 C++ 的习惯对符号根据参数增加名字前缀, 因此大部分编译器在遇到 C++ 程序定义全局 main() 的时候也会按照习惯采取 C linkage 方式去翻译。这一规则首先被 GCC 采纳,随后 LLVM 也跟进了。

阅读全文…( 本文约 389 字,阅读大致需要 1 分钟 )

FreeBSD CLang/LLVM项目终于进svn了

| *nix and Win32 Kernel | #CLang | #FreeBSD | #LLVM

如题。

不过这一次因为-CURRENT code slush的缘故,应该不会在 8.0-CURRENT 里面引入了(Ed在svn里面建立了另一个branch来做)。我想从各方面考虑,9.0-RELEASE里面正式砍掉gcc那一套东西应该不会是很困难的事情。传统上 FreeBSD 的代码用到了很多gcc的扩展,因此可能还需要一段时间。

阅读全文…( 本文约 197 字,阅读大致需要 1 分钟 )

LLVM: 为什么你需要关注这个项目

| Development | #LLVM

LLVM 是 Illinois 大学发起的一个开源项目,它到底是什么呢?从字面上看,它是一个虚机系统,然而这又和之前为大家所熟知的 JVM 以及 .net Runtime 这样的虚机不同,它提供了一套中立的中间代码和编译基础设施,并围绕这些设施提供了一套全新的编译策略(使得优化能够在编译、连接、运行环境执行过程中,以及安装之后以有效的方式进行)和其他一些非常有意思的功能。

为什么这个项目很重要呢?对于普通的开发人员来说,LLVM计划提供了越来越多的可以使用、编译器以外的其他工具。例如代码静态检查工具 LLVM/Clang Static Analyzer,是一个 Clang 的子项目,能够使用同样的 Makefile 生成 HTML 格式的分析报告;而对关注编译技术的开发人员来说,LLVM提供了很多优点:

阅读全文…( 本文约 725 字,阅读大致需要 2 分钟 )

GCC运行环境豁免条款再次狠狠地打了苹果的耳光

| Development | #clang | #FSF | #GPL | #llvm

今年 1 月 27 日发表的 《GCC运行环境豁免条款 (英文版)》 再次狠狠地打了苹果的耳光。

原先的豁免条款如下:

// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

阅读全文…( 本文约 549 字,阅读大致需要 2 分钟 )

Progress on LLVM clang

| *nix and Win32 Kernel | #clang | #FreeBSD | #gcc | #llvm

As some of you already know, FreeBSD, along with some other Open Source projects, is moving away from GCC due to GPLv3. From a technology perspective, this also makes sense since the (likely) candidate, BSD-style licensed, LLVM based clang, a C compiler, is making reasonably good progress.

So, what should we expect from LLVM or clang?

Here is a good comparison between GCC and clang. Despite GCC is popular, considerably more mature, and supports more languages (especially C++, which clang’s support is incomplete at this moment), clang provides cleaner AST (Abstract Syntax Tree), much more modularized (if you take a look at GCC’s history, Richard Stallman intentionally made GCC’s code not reusable in other software), provided much more information for optimizer, is much faster and use much less memory, etc.

For FreeBSD, currently, clang can compile its kernel with only very few tweaks.

阅读全文…( 本文约 315 字,阅读大致需要 2 分钟 )