fpco / inline-c

284 stars 50 forks source link

with --profile, error: invalid argument '-std=c++11' not allowed with 'C' #102

Closed gaze closed 4 years ago

gaze commented 4 years ago

Hey all, I have an lts-14.11 stack project that builds just fine when invoking stack build, but when building using stack build --profile, I get the following output

$ stack build --profile
inline-c-cpp-0.3.0.2: configure
inline-c-cpp-0.3.0.2: build
Progress 1/2

--  While building package inline-c-cpp-0.3.0.2 using:
      /Users/gaze/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/gaze/my/nestor-hs/nestor/.stack-work/logs/inline-c-cpp-0.3.0.2.log

    Configuring inline-c-cpp-0.3.0.2...
    Preprocessing library for inline-c-cpp-0.3.0.2..
    Building library for inline-c-cpp-0.3.0.2..
    [1 of 2] Compiling Language.C.Inline.Cpp ( src/Language/C/Inline/Cpp.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Language/C/Inline/Cpp.o )
    [2 of 2] Compiling Language.C.Inline.Cpp.Exceptions ( src/Language/C/Inline/Cpp/Exceptions.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Language/C/Inline/Cpp/Exceptions.o )
    [1 of 2] Compiling Language.C.Inline.Cpp ( src/Language/C/Inline/Cpp.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Language/C/Inline/Cpp.p_o )
    error: invalid argument '-std=c++11' not allowed with 'C'
    `clang++' failed in phase `C Compiler'. (Exit code: 1)

This is under macOS 10.14.4. It's repeatable when deleting ~/.stack and/or .stack-work and then running build or build --profile in either order.

bitonic commented 4 years ago

Thanks for the report. It looks like a clang-specific issue. However, I can't easily reproduce because of https://github.com/commercialhaskell/stack/issues/4073 . I might just try on the macbook later, but in the meantime, can you post a fully verbose build here? Maybe I can offer some guidance then.

gaze commented 4 years ago

Here's stack build --profile --verbose

dump.txt

bitonic commented 4 years ago

@gaze sadly that does not include the ghc invocation, and the invocation itself is not verbose. I think --verbose --cabal-verbose --ghc-options=-v should do it.

gaze commented 4 years ago

Apologies! Still a bit new to Haskell.

stack build --profile --verbose --cabal-verbose --ghc-options=-v 2> dump2.txt dump2.txt

gaze commented 4 years ago

Fwiw, this allowed me to build. Not sure what the interaction would be with other platforms

diff --git a/inline-c-cpp/inline-c-cpp.cabal b/inline-c-cpp/inline-c-cpp.cabal
index 7985158..2e9ad42 100644
--- a/inline-c-cpp/inline-c-cpp.cabal
+++ b/inline-c-cpp/inline-c-cpp.cabal
@@ -26,7 +26,7 @@ library
                      , safe-exceptions
   hs-source-dirs:      src
   default-language:    Haskell2010
-  ghc-options:         -Wall -optc-std=c++11
+  ghc-options:         -Wall -optc-xc++
   if os(darwin)
     -- avoid https://gitlab.haskell.org/ghc/ghc/issues/11829
     ld-options:        -Wl,-keep_dwarf_unwind
bitonic commented 4 years ago

@gaze thank you, -optc-x-c++ makes a lot of sense, but I do not know why it'd break only with --profile. Anyway, I've created https://github.com/fpco/inline-c/pull/103 to fix this problem in the repo. It's a shame that even with those verbosity options we still do not see the cc invocation...

bitonic commented 4 years ago

@gaze I've added -x-c++ to inline-c-cpp.cabal, and uploaded new inline-c-cpp version 0.3.0.3.

tscholak commented 3 years ago

seems this issue is back with ghc 8.10.3. has anybody else run into this again recently?