[MacPorts] #44129: cmake: fix build against libc++ on Lion

MacPorts noreply at macports.org
Mon Jul 28 14:16:06 PDT 2014


#44129: cmake: fix build against libc++ on Lion
----------------------+-------------------
  Reporter:  mojca@…  |      Owner:  css@…
      Type:  defect   |     Status:  new
  Priority:  Normal   |  Milestone:
 Component:  ports    |    Version:
Resolution:           |   Keywords:  lion
      Port:  cmake    |
----------------------+-------------------

Comment (by mojca@…):

 I found out what the problem was. CMake uses complicated code (as a
 workaround to compiler bugs) to read lines and `istream.gcount()` in clang
 3.3 with libc++ is buggy. The following code:
 {{{
 #include <iostream>
 #include <fstream>
 #include <string>

 int main()
 {
   std::ifstream is("test.txt");
   std::string line;
   const int bufferSize = 11;
   char buffer[bufferSize];
   is.getline(buffer, bufferSize);
   std::cout << is.gcount() << std::endl;
   return 0;
 }
 }}}
 returns 11 instead of 10 (for input text with > 10 characters).

 Until the problem gets fixed the workaround is to use clang 3.4 or 3.5.

 Would something like that work?

 {{{
     platform darwin 11 {
         if {${configure.cxx_stdlib} eq "libc++"} {
             # everything but macports-clang-3.4 macports-clang-3.5
             compiler.blacklist-append *gcc* {clang < 500} macports-
 clang-2.9 macports-clang-3.0 macports-clang-3.1 macports-clang-3.2
 macports-clang-3.3
             compiler.fallback-append macports-clang-3.4 macports-clang-3.5
         }
     }
 }}}

 We probably need to blacklist just clang 3.3 (`{clang < 500} macports-
 clang-3.3`). (I'm not sure if other compilers even work with libc++.)

 On the other hand we can simply wait for an upstream fix.

-- 
Ticket URL: <https://trac.macports.org/ticket/44129#comment:4>
MacPorts <http://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list