<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124635>124635</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc][spawn] wrong function signature for `posix_spawn`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickdesaulniers
</td>
</tr>
</table>
<pre>
Building clang against llvm-libc fails with:
```
In file included from /llvm-project-main/llvm/lib/Support/Program.cpp:104:
/llvm-project-main/llvm/lib/Support/Unix/Program.inc:259:13: error: no matching function for call to 'posix_spawn'
259 | Err = posix_spawn(&PID, Program.str().c_str(), FileActions,
| ^~~~~~~~~~~
/usr/include/spawn.h:21:5: note: candidate function not viable: no known conversion from 'char **' to 'const char *__restrict *' for 5th argument
21 | int posix_spawn(pid_t *__restrict, const char *__restrict, posix_spawn_file_actions_t *, posix_spawnattr_t *__restrict, const char *__restrict *, const char *__restrict *) __NOEXCEPT;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~
```
this is because the generated spawn.h has the wrong fn signature for posix_spawn. Specifically, we generate
```
int posix_spawn(pid_t *__restrict, const char *__restrict, posix_spawn_file_actions_t *, posix_spawnattr_t *__restrict, const char *__restrict *, const char *__restrict *) __NOEXCEPT;
```
but this is subtly wrong; indeed the last two parameters are currently:
```c
const char *__restrict *
```
but should be:
```c
char * const * __restrict
```
This can be fixed in libc/include/spawn.yaml a la https://github.com/llvm/llvm-project/commit/6045146014151a8f63a60612445de9ff6af47626 (cc @alexprabhat99)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcVU2P4ygQ_TXkUpoIY2MnBx_cH5HmstvSzEp7i8qAbXYwWIA73Zf57SscZzrpnRmpr4ssgUzxqt4rqsAQdG-Vqgm_I_xhg3McnK-tFt-kCjgbq5UPm9bJ1_pu1kZq24MwaHvAHrUNEYx5Hj8Z3QroUJsA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