1
votes

so I'm trying to figure out how to build ICU for android. Initially I tryed to make it with standalone tool-chain, and after some battles I was able to do that at least for x86_64 arch (didn't try with others). However I don't want to have fully custom build system so I decide to figure out how to make it with prebuild toolchains. And I found that it's behave very different - which is very strange. So this was my command when I actually try to configure ICU with standalone tool-chain:

icu/source/configure --disable-shared --enable-static --disable-dyload --disable-extras --disable-tests --disable-samples --prefix=/icu/build --host=x86_64-linux-android --with-cross-build=/toplay/icu/icu_linux CC=/custom_toolchain/bin/clang CXX=/custom_toolchain/bin/clang++ LD=/custom_toolchain/bin/x86_64-linux-android-ld AR=/custom_toolchain/bin/x86_64-linux-android-ar CFLAGS="-fPIC -DANDROID -fdata-sections -ffunction-sections" CXXFLAGS="-fPIC -DANDROID -frtti -fno-exceptions -fdata-sections -ffunction-sections"

So, having all the same command, but only changing compilers and tools from prebuild toolchain which will look like:

icu/source/configure --disable-shared --enable-static --disable-dyload --disable-extras --disable-tests --disable-samples --prefix=/icu/build --host=x86_64-linux-android --with-cross-build=/toplay/icu/icu_linux CC=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/clang CXX=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/clang++ LD=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-ld AR=/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64//bin/x86_64-linux-android-ar CFLAGS="-fPIC -DANDROID -fdata-sections -ffunction-sections" CXXFLAGS="-fPIC -DANDROID -frtti -fno-exceptions -fdata-sections -ffunction-sections"

I get very different configure step results. Which I placed there: (TLDR: main diff: in prebuild tool-chain case system can't understand that it's cross-compile mode, it's find nl_langinfo, strtod_l which isn't available in android) And if standalone tool-chain initially could build ICU, in prebuild case build process eventually broke.

So my question: what is the difference between compilers and tools in prebuild and standalone case and what flags/settings I need to add to make it work in prebuild case?

1
I found it useful to run configure from arch-specific directories, e.g. from obj/local/armeabi-v7a/objs/icu, and then I can perform it as one step of the global ndk-build. See an example here: stackoverflow.com/a/42964186/192373Alex Cohn

1 Answers

2
votes

This is the expected behavior. I've answered this on our bugtracker.

Our Clang defaults to targeting x86 Linux, not any flavor of Android. Setting up your target flags is one of the many things standalone toolchains do.

I'm not really sure what problem you're trying to solve. Whatever you get working with autoconf is going to essentially be a cobbled together standalone toolchain. Standalone toolchains exist entirely for dealing with this kind of scenario.

To answer your specific question here:

what is the difference between compilers and tools in prebuild and standalone case and what flags/settings I need to add to make it work in prebuild case?

Standalone toolchains are the prebuilt toolchains with a different directory layout (so the compilers can infer the locations of binutils, the sysroot, and the STL) and a few default flags (like -target for Clang). If you were to get this working, you'd have just reinvented this wheel (possibly by using -gcc-toolchain and a bunch of --sysroot, -isystem, -L stuff rather than changing the directory structure.

In case "why doesn't this work out of the box?" is a follow up question, remember that in Android you have many architectures, even more target versions of the OS, and a handful of STLs to choose from. Neither Clang nor GCC can currently be set up in a way that it can deal with all of Android's variations (long term I do expect to change that, but that's quite a ways down the road).