From 313f2a86b06b413bb1a43619e62392200ab6e6aa 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 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index 8b3eb495..cfc76283 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -263,8 +263,15 @@ class Android: def cflags(self, cxx = False): cflags = [] + 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: + 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 @@ class Android: ] 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 @@ class Android: 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