Author Topic: Adding Multiple Compilers  (Read 17131 times)

Offline puneet_m

  • Multiple posting newcomer
  • *
  • Posts: 73
Adding Multiple Compilers
« 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,

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Adding Multiple Compilers
« Reply #1 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. :)
Be a part of the solution, not a part of the problem.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Adding Multiple Compilers
« Reply #2 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline puneet_m

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: Adding Multiple Compilers
« Reply #3 on: October 25, 2007, 05:55:30 pm »
Where is the code for wxWidget target wizard??

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Adding Multiple Compilers
« Reply #4 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
Be a part of the solution, not a part of the problem.

Offline puneet_m

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: Adding Multiple Compilers
« Reply #5 on: October 26, 2007, 08:18:40 pm »
Can we add multiple compilers to the same target?

Thanks,

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Adding Multiple Compilers
« Reply #6 on: October 26, 2007, 08:23:54 pm »
Can we add multiple compilers to the same target?

Exactly what do you want to do?
Be a part of the solution, not a part of the problem.

Offline puneet_m

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: Adding Multiple Compilers
« Reply #7 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>

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Adding Multiple Compilers
« Reply #8 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.
Be a part of the solution, not a part of the problem.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Adding Multiple Compilers
« Reply #9 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.
« Last Edit: October 27, 2007, 02:34:12 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline hd

  • Multiple posting newcomer
  • *
  • Posts: 45
    • http://www.dynaset.org/dogusanh
Re: Adding Multiple Compilers
« Reply #10 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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Adding Multiple Compilers
« Reply #11 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline huhlig

  • Single posting newcomer
  • *
  • Posts: 4
Re: Adding Multiple Compilers
« Reply #12 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'.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Adding Multiple Compilers
« Reply #13 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).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline huhlig

  • Single posting newcomer
  • *
  • Posts: 4
Re: Adding Multiple Compilers
« Reply #14 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.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Adding Multiple Compilers
« Reply #15 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.
Be a part of the solution, not a part of the problem.

Offline huhlig

  • Single posting newcomer
  • *
  • Posts: 4
Re: Adding Multiple Compilers
« Reply #16 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: Adding Multiple Compilers
« Reply #17 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
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Adding Multiple Compilers
« Reply #18 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."