[GHC] #8528: Preprocessor issues building GHC HEAD on Mavericks

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------+---------------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: Building GHC failed Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ----------------------------------+---------------------------------------- I can't build GHC HEAD on Mavericks with Xcode 5 and GCC 4.2. My system: * Mavericks, Xcode 5. * Building with GHC 7.6.3 x64 installed from . * Apple GCC 4.2 installed via homebrew. In /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/settings, I've changed the compiled to this: ("C compiler command", "/Users/nkpart/bin/gcc"), ~/bin/gcc is #!/bin/sh echo $* >> ~/bin/gcc_log gcc-4.2 $@ I have run: $ git clone .. $ perl boot $ ./configure $ make The error I get is: "/usr/bin/ghc" -M -static -H64m -O0 -fasm -package-db libraries/bootstrapping.conf -i -iutils/genprimopcode/. -iutils/genprimopcode/dist/build -iutils/genprimopcode/dist/build/autogen -Iutils/genprimopcode/dist/build -Iutils/genprimopcode/dist/build/autogen -package array -no-user-package-db -rtsopts -odir utils/genprimopcode/dist/build -hidir utils/genprimopcode/dist/build -stubdir utils/genprimopcode/dist/build -dep-makefile utils/genprimopcode/dist/build/.depend.haskell.tmp -dep-suffix "" -include-pkg-deps utils/genprimopcode/dist/build/Lexer.hs utils/genprimopcode/./Main.hs utils/genprimopcode/./ParserM.hs utils/genprimopcode/dist/build/Parser.hs utils/genprimopcode/./Syntax.hs line-map.c: file "templates/GenericTemplate.hs" left but not entered utils/genprimopcode/dist/build/Lexer.hs:143:0: error: #else without #if utils/genprimopcode/dist/build/Lexer.hs:144:0: warning: "GTE" redefined utils/genprimopcode/dist/build/Lexer.hs:141:0: warning: this is the location of the previous definition utils/genprimopcode/dist/build/Lexer.hs:145:0: warning: "EQ" redefined utils/genprimopcode/dist/build/Lexer.hs:142:0: warning: this is the location of the previous definition utils/genprimopcode/dist/build/Lexer.hs:146:0: error: #endif without #if utils/genprimopcode/dist/build/Lexer.hs:197:0: error: #else without #if utils/genprimopcode/dist/build/Lexer.hs:200:0: error: #endif without #if make[1]: *** [utils/genprimopcode/dist/build/.depend.haskell] Error 1 make: *** [all] Error 2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ----------------------------------------+---------------------------------- Comment (by nkpart): The gcc command that it fails on is this: {{{ gcc -E -undef -traditional -m64 -fno-stack-protector -m64 -I utils/genprimopcode/dist/build -I utils/genprimopcode/dist/build -I utils/genprimopcode/dist/build/autogen -I /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/base-4.6.0.1/include -I /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/include -D__GLASGOW_HASKELL__=706 -Ddarwin_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Ddarwin_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -U __PIC__ -D__PIC__ -x c utils/genprimopcode/dist/build/Lexer.hs -o /var/folders/s6/tzn1w8qn3vbdym7p74zs62lr0000gn/T/ghc49990_0/ghc49990_0.hscpp }}} I can run that command outside of the build and replicate the failure (as long as I change the `-o`). It fails with gcc-4.2 and gcc-4.8. However, it works with clang. Does the build try and guess if I've got fake clang gcc or apple-gcc installed? Could it be getting that wrong? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ----------------------------------------+---------------------------------- Comment (by carter): huh, this is really weird! Can we get someone else with a machine that has Mavericks to try to repro this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Changes (by hvr): * keywords: => clang * priority: normal => high * related: => #8480 Old description:
I can't build GHC HEAD on Mavericks with Xcode 5 and GCC 4.2.
My system:
* Mavericks, Xcode 5. * Building with GHC 7.6.3 x64 installed from . * Apple GCC 4.2 installed via homebrew.
In /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/settings, I've changed the compiled to this:
("C compiler command", "/Users/nkpart/bin/gcc"),
~/bin/gcc is
#!/bin/sh echo $* >> ~/bin/gcc_log gcc-4.2 $@
I have run:
$ git clone .. $ perl boot $ ./configure $ make
The error I get is:
"/usr/bin/ghc" -M -static -H64m -O0 -fasm -package-db libraries/bootstrapping.conf -i -iutils/genprimopcode/. -iutils/genprimopcode/dist/build -iutils/genprimopcode/dist/build/autogen -Iutils/genprimopcode/dist/build -Iutils/genprimopcode/dist/build/autogen -package array -no-user-package-db -rtsopts -odir utils/genprimopcode/dist/build -hidir utils/genprimopcode/dist/build -stubdir utils/genprimopcode/dist/build -dep-makefile utils/genprimopcode/dist/build/.depend.haskell.tmp -dep-suffix "" -include-pkg-deps utils/genprimopcode/dist/build/Lexer.hs utils/genprimopcode/./Main.hs utils/genprimopcode/./ParserM.hs utils/genprimopcode/dist/build/Parser.hs utils/genprimopcode/./Syntax.hs line-map.c: file "templates/GenericTemplate.hs" left but not entered
utils/genprimopcode/dist/build/Lexer.hs:143:0: error: #else without #if
utils/genprimopcode/dist/build/Lexer.hs:144:0: warning: "GTE" redefined
utils/genprimopcode/dist/build/Lexer.hs:141:0: warning: this is the location of the previous definition
utils/genprimopcode/dist/build/Lexer.hs:145:0: warning: "EQ" redefined
utils/genprimopcode/dist/build/Lexer.hs:142:0: warning: this is the location of the previous definition
utils/genprimopcode/dist/build/Lexer.hs:146:0: error: #endif without #if
utils/genprimopcode/dist/build/Lexer.hs:197:0: error: #else without #if
utils/genprimopcode/dist/build/Lexer.hs:200:0: error: #endif without #if make[1]: *** [utils/genprimopcode/dist/build/.depend.haskell] Error 1 make: *** [all] Error 2
New description: I can't build GHC HEAD on Mavericks with Xcode 5 and GCC 4.2. My system: * Mavericks, Xcode 5. * Building with GHC 7.6.3 x64 installed from . * Apple GCC 4.2 installed via homebrew. In `/Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/settings`, I've changed the compiled to this: {{{ ("C compiler command", "/Users/nkpart/bin/gcc"), }}} `~/bin/gcc` is {{{ #!/bin/sh echo $* >> ~/bin/gcc_log gcc-4.2 $@ }}} I have run: {{{ $ git clone .. $ perl boot $ ./configure $ make }}} The error I get is: {{{ "/usr/bin/ghc" -M -static -H64m -O0 -fasm -package-db libraries/bootstrapping.conf -i -iutils/genprimopcode/. -iutils/genprimopcode/dist/build -iutils/genprimopcode/dist/build/autogen -Iutils/genprimopcode/dist/build -Iutils/genprimopcode/dist/build/autogen -package array -no-user-package-db -rtsopts -odir utils/genprimopcode/dist/build -hidir utils/genprimopcode/dist/build -stubdir utils/genprimopcode/dist/build -dep-makefile utils/genprimopcode/dist/build/.depend.haskell.tmp -dep-suffix "" -include-pkg-deps utils/genprimopcode/dist/build/Lexer.hs utils/genprimopcode/./Main.hs utils/genprimopcode/./ParserM.hs utils/genprimopcode/dist/build/Parser.hs utils/genprimopcode/./Syntax.hs line-map.c: file "templates/GenericTemplate.hs" left but not entered utils/genprimopcode/dist/build/Lexer.hs:143:0: error: #else without #if utils/genprimopcode/dist/build/Lexer.hs:144:0: warning: "GTE" redefined utils/genprimopcode/dist/build/Lexer.hs:141:0: warning: this is the location of the previous definition utils/genprimopcode/dist/build/Lexer.hs:145:0: warning: "EQ" redefined utils/genprimopcode/dist/build/Lexer.hs:142:0: warning: this is the location of the previous definition utils/genprimopcode/dist/build/Lexer.hs:146:0: error: #endif without #if utils/genprimopcode/dist/build/Lexer.hs:197:0: error: #else without #if utils/genprimopcode/dist/build/Lexer.hs:200:0: error: #endif without #if make[1]: *** [utils/genprimopcode/dist/build/.depend.haskell] Error 1 make: *** [all] Error 2 }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by nkpart): Aha! I have a fix. Although I'm still pretty confused about where the bug really is. Initially, I installed the latest versions of alex (3.1.2) and happy (1.19.1) available on hackage. These were updated in the last couple of days. Rolling back alex to 3.1.0 seems to resolve it. I the clean rebuild process I used was: {{{ # Change the alex link git clean -fdx perl boot ./configure make }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by nkpart): Diffing the generated Lexer.hs file: {{{ ∴ diff Lexer-3.1.0.hs Lexer-3.1.2.hs 123,124c123,124 < {-# LINE 1 "<command-line>" #-} < {-# LINE 1 "templates/GenericTemplate.hs" #-} ---
# 1 "<built-in>" 1 # 1 "templates/GenericTemplate.hs" 2 133a134
140c141 < #if __GLASGOW_HASKELL__ > 706 ---
#if __GLASGOW_HASKELL__ > 706 146a148
194c196 < #if __GLASGOW_HASKELL__ < 503 ---
#if __GLASGOW_HASKELL__ < 503 281a284
297a301
301a306
}}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by hvr): Btw, deciding whether Alex is to blame or rather GHC, and how to actually *fix* the situation really depends on what the formal specification for `{-# LANGUAGE CPP #-}` actually is... but I couldn't find any :-/ The way I understand it, Haskell code on Hackage using CPP seems to have implicitly assumed for several years that http://gcc.gnu.org/onlinedocs/cpp/Traditional-Mode.html is the underlying CPP model. However, Clang's cpp obviously implements different semantics and/or doesn't implement traditional mode at all. So this actually a much larger issue, and it isn't enough to just patch code to compile with both Clang's cpp and GCC's cpp (and hope it doesn't break again, as developers generally don't have both cpp implementation available for testing) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by simonmar): I'm without a clue about what the problem is and how to fix it, and I don't have a Mac. Pull requests gladly accepted :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by hvr): Replying to [comment:7 simonmar]:
I'm without a clue about what the problem is and how to fix it, and I don't have a Mac. Pull requests gladly accepted :-)
One of the problems is that tradional CPP has different semantics, GNU cpp has the `-Wtraditional` flag that warns about some problematic constructs which differ between traditional/non-traditional CPP mode, e.g. assume the following `foo.hs` file: {{{ #if __GLASGOW_HASKELL__ > 706 -- ... #endif }}} then `cpp -Wtraditional foo.hs` would explain that {{{ # 1 "foo.hs" foo.hs:1:3: warning: traditional C ignores #if with the # indented [-Wtraditional] #if __GLASGOW_HASKELL__ > 706 ^ foo.hs:3:3: warning: traditional C ignores #endif with the # indented [-Wtraditional] #endif ^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by simonmar): Yes I understand that clang's cpp doesn't support the same syntax as `cpp -traditional`. What I don't understand is what broke in Alex and how to fix it. I didn't write any indented cpp directives, and there were no changes to `GenericTemplate.hs` between 3.1.0 and 3.1.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by nkpart): Turns out that rolling back alex was a red herring. I needed to make sure that alex was being built with GCC, not with clang. Alex can be built with clang (pretending to be gcc), but if you later call it with gcc (actually being gcc) then it fails in the way you see above. So at the moment, do not build alex with clang-as-gcc, then later call it with gcc-as-gcc. The diff in the Lexer.hs file that I posted above are actually the changes that arise when you switch from a GCC-compiled Alex (what I labeled 3.1.0) to a Clang-compiled Alex (3.1.2). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by simonmar): Right, that makes sense. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Comment (by nkpart): I've sent a small PR against alex on github (https://github.com/simonmar/alex/pull/37), and a similar change for happy (https://github.com/simonmar/happy/pull/12). With those 2 patches, you can build/install alex and happy with clang and then use those tools with GHC-over-gcc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks ----------------------------------------+---------------------------------- Reporter: guest | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building GHC failed | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #8480 ----------------------------------------+---------------------------------- Changes (by thoughtpolice): * milestone: => 7.10.1 Comment: Moving to 7.10, as there's still stuff to do here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8528: Preprocessor issues building GHC HEAD on Mavericks -------------------------------------+------------------------------------- Reporter: guest | Owner: Type: bug | Status: closed Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: clang Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Building | Difficulty: Unknown GHC failed | Blocked By: Test Case: | Related Tickets: #8480 Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => fixed Comment: The patches to Alex and Happy have been released. I think the immediate issue here is fixed. See #7678 for the general issue to accommodate the clang preprocessor. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8528#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC