Sunday, October 07, 2012

Moved to wordpress

Just moved this blog to wordpress, expecting to write technical text more easily. The address is

Monday, May 25, 2009

libposix project started !

libposix is a bold attempt to unify the implementation of the core functionality of all Unix systems. libposix is:

  • A full implementation of the POSIX 2008 standard
  • A cross platform implementation, that should replace existing implementations of the system core libraries and unify the core Unix implementation for all systems
  • An exact implementation of POSIX 2008 and nothing else (no extensions, no previous POSIX versions)
  • An implementation that works well with possible extensions to the core system functionallity (ex: GNU, BSD)
  • An implementation of POSIX written from scratch
  • Free and open source software

The main goal of the libposix project is to successfully replace free Unix "libc" implementations with an implementation that is portable, conformant, easy to build, to cross-build, to use, to study and to mantain. Read more about libposix in the introduction page.

Tuesday, May 05, 2009

A benchmark where clang wins gcc

I have sent my last post about clang to a friend, suggesting that the final days of gcc could be coming, and he refuted with a very pragmatic point: "talk is cheap, show me the (generated) code". :-P So I decided to get serious.

I have already told in the article that clang is in development stage, so how could I show him a working example ? I know clang able to compile large projects, like gcc and FreeBSD. After playing with some small projects, I found this one, from the Computer Language Benchmarks Game. The benchmark is called fasta, and it generates pseudo random DNA sequences. I chose this one because it was small and, even though floating point was used in the program, outputs could be directly compared without rounding errors (becuase they're composed of DNA elements).

My system: My machine is a HP Pavilion dv9000, Core 2 Duo T5500 1.66 GHz, 2GB RAM, with Ubuntu 9.04.

The compilers: the old guy is gcc 4.3.3 from the standard Ubuntu package. The new guy is clang, downloaded today from svn (llvm rev 71035/clang rev 71041). llvm and clang were compiled with "--prefix=/opt/clang --enable-optimized".

The execution: I've just used GNU time repeatedly until the execution time converged, chose a result at random and rounded it to one decimal figure. Remember that I just have to convince a friend. :-P Standard output was redirected to /dev/null.

At first I did this:
$ gcc -O3 -o b b.c
$ /opt/clang/bin/clang -O3 -o bb b.c
$ time ./b 25000000 > /dev/null
$ time ./bb 25000000 > /dev/null

But this gave incredible 11.1s for gcc and 7.4s for clang. It was a good surprise to see clang surpassing gcc, but there was something wrong, since gcc is not a bad compiler. A quick look in assembly output showed that clang was using SSE registers for moving data around and for calculating, while gcc was not. This is a good point for the clang driver, but it doesn't tell us anything. So, the correct command line for gcc is:

$ gcc -O3 -march=native -mmmx -msse -msse2 -msse3 -mfpmath=sse -o b b.c

Then we finally settle with the results: 7.7s for gcc and 7.4s for clang. Clang wins !

Friday, April 17, 2009

clang compiler quickstart

Have you ever heard about clang ? It's a new compiler for C, C++ and Objective C languages. clang is being developed in a fast pace and is expected to become an alternative for the gcc compilers.

What are its advantages ? It's a compiler written from scratch, its code is completely modular and easily readable, it aims to offer user-friendly expressive diagnostics, it's much smaller and faster than gcc, it's expected to support IDE integration and code analysis and it's compatible with gcc. The C part of the compiler is in an advanced stage and can build large projects, like sqlite and the FreeBSD kernel. The C++ part is in an early stage (clang can't compile itself, for example).

Quick start:

$ svn co llvm
$ cd llvm/tools
$ svn co clang
$ cd ..
$ ./configure --prefix=/opt/clang
$ make
$ sudo make install

In the sequence above, llvm is the compiler back end and clang is the compiler front end. The compiler is installed in the /opt/clang directory, so it's available at /opt/clang/bin/clang (the directory can be deleted for a full uninstall when you're done).

Try it out:

$ cat hello.c
#include "stdio.h"

int main (void) {
printf("Hello world!\n");
return 0;
$ /opt/clang/bin/clang -o hello hello.c
$ ./hello
Hello world!
$ tar xf lame-398-2.tar.gz
$ cd lame-398-2
$ ./configure --prefix=/opt/lame CC=/opt/clang/bin/clang
$ make
$ sudo make install
$ /opt/lame/bin/lame myaudio.wav

As you can see, clang is in development stage, so it's only available trough svn.

Do you want to contribute ? See more information at clang home page !

Wednesday, April 01, 2009

POSIX 2008

The POSIX standard has been updated in December 2008. The standard is an attempt to standardize the core API of all Unix systems and, nowadays, most Unix clones try to adhere to the standard in some level of conformance (including GNU and BSD based systems). Register and read the new standard in the Open Group UNIX System site.

Tuesday, January 13, 2009

The best job in the world

Australian's Queensland Tourism is seeking applicants for what they call the best job in the world. Are you interested in a 6 month contract and AUD$ 150.000,00 (US$ 100.950,00) for diving, feeding turtles and blogging, while living in paradise ? Then apply for the island caretaker job in Hamilton Island. See the pdf in the site Island Reef Job for details.

Tuesday, December 30, 2008

Android is updated and goes unnoticed

This December Android source code received a significant update, but apparently it went completelly unnoticed. The git repository of most components were updated to be compatible with the new Android kernel, based on linux 2.6.27 (previously 2.6.25). Most components have merged a repository called "cupcake", with lots of changes that have now become official. Also, external libraries were updated too. I think we should expect a new minor release of the SDK in a few weeks too. Remember to run a "repo sync" to keep your source code up-to-date (this one will take a lot of time).

This is great news for me, since I was not being able to port Palm TX to Android. I needed version 2.6.27 because it's the first version with official support for Palm TX. I was getting segfaults when executing one of the core applications in Android (servicemanager) in that version. Now I believe the port will work flawlessly. :-D