diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2020-07-14 17:57:04 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2020-07-23 11:39:42 +0700 |
commit | dab898f9ab62275f55eb2a7e76ea0cd01696f68e (patch) | |
tree | 19c839031d1e3804d801c70def9a763b3126859e /llvm/unittests/Support/CommandLineTest.cpp | |
parent | 557db6f8aa56dd14803a65aae443d8019b4dcdde (diff) | |
download | llvm-dab898f9ab62275f55eb2a7e76ea0cd01696f68e.zip llvm-dab898f9ab62275f55eb2a7e76ea0cd01696f68e.tar.gz llvm-dab898f9ab62275f55eb2a7e76ea0cd01696f68e.tar.bz2 |
[Windows] Fix limit on command line size
This reapplies commit d4020ef7c474, reverted in ac0edc55887b because it
broke build of LLDB. This commit contains appropriate changes for LLDB.
The original commit message is below.
Documentation on CreateProcessW states that maximal size of command line
is 32767 characters including ternimation null character. In the
function llvm::sys::commandLineFitsWithinSystemLimits this limit was set
to 32768. As a result if command line was exactly 32768 characters long,
a response file was not created and CreateProcessW was called with
too long command line.
Differential Revision: https://reviews.llvm.org/D83772
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r-- | llvm/unittests/Support/CommandLineTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index e1b706e..e8c2cef 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -763,6 +763,18 @@ TEST(CommandLineTest, DefaultOptions) { TEST(CommandLineTest, ArgumentLimit) { std::string args(32 * 4096, 'a'); EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data())); + std::string args2(256, 'a'); + EXPECT_TRUE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args2.data())); + if (Triple(sys::getProcessTriple()).isOSWindows()) { + // We use 32000 as a limit for command line length. Program name ('cl'), + // separating spaces and termination null character occupy 5 symbols. + std::string long_arg(32000 - 5, 'b'); + EXPECT_TRUE( + llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); + long_arg += 'b'; + EXPECT_FALSE( + llvm::sys::commandLineFitsWithinSystemLimits("cl", long_arg.data())); + } } TEST(CommandLineTest, ResponseFileWindows) { |