Skip to content

Commit

Permalink
linux: add linux rump kernel build
Browse files Browse the repository at this point in the history
build-rr.sh adds new -r option to switch what rump kernel is used:
NetBSD is the default one and add Linux one for the alternative in this
patch.

Although there are several limitations (listed below) in this stage,
this would be a first step toward supporting alternate rump kernel
across different ones.

Limitations:
- no xen execution support (build should be fine)
- no i486 build support
- CXX is always false: CXX=false should be added to build linux rump
  kernel
- no libz support
- no cookfs (/rootfs) support
- rumprun-packages needs more work: current test on travis is only build
  test and the executions might have various issues.
  • Loading branch information
thehajime committed Apr 11, 2017
1 parent bbfbaf4 commit 5995ebe
Show file tree
Hide file tree
Showing 36 changed files with 798 additions and 70 deletions.
8 changes: 7 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
[submodule "buildrump.sh"]
path = buildrump.sh
url = https://github.com/rumpkernel/buildrump.sh
url = https://github.com/libos-nuse/buildrump.sh
[submodule "src-netbsd"]
path = src-netbsd
url = https://github.com/rumpkernel/src-netbsd
[submodule "linux"]
path = linux
url = https://github.com/libos-nuse/lkl-linux.git
[submodule "musl"]
path = musl
url = https://github.com/libos-nuse/musl.git
32 changes: 24 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,33 @@ before_script:
- sudo apt-get install --only-upgrade binutils gcc -y

env:
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS=
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
- PLATFORM=xen MACHINE=x86_64 TESTS=none EXTRAFLAGS=
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none EXTRAFLAGS='-- -F ACLFLAGS=-m32'
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS= CXX='false'
- PLATFORM=hw MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS=
- PLATFORM=xen MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS=
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS=
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" EXTRAFLAGS=
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r netbsd" EXTRAFLAGS='-- -F ACLFLAGS=-m32'
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS= CXX='false'
- PLATFORM=hw MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" KERNONLY=-k EXTRAFLAGS=
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" KERNONLY=-k EXTRAFLAGS=
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS=
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS=
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32'
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS= CXX='false'
- PLATFORM=hw MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" KERNONLY=-k EXTRAFLAGS=
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" KERNONLY=-k EXTRAFLAGS=

matrix:
allow_failures:
# no CXX
- env: PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS=
- env: PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS=
# no i486 build yet
- env: PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
- env: PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32'

script:
- git submodule update --init
- ./build-rr.sh -o myobj -j16 -qq ${KERNONLY} ${PLATFORM} ${EXTRAFLAGS}
- ./build-rr.sh -o myobj -j16 -qq ${RUMPKERNEL} ${KERNONLY} ${PLATFORM} ${EXTRAFLAGS}
- . ./myobj/config
- ./tests/buildtests.sh ${KERNONLY}
- ./tests/runtests.sh ${TESTS}
Expand Down
12 changes: 9 additions & 3 deletions app-tools/rumprun
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ run_qemu ()
if [ -n "$opt_interactive" ]; then
${qemucmd} -append "${json_coma}"
else
qemucmd="${qemucmd} -display none"
qemucmd="${qemucmd} -display none -vga none"
${qemucmd} -append "${json_coma}" 1>/dev/null 2>&1 &
echo qemu:$!
fi
Expand All @@ -703,7 +703,13 @@ bake_iso ()
[ -z "${DUMPCMD}" ] || die -D not supported by iso. Use -T.

type xorriso >/dev/null || die bake_iso needs xorriso
type grub-mkrescue >/dev/null || die bake_iso needs grub-mkrescue
if type grub-mkrescue 2>/dev/null >/dev/null; then
MKRESCUE=grub-mkrescue
elif type grub2-mkrescue 2>/dev/null >/dev/null; then
MKRESCUE=grub2-mkrescue
else
die bake_iso needs grub-mkrescue or grub2-mkrescue
fi

store_blkspec=json_store_iso_blkspec
store_netspec=json_store_netspec
Expand Down Expand Up @@ -777,7 +783,7 @@ bake_iso ()
$(basename $1) >> "${ISODIR}/boot/grub/grub.cfg"
cp ${bootimage} "${ISODIR}/boot"
cp "${TMPDIR}/json.cfg" "${ISODIR}"
grub-mkrescue -o ${opt_name} "${ISODIR}"
${MKRESCUE} -o ${opt_name} "${ISODIR}"
}

make_ec2 ()
Expand Down
14 changes: 14 additions & 0 deletions app-tools/rumprun-bake.conf
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,17 @@ conf hw_generic
_pciether \
_usb
fnoc

conf hw_lkl
create "LKL generic (a.k.a all) targets"
add -llkl
add -lrumprun_base
add -lrumpdev_linux_pci
fnoc

conf xen_pv_lkl
create "Xen with paravirtualized I/O drivers with LKL"
add -llkl
add -lrumprun_base
add -lrumpdev_linux_pci
fnoc
73 changes: 36 additions & 37 deletions build-rr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ helpme ()
printf "\t-o: use non-default object directory\n"
printf "\t-k: build kernel only, without libc or tools\n"
printf "\t-s: specify alternative src-netbsd location\n\n"
printf "\t-r: type of rump kernel [netbsd|linux]. default netbsd\n\n\n"
printf "\tbuildrump.sh opts are passed to buildrump.sh\n"
printf "\n"
printf "The toolchain is picked up from the environment. See the\n"
Expand Down Expand Up @@ -96,14 +97,16 @@ parseargs ()
KERNONLY=false
RROBJ=
RUMPSRC=src-netbsd
LKLSRC=linux
RUMPKERNEL=netbsd
STDJ=-j4
EXTSRC=

DObuild=false
DOinstall=false

orignargs=$#
while getopts '?d:hj:ko:qs:' opt; do
while getopts '?d:hj:kr:o:qs:' opt; do
case "$opt" in
'j')
[ -z "$(echo ${OPTARG} | tr -d '[0-9]')" ] \
Expand All @@ -116,6 +119,14 @@ parseargs ()
'k')
KERNONLY=true
;;
'r')
RUMPKERNEL="${OPTARG}"
if [ ${RUMPKERNEL} != "netbsd" -a ${RUMPKERNEL} != "linux" ]; then
echo '>> ERROR:'
echo '>> -r option (RUMPKERNEL) must be netbsd or linux'
exit 1
fi
;;
'o')
RROBJ="${OPTARG}"
;;
Expand Down Expand Up @@ -180,6 +191,8 @@ parseargs ()
DOinstall=true
fi

. rumpkernel/${RUMPKERNEL}.sh

case ${RUMPSRC} in
/*)
;;
Expand All @@ -190,6 +203,7 @@ parseargs ()

export RUMPSRC
export BUILD_QUIET
export RUMPKERNEL

ARGSSHIFT=$((${orignargs} - $#))
}
Expand Down Expand Up @@ -297,6 +311,9 @@ setvars ()
abspath RRDEST
abspath RROBJ
abspath RUMPSRC
abspath LKLSRC
export RROBJ
export LKLSRC
}

checktools ()
Expand Down Expand Up @@ -357,7 +374,7 @@ buildrump ()
-s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING} \
-V MKPIC=no -V RUMP_CURLWP=__thread \
-V RUMP_KERNEL_IS_LIBC=1 -V BUILDRUMP_SYSROOT=yes \
${extracflags} "$@" tools
${extracflags} -l ${RUMPKERNEL} "$@" tools

echo '>>'
echo '>> Now that we have the appropriate tools, performing'
Expand All @@ -367,7 +384,7 @@ buildrump ()
RUMPMAKE=$(pwd)/${RUMPTOOLS}/rumpmake

TOOLTUPLE=$(${RUMPMAKE} -f bsd.own.mk \
-V '${MACHINE_GNU_PLATFORM:S/--netbsd/-rumprun-netbsd/}')
-V '${MACHINE_GNU_PLATFORM:S/--netbsd/-rumprun-${RUMPKERNEL}/}')

[ $(${RUMPMAKE} -f bsd.own.mk -V '${_BUILDRUMP_CXX}') != 'yes' ] \
|| HAVECXX=true
Expand Down Expand Up @@ -406,7 +423,7 @@ EOF
# build rump kernel
${BUILDRUMP}/buildrump.sh ${BUILD_QUIET} ${STDJ} -k \
-s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING} \
"$@" build kernelheaders install
-l ${RUMPKERNEL} "$@" build kernelheaders install

echo '>>'
echo '>> Rump kernel components built. Proceeding to build'
Expand All @@ -421,33 +438,6 @@ buildapptools ()
${MAKE} -C app-tools BUILDRR=true install
}

builduserspace ()
{

usermtree ${STAGING}

LIBS="$(stdlibs ${RUMPSRC})"
! ${HAVECXX} || LIBS="${LIBS} $(stdlibsxx ${RUMPSRC})"

userincludes ${RUMPSRC} ${LIBS} $(pwd)/lib/librumprun_tester
for lib in ${LIBS}; do
makeuserlib ${lib}
done
}

buildpci ()
{

if eval ${PLATFORM_PCI_P}; then
(
cd ${PLATFORMDIR}/pci
${RUMPMAKE} ${STDJ} obj
${RUMPMAKE} ${STDJ} dependall
${RUMPMAKE} ${STDJ} install
)
fi
}

wraponetool ()
{

Expand Down Expand Up @@ -476,6 +466,7 @@ makeconfig ()
echo "TOOLTUPLE=${quote}${TOOLTUPLE}${quote}" >> ${1}
echo "KERNONLY=${quote}${KERNONLY}${quote}" >> ${1}
echo "PLATFORM=${quote}${PLATFORM}${quote}" >> ${1}
echo "RUMPKERNEL=${quote}${RUMPKERNEL}${quote}" >> ${1}

echo "RRDEST=${quote}${RRDEST}${quote}" >> ${1}
echo "RROBJ=${quote}${RROBJ}${quote}" >> ${1}
Expand Down Expand Up @@ -517,7 +508,7 @@ dobuild ()

# do final build of the platform bits
( cd ${PLATFORMDIR} \
&& ${MAKE} BUILDRR=true \
&& ${MAKE} BUILDRR=true RUMPKERNEL=${RUMPKERNEL} \
&& ${MAKE} BUILDRR=true install || exit 1)
[ $? -eq 0 ] || die platform make failed!
}
Expand All @@ -543,11 +534,19 @@ doinstall ()
# first, move things to where we want them to be
cd ${STAGING}
rm -rf lib/pkgconfig
find lib -maxdepth 1 -name librump\*.a \
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
find lib -maxdepth 1 -name \*.a \
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;

if [ ${RUMPKERNEL} = "netbsd" ] ; then
find lib -maxdepth 1 -name librump\*.a \
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
find lib -maxdepth 1 -name \*.a \
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;
elif [ ${RUMPKERNEL} = "linux" ] ; then
find lib -maxdepth 1 -name \*.a \
-exec cp -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
find lib -maxdepth 1 -name \*.a \
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;
# FIXME: need to create empty librump.a for linux
ar rc rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/librump.a
fi
# make sure special cases are visible everywhere
for x in c pthread ; do
rm -f rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/lib${x}.a
Expand Down
2 changes: 1 addition & 1 deletion buildrump.sh
Submodule buildrump.sh updated 5 files
+19 −2 .travis.yml
+31 −175 buildrump.sh
+43 −0 checkout.sh
+93 −0 linux.sh
+175 −0 netbsd.sh
4 changes: 4 additions & 0 deletions include/rumprun-base/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ struct rumprun_exec {
TAILQ_HEAD(rumprun_execs, rumprun_exec);
extern struct rumprun_execs rumprun_execs;

#ifndef __arraycount
#define __arraycount(_ar_) (sizeof(_ar_)/sizeof(_ar_[0]))
#endif

#endif /* _BMKCOMMON_RUMPRUN_CONFIG_H_ */
16 changes: 16 additions & 0 deletions include/rumprun-base/rumprun.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ void rumprun_daemon(void);

extern int rumprun_cold;

#ifndef _STRING
#define _STRING(x) x
#endif

#ifndef __strong_alias
#define __strong_alias(alias,sym) \
__asm(".global " _STRING(#alias) "\n" \
_STRING(#alias) " = " _STRING(#sym));
#endif

#ifndef __weak_alias
#define __weak_alias(alias,sym) \
__asm(".weak " _STRING(#alias) "\n" \
_STRING(#alias) " = " _STRING(#sym));
#endif

#endif /* _RUMPRUN_BASE_RUMPRUN_H_ */
8 changes: 8 additions & 0 deletions lib/libbmk_rumpuser/rumpuser_synch.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ rumpuser_thread_join(void *p)
return 0;
}

/* FIXME */
void *rumpuser_thread_self(void);
void *
rumpuser_thread_self(void)
{
return bmk_current;
}

struct rumpuser_mtx {
struct waithead waiters;
int v;
Expand Down
17 changes: 13 additions & 4 deletions lib/librumprun_base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ LIB= rumprun_base

SRCS= main.c rumprun.c
SRCS+= parseargs.c config.c
SRCS+= malloc.c netbsd_initfini.c signals.c
SRCS+= syscall_mman.c syscall_misc.c
SRCS+= __errno.c _lwp.c libc_stubs.c
SRCS+= daemon.c
SRCS+= malloc.c
SRCS+= __errno.c libc_stubs.c
SRCS+= daemon.c syscall_misc.c

.if ${RUMPKERNEL} == "netbsd"
SRCS+= netbsd_initfini.c signals.c
SRCS+= _lwp.c
SRCS+= syscall_mman.c
SRCS+= sysproxy.c

# doesn't really belong here, but at the moment we don't have
Expand All @@ -14,6 +18,11 @@ SRCS+= platefs.c

INCS= platefs.h
INCSDIR= /usr/include/rumprun
.else
SRCS+= linux_initfini.c
.include "${.CURDIR}/pthread/Makefile.inc"
CFLAGS+= -DCONFIG_LKL -DMUSL_LIBC
.endif

WARNS= 5

Expand Down
Loading

0 comments on commit 5995ebe

Please sign in to comment.