igcc icon indicating copy to clipboard operation
igcc copied to clipboard

PCH setup

Open Artoria2e5 opened this issue 1 year ago • 0 comments

One of the ways to cut down on the overhead of repeated compilation is to make a precompiled header. The current set up is basically ready: boilerplate.h is always included, and with bits/stdc++.h it's got almost the entire standard library.

In fact, bits/stdc++.h states plainly at the top:

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

That's how it's supposed to be used!


But how do we really do it?

  • The config file needs a new pch_command option to run gcc -x c++-header $header -o $pcheader. This helps interaction with #10.
  • Use -include (or -include-pch in clang) in the compiler invocation to get it to include. Doing it via command line lets us avoid writing to the igcc install directory, which can have permission issues. It does prevent users from opting out the boilerplate though.

Artoria2e5 avatar May 13 '23 13:05 Artoria2e5