From 6a9411e784c58492e62a5dcb7d5d1aadfb2e1830 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 3 Oct 2018 09:31:01 -0400 Subject: manual: mention the "invalid parameter" case This happens often enough and the error message is quite unhelpful. Mention this error explicitly in the documentation. --- doc/manual.asciidoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual.asciidoc b/doc/manual.asciidoc index 9e55c02..db164e7 100644 --- a/doc/manual.asciidoc +++ b/doc/manual.asciidoc @@ -880,7 +880,8 @@ quoting rules are deterimined by the called program, which on Windows are usually provided by the C library. If you need shell interpretation of the command (such as the use of `&&` to chain multiple commands), make the command execute the Windows shell by -prefixing the command with `cmd /c`. +prefixing the command with `cmd /c`. Ninja may error with "invalid parameter" +which usually indicates that the command line length has been exceeded. [[ref_outputs]] Build outputs -- cgit v0.12 From e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 3 Oct 2018 09:31:02 -0400 Subject: Win32Fatal: support a "hint" for the error The callsite might have extra context which is helpful for interpreting the error message. --- src/util.cc | 8 ++++++-- src/util.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util.cc b/src/util.cc index 760bc23..8e67fd9 100644 --- a/src/util.cc +++ b/src/util.cc @@ -432,8 +432,12 @@ string GetLastErrorString() { return msg; } -void Win32Fatal(const char* function) { - Fatal("%s: %s", function, GetLastErrorString().c_str()); +void Win32Fatal(const char* function, const char* hint) { + if (hint) { + Fatal("%s: %s (%s)", function, GetLastErrorString().c_str(), hint); + } else { + Fatal("%s: %s", function, GetLastErrorString().c_str()); + } } #endif diff --git a/src/util.h b/src/util.h index 1b4227c..6a4a7a9 100644 --- a/src/util.h +++ b/src/util.h @@ -119,7 +119,7 @@ bool Truncate(const string& path, size_t size, string* err); string GetLastErrorString(); /// Calls Fatal() with a function name and GetLastErrorString. -NORETURN void Win32Fatal(const char* function); +NORETURN void Win32Fatal(const char* function, const char* hint = NULL); #endif #endif // NINJA_UTIL_H_ -- cgit v0.12 From 1463fdc0f73136aca4869be9ad577d08528b19c4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 3 Oct 2018 09:31:02 -0400 Subject: subprocess-win32: add hint on ERROR_INVALID_PARAMETER This is generally associated with the command line being too long. Give a hint to this case in the error message. --- src/subprocess-win32.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc index 5982b06..a4a7669 100644 --- a/src/subprocess-win32.cc +++ b/src/subprocess-win32.cc @@ -124,6 +124,10 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { buf_ = "CreateProcess failed: The system cannot find the file " "specified.\n"; return true; + } else if (error == ERROR_INVALID_PARAMETER) { + // This generally means that the command line was too long. Give extra + // context for this case. + Win32Fatal("CreateProcess", "is the command line too long?"); } else { Win32Fatal("CreateProcess"); // pass all other errors to Win32Fatal } -- cgit v0.12