Thanks, it built on my 18.04 machine but it seems that newer versions of GCC had different behavior on the underscore assembly functions. I will fix it and test on 20.04.
-j On Sun, Nov 8, 2020 at 7:46 AM Philippe Mathieu-Daudé <f4...@amsat.org> wrote: > > Hi Joelle, > > On 11/8/20 6:26 AM, Joelle van Dyne wrote: > > iOS does not support ucontext natively for aarch64 and the sigaltstack is > > also unsupported (even worse, it fails silently, see: > > https://openradar.appspot.com/13002712 ) > > > > As a workaround we include a library implementation of ucontext and add it > > as a build option. > > > > Signed-off-by: Joelle van Dyne <j...@getutm.app> > > --- > > configure | 23 ++++++++++++++++++++--- > > meson.build | 28 +++++++++++++++++++++++++++- > > util/coroutine-ucontext.c | 9 +++++++++ > > .gitmodules | 3 +++ > > libucontext | 1 + > > meson_options.txt | 2 ++ > > 6 files changed, 62 insertions(+), 4 deletions(-) > > create mode 160000 libucontext > ... > > > diff --git a/meson.build b/meson.build > > index 8894171bd1..e62324d5ac 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -1259,9 +1259,34 @@ if not fdt.found() and fdt_required.length() > 0 > > error('fdt not available but required by targets ' + ', > > '.join(fdt_required)) > > endif > > > > +ucontext = not_found > > +if get_option('ucontext').enabled() > > + if not fs.is_dir(meson.current_source_dir() / 'libucontext/arch' / cpu) > > + error('libucontext is wanted but not implemented for host ' + cpu) > > + endif > > + arch = host_machine.cpu() > > + ucontext_cargs = ['-DG_LOG_DOMAIN="ucontext"', '-DCUSTOM_IMPL'] > > + ucontext_files = [ > > + 'libucontext/arch' / arch / 'getcontext.S', > > + 'libucontext/arch' / arch / 'setcontext.S', > > + 'libucontext/arch' / arch / 'makecontext.c', > > + 'libucontext/arch' / arch / 'startcontext.S', > > + 'libucontext/arch' / arch / 'swapcontext.S', > > + ] > > + > > + ucontext_inc = include_directories('libucontext/include') > > + libucontext = static_library('ucontext', > > + sources: ucontext_files, > > + c_args: ucontext_cargs, > > + include_directories: ucontext_inc) > > + ucontext = declare_dependency(link_with: libucontext, > > + include_directories: ucontext_inc) > > +endif > > + > > config_host_data.set('CONFIG_CAPSTONE', capstone.found()) > > config_host_data.set('CONFIG_FDT', fdt.found()) > > config_host_data.set('CONFIG_SLIRP', slirp.found()) > > +config_host_data.set('CONFIG_LIBUCONTEXT', ucontext.found()) > > > > ##################### > > # Generated sources # > > @@ -1477,7 +1502,7 @@ util_ss.add_all(trace_ss) > > util_ss = util_ss.apply(config_all, strict: false) > > libqemuutil = static_library('qemuutil', > > sources: util_ss.sources() + > > stub_ss.sources() + genh, > > - dependencies: [util_ss.dependencies(), m, > > glib, socket, malloc]) > > + dependencies: [util_ss.dependencies(), m, > > glib, socket, malloc, ucontext]) > > qemuutil = declare_dependency(link_with: libqemuutil, > > sources: genh + version_res) > > > > @@ -2135,6 +2160,7 @@ if targetos == 'windows' > > summary_info += {'QGA MSI support': > > config_host.has_key('CONFIG_QGA_MSI')} > > endif > > summary_info += {'seccomp support': > > config_host.has_key('CONFIG_SECCOMP')} > > +summary_info += {'libucontext support': ucontext.found()} > > summary_info += {'coroutine backend': > > config_host['CONFIG_COROUTINE_BACKEND']} > > summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] > > == '1'} > > summary_info += {'debug stack usage': > > config_host.has_key('CONFIG_DEBUG_STACK_USAGE')} > > diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c > > index 904b375192..1e1dd43512 100644 > > --- a/util/coroutine-ucontext.c > > +++ b/util/coroutine-ucontext.c > > @@ -23,7 +23,16 @@ > > #undef _FORTIFY_SOURCE > > #endif > > #include "qemu/osdep.h" > > +#if defined(CONFIG_LIBUCONTEXT) > > +#include <libucontext.h> > > +#define ucontext_t libucontext_ucontext_t > > +#define getcontext libucontext_getcontext > > +#define setcontext libucontext_setcontext > > +#define swapcontext libucontext_swapcontext > > +#define makecontext libucontext_makecontext > > +#else > > #include <ucontext.h> > > +#endif > > #include "qemu/coroutine_int.h" > > Trying on Ubuntu 20.04 I'm getting: > > /usr/bin/ld: libqemuutil.a(util_coroutine-ucontext.c.o): in function > `qemu_coroutine_new': > util/coroutine-ucontext.c:203: undefined reference to > `libucontext_getcontext' > /usr/bin/ld: util/coroutine-ucontext.c:254: undefined reference to > `libucontext_swapcontext' > /usr/bin/ld: libucontext.a(libucontext_arch_x86_64_makecontext.c.o): in > function `libucontext_makecontext': > libucontext/arch/x86_64/makecontext.c:54: undefined reference to > `_start_context' > collect2: error: ld returned 1 exit status > > Regards, > > Phil.