User forums > Using Code::Blocks

To use Clang-cl.exe with Codeblocks on Windows 10 needs a new compiler type

(1/2) > >>

pabristow:
I have been trying to use CodeBlocks on Windows 10 to using the latest Clang compiler (8.0) to build Boost libraries especially Boost.Math and Boost.Multiprecision, but conclude after some confusing work that Windows really needs a new compiler type using clang-cl.exe and not clang.exe.  This is because Clang-cl.exe is a variant specifically adapted to work with Windows (and Visual studio) and it responds, confusingly, to (some) MS style configuration command like /EHsc (and not -fexceptions) and /std:c++17 (and not -std=c++17).

https://clang.llvm.org/docs/MSVCCompatibility.html

In turn, this also has implications for Boost's complex multi-platform configuration system.

This means some changes are needed to

 C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\common_functions.script

and

C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\compilers\options_clang.xml

that at a glance I conclude are not in my skill-set ;)

I hope someone will be able to tackle this for the next release because it allows side-by-side IDE development of code for GCC and Clang, something that Visual Studio still does not permit.

BlueHazzard:
Can you show a command line, how a typical c-lang compilation for windows would look like? i can not find anything in the link you provided...

oBFusCATed:
pabristow:
Are you using the llvm compiler to run clang-cl?
Have you tried to run the Visual studio compiler instead?
clang-cl is meant to be a drop in replacement for cl.exe, so it should work just fine when using with the Visual studio compiler in Code::Blocks.

pabristow:
I have finally returned to this problem after being distracted on other maintenance and release issues.

I have used clang-cl.exe with some success, but for reasons too complex to discuss here, I would like to use the pure Clang compiler with the latest lld linker in order to confirm that this works using Windows as the base for Codeblocks.

This works for me, until I include the need for exceptions handling by including try'n'catch blocks, but I find, after a distressing amount of debugging, that exceptions are not being handled correctly (and as a result the .o link fed to the linker silently does not produce any .exe file).

A warning that there is trouble ahead was that

after CodeBlocks creating a project and choosing Clang 9.0.0 as compiler it says

 "This wizard doesn't know how to set up exception handling for this compiler".

I think this means I have messed up the global compiler configuration :-(

Sadly (and most regrettably IMO because everyone should be using the latest versions with the least number of bugs), the standard release does not include even moderately new Clang compilers (but a lot that I will never use).

Meanwhile can anyone suggest how to get back to the default Clang provided.

and how to reconfigure for new versions.  I would appear that one just needs to copy and then change the toolset executables to match.  Is this correct?

Do I need to remove and reinstall CodeBlocks?  Or can I refressh just key files?

Thanks

Paul







oBFusCATed:

--- Quote from: pabristow on October 18, 2019, 06:15:12 pm ---after CodeBlocks creating a project and choosing Clang 9.0.0 as compiler it says

 "This wizard doesn't know how to set up exception handling for this compiler".

--- End quote ---
Are you sure this is the exact spelling of the message? I don't see such thing in our whole codebase. :shrug:


--- Quote from: pabristow on October 18, 2019, 06:15:12 pm ---Sadly (and most regrettably IMO because everyone should be using the latest versions with the least number of bugs), the standard release does not include even moderately new Clang compilers (but a lot that I will never use).

--- End quote ---
What do you mean by this? CB doesn't ship clang on windows. We ship mingw to make it easier for some users, but we cannot ship all compilers we support. It is not our goal.



--- Quote from: pabristow on October 18, 2019, 06:15:12 pm ---Meanwhile can anyone suggest how to get back to the default Clang provided.

and how to reconfigure for new versions.  I would appear that one just needs to copy and then change the toolset executables to match.  Is this correct?

--- End quote ---

Yes this is how it works. Changing the base path should get you a working compiler. But I've not tested if the clang xml files are working correctly with the latest clang releases on windows.


--- Quote from: pabristow on October 18, 2019, 06:15:12 pm ---Do I need to remove and reinstall CodeBlocks?  Or can I refressh just key files?

--- End quote ---
No you don't have to... The changes done in the ui are saved in your user folder. If you want to reset your setting you can just delete them (somewhere in AppData/...../CodeBlocks)

Have you tried to compile simple program with exceptions on the command line? Does it work? Do you pass -fexceptions (or whatever the correct spelling for this is, check the clang manual)?

Navigation

[0] Message Index

[#] Next page

Go to full version