Precompiled header filesize

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
vanarieleyen
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Aug 29, 2019 3:55 am
Location: China, Shenzhen

Precompiled header filesize

Post by vanarieleyen »

The project that I am busy with is getting too large, so I am trying to speed up the build process by using a few precompiled headers.

The precompiled header that is created is extremely large (about 300 Mb) and as a result cc1plus.exe is crashing during a build.

To investigate the problem I have created a new project with an empty pch-file:

Code: Select all

#ifndef WX_PCH_H_INCLUDED
#define WX_PCH_H_INCLUDED

// basic wxWidgets headers
#include <wx/wxprec.h>

#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
When I build this project it creates a compiled header file of 244 Mb that cc1plus.exe doesn't like.

How is it possible that an empty (default) header file creates such a large compiled file?

The command that is used to create the file is:
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c c:\dev\pch_test\wx_pch.h -o wx_pch.h.gch\Release_wx_pch_h_gch

I am using wxWidgets version 3.1.2 on Windows 8.1
The development environment is Code:Blocks with minGW (using GCC 8.2)
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Precompiled header filesize

Post by ONEEYEMAN »

Hi,
Does it throw an "Internal compiler error?"

What type of hardware do you use? Any faulty RAM/HDD? Do you have enough space in both?

Thank you.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

How is it possible that an empty (default) header file creates such a large compiled file?
I do NOT consider all of the files in "wx/wx.h" to be a small/empty PCH header.

Tim S.
vanarieleyen
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Aug 29, 2019 3:55 am
Location: China, Shenzhen

Re: Precompiled header filesize

Post by vanarieleyen »

At my work I run windows 8 in a virtual box and I also think that memory might be an issue.

However on the internet I also see other people with the same problems and it seems that the cause of the problem with cc1plus.exe is a lack of memory.

Also note that I have done several tests yesterday and found out that when I strip the pch file it runs perfectly:

Code: Select all

#ifndef WX_PCH_H_INCLUDED
#define WX_PCH_H_INCLUDED

#include <file1.h>
#include <file2.h>
#include <file3.h>
.... etc....

#endif // WX_PCH_H_INCLUDED
As you see I have removed almost everything. It now still creates a very large object file, but cc1plus.exe doesn't give any problems anymore. The strange thing is that when I add wxprec.h the problems start all over again.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

Please give detail info about your compiler and I will see if I can duplicate the issue.

I am guessing some header is causing the issue.

Code: Select all

gcc --version
gcc (MinGW.org GCC-8.2.0-5) 8.2.0
Above is the GCC 8.2.0 I currently have installed; it is an 32 bit Compiler. I do not think using wx PCH works very well when 32 bit GCC mingw compiler is used.

Tim S.
vanarieleyen
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Aug 29, 2019 3:55 am
Location: China, Shenzhen

Re: Precompiled header filesize

Post by vanarieleyen »

The compiler version is 8.2.0

The minGW version is from Nuwen: https://nuwen.net/mingw.html, its version 16.1. On this moment he also has a version 17.1 which I have tried but gives the same result (this version uses GCC 9.2)
According to his information he only uses 64 bit versions of all programs, but I don't know how to check this in windows.

On this moment I use the method that I described before (without the wxprec.h) and that works fine. The generated GHC file is 433mb and contains a dozen includes. I don't know if this size can be expected, but when I remove all headers and compile it it gives a size of a few kb so that seems ok.

I am also sure that the compiler can find the compiled headers. I have removed them from the sources and only use the precompiled one, and the compiler doesn't complain.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

Code: Select all

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c c:\dev\pch_test\wx_pch.h -o wx_pch.h.gch\Release_wx_pch_h_gch
I suggest not including a PCH file when making a PCH file.

In other words, remove "-include wx_pch.h"

Note: That is not likely the cause of your issue, I am still downloading the compiler to try to duplicate your issue.

Tim S.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

You are running the commands under the "open_distro_window.bat" command window, correct?

Tim S.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

What command did you use to build wxWidgets?

Tim S.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: Precompiled header filesize

Post by stahta01 »

Please post a simple C++ file and the build command used that files to work?
Also, post the build error and state whether the command crashes without error?

Edit: I suggest creating an CB Project that uses one of the wxWidgets samples and upload the CB project to here for me to test.

Tim S.
Post Reply