You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
clang doesn't export explicit specializations function templates #34
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).
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):
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
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.
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).
Activity
DanAlbert commentedon Mar 21, 2016
You've set
-fvisibility-hidden, so the compiler is doing what you asked.Q_CORE_EXPORTseems to be configured as follows: http://stackoverflow.com/a/3148584/632035Don'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).
bog-dan-ro commentedon Mar 22, 2016
A few clarifications:
Because seeing is believing, I'll give you the steps to compile Qt yourself:
Next you'll need to cherry-pick https://codereview.qt-project.org/#/c/153564/
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):
DanAlbert commentedon Mar 23, 2016
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.Workaround clang buggy explicit specializations function templates ex…
Workaround clang explicit specializations function templates export bug
pirama-arumuga-nainar commentedon Aug 15, 2016
Can you give me updated instructions to reproduce this issue? In particular, from your comment on March 22:
What WAR should be reverted?
bog-dan-ro commentedon Aug 16, 2016
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:
pirama-arumuga-nainar commentedon Aug 16, 2016
After looking at this a bit, not sure why the symbols are hidden.
callObjectMethoddoes 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.iiThe problematic functions will be marked hidden in the generated
qjni.llqjni.zip
pirama-arumuga-nainar commentedon Aug 19, 2016
Aah, found the reason after digging into how Clang's visiblity-determination code. Thes specializations are getting
hiddenvisiblity because the types they specialize (jstringetc.) havehiddenvisibility 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).
bog-dan-ro commentedon Aug 23, 2016
@pirama-arumuga-nainar but I'm changing the visibility of the entire class ... so IMHO all the methods should be exported properly :)
pirama-arumuga-nainar commentedon Aug 23, 2016
And, the visibility of
jstringetc is hidden, so Clang concludes that this specializationjstringis 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).