From 878eb0ad9837997247ce08479df080a06b035637 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, 21 May 2019 00:00:00 +0000 Subject: [PATCH] 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 --- build-linux | 2 +- build-modules | 2 +- common.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build-linux b/build-linux index a49f6f6..773775f 100755 --- a/build-linux +++ b/build-linux @@ -102,7 +102,7 @@ Run `make modules_install` after `make`. 'make', LF, '-j', str(self.env['nproc']), 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, 'O={}'.format(build_dir), LF, ] + verbose diff --git a/build-modules b/build-modules index 6f1b344..bef0bfb 100755 --- a/build-modules +++ b/build-modules @@ -102,7 +102,7 @@ Place the modules on a separate magic directory from non --host builds. 'ARCH={}'.format(self.env['linux_arch']), LF, 'CC={}'.format(cc), 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, 'M={}'.format(build_subdir), LF, 'OBJECT_FILES={}'.format(' '.join(object_files)), LF, diff --git a/common.py b/common.py index 94f011b..dcb5b27 100644 --- a/common.py +++ b/common.py @@ -949,7 +949,10 @@ lunch aosp_{}-eng env['crosstool_ng_toolchain_prefix'] ) 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': env['userland_library_dir'] = '/' elif env['arch'] == 'arm': @@ -964,6 +967,10 @@ lunch aosp_{}-eng raise Exception('There is no host baremetal chain for arch: ' + env['arch']) else: 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['gxx_path'] = self.get_toolchain_tool('g++') env['ld_path'] = self.get_toolchain_tool('ld') @@ -1062,7 +1069,7 @@ lunch aosp_{}-eng return ret 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( self,