<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body smarttemplateinserted="true">
    <div id="smartTemplate4-template">
      <p>Hi Sandeep, Petr, <br>
      </p>
    </div>
    <br>
    <div id="smartTemplate4-quoteHeader">-------- Original Message --------<br>
      From: Petr Vorel<br>
      Sent: Wed, 17 Apr 2019 19:06:51 +0200<br>
      To: Sandeep Patil<br>
      Cc: Zhengwang Ruan, Ltp, Steve Muckle<br>
      Subject: Re: [LTP] 回复:[PATCH v1] include/mk/env_post.mk : enable
      __ANDROID__ definition for Android build<br>
    </div>
    <blockquote type="cite" cite="mid:20190417170651.GA26229@x230">
      <pre class="moz-quote-pre" wrap="">Hi Sandeep,

</pre>
      <blockquote type="cite">
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">Have you tried to build out-of-aosp? :-)
</pre>
        </blockquote>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">Yes, I did that now and ran into a build error with pread02 pasted at the
end of this email.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">This was much easier than I thought and I think I can start sending trivial
fixes as I go. Here's what I did.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">1. Download the ndk20 beta from - <a class="moz-txt-link-freetext" href="https://developer.android.com/ndk/downloads">https://developer.android.com/ndk/downloads</a>
2. Set up ndk toolchains for autoconf as shown in
   <a class="moz-txt-link-freetext" href="https://developer.android.com/ndk/guides/other_build_systems#autoconf">https://developer.android.com/ndk/guides/other_build_systems#autoconf</a>
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">Thanks for a hint. I was using standalone toolchain [1], created with NKD r19,
but see according a doc that it was deprecated even for r19.

[1] <a class="moz-txt-link-freetext" href="https://developer.android.com/ndk/guides/standalone_toolchain">https://developer.android.com/ndk/guides/standalone_toolchain</a>

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">3. In LTP, do
   $ ./configure --host x86_64-linux-android --prefix=<preferred install location>
   $ make ANDROID=1
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
I'm also passing these flags to CFLAGS, but it might not be necessary:
 --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include

for arm host I use:
--host arm-linux-androideabi

and also define CROSS_COMPILE + other variables:
export CROSS_COMPILE=$TOOLCHAIN_ROOT/bin/arm-linux-androideabi-
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export NM=${CROSS_COMPILE}nm
export CC=${CROSS_COMPILE}gcc
export LD=${CROSS_COMPILE}ld
export RANLIB=${CROSS_COMPILE}ranlib

Only CROSS_COMPILE should be needed as, others are in
include/mk/config.mk.default, but my toolchain setup does not detect them
(include/mk/config.mk does not have cross-compile versions)

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">Please let me know if this doesn't sound right? It seems a lot easier than
the steps pasted earlier.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">- ssp
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">======================
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">/usr/local/google/home/sspatil/bin/android-ndk-r20-beta2/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android28-clang -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -Werror-implicit-function-declaration -D_FORTIFY_SOURCE=2 -I/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases/kernel/syscalls/preadv -I/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases/kernel/syscalls/preadv/../utils -I../../../../include -I../../../../include -I../../../../include/old/   -L../../../../lib -L../../../../lib/android_libpthread -L../../../../lib/android_librt  preadv02.c   -lltp -o preadv02
preadv02.c:89:7: error: implicit declaration of function 'preadv' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        TEST(preadv(*tc->fd, tc->name, tc->count, tc->offset));
             ^
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">I bump into the same problem

+ this one:
pwritev02.c:85:7: error: implicit declaration of function 'pwritev' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        TEST(pwritev(*tc->fd, tc->name, tc->count, tc->offset));

So for the build is needed to comment out HAVE_PREADV and HAVE_PWRITEV
definitions in include/config.h.

I don't know why autotools fails preadv and pwritev detection with AC_CHECK_FUNCS.
I considered it as problem of my setup, but maybe it's an autotools bug.
</pre>
    </blockquote>
    <p>I also encountered this issue, but I temporarily walked around it
      by applying the following patch.</p>
    <p>==================<br>
    </p>
    <p>$ git diff testcases/<br>
      diff --git a/testcases/commands/ldd/datafiles/Makefile
      b/testcases/commands/ldd/datafiles/Makefile<br>
      index d8bcf5c..74fbe50 100644<br>
      --- a/testcases/commands/ldd/datafiles/Makefile<br>
      +++ b/testcases/commands/ldd/datafiles/Makefile<br>
      @@ -30,7 +30,7 @@ CLEAN_TARGETS         += *.obj $(LDD_SO_FILES)<br>
              $(CC) $(CFLAGS) -shared -o $@ $^<br>
       <br>
       lddfile.out: main.o $(LDD_SO_FILES)<br>
      -       $(CC) $(CFLAGS) -O -o $@ $?<br>
      +       $(CC) $(CFLAGS) $(LDFLAGS) -O -o $@ $?<br>
       <br>
       INSTALL_DIR            := testcases/data/ldd01<br>
       <br>
      diff --git a/testcases/kernel/syscalls/Makefile
      b/testcases/kernel/syscalls/Makefile<br>
      index 45a00cf..27c2e7a 100644<br>
      --- a/testcases/kernel/syscalls/Makefile<br>
      +++ b/testcases/kernel/syscalls/Makefile<br>
      @@ -43,6 +43,8 @@ FILTER_OUT_DIRS       += \<br>
              sched_getaffinity sched_setaffinity sendmsg setgroups
      setns sighold \<br>
              sigrelse sigsuspend sigtimedwait sigwait sigwaitinfo stime
      \<br>
              setdomainname sethostname symlinkat ulimit ustat vfork
      vhangup vmsplice<br>
      +<br>
      +FILTER_OUT_DIRS += preadv pwritev<br>
       endif<br>
    </p>
    <p>==========</p>
    <p>Then I can accomplish compiling LTP with android-ndk-r19c, and my
      configure as below.</p>
    <p>==============</p>
    <p>$ export NDK_TOOL_DIR=/path/to/android-ndk-r19c</p>
    <p>$ ./configure --prefix=/tmp/ltp
      CC=${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
AR=${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
      CFLAGS="-isystem ${NDK_TOOL_DIR}/sysroot/usr/include -I
/media/Workspace/Softwares/Linux/toolschain/ndk/android-ndk-r19c/sysroot/usr/include
      -I
/media/Workspace/Softwares/Linux/toolschain/ndk/android-ndk-r19c/sysroot/usr/include/aarch64-linux-android
      <font color="#cc0000">-D__ANDROID__ </font>-fmessage-length=0 -W
      -Wall -Wno-unused -Winit-self -Wpointer-arith
      -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions
      -Wno-multichar -O2 -g -fno-strict-aliasing
      -fdebug-prefix-map=/proc/self/cwd=
      -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion
      -Wno-reserved-id-macro -Wno-format-pedantic
      -Wno-unused-command-line-argument -fcolor-diagnostics
      -Wno-expansion-to-defined -Wno-zero-as-null-pointer-constant
      -ffunction-sections -fdata-sections -fno-short-enums
      -funwind-tables -fstack-protector-strong -Wa,--noexecstack
      -D_FORTIFY_SOURCE=2 -Wstrict-aliasing=2 -Werror=return-type
      -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point
      -Werror=date-time -Werror=format-security -nostdlibinc
      -march=armv8-a  -target aarch64-linux-android
      -B${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin
      -std=gnu99 -Wall -fPIE -D_USING_LIBCXX -Werror=int-to-pointer-cast
      -Werror=pointer-to-int-cast -Werror=address-of-temporary
      -Werror=return-type -Wno-tautological-constant-compare
      -Wno-null-pointer-arithmetic -Wno-enum-compare
      -Wno-enum-compare-switch -MD -nostdlib -pthread"
      --host=aarch64-linux-gnu LDFLAGS="-nostdlib
      -Wl,-dynamic-linker,/system/bin/linker64 -Wl,--gc-sections
      -Wl,-z,nocopyreloc
      -Wl,-rpath-link=${BUILD_PROJ_DIR}/out/target/product/e28/obj/lib
${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/28/crtbegin_dynamic.o
      -Wl,--whole-archive  -Wl,--no-whole-archive  
${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2/lib/linux/libclang_rt.ubsan_minimal-aarch64-android.a 
${NDK_TOOL_DIR}/sysroot/usr/lib/aarch64-linux-android/libcompiler_rt-extras.a
${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/lib64/libatomic.a
${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/libgcc.a
      -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5
      -Wl,--warn-shared-textrel -Wl,--fatal-warnings
      -Wl,--no-undefined-version -Wl,-m,aarch64_elf64_le_vec
      -Wl,--hash-style=gnu -fuse-ld=gold -Wl,--icf=safe
      -Wl,--exclude-libs,libclang_rt.ubsan_minimal-aarch64-android.a
      -Wl,--no-undefined
      -B${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin
-L${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/28
      -lc++ -lc -lm -ldl
${NDK_TOOL_DIR}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/28/crtend_android.o
      -target aarch64-linux-android"</p>
    <p>$ make ANDROID=1<br>
    </p>
    <p><br>
    </p>
    <p>Regards,</p>
    <p>Zhengwang<br>
    </p>
    <blockquote type="cite" cite="mid:20190417170651.GA26229@x230">
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">1 error generated.
<builtin>: recipe for target 'preadv02' failed
make[4]: *** [preadv02] Error 1
make[4]: Leaving directory '/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases/kernel/syscalls/preadv'
../../../include/mk/generic_trunk_target.inc:93: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases/kernel/syscalls'
../../include/mk/generic_trunk_target.inc:93: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases/kernel'
../include/mk/generic_trunk_target.inc:93: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/local/google/home/sspatil/dev/ssd2/ltp/testcases'
Makefile:111: recipe for target 'testcases-all' failed
make: *** [testcases-all] Error 2
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">

Kind regards,
Petr
</pre>
    </blockquote>
  </body>
</html>