It seems that for compiling legato user should use a single job mode (-j1). On my machine I had MAKEFLAGS=-j8 which led to problems like:
Using ninja installed at: /bin/ninja ***ERROR: Bad system file build/localhost/system.localhost.update Try 'systoimg --help' for usage instructions. make: *** [Makefile:584: stage_systoimg] Error 1 make: *** Waiting for unfinished jobs....
make -j1 it compiled well. Perhaps it should be mentioned in the doc?