build: use just gcc instead of x86_64-linux-gnu-gcc when host arch == target arch and --gcc-which host

This is particularly important to easily build userland content on host,
as different distros will have different prefixes as mentioned at:
https://github.com/cirosantilli/linux-kernel-module-cheat/issues/66
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-21 00:00:00 +00:00
parent 635e5e3133
commit 878eb0ad98
3 changed files with 11 additions and 4 deletions

View File

@@ -102,7 +102,7 @@ Run `make modules_install` after `make`.
'make', LF, 'make', LF,
'-j', str(self.env['nproc']), LF, '-j', str(self.env['nproc']), LF,
'ARCH={}'.format(self.env['linux_arch']), LF, 'ARCH={}'.format(self.env['linux_arch']), LF,
'CROSS_COMPILE={}-'.format(self.env['toolchain_prefix']), LF, 'CROSS_COMPILE={}'.format(self.env['toolchain_prefix_dash']), LF,
'CC={}'.format(cc), LF, 'CC={}'.format(cc), LF,
'O={}'.format(build_dir), LF, 'O={}'.format(build_dir), LF,
] + verbose ] + verbose

View File

@@ -102,7 +102,7 @@ Place the modules on a separate magic directory from non --host builds.
'ARCH={}'.format(self.env['linux_arch']), LF, 'ARCH={}'.format(self.env['linux_arch']), LF,
'CC={}'.format(cc), LF, 'CC={}'.format(cc), LF,
'CCFLAGS={}'.format(self.sh.cmd_to_string(ccflags)), LF, 'CCFLAGS={}'.format(self.sh.cmd_to_string(ccflags)), LF,
'CROSS_COMPILE={}-'.format(self.env['toolchain_prefix']), LF, 'CROSS_COMPILE={}'.format(self.env['toolchain_prefix_dash']), LF,
'LINUX_DIR={}'.format(linux_dir), LF, 'LINUX_DIR={}'.format(linux_dir), LF,
'M={}'.format(build_subdir), LF, 'M={}'.format(build_subdir), LF,
'OBJECT_FILES={}'.format(' '.join(object_files)), LF, 'OBJECT_FILES={}'.format(' '.join(object_files)), LF,

View File

@@ -949,7 +949,10 @@ lunch aosp_{}-eng
env['crosstool_ng_toolchain_prefix'] env['crosstool_ng_toolchain_prefix']
) )
elif env['gcc_which'] == 'host': elif env['gcc_which'] == 'host':
env['toolchain_prefix'] = env['ubuntu_toolchain_prefix'] if env['arch'] == env['host_arch']:
env['toolchain_prefix'] = ''
else:
env['toolchain_prefix'] = env['ubuntu_toolchain_prefix']
if env['arch'] == 'x86_64': if env['arch'] == 'x86_64':
env['userland_library_dir'] = '/' env['userland_library_dir'] = '/'
elif env['arch'] == 'arm': elif env['arch'] == 'arm':
@@ -964,6 +967,10 @@ lunch aosp_{}-eng
raise Exception('There is no host baremetal chain for arch: ' + env['arch']) raise Exception('There is no host baremetal chain for arch: ' + env['arch'])
else: else:
raise Exception('Unknown toolchain: ' + env['gcc_which']) raise Exception('Unknown toolchain: ' + env['gcc_which'])
if env['toolchain_prefix'] == '':
env['toolchain_prefix_dash'] = ''
else:
env['toolchain_prefix_dash'] = '{}-'.format(env['toolchain_prefix'])
env['gcc_path'] = self.get_toolchain_tool('gcc') env['gcc_path'] = self.get_toolchain_tool('gcc')
env['gxx_path'] = self.get_toolchain_tool('g++') env['gxx_path'] = self.get_toolchain_tool('g++')
env['ld_path'] = self.get_toolchain_tool('ld') env['ld_path'] = self.get_toolchain_tool('ld')
@@ -1062,7 +1069,7 @@ lunch aosp_{}-eng
return ret return ret
def get_toolchain_tool(self, tool): def get_toolchain_tool(self, tool):
return '{}-{}'.format(self.env['toolchain_prefix'], tool) return '{}{}'.format(self.env['toolchain_prefix_dash'], tool)
def github_make_request( def github_make_request(
self, self,