Android NDK STL c++_shared w/LIBCXX_FORCE_REBUILD results in std::stringstream NOP

后端 未结 2 1063
逝去的感伤
逝去的感伤 2021-02-04 00:32

tl;dr: The question is for an explanation for why std::stringstream \"fails\", and why it fails in the way it does (by simply doing nothing), when

相关标签:
2条回答
  • 2021-02-04 00:37

    I can't answer why the NOP is occurring in some permutations. But I did manage to find out about the build failures.

    I was in a worse situation than you. I was experiencing the build failures relating to the combination of using c++_static and the default value for LIBCXX_FORCE_REBUILD (false) and had no idea why.

    Thanks to you for sharing your research into the various permutations of linking STL - I was able to jump straight to the salient documentation to fix the build error.

    It's likely that you need libatomic if you #include . Add "LOCAL_LDLIBS += -latomic" for ndk-build

    To be able to use libatomic you need to set your NDK_TOOLCHAIN_VERSION to 4.8

    0 讨论(0)
  • 2021-02-04 00:43

    Please try this:

    LOCAL_LDFLAGS += -Wl,--gc-sections
    

    It seems that the code snippet doesn't really called atomic_fetch_add(). With --gc-sections LD option, the linker will eliminate the unused code and data from the final executable or shared library. So that the dependency of atomic_fetch_add() is likely to be removed.

    Description of "--gc-sections": https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html

    Some other infomation: https://code.google.com/p/android/issues/detail?id=68779

    0 讨论(0)
提交回复
热议问题