Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: puneet_m on October 25, 2007, 01:16:51 am

Title: Adding Multiple Compilers
Post by: puneet_m on October 25, 2007, 01:16:51 am
I want to add a separate compiler for each of the target in a given project. But currently, addition of multiple compilers is not supported. Can anyone highlight as to how to fix this?

Thanks,
Title: Re: Adding Multiple Compilers
Post by: Biplab on October 25, 2007, 05:37:14 am
This is possible. Just take a look at wxWidgets Target wizard, where you can add a new target to an existing project with a different compiler. At the moment it won't work as some compiler options are added at project level which spoils this wizard. :)
Title: Re: Adding Multiple Compilers
Post by: thomas on October 25, 2007, 08:41:02 am
There are only few examples where it really makes sense to do that (for example if a project contains sources in different languages, which are to be linked into one program). However, whether it makes sense or not, it is certainly supported.
Title: Re: Adding Multiple Compilers
Post by: puneet_m on October 25, 2007, 05:55:30 pm
Where is the code for wxWidget target wizard??
Title: Re: Adding Multiple Compilers
Post by: Biplab on October 25, 2007, 06:48:09 pm
Where is the code for wxWidget target wizard??

<C::B-dir>\share\CodeBlocks\templates\wizard\wxwidgets\wizard.script
Title: Re: Adding Multiple Compilers
Post by: puneet_m on October 26, 2007, 08:18:40 pm
Can we add multiple compilers to the same target?

Thanks,
Title: Re: Adding Multiple Compilers
Post by: Biplab on October 26, 2007, 08:23:54 pm
Can we add multiple compilers to the same target?

Exactly what do you want to do?
Title: Re: Adding Multiple Compilers
Post by: puneet_m on October 26, 2007, 08:36:03 pm
I want to add multiple compilers to same target, check the example below:

<Target title="Debug">
<Option output="bin\Debug\fd.exe" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />

<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>

<Option compiler="bcc" />
<Compiler>
<Add option="-b" />
</Compiler>

</Target>
Title: Re: Adding Multiple Compilers
Post by: Biplab on October 26, 2007, 08:42:17 pm
I want to add multiple compilers to same target, check the example below:

AFAIK, it isn't allowed.
Title: Re: Adding Multiple Compilers
Post by: thomas on October 27, 2007, 02:32:38 pm
This is not possible (and will not be), as it does not make sense. The build system needs to have unambiguous information about what compiler to use.
Title: Re: Adding Multiple Compilers
Post by: hd on October 27, 2007, 10:37:38 pm
Hi,

I want to add multiple compilers to same target, check the example below:

Not multiple compiler for the same target, but you may add multiple target using different compiler for each. (Maybe you already know this but..)

--
Regards,
Hakki Dogusan
Title: Re: Adding Multiple Compilers
Post by: thomas on October 28, 2007, 12:28:51 am
Not multiple compiler for the same target, but you may add multiple target using different compiler for each. (Maybe you already know this but..)
Yes, this works, and this makes perfect sense.
Title: Re: Adding Multiple Compilers
Post by: huhlig on April 25, 2008, 09:23:20 am
Would it be possible to use multiple compilers in the same target for different file extensions or individual files. I am working on a mixture of C and D and need multiple compilers to accomplish this. The option seems to be available on the Files advanced tab but it never seems to 'stick'.
Title: Re: Adding Multiple Compilers
Post by: thomas on April 25, 2008, 09:39:50 am
No, although it accidentially works nevertheless if you use gcc (since gcc is not a compiler, but really a front-end to half a dozen compilers). One target, one compiler, it doesn't work differently.
What you can do is, use the C compiler in one target to compile, but not link. Then add the object files to the next target which uses the D compiler (or the other way around). Or, make a static library, which only requires you to link one file afterwards (instead of a dozen object files).
Title: Re: Adding Multiple Compilers
Post by: huhlig on April 25, 2008, 05:23:43 pm
Any particular reason for this lack of functionality? I am curious, the only reason I can find seems to be "it doesn't make sense" which multiple people have refuted.
Title: Re: Adding Multiple Compilers
Post by: Biplab on April 25, 2008, 05:46:51 pm
Any particular reason for this lack of functionality? I am curious, the only reason I can find seems to be "it doesn't make sense" which multiple people have refuted.

To give you a reason, you may know that not all the compilers accept same command line switches while compiling. Just compare GCC and MSVC and you'll see the difference. They even behave differently. So for a simple project adding multiple compilers to a target may work. But for a complex project, it may not. Yes it's possible if we record full command line for that particular file; but this doesn't ensures that it'll work across all the pcs.
Title: Re: Adding Multiple Compilers
Post by: huhlig on April 25, 2008, 06:03:17 pm
Thats fair, would it be possible to assign different compilers(and associated options to different "Source" groups) As I mentioned in the other thread I am working with D, so I either use gcc/gdc or dmc/dmd. Both of which are supported out of box by code::blocks and are abi complaint. Would it be possible to simply assign a "compiler" to a source group, so all files of that extension set are compiled by that compiler? Settings would be per compiler not per file anyhow.
Title: Re: Adding Multiple Compilers
Post by: stahta01 on April 26, 2008, 06:07:45 am
Any particular reason for this lack of functionality? I am curious, the only reason I can find seems to be "it doesn't make sense" which multiple people have refuted.

The code to support the feature is not in the trunk where I can find it.
Note they were working on a new compiler framework that might make it possible to add. But, I don't know the status of it. It could have been merged into trunk, still being work on, or dropped.

Tim S
Title: Re: Adding Multiple Compilers
Post by: thomas on April 28, 2008, 09:57:28 am
Defining a build target as one thing with one compiler keeps things simple, unambiguous, and manageable. Defining them differently can be asking for trouble.
A compiler in a build target in Code::Blocks is not just the compiler, but at least the combined functionality precompiler, compiler, linker, and debugger (if these are available). Alternatively, there are compilers available which are really assemblers or something completely different.
If we support two compilers, we might end up precompiling some files, compiling them, having to figure out how to link them together, and then ending up with something that maybe doesn't work properly with the debugger. This can still happen if you use different compilers in different build targets, but it will happen less often, and it is more explicit and thus easier to fix. Most people will build one library or one program per build target and will be just happy with that, it will never fail. In those cases where people do something else, it will be obvious what's up when it fails.
Besides, if we allowed 2 compilers, we would really have to allow n compilers (because if x are allowed, people will ask for x+1 anway). If we allow n compilers, we have to solve the linker problem for n(n-1) combinations by hand, unless someone comes up with an AI solution which just magically knows the compilers, linkers, and debuggers that are compatible with each other.