-
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
build Setup.hs with local compiler when cross-compiling #1493
Comments
What would be an appropriate name for such an option? |
I was imagining a series of options like |
Apparently the Haskell-iPhone people are working around this by patching packages to use |
Yeah, this is also a pain point for me. I work around it by just running |
Another possibility, which seems to be sufficient for most cases, would be to allow "build-type" to exist within "if" branches, so that, for example: if os(HaLVM) || os(iOS) I was considering looking into a patch to do this, which seemed like it might be simpler, as long as the if cases were restricted to non-computed things (like os()). |
This is a bad idea IMO, since it requires all package authors to modify their |
I think that rwbarton is right with his idea. What about adding flags along the line of '--with-build-ghc' --with-target-ghc? Additionally we could allow for additional config file entries. Is anyone working on this? Otherwise I will go ahead and try to implement a proposal... |
@sheyll I think we only need a I imagine that we would have a new section in the config file for this stuff, akin to
|
@23Skidoo Ok it seems to be consensus that additional flags are useful. I will simply start with "--with-build-PROGRAM" for ghc and ghc-pkg and we'll see how it flows from there. |
Ok .. I now have a draft for code review, located here: |
Thanks sheyll. This is great stuff and just what I need right now to take the pain out of cross building packages (PowerPC as well as ARM). Though I don't feel qualified to comment on your changes in detail will take them for a spin soon. |
hey wait this was only a prototype, the real thing is in the making.. I do not would you mind making me some kind docker recipe for your cross compiling wbr Sven
|
I should have said I am very new to Haskell, even more so to cabal (a week or two) and the term docker has me reaching for Google. I am off the ground with cross compilers though and have gained some knowledge that might be used to improve https://ghc.haskell.org/trac/ghc/wiki/CrossCompilation and friends. |
I just wanted to let you know I continue to work on this now, Do you think this issue could be assigned to me, to indicate that work is going on there? I have done a fork of this repo a while ago, but I rebase it regularily, so it should not be too painful to merge when it is done. I must admit I am surprised by the sophistication of the cabal internals, and coming from industry rather than academia I appreciate the pragmatic approaches chosen, although I have struggled with the fact that I had to touch so many different places for the intended changes; but this might as well have todo with me having the urge to make the changes as test-covered as possible and follow the boy-scout-rule. I'd rather take some more time than leave a mess that just makes other maybe more important changes more expensive |
It looks like you need to be a member of the Haskell organization on GitHub for me to be able to do that. |
@sheyll any progress lately? I would be willing to test it out if you have something working. I want to cross-compile a cabal sandbox on a x86_64 server for use on an arm laptop, so I need I understand my setup isn't widely adopted, but I thought I'd mention it. |
I will make an experimental version on the fork I have in my github account, and notify you here. |
Hey, what's the status on this? Is there anything we can do to accelerate this getting into mainline? |
hi Wbr Sven
|
@ezyang heh I actually missed the link to that patch reading through, I was just commenting on the issue in principle. Your plan there looks very good to me: "mixed GHC" plans should hopefully just a be a further decoupling of setup depends on normal depends solving. |
Merged! Thanks! |
Ok, to do this the Right Way™, I think I want to change the type of qualifiers. Note the comment on setup about nesting. Well, this applies equally well to exe deps too, and because packages can constrain on exe version, when cross compiling or bootstrapping this matters. [expansio ad absurdum: Let's say somebody wants to bootstrap across 5 platforms (and platform-specific compilers), oh my! A Thus, I propose instead type Qualifier = [QualifyingEdge]
data QualifierEdge
= QualBase PackageName
| QualExe { from :: PackageName, to :: QualExeTarget }
-- | May just use `Maybe PackageName` in practice
data QualExeTarget = TargetExe PackageName | TargetOwnSetup Now, there is also a good argument in that comment about the search space growing too large. Well, I propose that after we build the deps we "prune" all qualifier paths accordingly. There are two options I see for this pruning. Let
How does this sound? |
For reference, the commits that reverted infinite qualifiers are 37978a6 (fix) and 3d2ad8e (test). I am not entirely sure why @edsko decided to change the package path structure, as oppose to teach the solver how to prune things, but I think that if you are working on this patch, it is more likely to work if you keep the qualifiers finite, because it is not known what changes you would have to make to the solver to prune qualifier paths. So, sure: in principle, someone might cross compile over five platforms. But are they actually going to in practice? How would they even say that they wanted to cross compile over five platforms? |
@ezyang well in practice there would probably only be two, but I think the code is clearer using a list and supporting arbitrary. |
Also BTW in https://github.com/Ericson2314/cabal/tree/cross-solve I have that change to qualifier, with prune just doing at most one exe/setup dep because there is no cross support yet. CC @grayjay |
I just took a quick look, and I think it looks similar to the qualifiers that cabal had before #3220. So I would want to make sure that a new implementation handles the issues that led to #3220 before increasing the depth. Other than that, I think that the structure of the qualifiers looks good. How would the solver know which compiler to use for each executable? Would it always be specified by the user? |
@grayjay the difference is the prune function---it limits the number of
Specifying a single compiler/platform, or single cross and native compiler/platform, generalizes into specifying a list of compilers/platforms----whatever the user-facing interface would be, this is how things would be stored internally. Then, simply take the number of FWIW I am doing some very similar changes with nixpkgs atm, and documenting the new world in https://github.com/NixOS/nixpkgs/blob/master/doc/cross-compilation.xml . That may of interest, but probably not yet. |
I meant that we should make sure that the solver continues to handle cycles well before increasing the pruning depth beyond 0. I don't know if this will be an issue, but increasing the depth might cause the solver to search a large tree of possibilities every time it encounters a cycle through setup dependencies, when it could backtrack quickly with a depth of 0.
So the solver never has to choose the compiler. Does this feature mean that the solver also needs to keep track of multiple compilers' package databases?
👍 |
@grayjay Granted, I haven't looked to much at the solver code, but as I understand it, cycles would be handled the same, and qualifiers essentially would unroll the cycle up to the length of the qualifier, with the longest qualifier in the series handling the remaining cycle. I hope that makes sense :).
In the new-build world, "improvement" i.e. dropping already-built packages/components from the plan takes place after solving. I think this makes stuff not so bad. But yes the compiler/platform, rather than being an input, is now a function of the number of |
@grayjay Would it be useful for me to bother rebasing that prior to your upcoming solver overhaul? |
@Ericson2314 Do you mean that you would rebase your cross-solve branch so that it could be merged as part of #4087? I think that the current design for #4087 doesn't affect package qualifiers, so you could change the qualifier types independently. #4087 would just add more information about components that we could use to make the qualifier edges more specific. |
@grayjay makes sense. Thanks for the feedback. |
Hi Folks - Any news on this one? In progress? Blocked on something? (And if so what?) I find myself working on a HaLVM issue, and am wondering if I should choose the Right Way, which relies on this issue being solved in the near future, or if I should do something fairly evil, under the assumption that this issue isn't going to be solved for awhile. I'm happy to help, if it's just a matter of someone piping data through to the right places, but it's been a long time since I've looked at Cabal internals. Alternatively, I do have a test cross compiler all ready to go, if you want me to run some experiments. 😃 |
I was sidetracked with other Cabal work (sub library refactors), and then Nixpkgs cross compilation work. I'd probably be best unwinding that stack before I got back to this. Not sure what the status of @grayjay's per-component solving is---it will be easiest to work when that's finished but there's things to do in the meantime. My plan is more expensive, but solves this the Really Right Way. If you want to write nice cabal files but get by with a hacky Cabal implementation, the patch earlier in the thread is probably still similar to what would be needed for a stop-gap. |
Instead of adding or extending existing options, why not make cabal just ignore At least as a quick short term solution. It isn't usable as is at the moment anyway. |
Actually, that won't work either. Please, ignore. |
Has there been any further progress on this? |
It's still on my radar, but no direct work yet. |
I have a script that invokes cabal with
--with-ghc=...
,--with-ghc-pkg=...
,--with-gcc=...
, etc. for cross-compiling to Android. It works great for most packages, but fails for a package with Build-type: Custom, because it buildsSetup.hs
with the cross-compiler specified on the command-line, and then obviously it can't rundist/setup/setup
because it's an ARM executable.I can work around the issue by doing an ordinary cabal configure with no
--with-ghc=...
options first, then doing a cabal install with my cross-compiler script, because the second invocation uses the cacheddist/setup/setup
from the first one. But that's a hack, obviously, and annoying to do when the package I'm installing is a dependency of the one I actually want.What I would like is a separate set of options for specifying the program configuration to use to build
Setup.hs
; or at least an option to tell cabal to just use the ones on my path. I found that usingdefaultSetupScriptOptions
forsetupScriptOptions
inconfigure
andperformInstallations
seemed to do the trick for me, to give an idea of what I want to happen, though I haven't tested the resulting libraries. I couldn't determine whether there is already a way to achieve the same effect through command-line options.The text was updated successfully, but these errors were encountered: