Skip to content

[libc][spawn] wrong function signature for posix_spawn #124635

@nickdesaulniers

Description

@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:

const char *__restrict *

but should be:

char * const * __restrict

This can be fixed in libc/include/spawn.yaml a la 6045146 (cc @alexprabhat99)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions