Reviewing merge request #433: Add ELF visibility support for SunStudio 8 or later

SunStudio since version 8 (CC version 5.5) has had the ability to control symbol visibility in ABI via the linker option
-xldscope=[global|symbolic|hidden]
and via code "attributes" __global, __symbolic & __hidden.

-xldscope=global maps to GCC's -fvisibility=default
-xldscope=symbolic maps to GCC's -fvisibility=protected
-xldscope=hidden maps to GCC's -fvisibility=hidden

__global maps to GCC's __attribute__((visibility("default"))
__symbolic maps to GCC's __attribute__((visibility("protected"))
__hidden maps to GCC's __attribute__((visibility("hidden"))

This merge requests adds SunStudio to the available compilers that can do ELF visibility.

During the development of this feature, it was noticed that 1 variable, qt_x11Data, was declared with a different visibility than it was defined with. Only SunStudio caught this. So, the 1st commit is to first that problem, with the 2nd commit being the actual changes to enable ELF visibility for the SunStudio 8 and later compiler suite.

Commits that would be merged:

Version 1
  • Version 1
  • 7dee69c
  • 346dc80
  • The declaration of qt_x11Data needs to be consistent across the header

  • 1a61739
  • Add the ability for the SunStudio 8+ compilers to do

  • ef67a11
  • Support both gcc & g++ as a valid GCC compiler.

Showing 7dee69c-346dc80

Comments

Hi

This patch looks correct and I'd apply it.

I jsut didn’t understand the change to qt_x11_p.h. Why did you make that change?

In qt_x11_p.h, with -xldscope=hidden in effect, makes the declaration of qt_x11Data essentially:

extern __hidden QX11Data *qt_x11Data;

In qapplication_x11.cpp, it’s definition is
Q_GUI_EXPORT QX11Data qt_x11Data;
which maps it to
__global QX11Data
qt_x11Data

The two must be identical. GCC doesn’t throw an error message, and makes it global (I think). SunStudio, however, issues an error message about it: “Error: Linker scopes may not change after symbol definition.”

Unfortunately, I don’t know which linker scope is the correct one. So, I went with the one that would cause the least headache if anyone uses it (Q_GUI_EXPORT). Now that I look at the Qt sources more carefully, it looks like qt_x11Data is only used in QtGui. So, the original declaration in qt_x11_p.h would be correct, and the definition in qapplication_x11.cpp would need to be changed to remove Q_GUI_EXPORT. That would remove any explicit linker scope to the variable and allow the compiler option to take effect, making it hidden.

Ok, fair enough, I’ll accept the change.

With GCC, what happens is that the first declaration has precedence.

→ State changed from New to Merged

Merged as 91eec1a5c15d53b9f66349430187785dd03d5ddd

Add a new comment:

Login or create an account to post a comment

How to apply this merge request to your repository