Fight for the Internet 1!

Showing posts with label compiler. Show all posts
Showing posts with label compiler. Show all posts

Tuesday, November 23, 2010

Ubuntu Graphics Session Fix after botched Kernel Upgrade

Overview
This post is about restoring graphics to your Linux Desktop session if you install some kernel updates that don't go so well. Particularly, ones that fail with your graphics drivers.

Quick Steps
If you get error message (when trying to upgrade kernel packages or kernel drivers): "Skipping (driver build) at this time because kernel-source is missing." Try the following steps:

Note: `uname -r` is a commandline option which will auto-substitute your kernel version and architecture into the install command. If installing via a GUI, just use the info output from running the console command `uname -r`.
sudo apt-get install linux-source-`uname -r` linux-headers-`uname -r`
If this does not automatically cause your nvidia drivers to compile, cause a manual install with:
sudo apt-get install nvidia-current
If that still doesn't work, try uninstalling and reinstalling nvidia-current.


Background
Today I noticed there were some kernel updates in Ubuntu, but they had been kept back. So I decided to manually install them, since they did not appear to be causing any package conflicts. I do updates from command line with 'apt-get' (because I'm awesome that way *wink*). While installing the held-back packages, being kernel updates, it tried to accommodate my Nvidia graphics drivers.

Apparently, this failed. I noticed the error on the console, and immediately downgraded my kernel back to the previous versions. But alas, it did no good. I rebooted and was confronted with a text-only machine. Now, I'm fine with this, since I spend a lot of time on console. (Screen, vim, ssh, and elinks are usually all I need for most rescue operations. Sometimes rtorrent, wget, and curl are handy too.)

After trying to get the packages to jive well together, I gave up trying to juggle the kernel packages and instead focused on the Nvidia drivers. I tried installing the nvidia-current package provided by the Ubuntu repositories. (I was running a later version from a PPA.). This failed, but triggered the same error.

"Skipping (driver build) at this time because kernel-source is missing." Now, I've seen this error before. So I quickly installed the linux-source-`uname -r` package. This did not quite do the trick, and I have been around long enough to know that the source-packages often require the header packages as well. So I install linux-headers-`uname -r` package.

Once installed that, I didn't even have to do anything. The system automatically compiled the missing nvidia drivers and installed them for me. A quick reboot later, and now I am blogging about this simple solution.

Sunday, April 19, 2009

GCC does everything MSVC does, and more

I came across a very encouraging report on compiler optimizations. I am bringing you some of the selected comparision results between GCC and MSVC. Source for this information is Software optimization resources published by Agner Fog. In particular, I used this PDF, which was last updated January 23, 2009.

The table in the PDF source states these results were from GCC 4.1 and MSVC 2005 which are probably from his original publication in late 2008. However I do not know what updates occured since, so these could be taken from later versions of either compiler. I do not know about MSVC, but I know for sure that GCC 4.2 and 4.3 are just getting faster and faster, and that is not counting LLVM.

One thing this evidence shows is clear: Saying MSVC produces faster binaries than GCC is simply not true, especially if they don't specify compiler versions and platforms and computing task. The next time you hear someone rip on the GCC compiler for being slow without specifics, just laugh in their face.










Tuesday, April 7, 2009

LLVM-GCC vs GCC

So I have been reading up on the LLVM, and on integrating it with GCC. I care about a possible integration of the system because I want Linux programs to continue to be fast. The compiler is an important component in that speed. Furthermore, unlike Microsoft, the GCC project does not have direct communication with Intel Compiler designers, so it is important that GCC compiler be damn good.

From what I read online, it seems like some people like to decry the GCC project as being difficult to contribute to, and perhaps it is... or was. I don't personally believe this after reading experts from The Cathedral and the Bazaar. But I also do not have a lot of experience with the GCC project personally. If nothing else, the history of the GCC since the late 1990s has definitely been one of better community involvement.

Benchmark Data
There is a project called LLVM-GCC which is the combination of GCC and LLVM and I have been trying to collect information on performance between the two compilers. Here follows some of the things I have found.

To note at the beginning, the speed of the compilers is dramatically effected by the CPU architectures they are compiling on. So, an X86_64 architecture compared to Darwin/PPC could give wildly different results for the same code. Many of these tests don't even mention their architectures.

At Cliff Hacks, we see the GCC outperforming LLVM when maximum optimization is enabled (-O3). Unfortunately comparing GCC with -O0 and LLVM standard is fairly invalid, since -O0 effectively ties GCC's hands for speed.

At Laurovenancio, we see LLVM-GCC outperforming GCC by about 2-4%, but this is using GCC 4.1.x. I know from other research that there have been some serious speed improvements in 4.2 and 4.3, and I know that 4.4 is continuing these efforts with Stack management improvements. Because of these updates, I would not take these results as very reliable now.

Leonardo-m's blog is the most recent (2008-12-14) and best illustration of results I have found so far.



These results seem to indicate an overall small speed increase when using LLVM-GCC. The nbody section was a bug which has been reported and fixed already.

If nothing else, the GCC is still an amazing piece of work to be competing so well, even with all of "supposed shortcomings" that I see frequently mentioned in relation to LLVM.

One reason that LLVM has not been adopted into GCC officially is that there are license conflicts between the two projects. I don't really care to list them now, but basically the GCC want to keep things GPL'd and LLVM is more interested in a BSD style license. This is probably because of funding and influence from Apple, their sponsor. I don't fault either party for their intents.

A Final Thought
If LLVM-GCC should become a significantly better/faster/superior/prettier compiler over the GCC, I wonder if there will be a movement to adopt it as the official compiler for Linux distribution packages? I mean, would Debian or Ubuntu start to build their packages with LLVM-GCC if it was a superior compiler? Or would they stick with GCC? Does license matter more than speed? Does "the official Linux compiler" stamp from GCC matter more the perceived performance?

I just hope that if LLVM-GCC should become a "better" compiler that the Linux community, specifically the package maintainers, will consider it as a possibility.