folly icon indicating copy to clipboard operation
folly copied to clipboard

build for Android failed

Open leleliu008 opened this issue 3 years ago • 9 comments

https://github.com/facebook/folly/archive/v2021.12.20.00.tar.gz

Android NDK: 23.1.7779620

/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --sysroot=/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DBOOST_ALL_NO_LIB -DFMT_LOCALE -DFMT_SHARED -DFOLLY_XLOG_STRIP_PREFIXES=\"/tmp/tmp.aUuUAgMLAk:/tmp/tmp.aUuUAgMLAk/1640279296/armeabi-v7a\" -DGFLAGS_IS_A_DLL=0 -D_GNU_SOURCE -D_REENTRANT -I/tmp/tmp.aUuUAgMLAk -I/tmp/tmp.aUuUAgMLAk/1640279296/armeabi-v7a --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Qunused-arguments -fpic -Wl,--dynamic-linker=/system/bin/linker -Wl,--strip-debug -Os -DNDEBUG -I/home/fpliu/.ndk-pkg/install.d/boost/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/zstd/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/zlib/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/icu4c/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/libiconv/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/python/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/expat/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/libffi/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/sqlite/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/readline/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/ncurses/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/bzip2/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/xz/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/double-conversion/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/fmt/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/glog/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/gflags/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/libevent/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/openssl/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/lz4/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/snappy/armeabi-v7a/include -I/home/fpliu/.ndk-pkg/install.d/libsodium/armeabi-v7a/include --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Qunused-arguments -I/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi -include /tmp/tmp.aUuUAgMLAk/1640279296/include.h -L/home/fpliu/.ndk-pkg/install.d/boost/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/zstd/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/zlib/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/icu4c/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/libiconv/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/python/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/expat/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/libffi/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/sqlite/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/readline/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/ncurses/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/bzip2/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/xz/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/double-conversion/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/fmt/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/glog/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/gflags/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/libevent/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/openssl/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/lz4/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/snappy/armeabi-v7a/lib -L/home/fpliu/.ndk-pkg/install.d/libsodium/armeabi-v7a/lib --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -L/tmp/tmp.aUuUAgMLAk/1640279296 -L/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/21 -Wl,--dynamic-linker=/system/bin/linker -Wl,--strip-debug -O3 -DNDEBUG -g -Wall -Wextra -O3 -fPIC -g -std=gnu++1z -finput-charset=UTF-8 -fsigned-char -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare -Wno-unused -Wunused-label -Wunused-result -Wno-noexcept-type -Wno-nullability-completeness -Wno-inconsistent-missing-override -faligned-new -fopenmp -std=gnu++17 -MD -MT CMakeFiles/folly_base.dir/folly/experimental/JSONSchema.cpp.o -MF CMakeFiles/folly_base.dir/folly/experimental/JSONSchema.cpp.o.d -o CMakeFiles/folly_base.dir/folly/experimental/JSONSchema.cpp.o -c /tmp/tmp.aUuUAgMLAk/folly/experimental/JSONSchema.cpp
/tmp/tmp.aUuUAgMLAk/folly/experimental/JSONSchema.cpp:139:24: error: no member named 'remainder' in namespace 'folly'; did you mean simply 'remainder'?
      const auto rem = folly::remainder(value.asDouble(), schema_.asDouble());
                       ^~~~~~~~~~~~~~~~
                       remainder
/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/math.h:1471:1: note: 'remainder' declared here
remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
^
/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/math.h:1474:5: error: static_assert failed due to requirement '!(std::integral_constant<bool, true>::value && std::integral_constant<bool, true>::value)' ""
    static_assert((!(std::_IsSame<_A1, __result_type>::value &&
    ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.aUuUAgMLAk/folly/experimental/JSONSchema.cpp:139:31: note: in instantiation of function template specialization 'remainder<double, double>' requested here
      const auto rem = folly::remainder(value.asDouble(), schema_.asDouble());
                              ^
2 errors generated.

leleliu008 avatar Dec 23 '21 17:12 leleliu008

Did you find a solution to this?

JonasVautherin avatar Aug 19 '22 12:08 JonasVautherin

Sorry, I'm not familiar with C++. I don't known how to patch it.

leleliu008 avatar Aug 19 '22 12:08 leleliu008

sed -i 's|folly::remainder|::remainder|' folly/experimental/JSONSchema.cpp

leleliu008 avatar Aug 19 '22 13:08 leleliu008

new error is coming:

/home/leleliu008/.ndk-pkg/installing.d/android/21/folly/src/folly/experimental/symbolizer/Elf.cpp:253:38: error: use of undeclared identifier 'ELFCLASSFOLLY_ELF_NATIVE_CLASS'
  if (elfHeader.e_ident[EI_CLASS] != EXPECTED_CLASS) {
                                     ^
/home/leleliu008/.ndk-pkg/installing.d/android/21/folly/src/folly/experimental/symbolizer/Elf.cpp:249:24: note: expanded from macro 'EXPECTED_CLASS'
#define EXPECTED_CLASS P1(ELFCLASS, FOLLY_ELF_NATIVE_CLASS)
                       ^
/home/leleliu008/.ndk-pkg/installing.d/android/21/folly/src/folly/experimental/symbolizer/Elf.cpp:250:18: note: expanded from macro 'P1'
#define P1(a, b) P2(a, b)
                 ^
/home/leleliu008/.ndk-pkg/installing.d/android/21/folly/src/folly/experimental/symbolizer/Elf.cpp:251:18: note: expanded from macro 'P2'
#define P2(a, b) a##b
                 ^
<scratch space>:11:1: note: expanded from here
ELFCLASSFOLLY_ELF_NATIVE_CLASS
^
1 error generated.

leleliu008 avatar Aug 19 '22 13:08 leleliu008

sed -i s|__FreeBSD__|__ANDROID__|' folly/experimental/symbolizer/Elf.cpp
export CPPFLAGS="-DELFCLASS="

leleliu008 avatar Aug 19 '22 14:08 leleliu008

/home/leleliu008/.ndk-pkg/installing.d/android/21/folly/src/folly/memcpy.S:464:37: error: expected '%<type>' or "<type>"
        .section .note.GNU-stack,"",@progbits
                                    ^

leleliu008 avatar Aug 19 '22 14:08 leleliu008

It seems that clang's integrated as can't recognize folly/memcpy.S syntax.

leleliu008 avatar Aug 19 '22 14:08 leleliu008

sed_in_place 's|__linux__|XXXXXXXXXXXXX|' folly/memcpy.S

leleliu008 avatar Aug 19 '22 14:08 leleliu008

It can be successfully built now.

More details please refer to https://github.com/leleliu008/ndk-pkg-formula-repository/blob/master/formula/folly.sh

The most easy way is to use ndk-pkg

ndk-pkg install folly

leleliu008 avatar Aug 19 '22 14:08 leleliu008