[GHC] #7904: GHC calls the cc1 of a gcc thats not the first in PATH

#7904: GHC calls the cc1 of a gcc thats not the first in PATH -------------------------+-------------------------------------------------- Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Blockedby: Blocking: | Related: -------------------------+-------------------------------------------------- I was earlier today trying to build some haskell code that ffi's out to some c code that uses SSE4 / AVX intrinsics, and was getting odd errors about not understanding -mavx or -msse4.2 , which was quite surprising since I was able to build those same c source files with clang or the gcc 4.8 i have at the top of my path. After some digging (and running dtrace while trying to bulld my code), I found that some point in the build process, ghc/cabal was running the cc1 of the apple gcc-llvm v4.2 (ie the gcc version i had used to build the ghc and comes with apple dev tools current version, and which lacks support for avx or sse4.2 ). I only hit this problem because i was deliberately writing code that would only compile assuming avx / sse4.2 support on the c compiler side, though this does have the implication that when ghc users are doing a simple cabalized build of some c code that has SIMD intrinsics, it'll only use simd <= ssse3, no higher. This could result in certain haskell codes on os x that lean on vectorized ffi's being 2x slower or worse than on other architectures perhaps. I'll be working around this problem in my own software development by rebuilding ghc on my mac using gcc 4.8 and see if that resolves that problem. That ends my overview of the bug whereby ghc uses the cc1 of the gcc that built it even when others are earlier in the path (which creates unexpected problems when naively using ghc as the c compilation driver). Now for the feature request: assuming theres a good reason for having the cc1 choice hard coded in, it'd probably be helpful for ghc to issue a warning when the hardwired cc1 refers to a gcc that isn't the first one visible when looking up gcc in the $path. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH -------------------------+-------------------------------------------------- Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Blockedby: Blocking: | Related: -------------------------+-------------------------------------------------- Comment(by carter): i can cook up a reproducible test case for this on os x if folks want one. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: wontfix | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by igloo): * status: new => closed * difficulty: => Unknown * resolution: => wontfix Comment: As far as I know GHC and Cabal only call gcc, not cc1. However, it's deliberate that we default to using the gcc (and the gcc flags) that was chosen when building ghc. This means that, for example, we know that on OS X the gcc will produce binaries for the right platform (OSX/x86_64 rather than OSX/x86, say). I don't think we want to warn every time GHC is run if you have asked it to use a different gcc to the default. If you want to see what gcc is being used, then you can add `-v` to the ghc command line. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by carter): * status: closed => new * resolution: wontfix => Comment: No, you misunderstand: i am saying that when I explicitly tell ghc to use either gcc-4.8 or clang, through -pgmc gcc-4.8 or -pgmc clang along with say trying the approach described in [http://stackoverflow.com/questions/2528887/c-compiler-selection-in-cabal- package this stack overflow discussion], ghc is still using the cc1 of gcc-llvm-4.2, which was used to build the ghc. I will attach the dtrace logs from my -fllvm and -pgmc clang run to provide proof of this. let me restate this: GHC ignores what compiler i tell it to use when it reaches the point where cc1 is called. There is no "default", there is a hard coded BUG. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by igloo): You might need to use `-pgml` or `-pgma`, depending on what GHC is doing when it calls the wrong C compiler. If that doesn't explain it, could you also add `-v` to the GHC command line, and paste both the command and the output here please? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by carter): mark lentczer has pointed out that the settings file in <local ghc base dir>/lib/ghc<ghcversion> has a field ("C compiler command", "/usr/bin/gcc"), and when i change it to be "clang" or "gcc-4.8" to match the rest of the build process, things work or at least i discover new problems that aren't quite this one :) @ igloo, i'll try that shortly. what are the default values for -pgml and -pgma? when i fix up the ghc settings file to point to my gcc, when i run the build i get {{{ cabal configure ; cabal build 1 ↵ Resolving dependencies... Configuring numerics-0.1.0.0... Building numerics-0.1.0.0... Preprocessing library numerics-0.1.0.0... /var/folders/py/wgp_hj9d2rl3cx48yym_ynj00000gn/T/ghc8512_0/ghc8512_0.s:18:0: no such instruction: `vmovsd (%rsi), %xmm1' /var/folders/py/wgp_hj9d2rl3cx48yym_ynj00000gn/T/ghc8512_0/ghc8512_0.s:19:0: no such instruction: `vmovsd 8(%rsi), %xmm0' /var/folders/py/wgp_hj9d2rl3cx48yym_ynj00000gn/T/ghc8512_0/ghc8512_0.s:20:0: no such instruction: `vmulsd (%rdx), %xmm1,%xmm1' /var/folders/py/wgp_hj9d2rl3cx48yym_ynj00000gn/T/ghc8512_0/ghc8512_0.s:21:0: no such instruction: `vmulsd 8(%rdx), %xmm0,%xmm0' }}} with the no such instruction verbiage going on for a few hundred more lines. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by carter): I should remark that things build fine when I don't do -mavx or -march=native at this point, but that kinda defeats the whole point of this exercise -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Comment(by carter): the way the haskell platform papers over this on mac is with https://github.com/haskell/haskell- platform/blob/master/src/macos/PatchSettings.hs to adjust the ar and gcc name settings in the ghc settings file. which effectively hides / papers over the issue that the -pgmc CCName flag doesn't seem to quite work Hrm, it looks like my other issue comes from the {{{as}}} that apple provides not supporting AVX! I tried the workaround using "gcc -c" or "clang -c" or "gcc -c -Xassembler" my assembler via the -pgma flags, but that didn't fix it / didn't work instead, i used the directions in this stack overflow http://stackoverflow.com/questions/9840207/how-to-use-avx-pclmulqdq-on- mac-os-x-lion to an {{{as}}} wrapper i've put on my PATH. This works. That still leaves the matter that -pgmc doesn't fully override the ghc SETTINGS file though, and that my attempt at using -pgma didn't work either -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7904: GHC calls the cc1 of a gcc thats not the first in PATH ---------------------------+------------------------------------------------ Reporter: carter | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: invalid | Keywords: Os: MacOS X | Architecture: x86_64 (amd64) Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ Changes (by carter): * status: new => closed * resolution: => invalid Comment: after much much digging, looks like its a cabal side problem -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7904#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC