Overview
Unfficial guide about how-to build lastest version of clang compiler and how to integrate it to CVI IDE.
This is targeted to people who need that nice new warning messages that native CVI compiler does not have yet.
Please feel free to edit this guide, but please do not remove Warnings ahead section.
Warnings ahead:
CVI can use clang as external compiler for release builds, but CVI allways use its own linker, this can lead to potential incompatibility!
I do not reccomend to use clang + CVI for production-distribution, at least without detailed testing!
Last warning:!Using different and/or non official compiler can bring serious problems. Some of them appear quickly, some can be very well hidden for very long time. Please be careful!
Note about compiler warnings and optimization:
Using different optimization settings/level will show or hide some bugs or warnings, this is by desing of compiler.
(especially in the case of using Undefined or Unspecified behaviour - by ansi-c specification)
Use it to your advantage.Try to compile your project with and without maximum optimization, even if you do not use it for production-distribution.
Using precompiled clang binaries
It is posible to use prebuild binaries. I test it a little and it seems that project can be compiled and executed.
I do not have deep knowledge about this, but it seems to me that there are potential problem because the prebuiltclang compiler has its target preset to _M_IX86=500 and CVI compiler template force the compiler to _M_IX86=400. I gues that CVI linker (which is used anyway) need this.
Also prebuilt clang will throw 3 line of warnings about _M_IX86 redefinition to every compiled file.
However, this can be suppresed by commandline parameters.
I do not like to have that warning suppresion on global level, so, togheter with "_M_IX86=500" potential problem, i still reccomend to modify the source code and build customized version of clang.
If you are still interested, there it is the "easy" way:
-Wno-macro-redefined
Build clang from source code (SVN repositories) and make it compatible with CVI
Integration of clang to CVI IDE
This is hidden in CVI Ide ->menu options->tab Build process options\Active 32bit compiler
clang2.9 template work well, just change path to your clang.exe file.
In the meantime, GCC documentation is good enought: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
#if __clang_major__ == 2 && __clang_minor__ == 9
#include <clang/2.9/stdint.h>
#else // clang 1.0 does not define version numbers
#include <clang/stdint.h>
#endif
#if __clang_major__ == 3 && __clang_minor__ == 7
//This #pragma is for suppres warnings about macro redefinition.
//This can also be achieved by add #undef ... before macro redefinition in clang/3.7/stdint.h
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbuiltin-macro-redefined"
#pragma clang diagnostic ignored "-Wmacro-redefined"
#include <clang/3.7/stdint.h>
#pragma clang diagnostic pop
#elif __clang_major__ == 2 && __clang_minor__ == 9
#include <clang/2.9/stdint.h>
#else // clang 1.0 does not define version numbers
#include <clang/stdint.h>
#endif
Requirements
Software
Microsoft Visual Studio Express 2013
Subversion or TortoiseSVN
Python for windows
Cmake
Thank you very much, particularly for your step 6!
Personally I probably will skip your steps 1 - 4 using prebuilt windows binaries that are available at the LLVM Download Page
I try prebuilt binaries before, but there are some problems with them.
So i move to source code and my customized clang build.
However, it is lot faster to make it work. So i add that way to guide too. Together with some reason why i avoid that.