[Mesa-dev] glx-tls: Visibility hidden attribute and fix x86/x86_64 tls/tds entry points

Sedat Dilek sedat.dilek at gmail.com
Fri Sep 25 19:47:19 PDT 2015


On Sat, Sep 26, 2015 at 1:59 AM, Sedat Dilek <sedat.dilek at gmail.com> wrote:
> Hi,
>
> unfortunately, we still have no cool upstream fix for
> -fvisibility=hidden compiler flag handling.
> There is still no visibility-attribute "hidden" available or defined.
>
> I see people again fell over this issue [2].
>
> I have one concern...
>
> GCC uses "default" visibility-attribute (defined as PUBLIC) when
> compiler-flag "-fvisibility=hidden" is used.
> But CLANG needs in some cases "hidden" visibility-attribute.
>
> [ src/util/macros.h ]
>
> /**
>  * PUBLIC/USED macros
>  *
>  * If we build the library with gcc's -fvisibility=hidden flag, we'll
>  * use the PUBLIC macro to mark functions that are to be exported.
>  *
>  * We also need to define a USED attribute, so the optimizer doesn't
>  * inline a static function that we later use in an alias. - ajax
>  */
> #ifndef PUBLIC
> #  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
> #    define PUBLIC __attribute__((visibility("default")))
> #    define USED __attribute__((used))
> #  elif defined(_MSC_VER)
> #    define PUBLIC __declspec(dllexport)
> #    define USED
> #  else
> #    define PUBLIC
> #    define USED
> #  endif
> #endif
>
> #ifdef HAVE_FUNC_ATTRIBUTE_VISIBILITY
> #define HIDDEN __attribute__((visibility("hidden")))
> #else
> #define HIDDEN
> #endif
>
> [ src/util/macros.h ]
>
> Alan pointed to a solution like in [4] ("Use clang's __has_attribute
> to check for attribute support")
>
> So, what can people do to help to nail this down?
>
> I have attached a refreshed version of Marc's and added the TDS
> snippet from [2] to 0002 patch.
> ( Patches have no changelog and are against mesa v10.6.8. )
>
> Hope this helps!
>
> Regards,
> - Sedat -
>
> [1] https://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg76122.html
> [2] http://patchwork.freedesktop.org/patch/49494/
> [3] https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html
> [4] http://cgit.freedesktop.org/xorg/proto/x11proto/commit/?id=ffd4a13042d24cb5c

So, I played a bit more and the result is a v3 of both patches with
some simplification etc.

Emil asked in another thread to check with --enable-asm and
--{en|dis}able-shared-glapi, but disabling for the latter was not
suitable for my setup (disabling OpenGL resulted in a conflict with
dri-drivers etc.).

Brian asked if this works with GCC v4.9 - yes.

Have fun!

- Sedat -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-configure-add-visibility-macro-detection-v3.patch
Type: text/x-patch
Size: 3937 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150926/b313366d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mapi-add-visibility-hidden-to-tls-entry-points-v3.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150926/b313366d/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_mesa-with-llvm.sh
Type: application/x-sh
Size: 4150 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150926/b313366d/attachment.sh>


More information about the mesa-dev mailing list