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

Android LTO, Clang NDK r14, API {16,21} {armeabi-v7a, arm64-v8a}: OpenCV failed #343

Closed
ruslo opened this issue Mar 11, 2017 · 10 comments
Closed
Assignees
Milestone

Comments

@ruslo
Copy link
Collaborator

ruslo commented Mar 11, 2017

Build OpenCV:

[hunter-packages/opencv]> git branch -vv
* hunter-3.0.0 25e3fe7 [origin/hunter-3.0.0] Disable '-Wc++11-narrowing' for Clang

Using this script:

End with:

CMake Error at /.../cmake/share/cmake-3.7/Modules/TestBigEndian.cmake:41 (message):
  no suitable type found
Call Stack (most recent call first):
  CMakeLists.txt:532 (test_big_endian)
@ruslo
Copy link
Collaborator Author

ruslo commented Mar 11, 2017

Quite the same for android-ndk-r14-api-21-arm64-v8a-clang-hid-sections-lto

@ruslo ruslo changed the title Android LTO, Clang NDK r14, API 16, armeabi-v7a: OpenCV failed Android LTO, Clang NDK r14, API {16,21} {armeabi-v7a, arm64-v8a}: OpenCV failed Mar 11, 2017
@ruslo
Copy link
Collaborator Author

ruslo commented Mar 12, 2017

This is because of MinSizeRel and -Os flag:

/.../android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold:
  fatal error: Optimization level must be between 0 and 3

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 12, 2017

Found this one:

It's a fresh bugs, I'm not sure if we can do anything about it now except to switch to -O3.

@headupinclouds
Copy link
Collaborator

Bummer. It seems it isn't just a Windows issue. My understanding is that -O3 with -flto will aim for cross translation unit speed optimizations only, and will not have much impact on size. Is drishti currently building with this toolchain using -O3 and -flto? I'm curious what the final size of this OpenCV benchmark is w/ these settings: drishti/src/benchmarks/opencv_size.

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 13, 2017

Is drishti currently building with this toolchain using -O3 and -flto?

Have problems with Boost. Working on fix.

@ruslo ruslo self-assigned this Mar 13, 2017
@ruslo ruslo added this to the 0.4 milestone Mar 13, 2017
@ruslo
Copy link
Collaborator Author

ruslo commented Mar 13, 2017

Working on fix

Testing now: ruslo/hunter#699

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 14, 2017

Looks like Clang/ld.gold is more pedantic about PIC vs non-PIC code. Got error:

/.../android-ndk/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.gold:
fatal error: Failed to link module
/.../.hunter/_Base/57991b4/b3b38b9/0f5ce42/Install/lib/libboost_serialization-mt.a.llvm.132988.basic_archive.cpp:
linking module flags 'PIC Level': IDs have conflicting values

Since the final product of build will be shared library I guess we have to use PIC versions of toolchains, i.e.:

  • android-ndk-r14-api-16-armeabi-v7a-neon-clang-hid-sections-lto-pic
  • android-ndk-r14-api-21-arm64-v8a-clang-hid-sections-lto-pic

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 17, 2017

Since the final product of build will be shared library I guess we have to use PIC versions of toolchains, i.e.

Doens't make any difference, reverting. I've run a few toolchain-id tests and it seems that PIC enabled by default for Android. The real problem here I think is the fact that non-CMake packages doesn't respect CMAKE_POSITION_INDEPENDENT_CODE variable. Working on fix.

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 17, 2017

Testing with temporary release:

It compiles now!

Toolchain android-ndk-r14-api-16-armeabi-v7a-neon-clang-hid-sections-lto + Release produce libdrishti.so with size 9.7 MB. Also one test failed:

CANNOT LINK EXECUTABLE:
  could not load library "libdrishti.so" needed by "/data/local/tmp/drishtisdk/android-ndk-r14-api-16-armeabi-v7a-neon-clang-hid-sections-lto/bin/test-drishti-drishti-eye";
  caused by cannot locate symbol "__tls_get_addr" referenced by "libdrishti.so"...                                                                                                                            

@ruslo
Copy link
Collaborator Author

ruslo commented Mar 17, 2017

Toolchain android-ndk-r14-api-21-arm64-v8a-clang-hid-sections-lto + Release produce 9.7 MB too. All tests passed.

@ruslo ruslo closed this as completed Mar 17, 2017
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

2 participants