* [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build
@ 2019-04-24 16:55 Zhengwang Ruan
2019-04-24 19:27 ` Steve Muckle
0 siblings, 1 reply; 4+ messages in thread
From: Zhengwang Ruan @ 2019-04-24 16:55 UTC (permalink / raw)
To: ltp
The definition of __ANDROID__ has been widely used to compile android-specific
things (i.e. busybox [1] [2], dnsmasq [3]), so we expected NDK to automatically
pass it to help build LTP for android, but unfortunately it didn't (it is tested
with android-ndk-r19c). Currently, we have to manually specify -D__ANDROID__ in
configure step before launch 'make ANDROID=1' command, and this is suffering for
those who don't have good knowledge of LTP, so it is necessary to enable it if
built for android.
In the past, there had been a lot of discussion about which one of __ANDROID__
and ANDROID was the best choice to define the android-only code, but __ANDROID__
seems better right now [4].
[1] https://git.busybox.net/busybox/tree/configs/android_defconfig
[2] https://git.busybox.net/busybox/tree/configs/android_ndk_defconfig
[3] http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=blob_plain;f=bld/Android.mk;hb=HEAD
[4] https://groups.google.com/forum/#!topic/android-ndk/cf9_f1SLXls
Signed-off-by: Zhengwang Ruan <ruanzw@xiaopeng.com>
---
include/mk/env_post.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/mk/env_post.mk b/include/mk/env_post.mk
index 913bdf5..7953e0a 100644
--- a/include/mk/env_post.mk
+++ b/include/mk/env_post.mk
@@ -44,7 +44,7 @@ endif
ifeq ($(ANDROID),1)
# There are many undeclared functions, it's best not to accidentally overlook
# them.
-CFLAGS += -Werror-implicit-function-declaration
+CFLAGS += -Werror-implicit-function-declaration -D__ANDROID__
LDFLAGS += -L$(top_builddir)/lib/android_libpthread
LDFLAGS += -L$(top_builddir)/lib/android_librt
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build
2019-04-24 16:55 [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build Zhengwang Ruan
@ 2019-04-24 19:27 ` Steve Muckle
2019-04-24 21:11 ` Petr Vorel
2019-04-25 3:13 ` =?unknown-8bit?b?6Ziu5q2j5pe6?=
0 siblings, 2 replies; 4+ messages in thread
From: Steve Muckle @ 2019-04-24 19:27 UTC (permalink / raw)
To: ltp
On 4/24/19 9:55 AM, Zhengwang Ruan wrote:
> The definition of __ANDROID__ has been widely used to compile android-specific
> things (i.e. busybox [1] [2], dnsmasq [3]), so we expected NDK to automatically
> pass it to help build LTP for android, but unfortunately it didn't (it is tested
> with android-ndk-r19c). Currently, we have to manually specify -D__ANDROID__ in
> configure step before launch 'make ANDROID=1' command, and this is suffering for
> those who don't have good knowledge of LTP, so it is necessary to enable it if
> built for android.
Hi Zhengwang I mentioned in the other thread but just to get it here
also, __ANDROID__ seems to be defined for me by the NDK. Could you try
the steps Sandeep shared?
thanks,
steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build
2019-04-24 19:27 ` Steve Muckle
@ 2019-04-24 21:11 ` Petr Vorel
2019-04-25 3:13 ` =?unknown-8bit?b?6Ziu5q2j5pe6?=
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-04-24 21:11 UTC (permalink / raw)
To: ltp
Hi,
> On 4/24/19 9:55 AM, Zhengwang Ruan wrote:
> > The definition of __ANDROID__ has been widely used to compile android-specific
> > things (i.e. busybox [1] [2], dnsmasq [3]), so we expected NDK to automatically
> > pass it to help build LTP for android, but unfortunately it didn't (it is tested
> > with android-ndk-r19c). Currently, we have to manually specify -D__ANDROID__ in
> > configure step before launch 'make ANDROID=1' command, and this is suffering for
> > those who don't have good knowledge of LTP, so it is necessary to enable it if
> > built for android.
> Hi Zhengwang I mentioned in the other thread but just to get it here also,
> __ANDROID__ seems to be defined for me by the NDK. Could you try the steps
> Sandeep shared?
Using old way (getting standalone toolchain from NDK r19, using API 27
and define $AR, $CC, $LD, ... variables) confirms what Steve said [1]: -D__ANDROID__
is not defined on the command line (see below), but #error macro inside #ifdef
__ANDROID__ guard is proved that arm-linux-androideabi-gcc defines it.
Just for sure I tested the same using Sandeep's way (NDK r20-beta2, using
variables with API 26) [2], it behaves the same.
IMHO the patch is not needed.
BTW minimal Android API for LTP is 26 (API 24 complains for missing hasmntopt()).
> thanks,
> steve
Kind regards,
Petr
[1]
/opt/android-standalone-toolchain.api-27/bin/arm-linux-androideabi-gcc --sysroot=/opt/android-standalone-toolchain.api-27/sysroot -I/opt/android-standalone-toolchain.api-27/sysroot/usr/include -I/include -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -I. -DLTPLIB -Werror-implicit-function-declaration --sysroot=/opt/android-standalone-toolchain.api-27/sysroot -I/opt/android-standalone-toolchain.api-27/sysroot/usr/include -I/include -I../include -I../include -I../include/old/ -c -o tst_kernel.o tst_kernel.c
[2]
/opt/android-ndk-r20-beta2/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -I. -DLTPLIB -Werror-implicit-function-declaration -D_FORTIFY_SOURCE=2 -I../include -I../include -I../include/old/ -c -o tst_resource.o tst_resource.c
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build
2019-04-24 19:27 ` Steve Muckle
2019-04-24 21:11 ` Petr Vorel
@ 2019-04-25 3:13 ` =?unknown-8bit?b?6Ziu5q2j5pe6?=
1 sibling, 0 replies; 4+ messages in thread
From: =?unknown-8bit?b?6Ziu5q2j5pe6?= @ 2019-04-25 3:13 UTC (permalink / raw)
To: ltp
Hi Steve, Petr, Sandeep,
-------- Original Message --------
From: Steve Muckle
Sent: Wed, 24 Apr 2019 12:27:32 -0700
To: Zhengwang Ruan, Ltp, Petr Vorel, Sandeep Patil
Cc:
Subject: Re: [PATCH v2] include/mk/env_post.mk: enable __ANDROID__
definition for Android build
> On 4/24/19 9:55 AM, Zhengwang Ruan wrote:
>> The definition of __ANDROID__ has been widely used to compile
>> android-specific
>> things (i.e. busybox [1] [2], dnsmasq [3]), so we expected NDK to
>> automatically
>> pass it to help build LTP for android, but unfortunately it didn't
>> (it is tested
>> with android-ndk-r19c). Currently, we have to manually specify
>> -D__ANDROID__ in
>> configure step before launch 'make ANDROID=1' command, and this is
>> suffering for
>> those who don't have good knowledge of LTP, so it is necessary to
>> enable it if
>> built for android.
>
> Hi Zhengwang I mentioned in the other thread but just to get it here
> also, __ANDROID__ seems to be defined for me by the NDK. Could you try
> the steps Sandeep shared?
Yes, I tried. And it proves NDK has defined it, and this patch is not
needed.
Thank you guys very much for your time and helping me review this.
--
Kind Regards,
Zhengwang
>
> thanks,
> steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190425/44dce375/attachment.html>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-25 3:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 16:55 [LTP] [PATCH v2] include/mk/env_post.mk: enable __ANDROID__ definition for Android build Zhengwang Ruan
2019-04-24 19:27 ` Steve Muckle
2019-04-24 21:11 ` Petr Vorel
2019-04-25 3:13 ` =?unknown-8bit?b?6Ziu5q2j5pe6?=
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.