PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Linking errors while recompiling

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
gmkrishn



Joined: 03 Sep 2005
Posts: 1

PostPosted: Sat Sep 03, 2005 1:31 pm    Post subject: Linking errors while recompiling Reply with quote

I have a directory containing about 400 .f90 files out of which about 30 are actually modules. So when I create the executable I create the 400 .o files (and the corresponding 30 .mod files get generated) and link them all up to produce the executable. I have been doing this without any issues so far.

Many times I need to change the source code (removal of files, addition of files and change of .F90) and recompile the executable. Instead of recreating all the .o files I decided to do the following:
* For files which get removed or changed, I remove the .o and .mod file (if exist)
* For newer files dont do anything

After this I recompile the whole executable. This way I get to use a lot of the previous run's .o files.

I cannot rely on timestamps of .f90 files (they are actually links to the real .f90 files) but the .o and .mod and regular files and so I can rely on their timestamps.

This has been working well for a couple of weeks, when I found one example where I get linking errors (when I do the above mentioned procedure). If I delete all the .o and .mod files and recompile, then things work. If I delete all the .mod files and the corresponding .o files, then also the things work.

If I just delete the .o and .mod files of changed/removed files, the recompiling produces a linker warning:

"alignment 8 of symbol 'X' in file1.o is smaller than 16 in file2.o"

If I run the executable anyway, I get array bounds errors.

Can somebody explain why these errors occur (something to do with .mod files I guess)? More specifically, is there any way I cam improve my logic so that I only require to recompile new files and files which have changed?

Any pointers will be appreciated.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6213
Location: The Portland Group Inc.

PostPosted: Tue Sep 06, 2005 12:28 pm    Post subject: Reply with quote

Hi gmkrishn,

What's most likely happening is when you modify one of your modules not all of the objects that use this module are being rebuilt. To fix, either rebuilt from scratch or use dependancies in your makefile (I'm assuming your using make), which will force the rebuild of the dependent objects.

Code:
file1.o:  mod_file1.o $(SRC)/file2.f90
     $(FC) $(FFLAGS) -o file1.o $(SRC)/file1.f90

file2.o:  mod_file1.o $(SRC)/file2.f90
     $(FC) $(FFLAGS) -o file2.o $(SRC)/file2.f90

mod_file1.o:  $(SRC)/mod_file1.f90
     $(FC) $(FFLAGS) -o mod_file1.o $(SRC)/mod_file1.f90


In this example, if mod_file1 gets re-built, so will file1 and file2. Also, consider setting "SRC" to directory which contains the actual files and remove the links. This way you'll be able to rely on the source file's timestamp and don't need to worry about which objects need to be removed when you make a change.

Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group