Skip to content

Commit 5a1633f

Browse files
committed
initial support for building linux kernel with buildrump.sh
This commit introduces a new options for buildrump.sh, which is '-l' option to specify which rumpkernel (netbsd or linux) is used (default: netbsd). Linux kernel is based on Linux Kernel Library (LKL) with non-upstreamed patches to implement with rump hypercall interfaces. Since LKL is not yet upstreamed to Linus tree and development is still ongoing, the commit tries to minimize future modifications to this script (buildrump.sh) by specifying interfaces to build Linux kernel. The new rumpkernel support involves the script structure refactor to split each rumpkernel dependent commands into separate files (netbsd.sh and linux.sh). Currently, when '-l' option is specified, NetBSD rump kernel code will be also built in addition to Linux kernel build since Linux part requires headers files (i.e., include/rump) to build it. A few more travis tests are also added though it's only build tests and no execution tests for Linux at this moment though. Plus, clang build is marked as 'allow_failure' since Linux kernel isn't able to build with clang so far. There are still a couple of limitations: - LKL_SRCDIR is hardcoded, which uses the current dir of the (root) script. - only build with standalone buildrump.sh. standalone execution (i.e., without rumprun or frankenlibc) are not implemented since LKL itself has to do it. - thus, no standalone test are implemented either. Signed-off-by: Hajime Tazaki <[email protected]>
1 parent 9c9b022 commit 5a1633f

File tree

5 files changed

+350
-177
lines changed

5 files changed

+350
-177
lines changed

.travis.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
language: c
2+
addons:
3+
apt:
4+
packages:
5+
- bc
6+
- libfuse-dev
7+
- libarchive-dev
8+
- xfsprogs
9+
- btrfs-tools
210

311
compiler:
412
- gcc
@@ -7,17 +15,26 @@ compiler:
715
sudo: false
816

917
before_script:
10-
- ./buildrump.sh checkout
18+
- ./buildrump.sh ${RUMPKERNEL} checkout
1119

1220
env:
1321
- NAME='static' LIBTYPE='MKPIC=no' BUILDTYPE='' TESTS='tests'
1422
- NAME='dynamic' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='' TESTS='tests'
1523
- NAME='debug' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-DDD' TESTS='tests'
1624
- NAME='release' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-r' TESTS='tests'
1725
- NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS=''
26+
- NAME='dynamic' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='' TESTS='' RUMPKERNEL='-l linux'
27+
- NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS='' RUMPKERNEL='-l linux'
28+
29+
matrix:
30+
allow_failures:
31+
- compiler: clang
32+
env: NAME='dynamic' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='' TESTS='' RUMPKERNEL='-l linux'
33+
- compiler: clang
34+
env: NAME='fibers' LIBTYPE='MKSTATICLIB=no' BUILDTYPE='-V RUMPUSER_THREADS=fiber -V RUMP_CURLWP=hypercall' TESTS='' RUMPKERNEL='-l linux'
1835

1936
script:
20-
- ./buildrump.sh -o obj.${NAME} -d rump.${NAME} -qq -j16 -V ${LIBTYPE} ${BUILDTYPE} fullbuild ${TESTS}
37+
- ./buildrump.sh ${RUMPKERNEL} -o obj.${NAME} -d rump.${NAME} -qq -j16 -V ${LIBTYPE} ${BUILDTYPE} fullbuild ${TESTS}
2138

2239
notifications:
2340
irc:

buildrump.sh

Lines changed: 31 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ helpme ()
6969
printf "\t-r: release build (no -g, DIAGNOSTIC, etc.). default: no\n"
7070
printf "\t-D: increase debugginess. default: -O2 -g\n"
7171
printf "\t-k: only kernel (no POSIX hypercalls). default: all\n"
72+
printf "\t-l: choose a rumpkernel: netbsd or linux. default: netbsd\n"
7273
echo
7374
printf "\t-H: ignore diagnostic checks (expert-only). default: no\n"
7475
printf "\t-V: specify -V arguments to NetBSD build (expert-only)\n"
@@ -289,19 +290,6 @@ doesitcxx ()
289290
-x c++ - -o /dev/null $* > /dev/null 2>&1
290291
}
291292

292-
checkcheckout ()
293-
{
294-
295-
[ -x "${SRCDIR}/build.sh" ] || die "Cannot find ${SRCDIR}/build.sh!"
296-
297-
[ ! -z "${TARBALLMODE}" ] && return
298-
299-
if ! ${BRDIR}/checkout.sh checkcheckout ${SRCDIR} \
300-
&& ! ${TITANMODE}; then
301-
die 'revision mismatch, run checkout (or -H to override)'
302-
fi
303-
}
304-
305293
checkcompiler ()
306294
{
307295

@@ -556,6 +544,7 @@ int main() {gzopen(NULL, NULL); return 0;}' -lz \
556544
else
557545
cppname=cpp
558546
fi
547+
# NB: we need rumpmake to build libbmk_*, but rumpmake needs --netbsd TOOLTUPLES
559548
tname=${BRTOOLDIR}/bin/${MACHINE_GNU_ARCH}--netbsd${TOOLABI}-${cppname}
560549
printf '#!/bin/sh\n\nexec %s -E -x c "${@}"\n' ${CC} > ${tname}
561550
chmod 755 ${tname}
@@ -616,8 +605,8 @@ EOF
616605
appendmkconf Cmd yes RUMPKERN_ONLY
617606
fi
618607

619-
if ${KERNONLY} && ! cppdefines __NetBSD__; then
620-
appendmkconf 'Cmd' '-D__NetBSD__' 'CPPFLAGS' +
608+
if ${KERNONLY} && ! cppdefines ${RUMPKERN_CPPFLAGS}; then
609+
appendmkconf 'Cmd' "${RUMPKERN_CPPFLAGS}" 'CPPFLAGS' +
621610
appendmkconf 'Probe' "${RUMPKERN_UNDEF}" 'CPPFLAGS' +
622611
else
623612
appendmkconf 'Probe' "${RUMPKERN_UNDEF}" "RUMPKERN_UNDEF"
@@ -654,8 +643,8 @@ EOF
654643
exec 3>&1 1>${BRTOOLDIR}/toolchain-conf.mk
655644
printf 'BUILDRUMP_TOOL_CFLAGS=%s\n' "${EXTRA_CFLAGS}"
656645
printf 'BUILDRUMP_TOOL_CXXFLAGS=%s\n' "${EXTRA_CFLAGS}"
657-
printf 'BUILDRUMP_TOOL_CPPFLAGS=-D__NetBSD__ %s %s\n' \
658-
"${EXTRA_CPPFLAGS}" "${RUMPKERN_UNDEF}"
646+
printf 'BUILDRUMP_TOOL_CPPFLAGS=%s %s %s\n' \
647+
"${RUMPKERN_CPPFLAGS}" "${EXTRA_CPPFLAGS}" "${RUMPKERN_UNDEF}"
659648
exec 1>&3 3>&-
660649

661650
chkcrt begins
@@ -754,120 +743,6 @@ makemake ()
754743
[ $? -ne 0 ] && die build.sh ${cmd} failed
755744
}
756745

757-
makebuild ()
758-
{
759-
760-
checkcheckout
761-
762-
# ensure we're in SRCDIR, in case "tools" wasn't run
763-
cd ${SRCDIR}
764-
765-
targets="obj includes dependall install"
766-
767-
#
768-
# Building takes 4 passes, just like when
769-
# building NetBSD the regular way. The passes are:
770-
# 1) obj
771-
# 2) includes
772-
# 3) dependall
773-
# 4) install
774-
#
775-
776-
DIRS_first='lib/librumpuser'
777-
DIRS_second='lib/librump'
778-
DIRS_third="lib/librumpdev lib/librumpnet lib/librumpvfs
779-
sys/rump/dev sys/rump/fs sys/rump/kern sys/rump/net
780-
sys/rump/include ${BRDIR}/brlib"
781-
782-
# sys/rump/share was added to ${SRCDIR} 11/2014
783-
[ -d ${SRCDIR}/sys/rump/share ] \
784-
&& appendvar DIRS_second ${SRCDIR}/sys/rump/share
785-
786-
if [ ${MACHINE} = "i386" -o ${MACHINE} = "amd64" \
787-
-o ${MACHINE#evbearm} != ${MACHINE} \
788-
-o ${MACHINE#evbppc} != ${MACHINE} ]; then
789-
DIRS_emul=sys/rump/kern/lib/libsys_linux
790-
fi
791-
${SYS_SUNOS} && appendvar DIRS_emul sys/rump/kern/lib/libsys_sunos
792-
if ${HIJACK}; then
793-
DIRS_final="lib/librumphijack"
794-
else
795-
DIRS_final=
796-
fi
797-
798-
DIRS_third="${DIRS_third} ${DIRS_emul}"
799-
800-
if ${KERNONLY}; then
801-
mkmakefile ${OBJDIR}/Makefile.all \
802-
sys/rump ${DIRS_emul} ${BRDIR}/brlib
803-
else
804-
DIRS_third="lib/librumpclient ${DIRS_third}"
805-
806-
mkmakefile ${OBJDIR}/Makefile.first ${DIRS_first}
807-
mkmakefile ${OBJDIR}/Makefile.second ${DIRS_second}
808-
mkmakefile ${OBJDIR}/Makefile.third ${DIRS_third}
809-
mkmakefile ${OBJDIR}/Makefile.final ${DIRS_final}
810-
mkmakefile ${OBJDIR}/Makefile.all \
811-
${DIRS_first} ${DIRS_second} ${DIRS_third} ${DIRS_final}
812-
fi
813-
814-
# try to minimize the amount of domake invocations. this makes a
815-
# difference especially on systems with a large number of slow cores
816-
for target in ${targets}; do
817-
if [ ${target} = "dependall" ] && ! ${KERNONLY}; then
818-
domake ${OBJDIR}/Makefile.first ${target}
819-
domake ${OBJDIR}/Makefile.second ${target}
820-
domake ${OBJDIR}/Makefile.third ${target}
821-
domake ${OBJDIR}/Makefile.final ${target}
822-
else
823-
domake ${OBJDIR}/Makefile.all ${target}
824-
fi
825-
done
826-
827-
if ! ${KERNONLY}; then
828-
mkmakefile ${OBJDIR}/Makefile.utils \
829-
usr.bin/rump_server usr.bin/rump_allserver \
830-
usr.bin/rump_wmd
831-
for target in ${targets}; do
832-
domake ${OBJDIR}/Makefile.utils ${target}
833-
done
834-
fi
835-
}
836-
837-
makeinstall ()
838-
{
839-
840-
# ensure we run this in a directory that does not have a
841-
# Makefile that could confuse rumpmake
842-
stage=$(cd ${BRTOOLDIR} && ${RUMPMAKE} -V '${BUILDRUMP_STAGE}')
843-
(cd ${stage}/usr ; tar -cf - .) | (cd ${DESTDIR} ; tar -xf -)
844-
}
845-
846-
#
847-
# install kernel headers.
848-
# Note: Do _NOT_ do this unless you want to install a
849-
# full rump kernel application stack
850-
#
851-
makekernelheaders ()
852-
{
853-
854-
dodirs=$(cd ${SRCDIR}/sys && \
855-
${RUMPMAKE} -V '${SUBDIR:Narch:Nmodules:Ncompat:Nnetnatm}' includes)
856-
# missing some architectures
857-
appendvar dodirs arch/amd64/include arch/i386/include arch/x86/include
858-
appendvar dodirs arch/arm/include arch/arm/include/arm32
859-
appendvar dodirs arch/evbarm64/include arch/aarch64/include
860-
appendvar dodirs arch/evbppc/include arch/powerpc/include
861-
appendvar dodirs arch/evbmips/include arch/mips/include
862-
appendvar dodirs arch/riscv/include
863-
for dir in ${dodirs}; do
864-
(cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} obj)
865-
(cd ${SRCDIR}/sys/${dir} && ${RUMPMAKE} includes)
866-
done
867-
# create machine symlink
868-
(cd ${SRCDIR}/sys/arch && ${RUMPMAKE} NOSUBDIR=1 includes)
869-
}
870-
871746
settool ()
872747
{
873748

@@ -1036,7 +911,9 @@ evaltoolchain ()
1036911

1037912
case ${CC_TARGET} in
1038913
*-linux*)
1039-
RUMPKERN_UNDEF='-Ulinux -U__linux -U__linux__ -U__gnu_linux__'
914+
if [ ${RUMPKERNEL} != "linux" ]; then
915+
RUMPKERN_UNDEF='-Ulinux -U__linux -U__linux__ -U__gnu_linux__'
916+
fi
1040917
cppdefines _BIG_ENDIAN \
1041918
&& appendvar RUMPKERN_UNDEF -U_BIG_ENDIAN
1042919
cppdefines _LITTLE_ENDIAN \
@@ -1353,12 +1230,14 @@ parseargs ()
13531230
NOISE=2
13541231
debugginess=0
13551232
KERNONLY=false
1233+
RUMPKERNEL=netbsd
13561234
OBJDIR=./obj
13571235
DESTDIR=./rump
13581236
SRCDIR=./src
1237+
LKL_SRCDIR=./linux
13591238
JNUM=4
13601239

1361-
while getopts 'd:DhHj:ko:qrs:T:V:F:' opt; do
1240+
while getopts 'd:DhHj:kl:o:qrs:T:V:F:' opt; do
13621241
case "$opt" in
13631242
d)
13641243
DESTDIR=${OPTARG}
@@ -1419,6 +1298,9 @@ parseargs ()
14191298
k)
14201299
KERNONLY=true
14211300
;;
1301+
l)
1302+
RUMPKERNEL=${OPTARG}
1303+
;;
14221304
o)
14231305
OBJDIR=${OPTARG}
14241306
;;
@@ -1451,6 +1333,14 @@ parseargs ()
14511333
done
14521334
shift $((${OPTIND} - 1))
14531335

1336+
# load rump kernel specific scripts
1337+
if [ ${RUMPKERNEL} != "netbsd" -a ${RUMPKERNEL} != "linux" ]; then
1338+
echo '>> ERROR:'
1339+
echo '>> -l option (RUMPKERNEL) must be netbsd or linux'
1340+
exit 1
1341+
fi
1342+
. ${BRDIR}/${RUMPKERNEL}.sh
1343+
14541344
DBG="${F_DBG:-${DBG}}"
14551345

14561346
BEQUIET="-N${NOISE}"
@@ -1508,6 +1398,10 @@ parseargs ()
15081398
docheckout=true
15091399
checkoutstyle=cvs
15101400
fi
1401+
if ${docheckout} && [ ${RUMPKERNEL} = "linux" ] ; then
1402+
docheckout=true
1403+
checkoutstyle=linux-git
1404+
fi
15111405

15121406
# sanity checks
15131407
if [ ! -z "${TARBALLMODE}" ]; then
@@ -1542,6 +1436,7 @@ resolvepaths ()
15421436

15431437
abspath BRTOOLDIR
15441438
abspath SRCDIR
1439+
[ "${RUMPKERNEL}" = "linux" ] && abspath LKL_SRCDIR
15451440

15461441
RUMPMAKE="${BRTOOLDIR}/bin/brrumpmake"
15471442
BRIMACROS="${BRTOOLDIR}/include/opt_buildrump.h"
@@ -1572,40 +1467,7 @@ resolvepaths ()
15721467
done
15731468
}
15741469

1575-
# create the makefiles used for building
1576-
mkmakefile ()
1577-
{
15781470

1579-
makefile=$1
1580-
shift
1581-
exec 3>&1 1>${makefile}
1582-
printf '# GENERATED FILE, MIGHT I SUGGEST NOT EDITING?\n'
1583-
printf 'SUBDIR='
1584-
for dir in $*; do
1585-
case ${dir} in
1586-
/*)
1587-
printf ' %s' ${dir}
1588-
;;
1589-
*)
1590-
printf ' %s' ${SRCDIR}/${dir}
1591-
;;
1592-
esac
1593-
done
1594-
1595-
printf '\n.include <bsd.subdir.mk>\n'
1596-
exec 1>&3 3>&-
1597-
}
1598-
1599-
domake ()
1600-
{
1601-
1602-
mkfile=${1}; shift
1603-
mktarget=${1}; shift
1604-
1605-
[ ! -x ${RUMPMAKE} ] && die "No rumpmake (${RUMPMAKE}). Forgot tools?"
1606-
${RUMPMAKE} $* -j ${JNUM} -f ${mkfile} ${mktarget}
1607-
[ $? -eq 0 ] || die "make $mkfile $mktarget"
1608-
}
16091471

16101472
###
16111473
###
@@ -1624,7 +1486,7 @@ done
16241486

16251487
parseargs "$@"
16261488

1627-
${docheckout} && { ${BRDIR}/checkout.sh ${checkoutstyle} ${SRCDIR} || exit 1; }
1489+
${docheckout} && { ${BRDIR}/checkout.sh ${checkoutstyle} ${SRCDIR} ${LKL_SRCDIR} || exit 1; }
16281490

16291491
if ${doprobe} || ${dotools} || ${dobuild} || ${dokernelheaders} \
16301492
|| ${doinstall} || ${dotests}; then
@@ -1635,20 +1497,14 @@ if ${doprobe} || ${dotools} || ${dobuild} || ${dokernelheaders} \
16351497

16361498
${KERNONLY} || evalplatform
16371499

1500+
export RUMPKERNEL
16381501
${doprobe} && writeproberes
16391502
${dotools} && maketools
16401503
${dobuild} && makebuild
16411504
${dokernelheaders} && makekernelheaders
16421505
${doinstall} && makeinstall
16431506

1644-
if ${dotests}; then
1645-
if ${KERNONLY}; then
1646-
diagout 'Kernel-only; skipping tests (no hypervisor)'
1647-
else
1648-
. ${BRDIR}/tests/testrump.sh
1649-
alltests
1650-
fi
1651-
fi
1507+
${dotests} && maketests
16521508
fi
16531509

16541510
diagout buildrump.sh ran successfully

0 commit comments

Comments
 (0)