diff --git a/clang/docs/LTOVisibility.rst b/clang/docs/LTOVisibility.rst --- a/clang/docs/LTOVisibility.rst +++ b/clang/docs/LTOVisibility.rst @@ -35,6 +35,16 @@ (e.g. classes declared in unnamed namespaces) also receive hidden LTO visibility. +During the LTO link, all classes with public LTO visibility will be refined +to hidden LTO visibility when the ``-lto-whole-program-visibility`` lld linker +option is applied (``-plugin-opt=whole_program_visibility`` for gold). This +can be used when it is known that the LTO link has whole program visibility, +because we are LTO linking all translation units as bitcode, except certain +(e.g. system) libraries or other native objects known to be safe by the user or +build system, and the binary will not dlopen any libraries deriving from the +binary’s classes. This is useful in situations where it is not safe to specify +``-fvisibility=hidden`` at compile time. + A class defined in a translation unit built without LTO receives public LTO visibility regardless of its object file visibility, linkage or other attributes.