LKMC v3.0

This is a squash commit, the unsquashed development went through many
unstable phases which would break bisects. The unsquashed branch is:
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/v3.0-unsquash

The main improvement of this release was to greatly generalize the testing system.

The key addition was cli_function.py, which allows scripts such as ./run to
be transparently called either from Python or from the command line.

New tests scripts were created using this improved framework: test-baremetal
and test-user-mode.

We were lazy to port some of less important tests to the new setup, TODO's were
added, and we need comes they will be fixed. Getting started is however sacred
as usual and should work.

Other changes include:

-   gem5: update to 7fa4c946386e7207ad5859e8ade0bbfc14000d91

-   run: --tmux-args implies --tmux

-   run: add --userland-args to make userland arguments across QEMU and gem5

    Get rid of --userland-before as a consequence.

-   bring initrd and initramfs back to life

-   build-userland: create --static to make build a bit easier

-   gem5: --gem5-worktree also set --gem5-build-id

-   remove --gem5, use --emulator gem5 everywhere

    Allow passing --emulator multiple times for transparent tests selection
    just like --arch.

-   test-userland: allow selecting just a few tests

-   linux: update to v4.20

-   buildroot: update to 2018.08

    The main motivation for this was to fix the build for Ubuntu 18.10, which
    has glibc 2.28, which broke the 2018.05 build at the m4-host package with:

        #error "Please port gnulib fseeko.c to your platform!

-   getvar --type input

-   failed xen attempt, refactor timer, failed svc attempt, aarch64 use gicv3

-   build-doc: exit 1 on error, add to release testing

-   build: add --apt option to make things easier on other distros

-   build-linux: --no-modules-install
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-01-22 00:00:00 +00:00
parent 3b0a343647
commit da900a579c
86 changed files with 5241 additions and 3543 deletions

View File

@@ -1,16 +1,19 @@
#!/usr/bin/env python3
import os
import platform
import shlex
import shutil
import subprocess
import common
from shell_helpers import LF
class UserlandComponent(common.Component):
def add_parser_arguments(self, parser):
parser.add_argument(
class Main(common.BuildCliFunction):
def __init__(self):
super().__init__(
description='''\
Build our compiled userland examples.
'''
)
self.add_argument(
'--has-package',
action='append',
default=[],
@@ -19,20 +22,27 @@ Indicate that a given package is present in the root filesystem, which
allows us to build examples that rely on it.
''',
)
parser.add_argument(
self.add_argument(
'--host',
action='store_true',
default=False,
help='''\
Build the userland programs for the host instead of guest.
Use the host packaged cross toolchain.
''',
)
parser.add_argument(
self.add_argument(
'--make-args',
default='',
)
parser.add_argument(
self.add_argument(
'--static',
default=False,
help='''\
Build the executables statically. TODO not implemented: Set the build id to 'static'
if one was not given explicitly.
''',
)
self.add_argument(
'targets',
default=[],
help='''\
@@ -44,49 +54,47 @@ has the OpenBLAS libraries and headers installed.
nargs='*',
)
def do_build(self, args):
build_dir = self.get_build_dir(args)
def build(self):
build_dir = self.get_build_dir()
os.makedirs(build_dir, exist_ok=True)
if args.host:
if self.env['host']:
allowed_toolchains = ['host']
else:
allowed_toolchains = ['buildroot']
cc = common.get_toolchain_tool('gcc', allowed_toolchains=allowed_toolchains)
cxx = common.get_toolchain_tool('g++', allowed_toolchains=allowed_toolchains)
common.run_cmd(
cc = self.get_toolchain_tool('gcc', allowed_toolchains=allowed_toolchains)
cxx = self.get_toolchain_tool('g++', allowed_toolchains=allowed_toolchains)
make_args = shlex.split(self.env['make_args'])
if self.env['static']:
make_args.extend(['CCFLAGS_EXTRA=-static', LF])
self.sh.run_cmd(
(
[
'make', common.Newline,
'-j', str(args.nproc), common.Newline,
'ARCH={}'.format(args.arch), common.Newline,
'CCFLAGS_SCRIPT={} {}'.format('-I', common.userland_src_dir), common.Newline,
'COMMON_DIR={}'.format(common.root_dir), common.Newline,
'CC={}'.format(cc), common.Newline,
'CXX={}'.format(cxx), common.Newline,
'PKG_CONFIG={}'.format(common.buildroot_pkg_config), common.Newline,
'STAGING_DIR={}'.format(common.buildroot_staging_dir), common.Newline,
'OUT_DIR={}'.format(build_dir), common.Newline,
'make', LF,
'-j', str(self.env['nproc']), LF,
'ARCH={}'.format(self.env['arch']), LF,
'CCFLAGS_SCRIPT={} {}'.format('-I', self.env['userland_source_dir']), LF,
'COMMON_DIR={}'.format(self.env['root_dir']), LF,
'CC={}'.format(cc), LF,
'CXX={}'.format(cxx), LF,
'PKG_CONFIG={}'.format(self.env['buildroot_pkg_config']), LF,
'STAGING_DIR={}'.format(self.env['buildroot_staging_dir']), LF,
'OUT_DIR={}'.format(build_dir), LF,
] +
common.add_newlines(['HAS_{}=y'.format(package.upper()) for package in args.has_package]) +
shlex.split(args.make_args) +
common.add_newlines([os.path.join(build_dir, os.path.splitext(os.path.split(target)[1])[0]) + common.userland_build_ext for target in args.targets])
self.sh.add_newlines(['HAS_{}=y'.format(package.upper()) for package in self.env['has_package']]) +
make_args +
self.sh.add_newlines([os.path.join(build_dir, os.path.splitext(os.path.split(target)[1])[0]) + self.env['userland_build_ext'] for target in self.env['targets']])
),
cwd=common.userland_src_dir,
extra_paths=[common.ccache_dir],
cwd=self.env['userland_source_dir'],
extra_paths=[self.env['ccache_dir']],
)
common.copy_dir_if_update_non_recursive(
self.sh.copy_dir_if_update_non_recursive(
srcdir=build_dir,
destdir=common.out_rootfs_overlay_dir,
filter_ext=common.userland_build_ext,
destdir=self.env['out_rootfs_overlay_dir'],
filter_ext=self.env['userland_build_ext'],
)
def get_argparse_args(self):
return {
'description': 'Build our compiled userland examples',
}
def get_build_dir(self, args):
return common.userland_build_dir
def get_build_dir(self):
return self.env['userland_build_dir']
if __name__ == '__main__':
UserlandComponent().build()
Main().cli()