mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 03:31:36 +01:00
common: make multi arch actually work for builds
userland: create --static to make build a bit easier Manually forward --dry-run to test-userland.
This commit is contained in:
10
README.adoc
10
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 <<p51>> 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[]
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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(
|
||||
|
||||
4
test-gdb
4
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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user