Bug #714
problem compiling with Sun Studio - visibility
100%
Description
On OpenSolaris b134 with the Sun Studio 12u1 compiler, the build of exiv2 0.20 fails with
...
"error.hpp", line 97: Error: Identifier expected instead of "__attribute__".
This is because the use of attribute ((visibility(x)) is not part of the C++ standard, it's gcc specific and not supported by sun studio.
The attached patch worked for me.
reference:
http://gcc.gnu.org/wiki/Visibility
http://wikis.sun.com/display/SunStudio/Using+Sun+Studio+for+open+source+apps
Files
Related issues
Associated revisions
History
Updated by Andreas Huggel over 11 years ago
Hi Pavel,
Thanks for reporting this issue. Assuming you configure your system with the ./configure script, for the patch to have any effect, the EXV_HAVE_GXXCLASSVISIBILITY
compiler define must be set. That's the case if the visibility support is not explicitely disabled with the --disable-visibility
configure option and if the compiler has a -fvisibility-inlines-hidden
option (see below).
Does the Sun compiler indeed have this option?
AC_MSG_CHECKING([whether to enable g++ visibility support]) AC_ARG_ENABLE(visibility, [ --disable-visibility do not use g++ visibility support ], GXX_VISIBILITY=$enableval, GXX_VISIBILITY=yes) AC_MSG_RESULT($GXX_VISIBILITY) if test "$GXX_VISIBILITY" = "yes"; then AX_CXX_CHECK_FLAG(-fvisibility-inlines-hidden,[],[],[GXX_VISIBILITY=yes],[GXX_VISIBILITY=no]) if test "$GXX_VISIBILITY" = "yes"; then CXXFLAGS="${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" AC_DEFINE(HAVE_GXXCLASSVISIBILITY,1) fi if test "$enable_shared" = "yes"; then AC_DEFINE(HAVE_DLL) fi fi
Updated by Pavel Heimlich over 11 years ago
Hi,
studio does not have the -fvisibility* options, however it may ignore them, so I guess that's how the HAVE_GXXCLASSVISIBILITY parameter got enabled.
The equivalent flag to fvisibility-hidden is -xldscope=hidden
see
http://forums.sun.com/thread.jspa?threadID=5404019
http://docs.sun.com/app/docs/doc/820-7599/bkbda?a=view
from what I gathered, -fvisibility-inlines-hidden does not have an equivalent in Studio
Updated by Andreas Huggel over 11 years ago
- Category set to build
- Target version set to 0.21
- % Done changed from 0 to 50
Checked-in generalized visibility support which should now also work with the Sun Studio compiler. It sets the compiler defines according to the patch and sets the -xldscope=hidden
flag if supported.
Appreciate if you can test this and let me know if it works.
Thanks,
Andreas
PS: This also needs to be implemented in the cmake build scripts.
Updated by Pavel Heimlich almost 10 years ago
- File exiv2-visibility.diff exiv2-visibility.diff added
I tried v0.22 with Solaris11 and Solaris Studio 12.3 and the Studio detection code is incomplete.
First, it only works for the C compiler (cc defines __SUNPRO_C, CC defines __SUNPRO_CC).
Second, the version condition is not really necessary as all currently supported (and available for download) Studio versions do support __global.
I had to use the attached patch to build exiv2 0.22
Updated by Robin Mills about 6 years ago
- Category changed from build to not-a-bug
- Status changed from New to Closed
- Assignee set to Robin Mills
- Target version changed from 1.0 to 0.26
This is an unsupported compiler. Please see the comments in #710 concerning compiler and platform support.
#714: Extended C++ symbol visibility support for Sun Studio C++ compiler.