Cuda dll init error

Hi,

I have a cuda shared library with init() and cleanup() functions. Since I am using linux and gcc, I marked those functions with attribute((constructor)) and attribute((destructor)), respectively. Now the compiler gives me error:

internal error: can’t generate code for non empty constructors or destructors on device

Is there any way around it other than using a flag and manually call init code on first dll function invocation and relying on the application to call the cleanup code in the dll?

All suggestions are appreciated.