From ca985f32d954c35768ba7ce488dc8b67e7255c9b Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 1 Nov 2023 21:30:18 +0300 Subject: [PATCH] waifulib/xcompile: add android-from-none for new host-clang versions, support hardfloat abi in host-clang --- scripts/waifulib/xcompile.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index 8b3eb495cc..cfc7628366 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -263,8 +263,15 @@ def sysroot(self): def cflags(self, cxx = False): cflags = [] - - if self.ndk_rev <= ANDROID_NDK_SYSROOT_FLAG_MAX: + android_from_none = False + if self.is_host() and self.is_arm() and self.is_hardfp(): + # clang android target may change with ndk + # override target to none while compiling and + # add some android options manually + android_from_none = True + cflags += ['--target=arm-none-eabi'] + + if self.ndk_rev <= ANDROID_NDK_SYSROOT_FLAG_MAX and not android_from_none: cflags += ['--sysroot=%s' % (self.sysroot())] else: if self.is_host(): @@ -274,8 +281,10 @@ def cflags(self, cxx = False): ] cflags += ['-I%s' % (self.system_stl())] - if not self.is_clang(): - cflags += ['-DANDROID', '-D__ANDROID__'] + if not self.is_clang() or android_from_none: + cflags += ['-DANDROID', '-D__ANDROID__=1'] + if android_from_none: + cflags += [ '-D__linux__=1', '-fPIC'] # TODO: compare with linux target? if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']: cflags += ['-fno-sized-deallocation'] @@ -292,7 +301,7 @@ def cflags(self, cxx = False): cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9'] if self.is_hardfp(): - cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK'] + cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK', '-DGLES_SOFTFLOAT'] if self.is_host(): # Clang builtin redefine w/ different calling convention bug