[MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
--------------------+-----------------------
 Reporter:  mojca   |      Owner:  jeremyhu
     Type:  defect  |     Status:  new
 Priority:  Low     |  Milestone:
Component:  ports   |    Version:
 Keywords:          |       Port:  clang-4.0
--------------------+-----------------------
 Related to #53194, #53329, #53330.

 Compare the following output on < 10.9:
 {{{
 > g++-mp-6 test.cpp -o test
 # OK
 }}}
 {{{
 > clang++-mp-4.0 -stdlib=libc++ test.cpp -o test
 # OK
 }}}
 {{{
 > clang++-mp-4.0 test.cpp -o test
 test.cpp:1:10: fatal error: 'regex' file not found
 #include <regex>
          ^~~~~~~
 1 error generated.
 }}}
 {{{
 > clang++-mp-4.0 -stdlib=macports-libstdc++ test.cpp -o test
 In file included from test.cpp:1:
 In file included from /opt/local/include/gcc6/c++/regex:35:
 /opt/local/include/gcc6/c++/bits/c++0x_warning.h:32:2: error: This file
 requires compiler and library support for the ISO C++ 2011 standard. This
 support must be
       enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^
 1 error generated.
 }}}
 The file `test.cpp` is a simple `#include <regex> int main() { return 0;
 }`

 While this can be avoided by adding a `-std=c++11` flag, the behaviour
 would be much more consistent if the compiler would assume C++11 by
 default.

 See also #53625 where this first came up.

--
Ticket URL: <https://trac.macports.org/ticket/53634>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------
Changes (by jeremyhu):

 * owner:  jeremyhu => mojca
 * status:  new => assigned


Comment:

 I'm certainly fine letting -stdlib=macports-libstdc++ imply -std=c++11.
 Feel free to make that change.  Of course, -stdlib=libstdc++ should not
 change.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by mojca):

 Marcus, since you were patching this, do you have any idea where/how to
 fix the behaviour? I'm not too familiar with llvm sources. I did some
 grep-ing for various variables, I found places like `Opts.CPlusPlus11 =
 Std.isCPlusPlus11()`, but it's so much code that it's nearly impossible to
 know where the decision is made about whether or not C++11 should be the
 default.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------
Changes (by mojca):

 * cc: kencu (added)


--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by kencu):

 I'm thinking that this bit in Marcus' patch:
 {{{
 +  case ToolChain::CST_MacPortsLibstdcxx:
 +    if (getVFS().exists("@@MACPORTS_libstdc++@@")) {
 +      CmdArgs.push_back("@@MACPORTS_libstdc++@@");
 +      return;
 +    }
 +    CmdArgs.push_back("-lstdc++");
 +    break;
 }}}

 could be this instead:
 {{{
 +    CmdArgs.push_back("-lstdc++");
 +    CmdArgs.push_back("-std=c++11");
 }}}

 there's another spot at the very end of the patch that does the same kind
 of push_back, and probably the same extra addition should go there,
 although the way it's written right now it might also affect CST_Libstdcxx
 and so we would need a separate break; item for each CST.

 {{{
    case ToolChain::CST_Libstdcxx:
 +  case ToolChain::CST_MacPortsLibstdcxx:
      CmdArgs.push_back("-lstdc++");
      break;
 }}}

 like this maybe:

 {{{
    case ToolChain::CST_Libstdcxx:
      CmdArgs.push_back("-lstdc++");
      break;
    case ToolChain::CST_MacPortsLibstdcxx:
      CmdArgs.push_back("-lstdc++");
      CmdArgs.push_back("-std=c++11");
      break;
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by kencu):

 Yeah, I'm not so sure about that now that I look at it -- this would be
 happening while the build line is being parsed, so would it work to push
 back the `std=` onto the build line again? Would it get re-parsed?

 Perhaps you'd have to find out what `-std=c++11` invokes when being
 parsed, and do that. Is setting this enough, I wonder:
 {{{
 Opts.CPlusPlus11 = Std.isCPlusPlus11()
 }}}

 There might be more to it.

 And then what if there is some other `-std=` line on the build line?
 Presumably that should win.

 Enough speculation, I guess. Have to dig in and try different things to
 sort this out.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by kencu):

 More I think about how this works, the more it seems a better idea to add
 {{{
 configure.cxxflags-append -std=c++11
 }}}

 in the right place in the cxx11 1.1 portgroup file rather than try to
 outsmart clang.

 Should also cover the option where the person has actually set
 `configure.cxx_stdlib macports-libstdc++` in macports.conf.

 and also not whitelist clang-4.0 on PPC, so solve a couple of tickets
 recently.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:7>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by kencu):

 There is a bit of logic in tools/clang/lib/Driver/Tools.cpp where the
 build line parsing logic looks for a std language standard to be set, and
 if there is none, appears to offer one up for c, but apparently not for
 c++ unless you're on Windows, if I read this correctly.

 {{{
     if (!types::isCXX(InputType))
       Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
 "-std=",
                                 /*Joined=*/true);
     else if (IsWindowsMSVC)
       ImplyVCPPCXXVer = true;
 }}}

 `ImplyVCPPCXXVer = true` leads to a block of code later down that sets a
 standard language on Windows. So far, this would seem to me to be the most
 likely place to add in a default c++ language standard, if a suitable test
 for darwin && stdlib=macports-libsdtc++ could be generated.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:8>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [MacPorts] #53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by default

MacPorts
In reply to this post by MacPorts
#53634: clang++-mp-4.0 -stdlib=macports-libstdc++ should be in C++11 mode by
default
------------------------+----------------------
  Reporter:  mojca      |      Owner:  mojca
      Type:  defect     |     Status:  assigned
  Priority:  Low        |  Milestone:
 Component:  ports      |    Version:
Resolution:             |   Keywords:
      Port:  clang-4.0  |
------------------------+----------------------

Comment (by kencu):

 FYI, it looks like there was some recent discussion going on about
 defaulting to c++11 or c++14 on the clang developers mailing list: <http
 ://clang-developers.42468.n3.nabble.com/Setting-default-dialect-
 to-C-11-td4055489.html.

--
Ticket URL: <https://trac.macports.org/ticket/53634#comment:9>
MacPorts <https://www.macports.org/>
Ports system for macOS
Loading...