summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Program.cpp
AgeCommit message (Collapse)Author
2025-04-28[Support] Construct SmallVector with ArrayRef (NFC) (#137586)Kazu Hirata
2024-03-06Reland "[llvm][Support] Add support for executing a detached process ↵Connor Sughrue
(#81708)" (#83367) Relands #81708, which was reverted by f410f74cd5b26319b5796e0404c6a0f3b5cc00a5, now with a corrected unit test. Origionally the test failed on Windows when run with lit as `GetConsoleWindow` could not retrieve a window handle regardless of whether `DetachProcess` was `true` or `false`. The test now uses `GetStdHandle(STD_OUTPUT_HANDLE)` which does not rely on a console window existing. Original commit message below. Adds a new parameter, `bool DetachProcess` with a default option of `false`, to `llvm::sys::ExecuteNoWait`, which, when set to `true`, executes the specified program without a controlling terminal. Functionality added so that the module build daemon can be run without a controlling terminal.
2024-02-26Revert "[llvm][Support] Add support for executing a detached process (#81708)"cpsughrue
This reverts commit 86f6caa562255f81b93e72a501a926b17f5ad244. Unit test was failing on a few windows build bots
2024-02-26[llvm][Support] Add support for executing a detached process (#81708)Connor Sughrue
Adds a new parameter, `bool DetachProcess` with a default option of `false`, to `llvm::sys::ExecuteNoWait`, which, when set to `true`, executes the specified program without a controlling terminal. Functionality added so that the module build daemon can be run without a controlling terminal.
2022-12-14Support: Make Wait's SecondsToWait be std::optional [NFC]Matt Arsenault
I found the interaction between SecondsToWait and WaitUntilChildTerminates confusing. Rather than have a boolean to ignore the value of SecondsToWait, combine these into one Optional parameter.
2022-12-01Support: Convert Program APIs to std::optionalMatt Arsenault
2022-03-11Cleanup include: TableGenserge-sans-paille
This also includes a few cleanup from Support. Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121331
2021-01-14Re-land [Support] On Windows, take the affinity mask into accountAlexandre Ganea
The number of hardware threads available to a ThreadPool can be limited if setting an affinity mask. For example: > start /B /AFFINITY 0xF lld-link.exe ... Would let LLD only use 4 hyper-threads. Previously, there was an outstanding issue on Windows Server 2019 on dual-CPU machines, which was preventing from using both CPU sockets. In normal conditions, when no affinity mask was set, ProcessorGroup::AllThreads was different from ProcessorGroup::UsableThreads. The previous code in llvm/lib/Support/Windows/Threading.inc L201 was improperly assuming those two values to be equal, and consequently was limiting the execution to only one CPU socket. Differential Revision: https://reviews.llvm.org/D92419
2021-01-13Revert "[Support] On Windows, take the affinity mask into account"Alexandre Ganea
This reverts commit 336ab2d51dfdd5ca09c2a9c506453db4fe653584.
2021-01-13[Support] On Windows, take the affinity mask into accountAlexandre Ganea
The number of hardware threads available to a ThreadPool can be limited if setting an affinity mask. For example: > start /B /AFFINITY 0xF lld-link.exe ... Would let LLD only use 4 hyper-threads. Previously, there was an outstanding issue on Windows Server 2019 on dual-CPU machines, which was preventing from using both CPU sockets. In normal conditions, when no affinity mask was set, ProcessorGroup::AllThreads was different from ProcessorGroup::UsableThreads. The previous code in llvm/lib/Support/Windows/Threading.inc L201 was improperly assuming those two values to be equal, and consequently was limiting the execution to only one CPU socket. Differential Revision: https://reviews.llvm.org/D92419
2020-06-18[Clang] Move clang::Job::printArg to llvm::sys::printArg. NFCI.Alexandre Ganea
This patch is to support/simplify https://reviews.llvm.org/D80833
2020-06-17[Support] Get process statistics in ExecuteAndWait and WaitSerge Pavlov
The functions sys::ExcecuteAndWait and sys::Wait now have additional argument of type pointer to structure, which is filled with process execution statistics upon process termination. These are total and user execution times and peak memory consumption. By default this argument is nullptr so existing users of these function must not change behavior. Differential Revision: https://reviews.llvm.org/D78901
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-06-12Refactor ExecuteAndWait to take StringRefs.Zachary Turner
This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
2018-06-10Attempt 3: Resubmit "[Support] Expose flattenWindowsCommandLine."Zachary Turner
I took some liberties and quoted fewer characters than before, based on an article from MSDN which says that only certain characters cause an arg to require quoting. This seems to be incorrect, though, and worse it seems to be a difference in Windows version. The bot that fails is Windows 7, and I can't reproduce the failure on Win 10. But it's definitely related to quoting and special characters, because both tests that fail have a * in the argument, which is one of the special characters that would cause an argument to be quoted before but not any longer after the new patch. Since I don't have Win 7, all I can do is just guess that I need to restore the old quoting rules. So this patch does that in hopes that it fixes the problem on Windows 7. llvm-svn: 334375
2018-06-10Revert "Resubmit "[Support] Expose flattenWindowsCommandLine.""Zachary Turner
This reverts commit 65243b6d19143cb7a03f68df0169dcb63e8b4632. Seems like it's not a flake. It might have something to do with the '*' character being in a command line. llvm-svn: 334356
2018-06-10Resubmit "[Support] Expose flattenWindowsCommandLine."Zachary Turner
There were a few linux compilation failures, but other than that I think this was just a flake that caused the tests to fail. I'm going to resubmit and see if the failures go away, if not I'll revert again. llvm-svn: 334355
2018-06-09Revert "[Support] Expose flattenWindowsCommandLine."Zachary Turner
This reverts commit 10d2e88e87150a35dc367ba30716189d2af26774. This is causing some test failures for some reason, reverting while I investigate. llvm-svn: 334354
2018-06-09[Support] Expose flattenWindowsCommandLine.Zachary Turner
This function was internal to Program.inc, but I've needed this on several occasions when I've had to use CreateProcess without llvm's sys::Execute functions. In doing so, I noticed that the function was written using unsafe C-string access and was pretty hard to understand / make sense of, so I've also re-written the functions to use more modern LLVM constructs. llvm-svn: 334353
2018-04-30IWYU for llvm-config.h in llvm, additions.Nico Weber
See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
2018-04-29s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber
LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. llvm-svn: 331127
2017-09-13Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko
Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
2017-09-06Minor style fixes in lib/Support/**/Program.(inc|cpp).Alexander Kornienko
No functional changes intended. llvm-svn: 312646
2015-03-23Purge unused includes throughout libSupport.Benjamin Kramer
NFC. llvm-svn: 232976
2014-06-20Fix .cpp files claiming to be header filesHans Wennborg
llvm-svn: 211334
2014-06-12Remove system_error.h.Rafael Espindola
This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
2014-05-31Fix the behavior of ExecuteAndWait with a non-zero timeout.Peter Collingbourne
llvm-svn: 209951
2013-10-01Add non-blocking Wait() for launched processesTareq A. Siraj
- New ProcessInfo class to encapsulate information about child processes. - Generalized the Wait() to support non-blocking wait on child processes. - ExecuteNoWait() now returns a ProcessInfo object with information about the launched child. Users will be able to use this object to perform non-blocking wait. - ExecuteNoWait() now accepts an ExecutionFailed param that tells if execution failed or not. These changes will allow users to implement basic process parallel tools. Differential Revision: http://llvm-reviews.chandlerc.com/D1728 llvm-svn: 191763
2013-06-14Replace use of PathV1.h in Program.cpp.Rafael Espindola
llvm-svn: 183996
2013-06-13Avoid using PathV1.h in Program.h.Rafael Espindola
llvm-svn: 183940
2013-06-13Add a version of sys::ExecuteAndWait that takes StringRefs.Rafael Espindola
llvm-svn: 183934
2013-06-13[Support] Fix handle and memory leak for processes that are not waited forReid Kleckner
Execute's Data parameter is now optional, so we won't allocate memory for it on Windows and we'll close the process handle. The Unix code should probably do something similar to avoid accumulation of zombie children that haven't been waited on. Tested on Linux and Windows. llvm-svn: 183906
2013-06-13Zero-initializing variables; fixes a build breakage introduced in r183864.Aaron Ballman
llvm-svn: 183904
2013-06-12Remove the program class.Rafael Espindola
It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just those two functions and make Execute and Wait implementations details. llvm-svn: 183864
2013-03-26Add a boolean parameter to the ExecuteAndWait static function to indicatedChad Rosier
if execution failed. ExecuteAndWait returns -1 upon an execution failure, but checking the return value isn't sufficient because the wait command may return -1 as well. This new parameter is to be used by the clang driver in a subsequent commit. Part of rdar://13362359 llvm-svn: 178087
2011-12-13Support/Program: Make Change<stream>ToBinary return error_code.Michael J. Spencer
llvm-svn: 146522
2011-05-21Have Program::Wait return -2 for crashed and timeouts instead of embeddingAndrew Trick
info in the error message. Per Dan's request. llvm-svn: 131780
2011-05-11Bugpoint support for miscompilations that result in a crash.Andrew Trick
This change allows bugpoint to pinpoint the "opt" pass and bitcode segment responsible for a crash caused by miscompilation. At least it works well for me now, without having to create any custom execution wrappers. llvm-svn: 131186
2010-11-29Merge System into Support.Michael J. Spencer
llvm-svn: 120298