#11544 closed Bugs (fixed)
Error: Linker scopes may not change after symbol definition.
Reported by: | Owned by: | ||
---|---|---|---|
Milestone: | To Be Determined | Component: | Building Boost |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | regex, serialization | Cc: |
Description
I compiled Boost 1.59.0 with Solaris Studio 12.4 in C++11 mode and I get the following error messages:
"./boost/regex/v4/instances.hpp", line 172: Error: Linker scopes may not change after symbol definition. "./boost/regex/v4/instances.hpp", line 174: Error: Linker scopes may not change after symbol definition. "libs/serialization/src/basic_archive.cpp", line 45: Error: Linker scopes may only be more restrictive. "libs/serialization/src/basic_archive.cpp", line 79: Error: Linker scopes may only be more restrictive. "libs/serialization/src/basic_xml_archive.cpp", line 18: Error: Linker scopes may only be more restrictive. "libs/serialization/src/basic_xml_archive.cpp", line 22: Error: Linker scopes may only be more restrictive. "libs/serialization/src/void_cast.cpp", line 315: Error: Linker scopes may only be more restrictive. "libs/serialization/src/void_cast.cpp", line 349: Error: Linker scopes may only be more restrictive.
dmr195 on stackoverflow.com suggested the temporary fix of removing the following lines in boost/config/compiler/sunpro_cc.hpp:
Dynamic shared object (DSO) and dynamic-link library (DLL) support #if SUNPRO_CC > 0x500 # define BOOST_SYMBOL_EXPORT global # define BOOST_SYMBOL_IMPORT global # define BOOST_SYMBOL_VISIBLE global #endif
For now I agree with him that everything works even without symbol scoping. It just means that the linker has to deal with a lot more symbols than it needs to.
According to the Solaris Studio 12.4 C++ User's Guide, to achieve linker scoping equivalent to Visual Studio's scoping the compiler option -xldscope=hidden must be used in combination with the following:
symbolic (equivalent to declspec(dllexport)) global (equivalent to declspec(dllimport))
The above user's guide also specifically warned to use global only on symbol declarations, not symbol definitions.
This warning is most likely the reason why the errors in regex are happening.
BTW, I tried simply changing global to symbolic in the definition of BOOST_SYMBOL_EXPORT without any luck. This may mean that either BOOST_SYMBOL_EXPORT or BOOST_SYMBOL_IMPORT is not used correctly.
Change History (3)
comment:1 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 7 years ago
This ticket has been closed based on a fix to regex. What about serialization? Should I raise a separate ticket for it?
comment:3 by , 7 years ago
This patch is also required for Oracle C++: https://github.com/boostorg/regex/commit/5e98fe9a6ababcc640cfcf0a76685f7ac70384f3
This ticket has been closed based on a fix to regex. What about serialization? Should I raise a separate ticket for it?
Yes please: one ticket per library always works best.
I fixed this slightly differently in https://github.com/boostorg/regex/commit/b9ee7a2f2ee07ff46af9f9339f4a155c2a9c5992, I'll try to find a better fix later.