Skip to content
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

cabal --version on a non-release build should include a Git commit #10528

Open
geekosaur opened this issue Nov 5, 2024 · 29 comments · May be fixed by #10541
Open

cabal --version on a non-release build should include a Git commit #10528

geekosaur opened this issue Nov 5, 2024 · 29 comments · May be fixed by #10541

Comments

@geekosaur
Copy link
Collaborator

geekosaur commented Nov 5, 2024

I wonder if cabal --version on a non-release build should include a Git commit. (@geekosaur)

This has been bugging me too, as a daily user of cabal-head, this would be greatly appreciated. (@Kleidukos)

(#10483 (comment) ff.)

@geekosaur
Copy link
Collaborator Author

There's at least one package that provides this information automatically, but I'm not sure we want it as a dependency even if it's restricted to cabal.validate.project.

@geekosaur geekosaur changed the title cabal --version on a non-release build should include a Git commit. cabal --version on a non-release build should include a Git commit Nov 5, 2024
@geekosaur
Copy link
Collaborator Author

geekosaur commented Nov 5, 2024

And I'm a daily user of cabal HEAD too, but I do my own (usually weekly) builds of HEAD and 3.12.

@geekosaur
Copy link
Collaborator Author

…the first two I found require TH, so no-go. I may have to cons up my own, although TH is by far the easiest way to do it.

@geekosaur
Copy link
Collaborator Author

The other way to do it is custom Setup for cabal-install, but that bugs me.

@Kleidukos
Copy link
Member

There is also the option of reading the data at run-time from a data-file, although now we have to properly install cabal as a package and not just as a lone binary

@Kleidukos
Copy link
Member

@ulysses4ever
Copy link
Collaborator

There's at least one package that provides this information automatically, but I'm not sure we want it as a dependency

A flag could help to deal with it?

I have been wanting to tackle this issue since day one of cabal-head because the current state is deeply unsatisfactory. We should implement a solution no matter what. And we can always improve the implementation down the road.

@ulysses4ever
Copy link
Collaborator

Re data-files: they work great for cabal install but don't work at all with cabal build. Which may cost us another build at CI time. I'd try to avoid all that.

@Kleidukos
Copy link
Member

@geekosaur TH being a no-go is a GHC-related limitation? We can control this behaviour with some good old CPP, and only enable this if we're building a -head release, no?

@geekosaur
Copy link
Collaborator Author

It's about platforms that don't have the bytecode backend but do need cabal. (ARM used to fit here, I don't know what currently supported platforms do but there's something somewhere in the tree saying that TH is forbidden in the codebase for this reason.)

@Kleidukos
Copy link
Member

I see, thank you.

@ulysses4ever
Copy link
Collaborator

Template Haskell is a non-issue if this is hidden behind a flag

@geekosaur
Copy link
Collaborator Author

I wonder if there's a good way to ask if TH is supported without using custom Setup (there's no impl for it and you can't check simply by adding a template-haskell dependency, AFAICT you need ghc --info). (I want to be able to fall back if TH isn't available. Again, I'm not sure simply gating template-haskell on a flag is good enough here, I don't know if we get a stub template-haskell on platforms without a bytecode linker.)

@geekosaur
Copy link
Collaborator Author

geekosaur commented Nov 5, 2024

I suppose there's also just requiring development to be on platforms with working TH, but I feel like that's poor devx. And requiring a cabal.validate.project.local that flips the flag back off doesn't seem a whole lot better. (cabal.release.project, of course, will force it off, and the default will be false so it will take specific effort for someone building from Hackage to encounter it.)

@geekosaur
Copy link
Collaborator Author

Working on a first cut at this. For now I am requiring that developers either use a system with TH or use cabal.validate.project.local to disable it (example in cabal.release.prroject which explicitly does so). We should find a better way to deal, but so far the answers I am getting are not encouraging.

@ulysses4ever
Copy link
Collaborator

I have a different proposal. It's based on the assumption that we have a flag that controls whether we bake in the SHA and, hence, weather we depend on TH or not.

The flag should be off by default because the common case is: you build cabal for local development (perhaps, trying your patch, running some tests with it and so on), and this shouldn't need the SHA and instead would benefit from the faster and more accessible (re: platforms with no TH) process.

Only in the CI we explicitly set the flag on. Now, how exactly we do it (project file or command-line; and weather to rebuild with the flag or build with it from the get-go), we can discuss further if you agree on the proposal above...

@geekosaur
Copy link
Collaborator Author

But I (and I gather Hécate) both use cabal-head builds which we save. I, at least, build from git weekly. Am I CI? Is Hécate?

@ulysses4ever
Copy link
Collaborator

You're not, but you're power users who can read the documentation and do the same as what CI does to get the SHA.

@Kleidukos
Copy link
Member

Personnally I dogfood the installation of cabal-head from ghcup, so I don't really tweak the build process

@ulysses4ever
Copy link
Collaborator

ghcup will take whatever you give it, so that's not relevant. If you need a sha, you can add a flag during build or download the artifact from GitHub. I assumed you did the latter? In that case you're covered because the GitHub artifacts will certainly have the SHA, that's the whole point.

@ulysses4ever ulysses4ever removed their assignment Nov 6, 2024
@Kleidukos
Copy link
Member

Yeah I'm getting it from GitHub. In any case I'm not too picky on how it's implemented, I just want to support the effort of making it available in our -head releases. :)

@geekosaur
Copy link
Collaborator Author

I was attempting to follow a best practice outside the little Cabal ecosystem.

That said, I am hard put to identify a time where I started to do something and then Artem immediately climbed my frame, and quite frankly I'm tired of it. I give up; it's his problem from now on.

@ulysses4ever
Copy link
Collaborator

@geekosaur, I apologize for being overly eager to propose changes and share my view. I've been working on Cabal CI on and off for a couple of years, at least, and I certainly have opinions. It's okay to disagree, and I'm happy to approve alternative designs. Discussing alternatives is what makes the design better.

@geekosaur
Copy link
Collaborator Author

(a) Maybe your first comment would have qualified as that, but your second was actively pushy.
(b) It's also the culmination of several months of my spending more time arguing with you than actually doing anything useful.

@Bodigrim
Copy link
Collaborator

Bodigrim commented Nov 7, 2024

I'm somewhat confused. I think that unless you compile cabal-install for WASM / JS architectures (which serves absolutely no purpose), TH should be fine. Is there an evidence of contrary? I don't think there is a need in any additional build flags to control this.

@geekosaur
Copy link
Collaborator Author

I believe that is currently true, but not so long ago there wasn't a bytecode linker for ARM so neither ghci nor TH worked. I don't know if the current situation will remain true for any new architectures that might show up in the future, though. (Has a BCO linker been written for RISC-V?)

@Kleidukos
Copy link
Member

@supersven got any insight about the RISC-V situation?

@geekosaur
Copy link
Collaborator Author

It's not really that important except as an example of the likely next platform we'll need to deal with. I would be surprised if it turns out to be the last.

@Bodigrim
Copy link
Collaborator

Bodigrim commented Nov 7, 2024

I imagine if you want to be fully future proof, you can write

if arch(arm64) || arch(aarch64) -- and a few other arches if any actively used by potential testers
  build-depends:
    githash

@geekosaur geekosaur linked a pull request Nov 9, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants