quarta-feira, 12 de fevereiro de 2014

How to compile a compiler? Clang! Let's do it!

On my MsC project, I wanted to use a compiler that was as powerful as GCC but not so loaded with unwanted things and efficient as well. GCC 4.8 has a very good performance and produces far-sized executables, but I needed an alternative. That's when I found CLANG. Clang is a C/C++/Objective-C front-end for LLVM Compiler (a stratified structured compiler with great performance - a really organized compiler, on simple therms).

Clang is known by its increased performance, low memory usage and is soft-spoken when talking about error (the messages are more accurate and simple for humans to understand). Compared to older version of GCC (until 4.6) Clang have an outstanding result.

This compiler is supported by a consortium, including Apple. It's a really new work in progress and worth trying.

Let's Start!

We will install Clang and LLVM on Fedora 19/20.

Installing Dependencies

I've compiled successfully Clang 3.4 (Final) on Fedora 19/20, both on x86_64 and ARM architectures (but take about 8 hours to compile on Pandaboard). I'll use on this tutorial the SVN version.

Make sure you have GCC (gcc, gcc-c++) packages and Perl (perl, perl-podlators) packages before you start the process.

# yum install gcc gcc-c++ perl perl-podlators -y

After that, create a directory named clang and a src directory inside of it

$ mkdir clang
$ mkdir clang/src

We will need libffi-devel too, so, to install it:

# yum install libffi-devel -y

And if you don't have SVN installed:

# yum install svn -y

Retrieving SVN Code

Now we'll retrieve the source code of LLVM from the official trunk:

$ cd clang/src
$ svn co http://llvm.org/svn/llvm-project/llvm/tas/RELEASE_34/final llvm


Now, the source code of Clang:

$ cd tools/

$ svn co http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_34/final clang


We will need the extra packages from Clang:

$ cd clang/tools
$ svn co http://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_34 extra

And last, compiler-rt files:

$ cd ../../../projects
$ svn co http://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_34/final compiler-rt

Configuring Clang for the next steps

We will create a build directory and request the configuration of the packages via configure script:

$ mkdir ../build
$ cd ../build

And now, configure:

$ ../configure --enable-optimized --disable-assertions --enable-jit --enable-libffi --enable-shared


Wait a little/long time, depending on your machine, and let's start making it, literally:

$ make -j X

WARNING: You'll need to substitute X for a number in the command above! X is the number of cores you have on your machine + 1, so, if you have a dual core, X = 3.

Again, wait a little/long time, depending on your machine.

Regression Tests

Clang and LLVM comes with a regression test suite, and is necessary for assuring Clang will execute perfectly. To run this test suite do:

$ cd test
$ make
$ cd ../tools/clang/test/
$ make
$ cd ../tools/extra/test/
$ make

If a message like "UNEXPECTED FAILURE" doesn't appear, it's all ready to go.

Install it!

Now, all you need to do is install Clang:

$ ../../../../../
$ sudo make install 

Maybe you'll need to reboot. Type clang on a terminal and you'll see:

[user@localhost ~]$ clang
clang: error: no input files

DONE!


The syntax for compilation on clang is very similar to the gcc syntax, and if you are a GCC User, Clang will be a piece of cake.

Hope you enjoyed! \o

This is a modified and updated version from this tutorial.


terça-feira, 11 de fevereiro de 2014

SongSpot #4

Some J-Rock to inspire the rest of week. This time featuring ONE OK ROCK. Great songs and finally a vocalist saying clear english words huahua!

Hope you enjoy!

ONE OK ROCK - Clock Strikes


ONE OK ROCK - 完全感覚Dreamer (Full Sense Dreamer)

segunda-feira, 10 de fevereiro de 2014

TED Weekly Spot #1

I'll post some of my favorite TED Talks on this post series. If you don't know, TED is an initiative that brings important icons of the present times to transmit knowledge and discuss many topics. As the slogan says: Ideas Worth Spreading.

This week, Bill Gates (talking about teachers and how important is the feedback, not just for teachers, but for professionals in all areas of knowledge) and Stephen Wolfram (the creator of Wolfram Alpha and Mathematica).

Hope you enjoy it!




domingo, 9 de fevereiro de 2014

All the Linux Flavors!

I've been testing a lot of Linux "flavors" on the last months, and spent a huge amount of time trying to learn specific information from those. Besides all the distributions are indeed Linux, each one pass a different "sensation" when using it.

I will list below the distributions i've tried, and will talk about each one a little bit. This is not a RANKING, is a review! =D

Ubuntu

 www.ubuntu.com

The distribution that I consider (not just me, of course) the responsible for popularize Linux to the masses, Ubuntu is the most straight-forward distribution available. Lots of enthusiasts, support, forums and all the crazy experiences possible were tested on this distro. It is a descendant of the ancient Debian.

This was the first version of Linux I had contact (without counting Kurumin Linux, a version created by Carlos Morimoto, also based on Debian - Debian is a father and grandfather of lots of distros available), and learned to use almost everything I know about Linux (that is not much XD) using Ubuntu.

With a really good interface until version 10 (Gnome 2 was the standard desktop manager - since Unity, I needed to change the interface to use Ubuntu, or use another "remix" (as named spin) with other desktop manager, like XFCE (Xubuntu), LXDE (Lubuntu) or KDE (Kubuntu)). Unity is a real problem for old-machines - I really recommend XFCE for most users.

Ubuntu has one specific remix to Multimedia users named Ubuntu Studio, that is worth trying for those searching for a Multimedia edition OS.

Changing the architecture, Ubuntu has an image of the LTS (Long Therm Support) version for ARM architectures with Hard Float Point - used on Raspberry Pi and Pandaboard, for example. I don't know if it's officially maintained by Canonical, but is functional and can open a path to your mobile/embedded development project also.

Mint

www.linuxmint.com/

Mint is another Debian/Ubuntu descendant and is known for the stability and design of its interface. It uses Cinnamon - that is a really gorgeous desktop manager and also easy to use. If you have used Ubuntu and is used to the Debian-like commands, it's a great distro to try. And if you're a little nostalgic about the design of Gnome 2 (since Gnome 2 has been discontinued), Mint has a spin with MATE, that is a Gnome 2 clone (a resurrection from the ashes), as usual, a great desktop manager.
 
Debian

www.debian.org

The grand-grand-grand-father of Linux distros, Debian is a safe-haven. If you need a hyper-stable version of Linux (i.e. for servers or mobile-nodes that you can't turnoff for maintenance when you want), this is your choice, but don't count with constant updates, since Debian is known to have really slow cycles of update. Of course, you still could update manually, but it can turn into a really tedious task. Compiling a new Kernel for Debian is worth trying and is very easy to do, just takes a considerable amount of time and patience, depending on your machine.

Debian is also known as the distro that can "run up in your fridge", and have compiled versions for most known architectures, including ARM. The ARM Image works really great, like a common x86 computer, but to install it, I needed to use a script written by a community user.


Gentoo

www.gentoo.org

Known as a "Build from scratch" distro, Gentoo is a great flavor for those who have time, a huge amount of time and patience, since all you have ready to use is a live-cd from where you can prepare your system and build each part of your future OS. I've to stop trying to use this because I've passed a day trying to install it and at the end, that thing doesn't work as expected XD.

With a not so huge legion of users, who are known as "hardcore users", Gentoo still attract the crazy human beings that have an "insatiable thirst of knowledge", or not.


Slackware

www.slackware.com


Considered as the most PURE UNIX DESCENDANT (Linux Royalty), Slackware is also a grandfather, but doesn't have many grandchildren (I know just one, Zenwalk). It is a more complex and conservative distro, but have all the resources and specialization for desktop or servers - the customer's taste.

Also have a great legion of users, but Slackware is suffering from the same aging problem of Debian, with aggravating of just having ONE maintainer, Patrick Volkerding, an old-times developer.

For those who want to learn Linux with some depth, this will help you gain know-how for most system managers.

Slackware doesn't come with a standard Package Manager, but you can install yasm, that will help with this task. If you don't want to build your apps from scratch, there are sites like SlackBuilds, that offer pre-compiled and straight-forward installation for most common packages.

It comes with around 5 desktop managers included on the DVD, and you just need to choose (I really recommend using KDE if your machine allows, since it has a great appearance, but for most machines, XFCE is the choice).


ArchLinux

www.archlinux.org

ArchLinux is great. You need to have some knowledge to install it (if you use ArchBang!, a spin based on ArchLinux, this problem is solved, as ArchBang! comes with a setup utility), an internet connection and a little patience. Lifehacker published a great tutorial to make your own ArchLinux installation (I use it when I need to install ArchLinux on a VM, since it's simple and useful).

You'll have the top edge software on the repositories, and a huge repository known as AUR (Arch User Repository) where you can find many specific packages not found on the official repositories.

The package manager for ArchLinux is pacman (you also use it for bring the dependencies when installing ArchLinux). If you want, you can install yaourt, that is capable to search also on AUR - piece of cake =].

ArchLinux doesn't have a standard desktop manager, again, taste of customer, but LXDE or XFCE is sufficient for most needs.


Fedora

www.fedoraproject.org

Last, but not less important, Fedora. Fedora is currently supported by RedHat, and is a direct descendant from RedHat opensource initiative (together with CentOS - a corporative oriented opensource version of RedHat).
In my opinion, the better able to compete with Ubuntu, and also, my current OS.

It has a great stability and a huge repository, not as complete as Ubuntu, but this is avoided using RPMFusion (that add more repositories to the list and permit to install top edge applications via package manager).

The Fedora 20 comes with the newest GNOME 3.10, (the last of the Linuxhicans that comes with Gnome as standard desktop manager). A great visual experience and also easy to install extensions (Firefox is integrated with the Gnome Addons Site - One click installation).

Yum is the standard package manager and also a powerful one. From it, it's possible to install/remove/reinstall/purge and other tasks (similar to Debian's apt and ArchLinux's pacman). Fedora comes with a Softwares application, that is a GUI for Yum.

I'm testing the ARM Image of Fedora on Pandaboard, until now, no problems with it. The great part is that the Fedora for ARM is maintained by RedHat, and official updates come to it as soon as possible.

That's it for now. Hope you enjoyed! \o

quarta-feira, 5 de fevereiro de 2014

Song Spot #3

This week, a little nostalgic post on Song Spot. Two of my favorite brazilian bands on the early 2000s: Skank and Kid Abelha.

Has been a while since I heard something from those two, but is really great to remember those songs. Hope you enjoy!

Kid Abelha - Lágrimas e Chuva (Tears and Rain)



Skank - Resposta (Answer)