Boost C++ Libraries: Ticket #6659: Filesystem compilation broken on Solaris 9 and 10 https://svn.boost.org/trac10/ticket/6659 <p> Output message: </p> <p> libs/filesystem/v3/src/operations.cpp: In function âvoid boost::filesystem3::detail::permissions(const boost::filesystem3::path&amp;, boost::filesystem3::perms, boost::system::error_code*)â: libs/filesystem/v3/src/operations.cpp:1391:11: error: â::fchmodatâ has not been declared </p> <p> This is regression, 1.48 compiles well. I reproduced on both sparc and x86 platforms. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6659 Trac 1.4.3 Beman Dawes Wed, 07 Mar 2012 13:58:36 GMT status changed https://svn.boost.org/trac10/ticket/6659#comment:1 https://svn.boost.org/trac10/ticket/6659#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Here is the code: </p> <blockquote> <p> <em> Mac OS X Lion and some other platforms don't support fchmodat() </em></p> </blockquote> <p> # if defined(AT_FDCWD) &amp;&amp; defined(AT_SYMLINK_NOFOLLOW) \ </p> <blockquote> </span><table class="wiki"> <tr>&amp;&amp; (!defined(<span class="underline">SUNPRO_CC) <td> <span class="underline">SUNPRO_CC &gt; 0x5100) </span></td></tr></table> <p> if (::fchmodat(AT_FDCWD, p.c_str(), mode_cast(prms), </p> <blockquote> <p> !(prms &amp; symlink_perms) ? 0 : AT_SYMLINK_NOFOLLOW)) </p> </blockquote> </blockquote> <p> # else <em> fallback if fchmodat() not supported </em></p> <blockquote> <p> if (::chmod(p.c_str(), mode_cast(prms))) </p> </blockquote> <p> # endif </p> <p> I'm guessing the SUNPRO_CC code is wrong. If you could submit a tested patch, I'd appreciate it. </p> <p> Thanks, </p> <p> --Beman </p> Ticket Vasily Sukhanov <basil@…> Wed, 07 Mar 2012 20:29:25 GMT <link>https://svn.boost.org/trac10/ticket/6659#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:2</guid> <description> <p> SUNPRO_CC has no relation to my case. I had to write that I am using GCC 4.5.3. I didn't find this function in Solaris headers. Documentation (<a class="ext-link" href="http://docs.oracle.com/cd/E19963-01/html/821-1463/chmod-2.html"><span class="icon">​</span>http://docs.oracle.com/cd/E19963-01/html/821-1463/chmod-2.html</a>) says fchmodat is present in Solaris 11. </p> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Mon, 12 Mar 2012 15:01:15 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/6659#comment:3 https://svn.boost.org/trac10/ticket/6659#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">duncanphilipnorman@…</span> added </li> </ul> <p> Just a note that I ran into this on Linux, albeit in a strange circumstance. </p> <ul><li>We develop on modern Linux, but since we support RHEL4, we have some builds that link against RHEL4 glibc (and pthread, etc.). <ul><li>Perhaps we should build Boost on RHEL4 and link against that, but we're lazy, and use the same build of Boost for all of our Linux builds. </li></ul></li><li>To others with the same issue: we're planning to work around this by modifying the same code Beman mentions (in <code>operations.cpp</code>) to <em>always</em> use the fallback. </li></ul><p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6659#comment:1" title="Comment 1">bemandawes</a>: </p> <blockquote class="citation"> <p> Here is the code: </p> </blockquote> <p> Beman, I think you broke the Trac renderer (it's adding funny italics because of the <code>//</code> comments). Perhaps you'd be willing to edit your comment: </p> <ul><li>If you add a line preceding the code snippet that contains just <code>{{{</code> and a line following the snippet that contains just <code>}}}</code>, the renderer will do the right thing. </li><li>Bonus: if you add a line containing just <code>#!cpp</code> to the top of the code snippet, you'll get C++ highlighting. </li></ul> Ticket Duncan Exon Smith <duncanphilipnorman@…> Mon, 12 Mar 2012 15:11:37 GMT <link>https://svn.boost.org/trac10/ticket/6659#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:4</guid> <description> <p> Another note: <code>AT_SYMLINK_NOFOLLOW</code> does not appear to be supported even in Linux. </p> <ul><li>See <a class="ext-link" href="http://www.kernel.org/doc/man-pages/online/pages/man2/fchmodat.2.html"><span class="icon">​</span>http://www.kernel.org/doc/man-pages/online/pages/man2/fchmodat.2.html</a> </li><li>Quote from flags description: <pre class="wiki"> AT_SYMLINK_NOFOLLOW If pathname is a symbolic link, do not dereference it: instead operate on the link itself. This flag is not currently implemented. </pre></li><li>Quote from <code>ERRORS</code>: <pre class="wiki"> ENOTSUP flags specified AT_SYMLINK_NOFOLLOW, which is not supported. </pre></li><li>Perhaps it's premature to use <code>fchmodat()</code>, especially since its main feature -- acting relative to <code>dirfd</code> -- is not even being used. </li></ul> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Mon, 12 Mar 2012 15:32:20 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6659 https://svn.boost.org/trac10/ticket/6659 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-1.49.0-dont_use_fchmodat.patch</span> </li> </ul> <p> Patch to remove unnecessary use of poorly supported <code>fchmodat()</code>. </p> Ticket Duncan Exon Smith <duncanphilipnorman@…> Mon, 12 Mar 2012 15:34:54 GMT <link>https://svn.boost.org/trac10/ticket/6659#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6659#comment:4" title="Comment 4">Duncan Exon Smith &lt;duncanphilipnorman@…&gt;</a>: </p> <blockquote class="citation"> <p> Another note: <code>AT_SYMLINK_NOFOLLOW</code> does not appear to be supported even in Linux. </p> <ul><li>See <a class="ext-link" href="http://www.kernel.org/doc/man-pages/online/pages/man2/fchmodat.2.html"><span class="icon">​</span>http://www.kernel.org/doc/man-pages/online/pages/man2/fchmodat.2.html</a> </li><li>Perhaps it's premature to use <code>fchmodat()</code>, especially since its main feature -- acting relative to <code>dirfd</code> -- is not even being used. </li></ul></blockquote> <p> I've added <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6659/boost-1.49.0-dont_use_fchmodat.patch" title="Attachment 'boost-1.49.0-dont_use_fchmodat.patch' in Ticket #6659">attachment:boost-1.49.0-dont_use_fchmodat.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6659/boost-1.49.0-dont_use_fchmodat.patch" title="Download">​</a> as one way of fixing these problems (as well as the original problem on Solaris), although I admit it may be heavy-handed. </p> </description> <category>Ticket</category> </item> <item> <author>Vasily Sukhanov <basil@…></author> <pubDate>Fri, 22 Jun 2012 09:49:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6659#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:6</guid> <description> <p> Why wasn't this patch integrated into boost 1.50? </p> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Fri, 22 Jun 2012 13:19:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6659#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6659#comment:6" title="Comment 6">Vasily Sukhanov &lt;basil@…&gt;</a>: </p> <blockquote class="citation"> <p> Why wasn't this patch integrated into boost 1.50? </p> </blockquote> <p> I don't know. Beman? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 04 Jul 2012 21:46:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6659#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:8</guid> <description> <p> In the Solaris case, testing the value of SUNPRO_CC won't tell us if fchmodat is supported. For that we need to test whether the system is Solaris 11 or not. The following will test for Solaris 11 if you are using Solaris Studio compilers </p> <pre class="wiki">defined(__SUNPRO_CC) &amp;&amp; defined(__SunOS_5_11) </pre> </description> <category>Ticket</category> </item> <item> <author>Vasily Sukhanov <basil@…></author> <pubDate>Thu, 05 Jul 2012 17:48:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6659#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:9</guid> <description> <p> This is a narrow case. I'm using gcc. </p> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Tue, 10 Jul 2012 15:22:46 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6659 https://svn.boost.org/trac10/ticket/6659 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test-fchmodat.cpp</span> </li> </ul> <p> Test program to demonstrate that Linux does not support AT_SYMLINK_NOFOLLOW. </p> Ticket chrmhoffmann@… Thu, 12 Jul 2012 09:54:17 GMT cc changed https://svn.boost.org/trac10/ticket/6659#comment:10 https://svn.boost.org/trac10/ticket/6659#comment:10 <ul> <li><strong>cc</strong> <span class="trac-author">chrmhoffmann@…</span> added </li> </ul> Ticket Beman Dawes Fri, 13 Jul 2012 12:54:04 GMT <link>https://svn.boost.org/trac10/ticket/6659#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:11</guid> <description> <p> Test_fchmodat.cpp was quite helpful. It runs without asserts a fresh install of Ubuntu 12.04. </p> <p> The problem with the patch is that, as you said, it is too heavy handed. It looses too much information, both in comments and in code. </p> <p> On Linux, I'd prefer to try fchmodat with AT_SYMLINK_NOFOLLOW and then if it fails with ENOTSUP, try again with 0 instead of AT_SYMLINK_NOFOLLOW. That way the code will work correctly if Linux ever fixes AT_SYMLINK_NOFOLLOW. A comment is needed to explain why the code is written that way, too. </p> <p> I'd prefer you rework the patch, test it, and resubmit. </p> <p> Thanks, </p> <p> --Beman </p> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Fri, 13 Jul 2012 15:26:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6659#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:12</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6659#comment:11" title="Comment 11">bemandawes</a>: </p> <blockquote class="citation"> <p> I'd prefer you rework the patch, test it, and resubmit. </p> </blockquote> <p> I've put together another patch that avoids <code>fchmodat()</code> on Linux (but only Linux, this time). Let me argue why: </p> <ul><li>As documented in <a class="ext-link" href="http://man7.org/linux/man-pages/man7/symlink.7.html"><span class="icon">​</span>http://man7.org/linux/man-pages/man7/symlink.7.html</a>, Linux does not support changing permissions on symbolic links (look for the section "Symbolic link ownership, permissions, and timestamps"). Based on the documentation, I can't believe they plan to support this in the future. </li><li>I think you're right that if support for <code>AT_SYMLINK_NOFOLLOW</code> were coming to <code>fchmodat()</code>, it would be best to "future proof" by testing for support programatically (check for <code>ENOTSUP</code> and recall <code>chmod()</code>). </li><li>However, since the limitation of <code>fchmodat()</code> is caused by an operating system limitation that's unlikely to change, I think it's better to just avoid the issue entirely. </li><li>Let me know what you think. </li></ul><p> This version of the patch (<a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6659/linux-no_fchmod_at-r79468.patch" title="Attachment 'linux-no_fchmod_at-r79468.patch' in Ticket #6659">attachment:linux-no_fchmod_at-r79468.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6659/linux-no_fchmod_at-r79468.patch" title="Download">​</a>) applies cleanly to the trunk at <a class="changeset" href="https://svn.boost.org/trac10/changeset/79568" title="Ensure use of __thread keyword is disabled for older Intel compilers.">r79568</a>. </p> <ul><li>It uses the simpler <code>chmod()</code> code on Linux. </li><li>It documents why <code>fchmodat()</code> is not being used on Linux. </li><li>Unlike <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6659/boost-1.49.0-dont_use_fchmodat.patch" title="Attachment 'boost-1.49.0-dont_use_fchmodat.patch' in Ticket #6659">attachment:boost-1.49.0-dont_use_fchmodat.patch</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6659/boost-1.49.0-dont_use_fchmodat.patch" title="Download">​</a>, it <strong>does not</strong> fix the Solaris issue from the <a class="ticket" href="https://svn.boost.org/trac10/ticket/6659#comment:description" title="Description">description</a>, and it also <strong>does not</strong> fix the related Solaris issue from <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7051" title="#7051: Bugs: boost::filesystem compile error on solaris 10 (closed: fixed)">#7051</a>. </li></ul><p> Finally, I don't have access to a Solaris system for testing. </p> <ul><li>If someone else can figure out the preprocessor code necessary to test for Solaris 11, please add it to the patch. I suspect you'll need some sort of sun-specific include. </li><li>Alternatively, if someone on a Solaris 11 or 12 box could run <a class="attachment" href="https://svn.boost.org/trac10/attachment/ticket/6659/test-fchmodat.cpp" title="Attachment 'test-fchmodat.cpp' in Ticket #6659">attachment:test-fchmodat.cpp</a><a class="trac-rawlink" href="https://svn.boost.org/trac10/raw-attachment/ticket/6659/test-fchmodat.cpp" title="Download">​</a> to determine if <code>AT_SYMLINK_NOFOLLOW</code> is even supported, perhaps the fix suggested in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7051" title="#7051: Bugs: boost::filesystem compile error on solaris 10 (closed: fixed)">#7051</a> would be appropriate. In that case a similar approach to the one I argue for above for Linux probably makes sense for Solaris as well (I think you'll just need to add <code>|| defined(sun) || defined(__sun)</code> to my list, as well as some supporting documentation in the comments). </li></ul> </description> <category>Ticket</category> </item> <item> <author>Duncan Exon Smith <duncanphilipnorman@…></author> <pubDate>Fri, 13 Jul 2012 15:28:03 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6659 https://svn.boost.org/trac10/ticket/6659 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">linux-no_fchmod_at-r79468.patch</span> </li> </ul> <p> Patch to stop using fchmodat() on Linux, with an explanation in the comments. </p> Ticket Beman Dawes Fri, 13 Jul 2012 21:02:38 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6659#comment:13 https://svn.boost.org/trac10/ticket/6659#comment:13 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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/79484" title="Fix #6659 and #7051, fchmodat supported only on Solaris 11. Disable ...">[79484]</a>) Fix <a class="reopened ticket" href="https://svn.boost.org/trac10/ticket/6659" title="#6659: Bugs: Filesystem compilation broken on Solaris 9 and 10 (reopened)">#6659</a> and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7051" title="#7051: Bugs: boost::filesystem compile error on solaris 10 (closed: fixed)">#7051</a>, fchmodat supported only on Solaris 11. Disable fchmodat for both Sun and GCC compilers regardless of OS version; a runtime check is too much trouble. </p> Ticket anonymous Fri, 13 Jul 2012 21:25:05 GMT <link>https://svn.boost.org/trac10/ticket/6659#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6659#comment:14</guid> <description> <p> Hi, </p> <p> Shouldn't this be handled in the config.hpp rather than with ifdefs in the cpp code itself? </p> <p> Otherwise thanks for looking into this. </p> <p> Rgds, Chris </p> </description> <category>Ticket</category> </item> <item> <author>szatmari.zs@…</author> <pubDate>Mon, 06 Apr 2015 12:22:25 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6659#comment:15 https://svn.boost.org/trac10/ticket/6659#comment:15 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Hi! </p> <blockquote> <p> This causes problems again. If compiled on a Mac with a target sdk of OS X 10.10 (Yosemite), but -mmacosx-version-min=10.7 (or anything before 10.10), it compiles and links successfully, but it will crash when deployed on older os, but only if it hits this function, so it might appear to be quite hectic and hard to diagnose if deployed on the end user's machine, therefore this is a severe problem. I am sure mmacosx-version-min defines some macros, but I wouldn't bother with it, really, just add an another fallback condition for chmod if: </p> </blockquote> <p> defined(<span class="underline">APPLE</span>) </p> <p> so operations.cpp:1418 becomes: </p> <p> # if defined(AT_FDCWD) &amp;&amp; defined(AT_SYMLINK_NOFOLLOW) \ </p> <blockquote> </span><table class="wiki"> <tr>&amp;&amp; !(defined(<span class="underline">SUNPRO_CC) <td> defined(<span class="underline">sun) </span></td><td> defined(sun)) \ </td></tr><tr>&amp;&amp; !(defined(linux) <td> defined(<span class="underline">linux) </span></td><td> defined(<span class="underline">linux</span>)) \ </td></tr></table> <p> &amp;&amp; !(defined(<span class="underline">APPLE</span>)) </p> </blockquote> Ticket