Skip to content

Conversation

robx
Copy link
Collaborator

@robx robx commented Apr 5, 2022

I found a bug in the bootstrap generation Makefile targets while checking them against #8079:

cabal v2-run -vnormal+stderr was (sometimes) writing GHC output to stdout, messing with
the boostrapping JSON. This fixes that, and makes things a tiny bit tidier.


Please include the following checklist in your PR:

Please also shortly describe how you tested your change. Bonus points for added tests!

@@ -215,7 +215,8 @@ instance A.ToJSON SrcType where
-------------------------------------------------------------------------------

info :: String -> IO ()
info msg = hPutStrLn stderr $ "INFO: " ++ msg
info _msg = return ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this on purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes... The bootstrap generation was uselessly verbose (dumping the whole json output and this list of all dependencies), part of what made finding this bug difficult because it kept getting hidden in the output.

And then I couldn't think of a better way to do this, and thought it might be fine for a tool such as this -- if someone is interested in the debug output they can easily change this.

Other options I've considered:

  • leave this in, but redirect stderr from the Makefile -- hard to get right since stderr vs stdout is already tricky with using cabal run (we don't want to hide cabal's stderr)
  • remove the logging entirely
  • disable the logging by default, add a -v flag to turn it on (seemed like overcomplicating things)

Happy for alternate suggestions (and also happy to just revert this part if preferred).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would go for 2 or 3, maybe using a env var would be slightly simple?
but current version would be fine too, it is a script at the end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be quite happy to remove the logging entirely -- will wait a while for further input then maybe make that change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with an extensive code comment that says put hPutStrLn stderr $ "INFO: " ++ msg there to get detailed debug info. Basically comment out the line and say why and when it's useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I'll make that change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I'm not completely sure I understood your suggestion. I pushed a doc comment for the disabled info function, is this good?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is perfect, thank you.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the fix and the clean up

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changelog item is not needed, becuase although verbosity of the script is changed, it's not a user-facing script at all.

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, blocking so that nobody merges by mistake...

--
-- Disabled by default to keep the output tidy, replace by
-- the version with 'hPutStrLn' when debugging.
--
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mikolaj this is the new comment.

@@ -215,7 +215,8 @@ instance A.ToJSON SrcType where
-------------------------------------------------------------------------------

info :: String -> IO ()
info msg = hPutStrLn stderr $ "INFO: " ++ msg
info _msg = return ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is perfect, thank you.

@Mikolaj Mikolaj added merge me Tell Mergify Bot to merge and removed attention: needs-review labels Apr 6, 2022
robx added 3 commits April 6, 2022 18:05
`cabal run -vnormal+err cabal-bootstrap-gen` would output ghc
build output on stdout, messing up the expected JSON output and
causing empty linux-*.json. Instead, call `cabal run -v0` which
silences ghc as well as cabal, unless something goes wrong.
This removes the need for passing dedicated project and build
directory names and cleans up the top level directory a little
bit.
- remove tee output
- disable debug logging in cabal-bootstrap-gen by default
@mergify mergify bot merged commit a9d532d into haskell:master Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Tell Mergify Bot to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants