Friday, November 20, 2009

Packaging Modified gcc

Let the fun begin!

So, what I had to accomplish here was build a gcc package with all the patches necessary for the modifications needed by DXR. This sounds easier than it was, although looking back at it now the reason it took so long was a very small mistake.

The first thing that I started with was getting the spec file for regular gcc by running the command

"yumdownloader --source gcc"

followed by

"rpm -i gcc-4.3.2-7.src.rpm"

where both commands were done in my ~/rpmbuild/SOURCES/ directory.

Next thing I did was grab the patches using the command

hg init .
hg clone http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq ~/gccplugins

and that put the patches in the directory ggcplugins in my home directory. After that I copied all the patches to the ~/rpmbuild/SOURCES directory.

From there all I had to do was the spec file which seemed easy. I added the lines -

#My Edits for modified GCC build
Patch20: plugin.patch
Patch21: gty.patch
Patch22: nopoison.patch
Patch23: parm_attrs.patch
Patch24: c_process_decl.patch

near the top of the file, and then the following lines in the %prep section -

#my patches
pwd
%patch20 -p1 -b .c_process_decl~
%patch21 -p1 -b .gty~
%patch22 -p1 -b .nopoison~
%patch23 -p1 -b .parm_attrs~
%patch24 -p1 -b .plugin~

My first problem came from using the -p0 switch when with these particular patches they need to use the -p1 switch. After my teacher and I found that out, there was still a problem becuase the patch failed because it was looking for the file gcc/tree-plugin-pass.c. After a good amount of googling I found that this file was actually created by one of the other patches (plugin.patch).

I then switched out c_process_decl with plugin and after that it built successfully.

The final build times were-

real 85m55.771s
user 135m26.897s
sys 51m59.042s

Tuesday, November 10, 2009

Testing g++ and modified g++

So we had the task in class of testing build times on a package using regular g++ and a modified g++. To do this we had to get the new modified version which I accomplished using this script here. After running this script you will have a new directory called "tools" in your home directory which has the new version of g++ in it.

First thing you should do before anything is test building a package that has a lot of c that needs to be compiled. I used abiword for this. I used the command

time rpmbuild -ba abiword.spec

to get the build times for this.

So to be able to use the modified g++ I had to change the the original /usr/bin/g++ to my new one. But we do not want to lose the old one so I just renamed the old one g++.original. I also did this for the c++ in /usr/bin.

Next I created a symbolic link using the command

su -c "ln -s /home/ashilts/tools/gcc-dehydra/installed/bin/[gc]++ /usr/bin"

and this command created a symbolic link name g++ and also one for c++ in the /usr/bin directory.

Next tried to do the building and it worked mostly until i got to the install section where it failed because it said there was something wrong with the rpaths. I asked my teacher Chris Tyler about this and he gave me the advice of using the command

time QA_RPATHS=$[ 0x003f ] rpmbuild -ba abiword.spec

to run the build process which worked perfectly. I am not very sure what rpaths are even after reading a wiki page on them, but I will link it for anybody that wants to get a little more insight on them.

RPATHS

So The final tests of mine showed that the regular g++ was a slight bit slower by around about 10 seconds at the most. Here is a chart with the stats

Test # Regular g++

Modified g++

1

real 6m42.508s

user 10m36.408s

sys 3m15.561s

real 4m20.988s

user 3m18.736s

sys 2m37.991s

2

real 3m43.744s

user 3m15.126s

sys 2m27.259s

real 4m18.335s

user 3m17.841s

sys 2m36.843s

3

real 3m44.547s

user 3m14.892s

sys 2m27.509s

real 3m51.537s

user 3m18.214s

sys 2m37.537s

4

real 3m41.988s

user 3m14.702s

sys 2m27.030s

real 4m15.478s

user 3m17.870s

sys 2m31.028s

Hmmm I was having troubles getting this table presentable but I think you should be able to make it out.

So in conclusion I think that the modified g++ had a decent build time but I dont know if it will be good enough to use when use to compile things that are much bigger and have longer build time.

I think that is all for now so cya!