Is there a way to enable rtti for android.hardware.gnss-V3-ndk?

51 views
Skip to first unread message

Thomas Yuan

unread,
Nov 6, 2024, 7:37:36 PMNov 6
to Android Building
Or, in general, Is there a way to enable RTTI for library build from AIDL generated code.

I'm implementing GNSS HAL, and I'm using type_index in my code. So I will need to enable RTTI when I build it.

Seems I can add `    rtti: true ` in the cc_binary or my Android.bp, but it will get error when it trying to link the lib. The error looks like this:

ld.lld: error: undefined symbol: typeinfo for aidl::android::hardware::gnss::BnGnssGeofence                                                                                
>>> referenced by GnssGeofence.cpp                                                                                                                                          
>>>               out/soong/.intermediates/vendor/gm/hardware/impls/sensor/vendor.gm.gnss_sensors_service/android_vendor.34_arm64_armv8-a/obj/vendor/gm/hardware/impls/sensor/src/gnss/aidl/GnssGeofence.o:(typeinfo for aidl::android::hardware::gnss::GnssGeofence)                                                                                  
>>> did you mean: vtable for aidl::android::hardware::gnss::BnGnssGeofence                                                                                                  
>>> defined in: out/soong/.intermediates/hardware/interfaces/gnss/aidl/android.hardware.gnss-V3-ndk/android_vendor.34_arm64_armv8-a_shared/android.hardware.gnss-V3-ndk.so


My understanding is that, the android.hardware.gnss-V3-ndk.so build without `-frtti` and "nm -C android.hardware.gnss-V3-ndk.so | grep typeinfo" shows nothing confirmed that.

Now the question is, 
1. Is it possible to enable RTTI for gnss aidl only?
2. Is it safe to enable RTTI for gnss aidl? 

I have spend almost 2 days trying find a way to enable it, google/chatGPT/Copilot, but can't find a way. 
ChatGPT said there is a global setup for that, in build/soong/cc/config/global.go, to add that in cc_library. The global.go exists, but the cc_library doesn't.  
There is something like
        // Flags used by lots of devices.  Putting them in package static variables
        // will save bytes in build.ninja so they aren't repeated for every file
        commonGlobalCflags = []string{

and I put the "-frtti" inside, seems not working. (not trigger the full build/clean build. just mma from my HAL repo). And even it works, seems too risky.

Any suggestions? Thanks very much!!

Reply all
Reply to author
Forward
0 new messages