Comments (9)
You've set -fvisibility-hidden
, so the compiler is doing what you asked.
Q_CORE_EXPORT
seems to be configured as follows: http://stackoverflow.com/a/3148584/632035
Don't know if that's something you're supposed to define on the command line or if there's something in QT's headers that set it up, but it's not being set properly.
A contrived test case shows that specializations are exported properly (no one would be able to use the Clang for production work if it didn't).
from ndk.
A few clarifications:
- Q_CORE_EXPORT is defined as attribute((visibility("default"))) when that file is compiled (you'll need to check QtCore/qglobal.h).
- only a few explicit specializations function templates are not exported (e.g. callObjectMethod).
- the other functions (including other explicit specializations function templates (i.e. callMethod) are exported properly).
- the bug I reported is quite similar to https://llvm.org/bugs/show_bug.cgi?id=23667 which seems to be fixed ~6 months ago.
Because seeing is believing, I'll give you the steps to compile Qt yourself:
- $ git clone git://code.qt.io/qt/qtbase.git
- $ cd qtbase
- $ git checkout 5.7
Next you'll need to cherry-pick https://codereview.qt-project.org/#/c/153564/
- $ git fetch https://codereview.qt-project.org/qt/qtbase refs/changes/64/153564/1 && git cherry-pick FETCH_HEAD
Next step is to make sure you revert the workaround I did to src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp. In this file you can see that we're using other methods and other explicit specializations function templates from that class, but *ONLY * callObjectMethod is not found.
Final step is to configure & compile Qt, you'll need Android NDK & SDK (with API-16 installed):
- $ ./configure -developer-build -release -force-debug-info -xplatform android-clang -nomake tests -nomake examples -android-ndk /path/to/NDK android-sdk /path/to/SDK
- $ make -j8 (you'll need to wait a few minutes)
from ndk.
The LLVM bug you point at looks to be specific to dllexport
, which is a Windows thing. We do already have that patch as well.
from ndk.
Can you give me updated instructions to reproduce this issue? In particular, from your comment on March 22:
Next step is to make sure you revert the workaround I did to src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp.
What WAR should be reverted?
from ndk.
You need to revert qt/qtbase@cc119de
Same setup as for #143
If you already have it compiled, just go to qtbase folder and do:
$ git revert cc119dee73c6
$ make clean
$ make -j10
from ndk.
After looking at this a bit, not sure why the symbols are hidden. callObjectMethod
does not use the template type but that doesn't seem to be the reason behind the issue. setField
, which takes a parameter of the template type, is also hidden.
I am attaching an easy reproduction for others to take a look. Run the following command on the .ii file (which is in a zip so github accepts it as an attachment):
clang++ -cc1 -triple thumbv7-none-linux-android -emit-llvm -emit-llvm-uselists -disable-free -disable-llvm-verifier -main-file-name qjni.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu cortex-a8 -target-feature +soft-float-abi -target-feature -fp-only-sp -target-feature -d16 -target-feature +vfp2 -target-feature -vfp3 -target-feature -fp16 -target-feature -vfp4 -target-feature -fp-armv8 -target-feature -neon -target-feature -crypto -target-abi aapcs-linux -mfloat-abi soft -target-linker-version 2.24 -v -dwarf-column-info -debugger-tuning=gdb -O3 -Wall -W -std=c++14 -fdeprecated-macro -ferror-limit 19 -fmessage-length 85 -fvisibility hidden -fvisibility-inlines-hidden -femulated-tls -stack-protector 2 -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -disable-llvm-passes -x c++-cpp-output qjni.ii
The problematic functions will be marked hidden in the generated qjni.ll
qjni.zip
from ndk.
Aah, found the reason after digging into how Clang's visiblity-determination code. Thes specializations are getting hidden
visiblity because the types they specialize (jstring
etc.) have hidden
visibility based on -fvisibility-hidden
.
I cannot find anything in the spec that explicitly clarifies this. But, I think Clang is reasonable here - based on the requested visiblity
, these types, and specializations on them, cannot be visible outside this unit.
@bog-dan-ro You can either (a) restrict your workaround to just those functions that specialize jobject and its subclasses or (b) use GCC visiblity pragmas around jni.h (https://gcc.gnu.org/onlinedocs/gcc/Visibility-Pragmas.html).
from ndk.
@pirama-arumuga-nainar but I'm changing the visibility of the entire class ... so IMHO all the methods should be exported properly :)
from ndk.
And, the visibility of jstring
etc is hidden, so Clang concludes that this specialization jstring
is not callable from outside the translational unit.
To determine a method's visiblity, Clang picks the strictest visibility among that of its class, types of its parameters and its template types. The way to override this is via the method's attribute (like in your WAR).
from ndk.
Related Issues (20)
- [BUG] Clang++ Segmentation fault when building AOSP branch android-14.0.0_r35 HOT 3
- [Bug]: error: ran out of registers during register allocation HOT 17
- Android builds with unity fail: "Library\Bee\artifacts\Android" HOT 4
- [FR] push/pop required policies in cmake toolchain file HOT 16
- [DOC] Clarification on 16k page size support for x86_64 devices HOT 3
- [DOC] `system_fonts.h` HOT 7
- [Bug]: Lambda segfaults in Clang HOT 11
- [FR] Official NDK release for Linux arm64 HOT 1
- [Bug]: fatal error: error in backend: Cannot select: 0x10ba8ace0: nxv4f32 = BUILD_VECTOR 0x133163a90, 0x1330f4800, 0x133108d20, 0x1248b9e60 HOT 6
- [BUG] Compilation Error with std::execution in C++17 HOT 3
- [BUG] CLEAR_VARS does not clear LOCAL_STRIP_MODE variable HOT 2
- [Bug]: Android NDK r27 rc2 miscompiles code with inderect gotos HOT 13
- [Bug] NDK's openmp test crashing on x86 with latest LLVM update HOT 4
- Please provide maintainable list of NDK codename-revision pairs HOT 3
- [Bug]: clang compile with -D_FORTIFY_SOURCE=2 -Dstatic= cause undefined symbol: snprintf HOT 7
- [BUG] android-ndk-r26c use -pg ld.lld: error: undefined symbol: _mcount HOT 7
- [Bug]: Compiler Crash HOT 5
- [FR] support libclang? HOT 1
- [BUG] investigate odd find_package behavior HOT 3
- [BUG] NDK 27 no longer supports passing in `CMAKE_SYSTEM_PROCESSOR` to CMake to set the arch HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ndk.