Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to prevent cross-gcc from adding dependency flags ? (Eclipse adds compiler flags not supported by my cross-gcc toolchain)
How to prevent cross-gcc from adding dependency flags ? [message #1735320] Fri, 17 June 2016 11:11 Go to next message
Timothee Fivaz is currently offline Timothee FivazFriend
Messages: 5
Registered: June 2016
Junior Member
Hello,

I am trying to configure the build settings of a cross-gcc compiler for a project and I'm a bit surprised to see some dependency flags that I didn't manually specify in the compile command.

After setting all the options I want, here is what my "All options" field (Project properties, C/C++ Build, Settings, Cross GCC compiler, Tool Settings) looks like :
-I"C:\workspace\project\src" -O1 --gdwarf2 -Wall


And when I build the project here is the command called by eclipse :
xxx-gcc -I"C:\workspace\project\src" -O1 --gdwarf2 -Wall -MMD -MP -MF"src/srcFile.d" -MT"src/srcFile.o" -o "src/srcFile.o" "../src/srcFile.c"


(Note : xxx represents my toolchain prefix)

My problem is that the toolchain I use doesn't implement the -MP, -MT and -MF flags, and gcc returns an error "fatal error: too many input files". It's a custom toolchain for a custom architecture and the toolchain is maintained by another company.

Is there a way to prevent the build manager to add these flags and to replace them by the dependency flag(s) that suit me ?

The only working solution I've come with is to use an external Makefile where I define the whole command with only the -MMD flag for dependencies, but I guess there is a way to do that directly into eclipse.

I am running eclipse Mars 4.5.2 and CDT 8.8.1.

[Updated on: Fri, 17 June 2016 11:15]

Report message to a moderator

Re: How to prevent cross-gcc from adding dependency flags ? [message #1735346 is a reply to message #1735320] Fri, 17 June 2016 13:27 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
The answer to this depends on whether you are a CDT End User or a CDT Extender (making a product based on CDT):

CDT End User

Short answer is there is no way to change that behaviour for an end user AFAIK. Your best bet is to define your own Makefile, extend the version of GCC you have received, or even make a simple wrapper script so that your custom GCC behaves a little more like GCC as CDT expects it to be.

CDT Extender

If you are an Eclipse extender, you can defined you own tool which has its own set of options and dependency management.

Here is a walkthrough of the existing code of relevance to you:

The existing code is in DefaultGCCDependencyCalculator2Commands, you will see that there are no options for configuring it in this code: https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java#n168

DefaultGCCDependencyCalculator2Commands is instantiated by DefaultGCCDependencyCalculator2: https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2.java#n63

which in turn is instantiated as the tool definition in the plugin.xml for GNU: https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml#n1330

So to declare to Eclipse CDT a tool that looks a little like GCC, but isn't quite GCC as CDT knows it, you need to define your own tool (probably extending the existing gcc one) using the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point: http://help.eclipse.org/mars/topic/org.eclipse.cdt.doc.isv/reference/extension-points/org_eclipse_cdt_managedbuilder_core_buildDefinitions.html?cp=14_1_1_20

HTH
Jonah
Re: How to prevent cross-gcc from adding dependency flags ? [message #1735353 is a reply to message #1735346] Fri, 17 June 2016 14:27 Go to previous messageGo to next message
Timothee Fivaz is currently offline Timothee FivazFriend
Messages: 5
Registered: June 2016
Junior Member
Thank you for your answer. I am a long time end user, I regret I don't have either the time or the Java skills to contribute... For the moment at least.

The Makefile solution works well but the source management is really poor and maintaining this Makefile for my coworkers will probably be time consuming.

Actually I have found that if I use the internal builder instead of the external one these specifics flags disappear since the dependencies are managed internally. I have to explore this way a bit more but it looks promising.

Concerning gcc and the lack of these options in the version I use I think it's due to the fact that it's a very old version, probably almost 10-15 years old. I have no control over this but I still hope we'll update it sometime in the future...
Re: How to prevent cross-gcc from adding dependency flags ? [message #1735354 is a reply to message #1735353] Fri, 17 June 2016 15:09 Go to previous message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Glad I can help. The internal builder is a good idea and I am glad you brought it up here.

Good luck with your continued use of CDT and come back to the site with more questions and hopefully someone will be able to answer them.
Previous Topic:custom builder for compiling Qt project
Next Topic:STK (Syntesis Toolkit) Library & Unresolved inclusion
Goto Forum:
  


Current Time: Fri Apr 19 18:17:03 GMT 2024

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

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

Back to the top