Compile GN-based projects with modified compiler flags

1.4k Views Asked by At

The build system that V8 uses is not straightforward. Assume I desired to add -save-temps to the build flags to keep all intermediate files produced during compilation. Where would I specify this information? Do you specify it in a particular command? Does it have to be added to a special build configuration file?

1

There are 1 best solutions below

2
jmrk On

(This question isn't really about V8, but rather the GN build system.)

GN is intentionally designed to take all build configuration from files (which you can check into git/etc for reproducible builds), rather than command-line flags and environment variables. So any extra compiler flags also have to be specified via files. Specifically, you can edit any of the cflags = ... or cflags += ... definitions that apply to the compilation units in question. In case of V8, you can e.g. add your flag to the cflags = [] initialization here, or you could make a similar change in build/config/compiler/BUILD.gn, which will also affect any dependencies.