On Fri, 22 Jan 2021 at 20:13, Joelle van Dyne <j...@getutm.app> wrote: > > Build without error on hosts without a working system(). An assertion > will trigger if system() is called. > > Signed-off-by: Joelle van Dyne <j...@getutm.app>
configure | 19 +++++++++++++++++++ Can we do the "does system() exist?" check in meson.build ? Untested, but looking at the existing check for "does gettid() exist?" it should be two lines: has_system = cc.has_function('system') and then later: config_host_data.set('HAVE_SYSTEM_FUNCTION', has_system) > +/** > + * Platforms which do not support system() gets an assertion failure. > + */ > +#ifndef HAVE_SYSTEM_FUNCTION > +#define system platform_does_not_support_system > +static inline int platform_does_not_support_system(const char *command) > +{ > + assert(0); > +} > +#endif /* !HAVE_SYSTEM_FUNCTION */ I think we should make this return an error code rather than assert: errno = ENOSYS; return -1; In particular, the arm, m68k and nios2 semihosting ABIs presented to the guest include 'SYSTEM' semihosting calls which we implement as "call system() with the string the guest hands us". On a platform without a system() function we want to return an error to the guest there, not assert. The other possible approach would be to find all the places which want to call system() and add suitable ifdeffery to handle platforms without system: * a win32-specific part of the guest-agent (no action needed) * net/slirp.c (already handled by the smbd patch in this series) * code in tests/ (5 instances) * the 3 semihosting uses But I think providing an always-fails system() is fine. thanks -- PMM