Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vcpkg build for Android failes due to the missing header: Monetary.h #1182

Closed
MMeram opened this issue Feb 4, 2020 · 7 comments
Closed

Vcpkg build for Android failes due to the missing header: Monetary.h #1182

MMeram opened this issue Feb 4, 2020 · 7 comments

Comments

@MMeram
Copy link

MMeram commented Feb 4, 2020

I tried to build "boost-locale" for Android x86 ABI and failed due to the missing header file:

[1/2] cd /opt/vcpkg/buildtrees/boost-locale/src/ost-1.70.0-64535d0e00/build && /opt/vcpkg/installed/x64-linux/tools/boost-build/b2 --user-config=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/user-config.jam --stagedir=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/stage --build-dir=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg boost.locale.iconv=on boost.locale.posix=on /boost/locale//boost_locale boost.locale.icu=off -sICONV_PATH=LIBICONV_LIBRARY-NOTFOUND runtime-link=static link=static address-model=32 target-os=linux toolset=gcc -sZLIB_BINARY=z -sZLIB_LIBPATH="/opt/vcpkg/installed/x86-android/debug/lib/libz.a" -sBZIP2_BINARY=bz2d -sBZIP2_LIBPATH="BZIP2_LIBPATH-NOTFOUND" variant=debug --layout=system --with-atomic --with-random --with-date_time --with-filesystem --with-system --with-thread --with-chrono -sZLIB_INCLUDE="/opt/vcpkg/installed/x86-android/include" -sBZIP2_INCLUDE="BZIP2_INCLUDE-NOTFOUND" -sICU_PATH="ICU_PATH-NOTFOUND" -j1 -sBOOST_ROOT=/opt/vcpkg/installed/x64-linux/tools/boost-build -sBOOST_BUILD_PATH=/opt/vcpkg/installed/x64-linux/tools/boost-build --debug-configuration --ignore-site-config --hash -q architecture=x86 threading=multi threadapi=pthread debug-symbols=on stage
FAILED: CMakeFiles/boost
cd /opt/vcpkg/buildtrees/boost-locale/src/ost-1.70.0-64535d0e00/build && /opt/vcpkg/installed/x64-linux/tools/boost-build/b2 --user-config=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/user-config.jam --stagedir=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/stage --build-dir=/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg boost.locale.iconv=on boost.locale.posix=on /boost/locale//boost_locale boost.locale.icu=off -sICONV_PATH=LIBICONV_LIBRARY-NOTFOUND runtime-link=static link=static address-model=32 target-os=linux toolset=gcc -sZLIB_BINARY=z -sZLIB_LIBPATH="/opt/vcpkg/installed/x86-android/debug/lib/libz.a" -sBZIP2_BINARY=bz2d -sBZIP2_LIBPATH="BZIP2_LIBPATH-NOTFOUND" variant=debug --layout=system --with-atomic --with-random --with-date_time --with-filesystem --with-system --with-thread --with-chrono -sZLIB_INCLUDE="/opt/vcpkg/installed/x86-android/include" -sBZIP2_INCLUDE="BZIP2_INCLUDE-NOTFOUND" -sICU_PATH="ICU_PATH-NOTFOUND" -j1 -sBOOST_ROOT=/opt/vcpkg/installed/x64-linux/tools/boost-build -sBOOST_BUILD_PATH=/opt/vcpkg/installed/x64-linux/tools/boost-build --debug-configuration --ignore-site-config --hash -q architecture=x86 threading=multi threadapi=pthread debug-symbols=on stage
notice: found boost-build.jam at /opt/vcpkg/installed/x64-linux/tools/boost-build/boost-build.jam
notice: loading Boost.Build from /opt/vcpkg/installed/x64-linux/tools/boost-build/src/kernel
notice: Site configuration files will be ignored due to the
notice: --ignore-site-config command-line option.
notice: Loading explicitly specified user configuration file:
/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/user-config.jam
notice: Searching '/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg'.
notice: will use '/home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++' for gcc, condition gcc-5.4.1
notice: using gcc libraries :: gcc-5.4.1 :: /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/lib /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/lib32 /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/lib64
notice: using gcc archiver :: gcc-5.4.1 :: /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ar
notice: using gcc ranlib :: gcc-5.4.1 :: /home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ranlib
warning: toolset gcc initialization: can not find tool windres
warning: initialized from /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/user-config.jam:22
notice: using rc compiler :: gcc-5.4.1 :: as
Performing configuration checks

- iconv (libc)             : yes

...patience...
...found 1176 targets...
...updating 35 targets...
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/encoding/codepage.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/date_time.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/format.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/formatting.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/generator.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/ids.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/localization_backend.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/message.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/shared/mo_lambda.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/util/codecvt_converter.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/util/default_locale.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/util/info.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/util/locale_data.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/codecvt.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/collate.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/converter.o
gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/numeric.o
../src/posix/numeric.cpp:26:10: fatal error: 'monetary.h' file not found
#include <monetary.h>
^~~~~~~~~~~~
1 error generated.

"/home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++"   -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info -m32 -pthread -O0 -fno-inline -Wall -g --target=i686-none-linux-android29 --gcc-toolchain=/home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/mmeram/experimental/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=i686  -DBOOST_ALL_NO_LIB=1 -DBOOST_LOCALE_NO_WINAPI_BACKEND=1 -DBOOST_LOCALE_WITH_ICONV=1 -DBOOST_THREAD_NO_LIB=1  -I"../include" -I"/opt/vcpkg/installed/x86-android/include" -c -o "/opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/numeric.o" "../src/posix/numeric.cpp"

...failed gcc.compile.c++ /opt/vcpkg/buildtrees/boost-locale/x86-android-dbg/boost/build/54eb8f1e1dc024f48fac6296d7a14461/posix/numeric.o...
...failed updating 1 target...
...updated 21 targets...
ninja: build stopped: subcommand failed.

I manually copied the monetary.h from the AOSP (sources/ to the folder:
<ndk_root>/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include/

and it worked. Why is this header missing in the NDK? I heard there were porting issues for Android 9.0 but it seems to be fixed...

@enh-google
Copy link
Collaborator

old versions of the NDK did include musl's <monetary.h> and corresponding implementation. as we cleaned up the NDK, we dropped this rather than replace it with code from bionic (which was our usual solution). we did briefly look at implementing our own <monetary.h>, but writing some tests based on the POSIX spec and testing against a few existing implementations found that there was a surprising amount of disagreement even for the C locale.

so we've just ignored <monetary.h>. any implementation we'd provide wouldn't actually be very useful because it wouldn't actually do any i18n. anyone who needs to do it right should use Java for now, and icu4c (when it's available: #548). anyone who's happy with a not-actually-useful <monetary.h> can always bundle a perfunctory implementation, but then at least they know what they're getting into, rather than us providing something that seems useful but isn't really.

is "having even a bogus <monetary.h> would let me build boost's locale library" sufficient reason to add it anyway? even if we ignore the argument that "it's probably better to not have obscure API at all rather than have a bad implementation of obscure API", which is a philosophy one might reasonably disagree with, i'm still not sure... boost only uses <monetary.h> for the "posix" backend, and i'm unconvinced that's actually a useful backend. looking at their comparison chart (https://www.boost.org/doc/libs/1_72_0/libs/locale/doc/html/using_localization_backends.html) i think the "std" backend is strictly better than the posix one (though still not very good), and that if you actually care you're still in the "use Java or use icu" boat.

but you're actually here because you want to build vckpg and don't actually care about boost or whether its posix i18n backend is any good. in which case i'd suggest switching your build to the "std" backend (i'd start by searching for the source of the boost.locale.posix=on in your build output above), and asking upstream vckpg to take that patch.

(one thing i don't remember doing, and probably should before we call the absence of <monetary.h> as "working as intended" is to investigate how well -- if at all -- the POSIX and icu4c APIs match. if we can implement the POSIX one in terms of icu4c, that's probably worth doing in bionic. i'm not optimistic though, given my experience with <iconv.h>.)

@DanAlbert
Copy link
Member

Not supporting unhelpful APIs that give a false sense of security SGTM. I'm guessing most people looking to use that don't know that it's really not what they want.

One thing we could do is add the header that contains only #error this isn't the API you want, use ICU or similar. An argument against doing that is that autoconfish things might be deciding whether or not the API is usable based on the presence of the header rather than the presence of a particular API.

@enh-google
Copy link
Collaborator

yeah, and iirc boost's existing configure equivalent does default to using the "std" implementation on Android rather than the "posix" one. i suspect vcpkg has explicitly asked for the posix implementation.

@MMeram
Copy link
Author

MMeram commented Feb 5, 2020

Thanks for the analysis. Indeed, in the ports/boost-locale/cmake-fragment.cmake I changed the config like this:

boost.locale.posix=off
boost.locale.std=on

And it worked like a magic :)
However, I'd appreciate if you could document it in release notes or somewhere (like posix localization backend is not supported or so) so that it doesn't pop up again

@enh-google
Copy link
Collaborator

BoredOutOfMyGit pushed a commit to codeaurora-unofficial/platform-bionic that referenced this issue Feb 8, 2020
We've had discussions about <monetary.h> (which wasn't previously
mentioned here at all, an oversight) and robust mutexes on github that
are worth linking to.

Bug: android/ndk#1181
Bug: android/ndk#1182
Test: N/A
Change-Id: If0d2c28757a3cbfffc358e8847dc4de1a67d9001
@DanAlbert
Copy link
Member

@enh-google anything else you want to do here? I'm still leaning toward not adding this header to bionic just for the #error because I'm worried about confusing autoconf.

@enh-google
Copy link
Collaborator

no, i think adding a fake monetary.h would cause more trouble than it solves, and i don't think we can realistically implement it in terms of icu4c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants