snowleopard / hadrian

Hadrian: a new build system for the Glasgow Haskell Compiler. Now merged into the GHC tree!
https://gitlab.haskell.org/ghc/ghc/tree/master/hadrian
MIT License
209 stars 37 forks source link

Add a clean check #131

Open ndmitchell opened 8 years ago

ndmitchell commented 8 years ago

A phony "clean" which removes everything would be very useful to test issues where the build system is likely reporting an old issue and needs a wipe.

angerman commented 8 years ago

Just linking #32 here. Ha. Almost 100 issues in-between.

ndmitchell commented 8 years ago

100 issues or 15 days - you guys are moving fast!

ndmitchell commented 8 years ago

For info, if you delete shake-files/.db then Shake considers everything dirty and tries rebuilding it, which is a reasonably good way to test the build system.

angerman commented 8 years ago

100 issues or 15 days - you guys are moving fast!

:100:

For info, if you delete shake-files/.db then Shake considers everything dirty and tries rebuilding it, which is a reasonably good way to test the build system.

I'm running

$ make clean && make distclean && make maintainer-clean && git clean -df && ./boot && ./configure && rm -fR shake-build/.db && rm -fR shake-build/.shake 

to be on the safe side :)

ndmitchell commented 8 years ago

Can we add that to the readme, or as a target "superclean" - agreed it's probably too paranoid, but useful to know.

snowleopard commented 8 years ago

As soon as we handle #113 this issue should be straightforward to implement.

The plan is to move all build artefacts to .build directory, as discussed in #32.

angerman commented 8 years ago

@ndmitchell are you up to the phony "clean" Pull Request challenge? :-)

ndmitchell commented 8 years ago

I'm not totally sure what the phony should do. I guess rm .build, and shake-build/.shake and the include files that were floating around?

snowleopard commented 8 years ago

@ndmitchell And all stuff we put into inplace.

It's going to be rather tedious to implement and hard to maintain. An ideal solution would be to eventually move everything into .build.

ndmitchell commented 8 years ago

Shouldn't it be about 4 or 5 directory names which don't change that often?

snowleopard commented 8 years ago

With includes it's not that simple: there are some source files which we'd like to keep.

However, directories inplace/bin and inplace/lib seem to contain only build artefacts.

ndmitchell commented 8 years ago

:( - that does seem a bit painful. But I don't think having clean is optional, sounds like it might be one for @snowleopard though.

snowleopard commented 8 years ago

@ndmitchell Agreed, I'll do this after #113.

ndmitchell commented 8 years ago

As a note, you generally only need to use removeFilesAfter if you are specifically removing the .shake.database file, which is otherwise locked open. For everything else it's better to use liftIO $ removeFiles.

snowleopard commented 8 years ago

@ndmitchell Thanks, I will fix this. Do we want to remove the Shake database too when doing clean?

ndmitchell commented 8 years ago

I see no reason not to remove the shake database - it gives you the best chance of reproducing issues from scratch, which is a major goal of doing clean.

snowleopard commented 8 years ago

Done, I agree.

ndmitchell commented 8 years ago

Thanks for this, I was waiting for a clean target before I conducted any more testing, so I'll give my Windows/Stack build a try tonight.

snowleopard commented 8 years ago

I hope I haven't missed anything. If you spot any left-over files while testing please let me know.

ndmitchell commented 8 years ago

@snowleopard - why not just test it properly on the CI machines? At the end of the build do clean, and then check something like git diff --exit-code, perhaps ignoring certain files, perhaps not applying the .gitignore. If that list is "longer than you expect", then error out. For info, I do this on all my builds, especially to check that those libraries with generators have had the generators applied and checked in (I have that pattern in derive, filepath and extra).

snowleopard commented 8 years ago

@ndmitchell Good idea! I'm a bit concerned that this might increase CI time; we are already close to AppVeyor time limit, where we are at the very edge even when building GHC stage1 only. I don't want to lower the bar any further (below GHC stage1). Can you spot any optimisation opportunities?

Of course, we don't have to run this check on all CI instances.

Another idea: could we ingrate the proposed check right into the clean rule? Then it will become self-checking.

ndmitchell commented 8 years ago

I wouldn't put the check into clean - users might (probably will) have locally modified files, or other stuff they have put somewhere else in the directory, and we don't want to report that as an error. Adding a cleancheck target that does it (just so the code can be properly integrated) which itself depends on clean, isn't a bad idea.

I suspect the clean and check will take ~10s at most - it should not be an expensive thing to do (if it is, let me know). I think the best thing is to find optimisation opportunities in the rest of the build, configure in parallel being the most obvious one I saw. Plus you can only run this on Travis, not Appveyor.

snowleopard commented 8 years ago

So, let me reopen this issue as it requires further work.

snowleopard commented 8 years ago

@ndmitchell You seem to be very familiar with the solution you are proposing, perhaps, you could take this over? Here are the tasks we have:

ndmitchell commented 8 years ago

Certainly, with the caveat that it will be about 1-2 weeks before I do it (assuming I don't get time tonight). The remaining part is unimportant though so can remilestone til later.

snowleopard commented 8 years ago

Thanks @ndmitchell! Take your time. I don't think this is on the critical path.