qthreads icon indicating copy to clipboard operation
qthreads copied to clipboard

Deliberate Symbol Visibility

Open insertinterestingnamehere opened this issue 2 years ago • 2 comments

It's generally a good a idea to set the default symbol visibility to "hidden" while compiling a library so that internal functions don't get automatically included in the interface exposed to downstream projects. This will require tagging which functions are supposed to be exported and setting up some build flags and ifdefs to turn on symbol exports only when building the main qthreads shared object.

Generally internal functions should already be prefaced with "INTERNAL", e.g.:

int INTERNAL qt_getmctxt(mctxt_t *);

It is possible that some functions are not properly marked though.

olivier-snl avatar Nov 01 '23 16:11 olivier-snl

Okay, just looked into the status of this a bit more. External API functions and some internal stuff is all marked. I think the only change needed here is setting -fvisibility=hidden to change the default behavior and then confirm that nothing breaks horribly.

Fixed in https://github.com/sandialabs/qthreads/pull/320. There's more work to do for Windows DLLs if we ever get around to supporting those. The current visibility header does the dllexport/dllimport stuff wrong. I'm calling this good enough for now though since Windows support is particularly involved for this codebase and it's not currently clear if we'll ever need it.