ghcup-hs icon indicating copy to clipboard operation
ghcup-hs copied to clipboard

Improve 'ghcup compile ghc' interface

Open hasufell opened this issue 1 year ago • 12 comments

The main issues are:

  1. passing additional flags to build configure...
  2. but also passing additional flags to bindist configure
  3. and also passing additional flags to hadrian itself

Currently we support the first case via -- longopts. But that can only cover one use case.

This is particularly important for cross builds, which may need different than default settings.

@hsyl20

hasufell avatar Jul 07 '23 06:07 hasufell

Should probably also make hadrian default or detect whether a make build system exists. --hadrian flag should only be required if there's both make and hadrian.

hasufell avatar Jul 13 '23 16:07 hasufell

Should probably also make hadrian default or detect whether a make build system exists. --hadrian flag should only be required if there's both make and hadrian.

Is it possible to say "Use make for <9.6 and Hadrian for >= 9.6"?

And fwiw I think 9.4 was the only series that officially supported both, although I also think Hadrian was pretty immature then.

chreekat avatar Jul 16 '23 05:07 chreekat

Is it possible to say "Use make for <9.6 and Hadrian for >= 9.6"?

Currently, my idea is just to look for the hadrian files and if they're not there, assume make:

https://github.com/haskell/ghcup-hs/pull/854/files#diff-3b9b75e85b8e396244d24bf04ef933cae33b4d20df6f5889304bfb36696c43d6R957

The choice can be made explicit with --hadrian | --make.

hasufell avatar Jul 16 '23 05:07 hasufell

I don't know that it's valuable to make it an option to users if 9.4 is the only version that officially supported both. <9.4, --hadrian might work but will be buggy (and the bugs will never get fixed); >=9.6, --make will fail.

chreekat avatar Jul 16 '23 05:07 chreekat

Yes, but GHC has made it extra hard to detect which version you're actually compiling: https://gitlab.haskell.org/ghc/ghc/-/issues/22322

The fix was backported, but I have no clear overview at the moment what versions work and which don't.

As such I'm moving away from logic that depends on version numbers. If you try to compile 9.6.1 with make, that may fail. But maybe not, because you're using custom patched bindists, a different branch etc (remember you can already supply patches before the build... that's explicitly supported).

Dynamic detection seems more flexible.

What we probably want is a more descriptive error in case you try to build 9.6.1 with make: "The make build system has been removed since 9.6. You probably want to omit '--make'."

hasufell avatar Jul 16 '23 05:07 hasufell

And I'll probably support the VERSION file, in case it exists.

hasufell avatar Jul 16 '23 06:07 hasufell

What's missing now is the question on how to support additional arguments to ./configure and hadrian ....

If we compile, we have two configure phases:

  1. configure before compilation
  2. configure of the bindist

It's not clear whether they support the exact same arguments. Or if you'd even want that.

For hadrian I think we're mostly good with the --flavour=foo switch, since many things are now flavour transformers.

hasufell avatar Jul 16 '23 13:07 hasufell

EDIT: Sorry, i was running this with github actions and it seems github actions doesn't display a part of the logs. I'll look into it

Hi, thanks again for so awesome tool, and your time.

(i think my issues are related to this ticket) I'm trying to build a cross-compiler from host x86_64-macos to target aarch64-macos with ghcup compile ghc

I've tried multiple combinations of ghc target versions (8.10.7, 9.0.2, 9.2.8, 9.4.5, 9.6.2) (all with bootstrapping version 9.4.5), and additional flags (particularly --jobs), without any success. I am mostly asking if I should keep trying to build using ghcup or I just should try directly from ghc source.

Here I leave some logs w/errors while trying to compile. ghcup compile ghc -v 9.6.2 -b 9.4.5 "" -x aarch64-apple-darwin with [ Error ] []8;;https://errors.haskell.org/messages/GHCup-00841\GHCup-00841]8;;\] Process "make" with arguments [] failed with exit code 2. ghcup compile ghc -v 9.2.8 -b 9.4.5 "" -x aarch64-apple-darwin with

[ Error ] []8;;https://errors.haskell.org/messages/GHCup-00841\GHCup-00841]8;;\] Process "sh" with arguments ["./configure",
[ ...   ]                              "--target=aarch64-apple-darwin",
[ ...   ]                              "--prefix=/Users/runner/.ghcup/ghc/aarch64-apple-darwin-9.2.8",
[ ...   ]                              ""] failed with exit code 1. 

ghcup compile ghc -v 9.0.2 -b 9.4.5 "" -x aarch64-apple-darwin with

[ Error ] []8;;https://errors.haskell.org/messages/GHCup-00841\GHCup-00841]8;;\] Process "sh" with arguments ["./configure",
[ ...   ]                              "--target=aarch64-apple-darwin",
[ ...   ]                              "--prefix=/Users/runner/.ghcup/ghc/aarch64-apple-darwin-9.0.2",
[ ...   ]                              ""] failed with exit code 1.

ghcup compile ghc -v 8.10.7 -b 9.4.5 "" -x aarch64-apple-darwin with

[ Error ] []8;;https://errors.haskell.org/messages/GHCup-00841\GHCup-00841]8;;\] Process "sh" with arguments ["./configure",
[ ...   ]                              "--target=aarch64-apple-darwin",
[ ...   ]                              "--prefix=/Users/runner/.ghcup/ghc/aarch64-apple-darwin-8.10.7",
[ ...   ]                              ""] failed with exit code 1.

The error 00841 is:

A process exited prematurely [GHCup-00841]

This error can happen for a variety of reasons and may indicate that GHCup needs to improve error handling/messages. Consider [raising an issue](https://github.com/haskell/ghcup-hs/issues).

One common source of errors is a missing or non-working C toolchain, leading to errors when trying to install GHC:

(i didn't post examples with -j flag, but the error was something like "make no parse -j8". if its necessary ill look it up

0rphee avatar Aug 21 '23 15:08 0rphee