Issue 124635
Summary [libc][spawn] wrong function signature for `posix_spawn`
Labels good first issue, libc
Assignees
Reporter nickdesaulniers
    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)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to