Official support for precompiled headers
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Official support for precompiled headers
Hi Eran,
the only thing I miss in CL and which would make me definitely happy with this GREAT IDE is 'official' support for precompiled headers. I know that they can be created via 'Custom makefile steps' dialog, but it would be nice to have some more user-friendly way how to do it. Moreover, I'm afraid that current approach have at least one serious drawback: if concurrent build is used (for example 8 files at the same time on my 8-core workstation ) then the first parallel build stage can produce compiler's warnings/errors because the PCH file is not fully completed yet. In my opinion the PCH file should be created separately before some 'barrier' and processing of the rest project files should be started after that. What do you think about it?
Regards
Michal
the only thing I miss in CL and which would make me definitely happy with this GREAT IDE is 'official' support for precompiled headers. I know that they can be created via 'Custom makefile steps' dialog, but it would be nice to have some more user-friendly way how to do it. Moreover, I'm afraid that current approach have at least one serious drawback: if concurrent build is used (for example 8 files at the same time on my 8-core workstation ) then the first parallel build stage can produce compiler's warnings/errors because the PCH file is not fully completed yet. In my opinion the PCH file should be created separately before some 'barrier' and processing of the rest project files should be started after that. What do you think about it?
Regards
Michal
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
Not really. The current build system is using the 'QueueCommand' class. We can create new command 'PreCompiledHeaderCommand' and push it *brefore* the 'Build' command so it will be processed before. We can also set the m_checkBuildSuccess for the build request to true so it wont be processed if the PHC compilation fails.marfi wrote:I'm afraid that current approach have at least one serious drawback:
Currently, the utilization of the #processors is done by the make file -j option, but from codelite point of view, its a single command - so I dont see any drawback here
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Re: Official support for precompiled headers
Just little clarification: the compiler warning mentioned above (something like "xyz.gch file is too short to be precompiled header") disappeared after project cleanup so now works even rebuild flawlessly. Only tiny 'problem' that remains is that 'Clean' command doesn't remove *.gch file which situation has pros as well as cons: advantage is that after rebuild command I haven't to wait for new PCH file creation, but if the precompiled code changes then I must remove this file manually.
Regards
Michal
Regards
Michal
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Re: Official support for precompiled headers
Hi Eran,
are you sure that 'custom makefile steps' are really performed before compilation of all other project files? See the output of compiler bellow:
This output is shown during first project build when the PCH file doesn't exist yet. Although the PCH file is really processed as the first file, the other files cannot use it, because it isn't probably fully created yet. All next project builds/rebuilds work fine if the PCH file already exists.
Best regards
Michal
are you sure that 'custom makefile steps' are really performed before compilation of all other project files? See the output of compiler bellow:
Code: Select all
----------Build Started--------
"make" -j 2 -f "Src_wsp.mk"
----------Building project:[ GizmoTest1 - Release ]----------
g++ wx_pch.h -O2 -Winvalid-pch -include wx_pch.h -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -D__WX__ -DWX_PRECOMP "-I."
g++ -c "/home/michal/Src/GizmoTest1/gizmotest1_app.cpp" -O2 -Winvalid-pch -include wx_pch.h -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -D__WX__ -DWX_PRECOMP -o ./Release/gizmotest1_app.o "-I."
cc1plus: warning: ./wx_pch.h.gch: not a PCH file
g++ -c "/home/michal/Src/GizmoTest1/gui.cpp" -O2 -Winvalid-pch -include wx_pch.h -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -D__WX__ -DWX_PRECOMP -o ./Release/gui.o "-I."
cc1plus: warning: ./wx_pch.h.gch: not a PCH file
g++ -o ./Release/GizmoTest1 ./Release/gizmotest1_app.o ./Release/gui.o "-L." -s -pthread -Wl,-Bsymbolic-functions -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8
----------Build Ended----------
0 errors, 0 warnings
Best regards
Michal
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
The custom makefile steps are part of a project, and not the workspace. So if a project has a 'custom makefile steps' they will be executed before that project compilation and the workspace.marfi wrote:are you sure that 'custom makefile steps' are really performed before compilation of all other project files?
I will be starting working on the PCH thing any time now.
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Re: Official support for precompiled headers
I know, I used wrong words I meant 'files included in a project'.The custom makefile steps are part of a project, and not the workspace.
Nice to hear about it! I'm looking forward.I will be starting working on the PCH thing any time now.
Best regards
Michal
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
How did you set your 'custom makefile steps' to include PCH file?
Eran
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Re: Official support for precompiled headers
It is not set in 'custom makefile steps' but in compiler options. Just use this flags:
where "wx_pch.h" is header file neme used in 'custom makefile steps'. If you want to use precompiled headers with wxWidgets then you have to also set WX_PRECOMP symbol in preprocessor definitions. My PCH file looks like this:
Regards
Michal
Code: Select all
-Winvalid-pch;-include wx_pch.h;
Code: Select all
#ifndef WX_PCH_H_INCLUDED
#define WX_PCH_H_INCLUDED
#ifdef _DISWARNINGS_MSVC
#pragma warning( disable : 4100 )
#pragma warning( disable : 4251 )
#pragma warning( disable : 4275 )
#endif
// basic wxWidgets headers
#include <wx/wxprec.h>
// debug memory allocation enhancement (MS VC only)
#ifdef _DEBUG_MSVC
#ifdef _DEBUG
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
#else
#define DEBUG_NEW new
#endif
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#ifdef WX_PRECOMP
// put here all your rarely-changing header files
#endif // WX_PRECOMP
#endif // WX_PCH_H_INCLUDED
Michal
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Official support for precompiled headers
I understand that, but you need to have wx_prec.h.gch to actually have it, no?
The wx_prec.h must be compiled to create wx_prec.h.gch
How did you do that, or did the WX makefile already provides that for you?
Eran
The wx_prec.h must be compiled to create wx_prec.h.gch
How did you do that, or did the WX makefile already provides that for you?
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Expert
- Posts: 159
- Joined: Mon Nov 03, 2008 9:17 pm
- Contact:
Re: Official support for precompiled headers
I use the way I've found somewhere in this forum. I've inserted
Regards
M.
into "Dependecies" field andwx_pch.h.gch
into "Rule action" (the second line must be indented by tab).wx_pch.h.gch: wx_pch.h
<TAB>$(CompilerName) wx_pch.h $(CmpOptions) $(IncludePath)
Regards
M.