Boost C++ Libraries: Ticket #7559: gcc-compatible symbol visibility not supported for clang https://svn.boost.org/trac10/ticket/7559 <p> boost/config/compiler/gcc.hpp defines BOOST_SYMBOL_VISIBLE and BOOST_SYMBOL_EXPORT to be <span class="underline">attribute</span>((visibility("default"))) when not running under Windows. But boost/config/compiler/clang.hpp does not define these symbols. This creates compatibility problems on OS X when linking binaries built with gcc to binaries built with clang. Since clang is used as a replacement for gcc, I would expect that BOOST_SYMBOL_VISIBLE and BOOST_SYMBOL_EXPORT should be defined in the same way for clang. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7559 Trac 1.4.3 Jonathan Jones <jonathan.jones@…> Tue, 23 Oct 2012 17:48:03 GMT cc set https://svn.boost.org/trac10/ticket/7559#comment:1 https://svn.boost.org/trac10/ticket/7559#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">jonathan.jones@…</span> added </li> </ul> Ticket James Walker <jamesw@…> Tue, 23 Oct 2012 22:56:52 GMT <link>https://svn.boost.org/trac10/ticket/7559#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:2</guid> <description> <p> Oops, the underscores in __attribute__ were taken as <a class="wiki" href="https://svn.boost.org/trac10/wiki/WikiFormatting">WikiFormatting</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Wed, 24 Oct 2012 00:24:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/81052" title="Adding `BOOST_SYMBOL_VISIBLE` macro; refs #7559">[81052]</a>) Adding <code>BOOST_SYMBOL_VISIBLE</code> macro; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7559" title="#7559: Bugs: gcc-compatible symbol visibility not supported for clang (closed: fixed)">#7559</a> </p> </description> <category>Ticket</category> </item> <item> <author>James Walker <jamesw@…></author> <pubDate>Wed, 24 Oct 2012 01:01:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7559#comment:3" title="Comment 3">michel</a>: </p> <blockquote class="citation"> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/81052" title="Adding `BOOST_SYMBOL_VISIBLE` macro; refs #7559">[81052]</a>) Adding <code>BOOST_SYMBOL_VISIBLE</code> macro; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7559" title="#7559: Bugs: gcc-compatible symbol visibility not supported for clang (closed: fixed)">#7559</a> </p> </blockquote> <p> Is there a reason for not also defining BOOST_SYMBOL_EXPORT? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Wed, 24 Oct 2012 01:23:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:5</guid> <description> <blockquote class="citation"> <p> Is there a reason for not also defining BOOST_SYMBOL_EXPORT? </p> </blockquote> <p> I'll add <code>BOOST_SYMBOL_EXPORT</code> and <code>BOOST_SYMBOL_IMPORT</code> after collecting information about clang on the Windows platform. It will be done in a few days, I think. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Mathias Gaunard</dc:creator> <pubDate>Thu, 25 Oct 2012 12:26:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:6</guid> <description> <p> on the Windows platform clang uses the code path in platform/win32.hpp. clang supports both <code>__attribute__</code> and <code>__declspec</code>. </p> <p> What I'd recommend is to put in compiler/clang.hpp the following </p> <pre class="wiki">#if !defined(_WIN32) &amp;&amp; !defined(__WIN32__) &amp;&amp; !defined(WIN32)) #define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) #define BOOST_SYMBOL_IMPORT #define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) #endif </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 25 Oct 2012 12:36:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:7</guid> <description> <p> Just a note to say I'm aware of this issue, but as I'm not a Clang user I'd really like for someone to provide a patch that I can just blindly go ahead and apply... </p> <p> Thanks, John Maddock. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Thu, 25 Oct 2012 15:42:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7559#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:8</guid> <description> <p> I was planning to add the following </p> <pre class="wiki">// // Dynamic shared object (DSO) and dynamic-link library (DLL) support // #if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) &amp;&amp; !defined(__CYGWIN__) // All Win32 development environments, including 64-bit Windows and MinGW, define // _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment, // so does not define _WIN32 or its variants. # define BOOST_HAS_DECLSPEC #else # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) # define BOOST_SYMBOL_IMPORT #endif #define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) </pre><p> But I'd like to defer the support for the Windows platform, since there are some subtleties on that platform. I'm going to add <code>BOOST_SYMBOL_EXPORT</code> and <code>BOOST_SYMBOL_IMPORT</code> macros only on other platforms (i.e. the <code>#else</code> branch) for the meantime. </p> <p> The <code>#if</code> condition in the above code is copied from <code>config/compiler/gcc.hpp</code>. John, do you know why <code>!defined(__CYGWIN__)</code> is needed? It looks verbose, since <code>_WIN32</code> or its variants are not defined on cygwin. </p> <p> Also, would it be nice to define <code>BOOST_SYMBOL_IMPORT</code> only on non-Windows platform , as mentioned by Mathias? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Fri, 26 Oct 2012 16:23:48 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7559#comment:9 https://svn.boost.org/trac10/ticket/7559#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/81068" title="Adding `BOOST_SYMBOL_EXPORT` and `BOOST_SYMBOL_IMPORT`; fixes #7559">[81068]</a>) Adding <code>BOOST_SYMBOL_EXPORT</code> and <code>BOOST_SYMBOL_IMPORT</code>; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7559" title="#7559: Bugs: gcc-compatible symbol visibility not supported for clang (closed: fixed)">#7559</a> </p> Ticket Michel Morin Fri, 26 Oct 2012 16:28:31 GMT <link>https://svn.boost.org/trac10/ticket/7559#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7559#comment:10</guid> <description> <p> I chose to use Mathias' code </p> <pre class="wiki">#if !defined(_WIN32) &amp;&amp; !defined(__WIN32__) &amp;&amp; !defined(WIN32) # define BOOST_SYMBOL_EXPORT __attribute__((__visibility__("default"))) # define BOOST_SYMBOL_IMPORT # define BOOST_SYMBOL_VISIBLE __attribute__((__visibility__("default"))) #endif </pre><p> rather than copying the code from <code>config/compiler/gcc.hpp</code>. </p> </description> <category>Ticket</category> </item> </channel> </rss>