Skip to content

No way to pass options to C++ compiler invoked for `addForeignSource LangCxx`

I can embed some C++ code in my Haskell with TH feature addForeignSource LangCxx. As far as I comprehend, this makes some GHC internals create a temporary C++ file and call C++ compiler to it.

When I do this with C code, I'm able to pass the C compiler any option with ghc-options: -optc=_.

But I have no such option for C++.

When I pass C++-specific options via -optc, I get error

Linking .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/foo/foo ...
error: invalid argument '-std=c++11' not allowed with 'C'
`gcc' failed in phase `C Compiler'. (Exit code: 1)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information