From b478346818d72c78da32adffdda18491456cc3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] common: make multi arch actually work for builds userland: create --static to make build a bit easier Manually forward --dry-run to test-userland. --- README.adoc | 10 ++++++---- build-userland | 13 ++++++++++++- common.py | 8 ++++---- test-gdb | 4 ++-- test-userland | 9 ++++++++- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.adoc b/README.adoc index ae8cd58..982d8b4 100644 --- a/README.adoc +++ b/README.adoc @@ -2944,7 +2944,7 @@ You can also try statically linked executables with: .... ./build-userland \ --arch aarch64 \ - --make-args='CCFLAGS_EXTRA=-static' \ + --static \ --userland-build-id static \ ; ./run \ @@ -2961,7 +2961,7 @@ Or you can run statically linked built by the host packaged toolchain with: ./build-userland \ --arch aarch64 \ --host \ - --make-args='-B CFLAGS_EXTRA=-static' \ + --static \ --userland-build-id host-static \ ; ./run \ @@ -3036,8 +3036,8 @@ So let's just play with some static ones: .... ./build-userland \ --arch aarch64 \ + --static \ --userland-build-id static \ - --make-args='CCFLAGS_EXTRA=-static' \ ; ./run \ --arch aarch64 \ @@ -3158,7 +3158,9 @@ Result on <> at bad30f513c46c1b0995d3a10c0d9bc2a33dc4fa0: Automatically run non-interactive userland tests that don't depend on nay kernel modules: .... -./test-userland +./build-userland --all-archs +./build-userland --all-archs --static --userland-build-id static +./test-userland --all-archs .... Source: link:test-userland[] diff --git a/build-userland b/build-userland index 749e3e5..37a1dfa 100755 --- a/build-userland +++ b/build-userland @@ -34,6 +34,14 @@ Use the host packaged cross toolchain. '--make-args', default='', ) + 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=[], @@ -55,6 +63,9 @@ has the OpenBLAS libraries and headers installed. allowed_toolchains = ['buildroot'] 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( ( [ @@ -70,7 +81,7 @@ has the OpenBLAS libraries and headers installed. 'OUT_DIR={}'.format(build_dir), LF, ] + self.sh.add_newlines(['HAS_{}=y'.format(package.upper()) for package in self.env['has_package']]) + - shlex.split(self.env['make_args']) + + 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=self.env['userland_source_dir'], diff --git a/common.py b/common.py index 6994531..6672baa 100644 --- a/common.py +++ b/common.py @@ -728,7 +728,7 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`. if not env['dry_run']: end_time = time.time() self._print_time(end_time - start_time) - if ret != 0: + if ret is not None and ret != 0: return ret return 0 @@ -802,8 +802,7 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`. argcopy.__dict__ = dict(list(defaults.items()) + list(argcopy.__dict__.items()) + list(extra_args.items())) return argcopy - @staticmethod - def resolve_executable(in_path, magic_in_dir, magic_out_dir, out_ext): + def resolve_executable(self, in_path, magic_in_dir, magic_out_dir, out_ext): if os.path.isabs(in_path): return in_path else: @@ -818,7 +817,8 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`. for path in paths: if os.path.exists(path): return path - raise Exception('Executable file not found. Tried:\n' + '\n'.join(paths)) + if not self.env['dry_run']: + raise Exception('Executable file not found. Tried:\n' + '\n'.join(paths)) def resolve_userland(self, path): return self.resolve_executable( diff --git a/test-gdb b/test-gdb index 962d17e..9af1fc8 100755 --- a/test-gdb +++ b/test-gdb @@ -25,7 +25,7 @@ class Main(common.LkmcCliFunction): test_scripts_noext.append(relpath) for test_script_noext in test_scripts_noext: run_thread = threading.Thread(target=lambda: run( - arch=arch, + archs=[arch], background=True, baremetal=test_script_noext, emulator=emulator, @@ -33,7 +33,7 @@ class Main(common.LkmcCliFunction): )) run_thread.start() run_gdb( - arch=arch, + archs=[arch], baremetal=test_script_noext, emulator=emulator, test=True, diff --git a/test-userland b/test-userland index 5e81337..ecca540 100755 --- a/test-userland +++ b/test-userland @@ -33,11 +33,18 @@ class Main(common.LkmcCliFunction): arch_sources[:] = [os.path.join('arch', self.env['arch'], arch_source) for arch_source in arch_sources] for source in sources + arch_sources: exit_status = run( - archs=self.env['archs'], + archs=[self.env['arch']], + dry_run=self.env['dry_run'], userland=source, emulator=emulator, **extra_args, ) + # TODO forward all args attempt. In particular, --dry-run. + #new_env = self.env.copy() + #new_env['userland'] = source + #new_env['emulator'] = emulator + #new_env.update(extra_args) + #exit_status = run(**new_env) if exit_status != 0: raise Exception('Test failed: {} {} {} {}'.format(emulator, arch, source, exit_status))