-
Notifications
You must be signed in to change notification settings - Fork 696
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
Emergency workaround for GHC 7.8.1 on OSX #1740
Comments
I would like to understand the issue before we do something. What's going wrong? Which program is to blame? |
The only thing I can offer right now as additional bit of information (as I don't have OSX here to investigate myself) is
maybe @thoughtpolice can comment on this a bit more |
Just to say this first: I don't think this is quite a blocker for the release of GHC, and an 'immediate' fix might not be necessary. For one, there is a temporary workaround. Two, the problem isn't fully understood, so I'm hesitant to rush this when for the most. That said - the interaction seems to be a bad one between Clang/GHC. I speculate the problem is this: Cabal first preprocesses the source files, and inserts line pragma markers. Then, Haddock is run over all the results of this. But Haddock uses GHC, which in turn invokes the preprocessor again. I suspect this second invocation is where the problem lies. But after staring at it for an inordinate amount of time, I couldn't make heads or tails as to why. For one, GHC's Lexer actually already handles these markers natively - I even tried tweaking the lexer itself, to no avail. Second, GHC emits line markers in almost the exact same way - some markers with only one Overall I don't think a temporary fix would be great in Cabal (I don't have time to write one, but I can test it), but in the mean time we can at least suggest a workaround for the moment. I'll follow up later with steps to reproduce and verify all this. |
Hold on - I don't think cabal is the right place to deal with this. |
I think Cabal is the right place for the fix, even if it's temporary: there is another case the Haskell Platform cannot fix, which is when people may use custom Cabal could easily determine if this workaround is needed. It is only needed during
|
If this is the only way to unbreak users I'm fine with it, but I'd like to understand the issue better first so we really are getting it fixed. |
On Mon, Mar 31, 2014 at 10:51 PM, Austin Seipp [email protected]:
("C compiler command", "/usr/bin/ghc-clang-wrapper") That wrapper script adds a bunch of arguments to clang, and adjusts some This won't work for the GHC build itself, but shouldn't that cover
P.S.: How fast can we move to cpphs for preprocessing? :-) |
Ideally we'd limit this to only when calling Haddock. Otherwise we will get poor error messages for all Haskell code that uses CPP, as the line numbers will be wrong in GHC's error messages. |
Alternatively: we could add the CPP settings patch to 7.8.1 and ship ghc with cpphs right? |
(I realize that the CPPHS patch work was punted to 7.8.2, but maybe this merits revisting doing that solution so that none of these wrapper hacks are needed). Especially since it should now validate and install cleanly. (all that'd be needed is to bundle cpphs along with a suitably patched ghc) |
@cartazio I don't want to delay 7.8.1 more. The cpphs thing is not tested well enough yet to know it doesn't break even more stuff. |
fair enough, though with the most recent CPPHS lens does build as is, which is a pretty good stress test |
fyi, one of the problems seem to be that the second pre-processing via by {-# LINE 1 "Control/Applicative/Free.hs" #-}
# 1 "Control/Applicative/Free.hs"
# 1 "<built-in>" 1
# 1 "Control/Applicative/Free.hs" 2
{-# LINE 1 "src/Control/Applicative/Free.hs" #-}
# 1 "src/Control/Applicative/Free.hs"
# 1 "<built-in>" 1
# 20 "<built-in>"
# 1 "dist/build/autogen/cabal_macros.h" 1
... |
Looks like we agreed to not add a Cabal workaround for this. Please reopen if disagree. |
ghc-7.8.3 is out and we still have this problem. I think this is pretty bad user experience: parallel cabal no longer prints errors to stdout, so you don't even know which packages failed to get documentation. You find out much later when there are broken links on the local haddock. Then you eventually figure out to manually unpack and haddock a package and see the error, then google it and the only references are two bugs (this one and the haddock one), both closed with "will not fix", and no fix in sight. The workaround seems to be to manually unpack and haddock each package with -P, then manually copy the haddock into place (a reinstall of everything has scary warnings about breaking other things). That's a lot of work! So the result is that OS X users either don't get reliable haddock, or can't use cabal-install. The solutions seem to be use cpphs, or put a hack in cabal. cpphs seems like it may not happen for a while, so what's wrong with the cabal hack? It would be nice at least to have a plan to fix documented in this thread so future people searching can find something more satisfying than "broken with no plan"! Is cpphs the plan? In any case, for any future searchers, I eventually figured out you can add -P to "Haskell CPP Flags" in /usr/local/lib/ghc-7.8.3/settings, then reinstall everything. |
@elaforge GHC 7.8.3 contains a fix to the compiler that allows you to trivially set the C preprocessor for Haskell code to a separate tool like In the future we're seriously considering bundling cpphs with GHC itself as a separate tool, and having it default to it. Personally I think the fix suggested in the OP should still be considered as a hack, but I can't reopen this ticket? |
|
@thoughtpolice I assume that's "Haskell CPP command"? I'm all in favor of using cpphs. Would a complete hackage build prove it good enough? I don't know how to do that, but I know some people do. @mzero 2 - I'm using the 7.8.3 for OS X downloaded from http://www.haskell.org/ghc/download_ghc_7_8_3, if that's the one you built, then yes, it does affect that. |
On Fri, Jul 11, 2014 at 12:17 PM, Evan Laforge [email protected]
-P Disable linemarker output in -E mode 2 - I'm using the 7.8.3 for OS X downloaded from
|
Yeah, I'd say that's the most important metric. Maybe @snoyberg could help here by performing a |
for what its worth, on my mac I'm using the following configure invocation on the binary dist
you can get CPPHS flags setup correctly if you do NB: last I checked, you can't build GHC with cpphs, maybe thats improved, |
Oh, if you mean the docs bundled with ghc, they seem to all be present. Also, as Johan mentioned, we would want -P only for haddock builds since it messes up line numbers in error msgs. |
Okay - well, now we are back at square 1: I can have the OS X Platform installer fix up the newly added "Haskell CPP flags" settings entry to include -P on clang systems.... ...but that will get used for all pre-processing, not just haddock, and it will break the line numbers in compilation error messages for -XCPP files. |
AHA! may be solved On Mac OS X, we wrap cabal. The purpose of the wrapper script is to install a default .cabal/~config for users. The new cabal config includes this option:
Can set it there?
In particular, when building haddock, does cabal call ghc to do the preprocessing step, or does haddock? |
FOUND! The root cause is a bug in cabal. |
So what do we do about it. We could make another Cabal release in the 1.18 series and ship that with the HP instead of the Cabal that shipped with GHC 7.8.3. I guess that would be morally equivalent to how some Linux distros ship patched versions of libs. I'm happy to make the extra Cabal release, if someone cooks up a patch that actually solves the problem. |
I'm assuming that the call to preprocessComponent If so, then the tension is between the CPP call in prepareSources
I suspect #2.1 might be the right thing to do... but I don't know enough Lastly, this whole bit of logic seems to be missing in HEAD of master. Did
|
/cc @dcoutts |
SCRAP ALL THAT! This commit: [5729bc5] does what we need... just back port? |
See pull request #2010 - fixes this issue. I have verified it on a clang based system, with GHC 7.8.3. |
I have merged #2010 and will make a Cabal release this afternoon (CET). |
Many thanks to both mzero and tibbe for tracking down and fixing the problem, and for backporting. I just installed Cabal-1.18.1.4 and haddock is back in action. |
The bug documented in Haddock#284 turned out be caused by Clang's specific CPP behavior. So it affects mostly OSX >= 10.9 users.
If things are left as they are, affected users would have to inject the ghc option
-optP-P
, i.e.By having
Cabal
workaround this, users could be shielded from this Clang-effect.Some discussions that occurred on IRC, where @thoughtpolice explains the underlying issue:
The text was updated successfully, but these errors were encountered: