[all-commits] [llvm/llvm-project] b4a99a: [Clang][Driver] Re-use the calling process instead...

Alexandre Ganea via All-commits all-commits at lists.llvm.org
Mon Jan 13 07:40:31 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b4a99a061f517e60985667e39519f60186cbb469
      https://github.com/llvm/llvm-project/commit/b4a99a061f517e60985667e39519f60186cbb469
  Author: Alexandre Ganea <alexandre.ganea at ubisoft.com>
  Date:   2020-01-13 (Mon, 13 Jan 2020)

  Changed paths:
    M clang/CMakeLists.txt
    M clang/include/clang/Config/config.h.cmake
    M clang/include/clang/Driver/Driver.h
    M clang/include/clang/Driver/Job.h
    M clang/lib/Driver/Job.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/CMakeLists.txt
    A clang/test/Driver/cc1-spawnprocess.c
    M clang/test/Driver/clang_f_opts.c
    M clang/test/Driver/fsanitize-blacklist.c
    M clang/test/Driver/unknown-arg.c
    M clang/test/Driver/warning-options_pedantic.cpp
    M clang/tools/driver/driver.cpp

  Log Message:
  -----------
  [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

With this patch, the clang tool will now call the -cc1 invocation directly inside the same process. Previously, the -cc1 invocation was creating, and waiting for, a new process.
This patch therefore reduces the number of created processes during a build, thus it reduces build times on platforms where process creation can be costly (Windows) and/or impacted by a antivirus.
It also makes debugging a bit easier, as there's no need to attach to the secondary -cc1 process anymore, breakpoints will be hit inside the same process.

Crashes or signaling inside the -cc1 invocation will have the same side-effect as before, and will be reported through the same means.

This behavior can be controlled at compile-time through the CLANG_SPAWN_CC1 cmake flag, which defaults to OFF. Setting it to ON will revert to the previous behavior, where any -cc1 invocation will create/fork a secondary process.
At run-time, it is also possible to tweak the CLANG_SPAWN_CC1 environment variable. Setting it and will override the compile-time setting. A value of 0 calls -cc1 inside the calling process; a value of 1 will create a secondary process, as before.

Differential Revision: https://reviews.llvm.org/D69825




More information about the All-commits mailing list