GCC generates a truncated object file (0 bytes)

Alwin Leerling leerling@xtra.co.nz
Thu Dec 17 06:39:00 GMT 2009


Hi everyone

The following problem has me stumped:

While compiling my computer locked up. The only option I had we to hit 
the reset button. When I tried to compile my source again an object file 
was truncated to 0 bytes.

To get an idea of my file organisation:

tidalcreek
    |
    | - debug
    |     |
    |     |- gui
    |     |   |- gtkdrawwidgets
    |     | ..... other build directories
    |-gui
    |  |- gtkdrawwidgets
    | .... other source directories

The offending object file is 
tidalcreek/debug/gui/gtkdrawwidgets/gtkroad.o (build from source file 
tidalcreek/gui/gtkdrawwidgets/gtkroad.c)

Steps I took to rectify the problem

Delete the truncated object file and recompile => resulting object file 
created with 0 bytes.
Delete the object file, forced a fsck on reboot, rebooted and recompiled 
=> resulting object file created with 0 bytes.
Deleted complete build tree (I am using autotools), remade the build 
tree and recompiled => resulting object file created with 0 bytes.
Created a text file gtkroad.o and put some text in it, saved and 
reloaded in text editor => fine
Deleted text file, compiled => resulting object file created with 0 bytes.

I tried to manually compile the file 
(PWD=tidalcreek/debug/gui/gtkdrawwidgets/):

gcc -DHAVE_CONFIG_H -I. 
-I/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets -I../.. 
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 
-I/usr/include/freetype2 -I/usr/include/libpng12      -Wall -O0 -g3  -MT 
gtkroad.o -MD -MP -c -o gtkroad.o 
/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets/gtkroad.c

Now I know that there is one warning generated when this code is 
compiled. When I execute the above line, no warning is generated and a 
truncated object file is created.

I next tried to change the name of the output file:

gcc -DHAVE_CONFIG_H -I. 
-I/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets -I../.. 
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 
-I/usr/include/freetype2 -I/usr/include/libpng12      -Wall -O0 -g3  -MT 
gtkroad.o -MD -MP -c -o gtkroad2.o 
/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets/gtkroad.c

This created a truncated object file called gtkroad2.o. No warning reported.

Next I changed the preprocessor target file name:

gcc -DHAVE_CONFIG_H -I. 
-I/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets -I../.. 
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 
-I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 
-I/usr/include/freetype2 -I/usr/include/libpng12      -Wall -O0 -g3  -MT 
gtkroad2.o -MD -MP -c -o gtkroad.o 
/home/alwin/transpread/trunk/tidalcreek/gui/gtkdrawwidgets/gtkroad.c

This worked! a valid gtkroad.o file was created as well as a gtkroad.d 
file with target gtkroad2.o in the first line.

Created build tree with a different build root name (debug1 instead of 
debug) and compile => works fine

I'm running Fedora 11 and gcc version 4.4

Any suggestions?

Thanks in advance

Alwin Leerling




More information about the Gcc-help mailing list