From 94e972609ca32ba90dca3f4d5b7ff27381056a26 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 1 Apr 2021 02:32:54 -0700 Subject: [PATCH] Remove wrapped_clang params files after use We use TempFile's destructor to remove the params file. Because we previously exec'd a new process, this was never called. Now we run them as subprocesses so we can cleanup afterwards. Closes #12896. PiperOrigin-RevId: 366211823 --- tools/osx/crosstool/wrapped_clang.cc | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/tools/osx/crosstool/wrapped_clang.cc b/tools/osx/crosstool/wrapped_clang.cc index 403528707b7bb5..367e3ad6141ed1 100644 --- a/tools/osx/crosstool/wrapped_clang.cc +++ b/tools/osx/crosstool/wrapped_clang.cc @@ -108,16 +108,6 @@ std::vector ConvertToCArgs(const std::vector &args) { return c_args; } -// Turn our current process into a new process. Avoids fork overhead. -// Never returns. -void ExecProcess(const std::vector &args) { - std::vector exec_argv = ConvertToCArgs(args); - execv(args[0].c_str(), const_cast(exec_argv.data())); - std::cerr << "Error executing child process.'" << args[0] << "'. " - << strerror(errno) << "\n"; - abort(); -} - // Spawns a subprocess for given arguments args. The first argument is used // for the executable path. void RunSubProcess(const std::vector &args) { @@ -410,19 +400,13 @@ int main(int argc, char *argv[]) { } } + RunSubProcess(invocation_args); if (!postprocess) { - ExecProcess(invocation_args); - std::cerr << "ExecProcess should not return. Please fix!\n"; - abort(); + return 0; } - RunSubProcess(invocation_args); - std::vector dsymutil_args = { "/usr/bin/xcrun", "dsymutil", linked_binary, "-o", dsym_path, "--flat"}; - ExecProcess(dsymutil_args); - std::cerr << "ExecProcess should not return. Please fix!\n"; - abort(); - + RunSubProcess(dsymutil_args); return 0; }