# ninja command line too long

**URL:** https://discourse.cmake.org/t/ninja-command-line-too-long/3086
**Category:** Code
**Tags:** os:windows, gen:ninja
**Created:** [April 5, 2021, 8:50pm UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086 "2021-04-05T20:50:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![erichschroeter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/erichschroeter/32/1297_2.png) [@erichschroeter](https://discourse.cmake.org/u/erichschroeter)
#### Post date: [April 5, 2021, 8:50pm UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/1 "2021-04-05T20:50:46Z")

</div>

I am getting a `The command line is too long.` error when building on Windows using CMake 3.20.0 and Ninja 1.10.2.  
I have tried the answer for [cmake-command-line-too-long-windows](https://stackoverflow.com/questions/43184251/cmake-command-line-too-long-windows), but it did not work.  
The actual command that is failing is the archiver:

```
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E rm -f path\to\mylib.a && C:\ti\ccs1010\ccs\tools\compiler\ti-cgt-arm_20.2.1.LTS\bin\armar.exe qr path\to\mylib.a <a-bunch-of-obj-files> && cd ."

```

I’m wondering if this is a bug (or lacking feature) of CMake where it needs to support using response files for archiving?  
Is there a workaround or solution for this?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 6, 2021, 11:37am UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/2 "2021-04-06T11:37:42Z")

</div>

It looks like you’re might be using a custom toolchain. There are some variables you can use to indicate that your compiler does support them. From a grep:

- `CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG`
- `CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES`
- `CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS`

If you’re not using a custom toolchain, CMake’s TI support might need updated if the compiler/linker does support response files now in different configurations. Please file [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) if that is the case.

---

<div class="post-metadata">

### Author: ![erichschroeter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/erichschroeter/32/1297_2.png) [@erichschroeter](https://discourse.cmake.org/u/erichschroeter)
#### Post date: [April 6, 2021, 5:33pm UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/3 "2021-04-06T17:33:50Z")

</div>

Ahh, ok, so this is really an issue with the TI compiler? I did notice that the `TI.cmake` mentioned `# After the --run_linker flag a response file is not possible`. I guess I didn’t realize that response files were a compiler-specific feature; I thought it was a Ninja-specific feature.

I guess for the time being, the workaround I’ve found is to just split my target into multiple targets to reduce the command line length.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 7, 2021, 12:45am UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/4 "2021-04-07T00:45:00Z")

</div>

> [@erichschroeter](#):
>
> I guess I didn’t realize that response files were a compiler-specific feature; I thought it was a Ninja-specific feature.

Ninja has support for making them, but the tool itself needs to provide the core logic for them. Splitting your libraries up can be suitable (though not always possible depending on the API you plan on providing).

---

<div class="post-metadata">

### Author: ![gillhaa46](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/f08c70/32.png) [@gillhaa46](https://discourse.cmake.org/u/gillhaa46)
#### Post date: [November 7, 2022, 9:55am UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/5 "2022-11-07T09:55:37Z")

</div>

I am having a similar issue, so using Ninja, TI C2000 compiler. Everything is fine on Darwin, Linux, and indeed on Windows when the path is short enough, but when the path increases the number of include-path directives creates a too long command line for Windows. I then tried forcing response files CMAKE\_NINJA\_FORCE\_RESPONSE\_FILE and CMAKE\_C\_USE\_RESPONSE\_FILE\_FOR\_OBJECTS and CMAKE\_C\_USE\_RESPONSE\_FILE\_FOR\_INCLUDES all TRUE, and various combinations of this, and get to the situation where most files build, but when the response file line length exceeds roughly 7054 characters, the compiler command fails.  
I wonder if there is some need to recognise the compiler response file length limitation in the toolchain on windows and either split the command into multiple response files?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 7, 2022, 12:40pm UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086/6 "2022-11-07T12:40:01Z")

</div>

Response files are to get around length limits…

IIRC, we are using Ninja’s built-in `rspfile` feature and teaching it about limits would be an interesting exercise.
