Author Topic: Compiler framework redesign (?)  (Read 48009 times)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Compiler framework redesign (?)
« Reply #15 on: January 02, 2006, 05:44:12 pm »
Well, the problem is that different compilers do not use the same switches. They do not even use the same filenames or compatible library images...

There is no way you can convert a MSVC project to gcc with one click...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Compiler framework redesign (?)
« Reply #16 on: January 02, 2006, 05:46:42 pm »
one compiler per project is pretty sufficient, one always can group several projects in a workspace - this is what i do for several used compiler sets. and with inter-project-dendencies properly set you can automate the build process over projects perfectly.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Compiler framework redesign (?)
« Reply #17 on: January 02, 2006, 05:53:37 pm »
Well, the problem is that different compilers do not use the same switches. They do not even use the same filenames or compatible library images...

There is no way you can convert a MSVC project to gcc with one click...

well thats obviously true !

but think of the Project's Build-options-dialog, where you can change the "selected compiler"
when one wants to change the compiler setting here, it could be possible to automate
to transfer the needed settings for the new selected compiler - at least for the basic
common options as declared above.

as it is now, all present settings are only preserved - this makes the least sense.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Compiler framework redesign (?)
« Reply #18 on: January 02, 2006, 05:54:49 pm »
Well, the problem is that different compilers do not use the same switches. They do not even use the same filenames or compatible library images...

There is no way you can convert a MSVC project to gcc with one click...

No, but my intention was to be able to save one same project with switches for different compilers.

i.e. storing the MSVC and GCC configs in one same cbp.

Yiannis, please explain to me because it seems i kinda missed the boat with the latest "target" changes on the build process.

For a project like Code::Blocks, which has a lot of targets, how could this (having switches for diff compilers on one same cbp) be done?

Edit: Thanks, tiwag. But look at the current "project build options" dialog. Wouldn't it be good that if you switched the compiler (i.e. from MSVC to GCC), a new set of default options would appear, and if you switched back, the first options were just like you left them before changing the compiler dropdown? Currently, whenever we switch the compiler for a project or target, the target's build options are updated. Wouldn't it be good to store the options for all the compilers used? i.e. a target having a set of options for GCC and for MSVC, and when compiling, only the options for the respective compiler were used... this (unlike being forced to use different projects/workspaces) seems very intuitive to me.

Yiannis, your stance on this?

Edit again: Thanks again, tiwag, we seem to think very alike! :lol:

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Compiler framework redesign (?)
« Reply #19 on: January 02, 2006, 05:56:16 pm »
Let me state my thoughts about this infamous redesign.
It seems people misunderstand it.

The current compiler infrastructure has served us well, more than well I 'd say. As the project moved forward, some weaknesses have been identified and so a buzz started about redesigning it.
But does this mean to rewrite everything compiler-related from the ground up? No, I don't think so. The current plugin is in a quite good state and, by using a state-machine as of late, is quite extendable too.

I must admit, I have misunderstood it :). I thought the idea was to redesign the compiler infrastructure from scratch.

What needs to change, is the sdk/compiler*.* files. This is the compiler framework I 'm referring to.
If we change the Compiler class to read/write XML configuration files, we will already have made the first step to easy customization and get rid of plugins/compilergcc/compiler*.* files (compilers implementations). This means that to add a new compiler in C::B, all one has to do is write one new XML file. We have to decide the format of this file, that is the crucial part.

The use of XML is a very good idea. IMHO, it would also be important the definition of an XML schema file which defines the syntax of the XML file.

We can (and should) use existing libraries to help us. For example, not many remember that we have a scripting language in C::B (AngelScript). We could use it for compiler options, for example. I mean, attach a script (as a tag in the XML file) to "Optimization" options to disable debugging when activated. Easy, simple, effective and already there.

The use of a script language within the XML file it is also interesting and IMHO a good way to go. It makes me remember of MPEG-21 DIP (even if they use javascript) :).

I 'm not going into more details here, as my intention was to clear things up a bit.
I hope it's more clear now what I mean when I talk about "compiler framework redesign".

Yiannis.

Yes, now all is more clear. Thank you for your explanations.

Michael

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Compiler framework redesign (?)
« Reply #20 on: January 02, 2006, 05:57:02 pm »
... Wouldn't it be good that if you switched the compiler (i.e. from MSVC to GCC), a new set of default options would appear, and if you switched back, the first options were just like you left them before changing the compiler dropdown?
totally agree

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Compiler framework redesign (?)
« Reply #21 on: January 02, 2006, 06:10:38 pm »
So you want some more details, huh? ;)
Here's some food for thought:

  • One XML file per compiler.
  • Contains the toolchain (programs) that make up this compiler and connects the separate tools together (we could probably use some scripting here to avoid hard-coding logic in C::B).
  • Contains some high-level mandatory options. Something like "debug", "optimize", "target cpu", etc. These high-level options will be defined by C::B and all compilers must implement them (even if they 're just dummy :P). This should take care of the "switching-compilers-back-and-forth" issue ;)

Another, short-term goal (i.e. before next release), is to add cross-platform support in the project file. This way you could define different sets of options based on the platform. This is a relatively easy change. The way I 've thought about it, is to add an extra attribute to <Project>, <Target>, <Compiler> and <Linker> tags defining the target platform. If not there, defaults to "any" (much like it works now, platform-agnostic and backwards-compatible). So, one would create a windows-target and a linux-target and the correct one would be chosen automatically by C::B based on the platform it runs in.
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Compiler framework redesign (?)
« Reply #22 on: January 02, 2006, 06:17:45 pm »
Cool!!! :)

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Compiler framework redesign (?)
« Reply #23 on: January 02, 2006, 06:22:30 pm »
... add cross-platform support in the project file. This way you could define different sets of options based on the platform. This is a relatively easy change. The way I 've thought about it, is to add an extra attribute to <Project>, <Target>, <Compiler> and <Linker> tags defining the target platform. If not there, defaults to "any" (much like it works now, platform-agnostic and backwards-compatible). So, one would create a windows-target and a linux-target and the correct one would be chosen automatically by C::B based on the platform it runs in.
great ! very important i think !

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Compiler framework redesign (?)
« Reply #24 on: January 07, 2006, 09:23:08 pm »
I just remembered what else I was thinking for the compiler plugin and luckily I had my browser open (I'd forget it otherwise...). The precompiled headers support should be available for all compilers that support it (and probably have an option that will disable the whole process if not). This should also be customizable per compiler (I know that linux icc has about the same syntax as gcc when it comes to precompiled headers), like the rest of the commands to the compiler are.
Life would be so much easier if we could just look at the source code.

PChris

  • Guest
Re: Compiler framework redesign (?)
« Reply #25 on: May 07, 2006, 09:46:25 am »
I just want to add my thoughts to the new Compiler Framework.
I think we could go with a structure like this:
In a separate directory we could put the XML files for the toolset (MinGW, Intel, Microsoft, ...):
Code: XML
  1. <toolset>
  2.   <code>MinGW</code>
  3.   <compiler>
  4.     <code>gcc</code>
  5.     <version>4.1.0</version>
  6.     ...
  7.   </compiler>
  8.   <rescomp>
  9.     <code>windres</code>
  10.     <version>...</version>
  11.   </rescomp>
  12.   ... other tools in the toolset ...
  13. </toolset>

And in a subdirectory named after the toolset (minGW) we could put XML descriptors for each tool. For the version control there are two things I thought of: Declare a base version, and add tags for the upcoming versions with nodes like <addfeature> or <removefeature>, or to create separate files for each major compiler version (gcc410.xml, gcc403.xml...)
Code: XML
  1. minGW/gcc.xml
  2.  
  3. <compiler>
  4.   <code>gcc</code>
  5.   <base>
  6.     <version>4.0.3</version>
  7.     <optiongroup>
  8.       <groupname>Optimization</groupname>
  9.       <option id="1">
  10.         <name>Optimize fully</name>
  11.         <value>-O3</value>
  12.       </option>
  13.       ...
  14.     </optiongroup>
  15.   </base>
  16.   <versionchanges>
  17.     <versionchange id="4.1.0">
  18.       <addoption id="54">
  19.         <name>Some new feature</name>
  20.         <value>-XxX</value>
  21.       </addoption>
  22.       <removeoption>
  23.         <id>1</id>
  24.       </removeoption>
  25.     </versionchange>
  26.     ...
  27.   </versionchanges>
  28. </compiler>
  29.  

OR

Code: XML
  1. minGW/gcc410.xml
  2.  
  3. <compiler>
  4.   <code>gcc</code>
  5.   <version>4.1.0</version>
  6.   <optiongroup>
  7.     <groupname>Optimization</groupname>
  8.     <option id="1">
  9.       <name>Optimize fully</name>
  10.       <value>-O3</value>
  11.     </option>
  12.     ...
  13.   </optiongroup>
  14.   ...
  15. </compiler>
  16.  

Is this a way to go? Please tell me, so I can think further  :D

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Compiler framework redesign (?)
« Reply #26 on: May 07, 2006, 02:45:15 pm »
We use something like depicted in your first code sample, except that we use named stages rather than dedicated tags for compiler and rescomp. There are separate configuration files for different versions of the same compiler.

We implement options slightly different too, insofar as we have behaviours and properties. The former are general, the latter compiler-specific.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

PChris

  • Guest
Re: Compiler framework redesign (?)
« Reply #27 on: May 07, 2006, 03:52:51 pm »
That's great news!  :D
How exactly is the version separation solved? I'd like to know more about the upcoming solution ;)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Compiler framework redesign (?)
« Reply #28 on: May 07, 2006, 03:59:17 pm »
That's done using a challenge-response system.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Yury Benesh (aka ybx)

  • Multiple posting newcomer
  • *
  • Posts: 16
    • http://ybx.narod.ru
Re: Compiler framework redesign (?)
« Reply #29 on: August 15, 2006, 10:33:27 am »
Clean command should also get additional temporary/itermediary files info, e.g. the OpenWatcom compiler produces *.err files if there are errors and/or warnings during the compilation.