mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
Make --host work for ./build-userland, ./build-dhrystone, etc. in addition to just ./build-modules
This commit is contained in:
13
README.adoc
13
README.adoc
@@ -921,7 +921,7 @@ It has however severe limitations:
|
||||
Still interested?
|
||||
|
||||
....
|
||||
./build-modules --gcc-which host --host
|
||||
./build-modules --host
|
||||
....
|
||||
|
||||
Compilation will likely fail for some modules because of kernel or toolchain differences that we can't control on the host.
|
||||
@@ -929,7 +929,7 @@ Compilation will likely fail for some modules because of kernel or toolchain dif
|
||||
The best workaround is to compile just your modules with:
|
||||
|
||||
....
|
||||
./build-modules --gcc-which host --host -- hello hello2
|
||||
./build-modules --host -- hello hello2
|
||||
....
|
||||
|
||||
which is equivalent to:
|
||||
@@ -14514,6 +14514,8 @@ git submodule update --init submodules/dhrystone
|
||||
./run --userland "$(./getvar userland_build_dir)/submodules/dhrystone/dhrystone"
|
||||
....
|
||||
|
||||
TODO automate run more nicely to dispense `getvar`.
|
||||
|
||||
Increase the number of loops to try and reach more meaningful results:
|
||||
|
||||
....
|
||||
@@ -14527,7 +14529,12 @@ Build and run on gem5 user mode:
|
||||
./run --emulator gem5 --userland "$(./getvar --static userland_build_dir)/submodules/dhrystone/dhrystone"
|
||||
....
|
||||
|
||||
TODO automate run more nicely.
|
||||
Run natively on the host:
|
||||
|
||||
....
|
||||
./build-dhrystone --host
|
||||
"$(./getvar --host userland_build_dir)/submodules/dhrystone/dhrystone"
|
||||
....
|
||||
|
||||
Build for <<baremetal>> execution and run it in baremetal QEMU. TODO: fix the build, just need to factor out all run arguments from link:build-baremetal[] into link:common.py[] and it should just work, no missing syscalls.
|
||||
|
||||
|
||||
@@ -23,14 +23,6 @@ See also: https://cirosantilli.com/linux-kernel-module-cheat#host
|
||||
default='',
|
||||
help='''
|
||||
Pass custom options to make.
|
||||
''',
|
||||
)
|
||||
self.add_argument(
|
||||
'--host',
|
||||
default=False,
|
||||
help='''\
|
||||
Build the Linux kernel modules against the host kernel.
|
||||
Place the modules on a separate magic directory from non --host builds.
|
||||
''',
|
||||
)
|
||||
self._add_argument('--force-rebuild')
|
||||
|
||||
17
common.py
17
common.py
@@ -499,6 +499,17 @@ options are given, for example --static, since users don't usually want
|
||||
static executables to be placed in the final image, but rather only for
|
||||
user mode simulations in simulators that don't support dynamic linking like gem5.
|
||||
'''
|
||||
)
|
||||
self.add_argument(
|
||||
'--host',
|
||||
default=False,
|
||||
help='''\
|
||||
Use the host toolchain and other dependencies to build exectuables for host execution.
|
||||
Automatically place the build output on a separate directory from non --host builds,
|
||||
e.g. by defaulting --userland-build-id host if that option has effect for the package.
|
||||
Make --copy-overlay default to False as the generated executables can't in general
|
||||
be run in the guest.
|
||||
''',
|
||||
)
|
||||
self.add_argument(
|
||||
'--out-rootfs-overlay-dir-prefix',
|
||||
@@ -694,6 +705,8 @@ Incompatible archs are skipped.
|
||||
if not env['_args_given']['userland_build_id']:
|
||||
if env['static']:
|
||||
env['userland_build_id'] = 'static'
|
||||
elif env['host']:
|
||||
env['userland_build_id'] = 'host'
|
||||
else:
|
||||
env['userland_build_id'] = env['default_build_id']
|
||||
if not env['_args_given']['gem5_build_id']:
|
||||
@@ -954,7 +967,7 @@ Incompatible archs are skipped.
|
||||
env['userland_build_dir'] = join(env['out_dir'], 'userland', env['userland_build_id'], env['arch'])
|
||||
env['package'] = set(env['package'])
|
||||
if not env['_args_given']['copy_overlay']:
|
||||
if self.env['in_tree'] or self.env['static']:
|
||||
if self.env['in_tree'] or self.env['static'] or self.env['host']:
|
||||
env['copy_overlay'] = False
|
||||
|
||||
# Kernel modules.
|
||||
@@ -1082,6 +1095,8 @@ lunch aosp_{}-eng
|
||||
if not env['_args_given']['gcc_which']:
|
||||
if env['mode'] == 'baremetal':
|
||||
env['gcc_which'] = 'crosstool-ng'
|
||||
elif env['host']:
|
||||
env['gcc_which'] = 'host'
|
||||
if env['gcc_which'] == 'buildroot':
|
||||
env['toolchain_prefix'] = os.path.join(
|
||||
env['buildroot_host_bin_dir'],
|
||||
|
||||
Reference in New Issue
Block a user