On Tuesday, 26.01.2016 at 14:25, Martin Lucina wrote: > - _bin_ is used as a discriminator to select which multibaked binary to > invoke. This drops the coupling between "order binaries are baked into > the image" and "order they are specified in rc" -- I still need to do the > work to implement this and associated changes to rumpbake.
Done, was easier than I thought. Pushed to mato-wip-rumprun-config branch: https://github.com/rumpkernel/rumprun/commit/59fac6766b2db5f935ede7822bbadcf91aab46a2 Simplifies a bunch of things, including removing all the weak rumprun_mainX symbols and the limit of 8 binaries multibaked into a unikernel image. The downside is that rumprun-bake needs to generate and compile C code at bake time. Excerpt from commit: --- a/app-tools/rumprun-bake.in +++ b/app-tools/rumprun-bake.in @@ -347,8 +347,6 @@ unset RUMPBAKE_CFLAGS # XXX: TOOLDIR is just dirname $0, so can simplify that bit unset RUMPBAKE_TOOLDIR -[ $# -le 8 ] || { echo '>> max 8 binaries supported currently' ; exit 1; } - # Santize the config argument passed in to remove shell # metacharacters config="$(echo ${TARGET} | sed -e 's/-/_/g' -e 's/[^A-Za-z0-9_]//g')" @@ -384,8 +382,49 @@ for f in "$@"; do objnum=$((${objnum}+1)) done +# Generate list of binaries baked into the unikernel image. +# XXX This definition needs to be kept in sync with that in +# include/rumprun-base/config.h. Also, no checks are made to ensure binname is +# unique, feel free to improve. +cat >${TMPDIR}/tmpbins.c <<EOM +#include <stddef.h> +typedef int mainlike_fn(int, char *[]); +EOM +objnum=1 +for f in "$@"; do + cat >>${TMPDIR}/tmpbins.c <<EOM +extern mainlike_fn rumprun_main${objnum}; +EOM + objnum=$((${objnum}+1)) +done +cat >>${TMPDIR}/tmpbins.c <<EOM +struct rumprun_bin { + const char *binname; + mainlike_fn *main; +} *rumprun_bins[] = { +EOM +objnum=1 +for f in "$@"; do + f=$(basename ${f}) + cat >>${TMPDIR}/tmpbins.c <<EOM + &(struct rumprun_bin){ "${f}", rumprun_main${objnum} }, +EOM + objnum=$((${objnum}+1)) +done +cat >>${TMPDIR}/tmpbins.c <<EOM + NULL +}; +EOM + MACHINE_GNU_ARCH=${RUMPBAKE_TUPLE%%-*} +# Compile the generated code. Use of funky initializers requires -std=c99. +${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} \ + --sysroot ${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH} \ + -specs=${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH}/lib/specs-compile_or + -std=c99 -o ${TMPDIR}/tmpbins.obj -c ${TMPDIR}/tmpbins.c || exit 1 +allobjs="${allobjs} ${TMPDIR}/tmpbins.obj" + # Final link using cc to produce the unikernel image. ${runcmd} ${RUMPBAKE_BACKINGCC} ${RUMPBAKE_CFLAGS} \ --sysroot ${RUMPBAKE_TOOLDIR}/rumprun-${MACHINE_GNU_ARCH} \ Given that rumprun-bake is already dependent on having the toolchain used to build the binaries present, this doesn't make things any worse. Related question #1 that came up while working on this -- should I implement rumprun-bake functionality to record/a tool to query the binaries baked into a unikernel image? Without this information the user cannot specify rc[].bin. Related question #2 -- rumprun-bake sets binname[x] to the basename of binary X. Do we need syntax to allow the user to specify binname?
