Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Wrong dependency rule in generated subdir.mk
Wrong dependency rule in generated subdir.mk [message #1404667] Mon, 04 August 2014 19:54 Go to next message
Laszlo Uveges is currently offline Laszlo UvegesFriend
Messages: 3
Registered: August 2014
Junior Member
Eclipse generates subdir.mk files in each build subdirectory of the project. This makefile (subdir.mk) contains a rule for compiling and generating dependencies of each object file. The generated dependency file (e.g. main.d) contains all prerequisites but for the wrong target. The correct target should be the corresponding object file (e.g. src/main.o) and not the dependency file (e.g. src/main.d). Therefore the dependency of (changed) header files will never be recognized.

Steps to reproduce:

1. You have a header file e.g. test.h that is included in main.c and consists only of the declaration of an integer with the value of 0.
2. You build the project from Eclipse. Everything is okay, makefiles are generated, project built.
3. Lets modify the value of that integer in test.h to 1.
4. Of course you could rebuild the project form Eclipse, but try running "make all" manually from the command line this time.

It will state that there is nothing to be done for 'all', altough there is.

The problem is in the subdir.mk file generated by eclipse:

Currently there is:  -MT"$(@:%.o=%.d)" 
But it should be:    -MT"$(@:%.o=%.o)"


To try it manually, lets continue after step 4.

5. Change the .d extension to .o in the main.d file and also in subdir.mk at the -MT option as mentioned above.
6. Manually run "make all" again.

This time the project will rebuild.

The problem is in
org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2Commands#getDependencyCommandOptions()


that is located in

org.eclipse.cdt.managedbuilder.core_[VERSION_NUMBER].jar


and instantiated by

org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2


I have checked version 8.4. for Luna and 8.1.2. for Juno and there are no apparent changes.

Another problem is that these options are hard coded in there - even tho the javadoc states that these classes are not meant to be subclassed.

Now of course it is not a problem if you always build the project from Eclipse - as inteded - but it could lead to wrong code in some use cases.

Is it a possible bug? Could someone point out how to generate the correct makefiles?
Re: Wrong dependency rule in generated subdir.mk [message #1481782 is a reply to message #1404667] Fri, 21 November 2014 08:10 Go to previous messageGo to next message
Andrey Sotnikov is currently offline Andrey SotnikovFriend
Messages: 23
Registered: October 2014
Junior Member
I noticed this problem as well. What is interesting, if you check the source code of DefaultGCCDependencyCalculator2Commands here: https://github.com/eclipse/cdt/blob/master/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java, the line that generates the problematic -MT is there since 2006, the last change of this file was made in 2011.

[Updated on: Fri, 21 November 2014 08:13]

Report message to a moderator

Re: Wrong dependency rule in generated subdir.mk [message #1481790 is a reply to message #1481782] Fri, 21 November 2014 08:19 Go to previous message
Andrey Sotnikov is currently offline Andrey SotnikovFriend
Messages: 23
Registered: October 2014
Junior Member
I found a solution: http://stackoverflow.com/questions/9884827/eclipse-cdt-not-building-project-on-header-file-change
Previous Topic:"Launch failed. Binary not found."
Next Topic:Can't build release because of makefile
Goto Forum:
  


Current Time: Thu Apr 25 00:42:41 GMT 2024

Powered by FUDForum. Page generated in 0.02697 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top