[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation
Alexandre Ganea via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 5 11:30:35 PST 2019
aganea added a comment.
I did this in driver.cpp:
// Whether the cc1 tool should be called inside the current process, or forked
// to a new new process.
bool UseCC1ProcessFork = CLANG_FORK_CC1;
StringRef ForkCC1Str = ::getenv("CLANG_FORK_CC1");
if (!ForkCC1Str.empty()) {
UseCC1ProcessFork = ForkCC1Str.compare("1") == 0 ||
ForkCC1Str.compare_lower("on") == 0 ||
ForkCC1Str.compare_lower("true") == 0;
}
if (!UseCC1ProcessFork) {
// Here we provide a shortcut for calling the -cc1 cmd-line within the
// same process, instead of starting a new process. This saves a some
// execution time of Windows, as process creation can be expensive on
// that platform.
TheDriver.CC1Main = &ExecuteCC1Tool;
}
With a new option in cmake to control the default behavior:
set(CLANG_FORK_CC1 OFF BOOL
"Whether clang should use a new process for the CC1 invocation")
if (APPLE)
set(CLANG_FORK_CC1 1)
endif()
And the corresponding flag in config.h:
/* If we want to fork a new process clang.exe for the CC1 invocation */
#cmakedefine01 CLANG_FORK_CC1
This option needs to be controlled at large (otherwise some TUs might compile with forking "on" and others with forking "off", depending on what happens in the build scripts), so I thought the env variable would make more sense. Do you think a new cmd-line option is worth it, or is the env var enough?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69825/new/
https://reviews.llvm.org/D69825
More information about the cfe-commits
mailing list