From c93aa8c5689821719179d07df853a2a7241b003a Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 20 Sep 2019 16:35:33 +0300 Subject: [PATCH] waifulib: xcompile: preserve order of MACROS_TO_DESTOS, add -stdlib=libstdc++ to use system provided C++ standard library, pass target in host clang --- scripts/waifulib/xcompile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index 78b2b4ac..a0854106 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -15,6 +15,7 @@ try: from fwgslib import get_flags_by_compiler except: from waflib.extras.fwgslib import get_flags_by_compiler from waflib import Logs from waflib.Tools import c_config +from collections import OrderedDict import os import sys @@ -183,12 +184,12 @@ class Android: def cc(self): if self.is_host(): - return 'clang' + return 'clang --target=%s' % self.clang_host_triplet() return self.toolchain_path + ('clang' if self.is_clang() else 'gcc') def cxx(self): if self.is_host(): - return 'clang++' + return 'clang++ --target=%s' % self.clang_host_triplet() return self.toolchain_path + ('clang++' if self.is_clang() else 'g++') def strip(self): @@ -230,7 +231,7 @@ class Android: def cflags(self): cflags = [] if self.is_host(): - cflags += ['-nostdlib', '--target=%s' % self.clang_host_triplet()] + cflags += ['-nostdlib'] if self.ndk_rev < 20: cflags += ['--sysroot={0}'.format(self.sysroot())] @@ -271,7 +272,7 @@ class Android: return linkflags def ldflags(self): - ldflags = ['-lgcc', '-no-canonical-prefixes'] + ldflags = ['-stdlib=libstdc++', '-lgcc', '-no-canonical-prefixes'] if self.is_arm(): if self.arch == 'armeabi-v7a': ldflags += ['-march=armv7-a'] @@ -325,10 +326,9 @@ def configure(conf): # conf.env.ANDROID_OPTS = android conf.env.DEST_OS2 = 'android' - MACRO_TO_DESTOS = { - '__ANDROID__' : 'android' - } - MACRO_TO_DESTOS.update(c_config.MACRO_TO_DESTOS) # ordering is important + MACRO_TO_DESTOS = OrderedDict({ '__ANDROID__' : 'android' }) + for k in c_config.MACRO_TO_DESTOS: + MACRO_TO_DESTOS[k] = c_config.MACRO_TO_DESTOS[k] # ordering is important c_config.MACRO_TO_DESTOS = MACRO_TO_DESTOS def post_compiler_cxx_configure(conf):