-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Dealing with C++11 support #22453
Comments
This is one case that the current stdlib tracking doesn't take care of. It needs to be added. We also need to look at adding a new, convenient single DSL command to indicate that a formula requires C++11 and which generates the appropriate Do you know which Apple clang build is necessary for C++11 support? |
Is the libstdc++ used by gcc-4.8+ ABI compatible with the one in clang from Xcode <= 4.6? |
Full C++11 support is ready for clang 3.3, which apple clang 5.0 is based on. Not sure about clang 3.2, but most software support it as well. |
No. Upstream GCC uses libsupc++, while libstdc++ shipped by Apple is (IIRC) ported to build upon libc++abi, so that it is compatible across apple gcc, llvm-gcc, and clang. |
Perhaps a crazy suggestion but instead of tracking and rebuilding this stuff (which seems like a nightmare) I'd suggest just deciding on a single item from that list we support on each OS. e.g. 10.9 and up (or 10.8/7 if they supports Xcode 5), system Clang and system libc++, 10.6 and below always use either gcc-4.8 or Homebrew clang and libc++ (whichever seems to work better). I don't think it's a good idea to be chopping and changing per package. |
I don't think there is a single thing we can choose for everything. Some C++11 packages are going to need GNU GCC, for example, even on newer OSs. And, if I'm reading right, @manphiz says that different revisions of the C++ standard aren't intercompatible either - something using an older version of C++ won't be compatible with something building for C++11. |
Ok. We can certainly pick a stdlib to use as standard per-compiler though. I'm also not sure there will be (m)any projects we want to support where they won't work with the Clang in Xcode 5 and only the latest GCC. |
Also consider this: Boost built with libc++ cannot be used in programs otherwise linked with libstdc++ and vice versa. Programs built with -std=c++11 cannot use Apple's libstdc++. So; if you have two programs, one that must use C++11 and one that can not use it, and they both use Boost, then you have an uninstallable set. One idea is to have a |
I don't see how this is drastically different to the problem we have with universal. At least a first pass should handle it the same way (have an ENV, have a special option which sets things up and stores state in the tab which can be queried by dependencies). @rolk We're not going to be creating duplicate packages. |
I've pushed a few commits which improve the C++ stdlib tracking, namely:
We still need to standardize a way for users to request what C++ stdlib to use when building with clang, so that we can track a) software on 10.7 and 10.8 being built against libc++ using clang, and b) software on 10.9+ building against libstdc++ using clang. |
I've got a bunch of bottles built on 10.8 that work on 10.6-10.8, but don't work on 10.9, due to the incorrect stdlib. Is there an option I can pass my 10.8 build machine to link against the "correct" stdlib for 10.9, or is there no stdlib that will work from 10.6-10.9? Thanks! |
@staticfloat Your issue is not related to this PR. Please open a new issue instead. |
This allows formulae to declare requirements on standards like C++11 or OpenMP, and automatically fills in the fails_with statements for compilers that don't support it. Partial solution for the features needed in Homebrew#22453.
This allows formulae to declare requirements on standards like C++11 or OpenMP, and automatically fills in the fails_with statements for compilers that don't support it. Partial solution for the features needed in Homebrew#22453.
* Add options and ENV method to specify building in C++11 mode. - Set C++ compiler flags to enable C++11 mode. - To add options to support C++11 mode, a formula can now use option :cxx11 to provide "--c++11" option, and detect and enable C++11 support in install method using ENV.cxx11 if build.cxx11? Closes Homebrew#22453.
Homebrew needs a way to handle C++11 support systematically. Different compilers use different flags/lib for C++11 support, which makes things even more complicated.
The C++11 support in different compiler can be summarized as following:
(It looks like 5.0 will default to libc++)
With stdlib tracking work by @mistydemeo it is possible to distinguish which stdlib is in use. Tracking C++11 support may be needed as well, and may be done using options.
To enable C++11 support:
clang++ -std=c++11 -stdlib=libc++
g++-4.8 -std=c++11
clang++-3.3 -std=c++11 -stdlib=libc++
. This will use system libc++. To use its own libc++, the command looks likeclang++-3.3 -std=c++11 -stdlib=libc++ -nostdlibc++ -I/usr/local/lib/llvm-3.3/c++/v1 -L/usr/local/lib/llvm-3.3/usr/lib -lc++
.Packages built against different stdlib, or same stdlib with different C++ standard support, are incompatible. Formula using C++ may need to track whether its dependency is built using C++11 or not, and attempt to build using the same standard switch.
For adding switch, I'm more fund of just changing ENV.cxx, as modifying flags may interfere with other compilers. For instance, LDFLAGS with -stdlib=libc++ will cause problem when linking fortran executable (e.g. openmpi). Meanwhile, INCLUDE and LIBS should be handled separately.
The text was updated successfully, but these errors were encountered: