New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cxx-Options for -std=c++11 #3700
Comments
We discussed this with @dcoutts once. Yes, there should be |
I'm trying to understand what changes this would entail. Are we still going to invoke GHC to build these C++'ified headers? Then how do we pass these C++ headers; i.e., what exact flags do you want GHC to be invoked with? @amigalemming , I think you can help here: can you run a build of your project with |
Me and @dcoutts think that we shouldn't be using a Haskell compiler for building non-Haskell sources at all; we should just invoke |
Recently I found that the issue was more serious on a Mac (or the gcc version installed there). On this Mac the |
@amigalemming, would you be interested in helping contributing a fix to this problem? Would be happy to mentor. |
I was hoping to use a convenience library described here to circumvent the issue by separating out the C++ code into the convenience library with differing Having proper support for handling C++ files would be better. I'd be willing to attempt to make some progress on this front if @ezyang's mentoring offer still stands. |
So, the big problem is deciding on a reasonable design. The key existing code is in The current design is that for each C source file, we call GHC to build it. We do some work to compute the options (vanillaCcOpts, profCcOpts) in each case to make sure that it works with each of the compilation modes. So the first thing to do is make a decision: are you going to build C++ with GHC (is this even possible? Sounds like it is, based on how people are putting C++ sources in c-sources), or teach Cabal how to lookup and interface with a C++ compiler? Former sounds easier, latter sounds "more correct" but could be a lot more work. If you opt for the former, then adding support for C++ might be as simple as effectively copy pasting the C build code, but replacing all references to C with C++. Of course, you shouldn't actually do that; it would be better to refactor the code so it isn't duplicated, and there may be a lot of places in Cabal where c-sources is hard coded that need to be adjusted to handle cpp-sources (best to refactor this to use some centralized function.) |
Thanks for the direction. I have a couple of irons in the fire right now, but hopefully I will be able to explore this over the next two weeks. I'll probably pursue the first, less correct but technically simpler approach you described. |
Resolved by #4810 |
In the
llvm-ffi
package I have C wrappers around C++ functions of LLVM in the filesupport.cpp
. However, the C++ header files of LLVM-3.5 and later use new C++11 features. Thus I have addedto
llvm-ffi.cabal
. Alternatively, I added-std=c++11
to theCFlags
field ofllvm.pc
for use bypkg-config
.Now I get these warnings:
This is nothing serious, the package works fine. However, the warnings are annoying. Would it help to have a
Cxx-Options
field for Cabal descriptions? However, I do not know whether the Cabal file is the right place for the-std=c++11
option. Unfortunately,pkg-config
does not haveCxxFlags
, too.The text was updated successfully, but these errors were encountered: