You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specifying flags for all non-local packages in cabal.project #3719
As far as I know currently there's no way to specify build options for all non-local packages at once while new-building. Options from global/local cabal.config don't apply to them, and package * in cabal.project doesn't work. I'm not sure why it's forbidden, is there any problem with changing options for all packages?
I'm interested in particular in split-objs, optimization, documentation, but it would be nice to support setting of any option for all non-local packages via cabal.project or some other way.
Sorry, I'm not really familiar with Cabal internals. It sounds surprising to me, because why it's possible to set options for all packages via global ~/.cabal/config file when not using new-build, but it's not possible to set options for all packages when using new-build?
No it should be possible, it's probably not even that difficult of a code fix. I think the primary problem here is a documentation one; figure out what we want cabal.project to mean, and make sure it means that. I've summarized the issues here: #3720
OK, having worked on the documentation, I think you are right, and there is no way to apply flags to ALL packages that are transitively reachable, and it seems like it would be useful.
Some thoughts:
In all the use-cases you specified, it's not that you specifically want to single out non-local packages; you just want to apply flags to everything that is transitively reachable. (That is what's suggested by package *.) I'm trying to think of a case where this is NOT what you want and I'm having a hard time.
We can't actually rebuild everything: anything that's in the global package database which the solver decides to pick (regardless of your settings) will get used. This is already true if you say, e.g., package base, but it's something to be aware of, e.g., re documentation.
What's a good syntax for cabal.project? package * is obvious and not a bad choice. The only thing I dislike is it implies that wildcards are available in package, which they are not. But maybe that's not a big deal.
You're correct, my primary usecase is that I would like to apply flags to everything that's transitively reachable (i.e. everything what's affecting the end result of a build). For example, I want to build an executable of minimal size and maximum performance, so I need to have correct split-objs and optimization settings applied to basically all packages my executable depends on.
However I think it makes sense to have a distinction and be able to apply some settings only to local (or in-place? didn't get the difference yet) packages, and some settings only to non-local packages (packages from Hackage). For example, what about minor GHC options in project file, like warning suppression options? If I put ghc-options: -fno-warn-tabs into project file, I probably prefer to not apply this option to non-local (Hackage) packages, hence reusing stored binaries for them instead of building them second time, because I'm not going to look into their build logs anyway.
I understand we cannot change anything about prebuilt packages like base, though I thought they are already built quite optimal (with optimization, documentation and split-objs enabled).
local-package-options and non-local-package-options or smth like that may be used if local/non-local distinction is deemed useful. And then all-package-options may be used instead of package * if it's looking better.
I know this is a rather old issue. It's not very precise about the intended use case too. It says:
package * in cabal.project doesn't work
package * has been working fine for some time now. See the docs. Only it applies to all local and non-local packages. So technically, it doesn't deliver on the ask in the issue title: "flags for all non-local packages (only)". But in practice "all local and non-local" works fine I think. Should we close it then?
Activity
ezyang commentedon Aug 24, 2016
The basic problem is it's not possible/no one knows how to set options for packages which are NOT inplace (non-local, in your words).
quyse commentedon Aug 24, 2016
Sorry, I'm not really familiar with Cabal internals. It sounds surprising to me, because why it's possible to set options for all packages via global
~/.cabal/configfile when not usingnew-build, but it's not possible to set options for all packages when usingnew-build?ezyang commentedon Aug 24, 2016
No it should be possible, it's probably not even that difficult of a code fix. I think the primary problem here is a documentation one; figure out what we want
cabal.projectto mean, and make sure it means that. I've summarized the issues here: #3720ezyang commentedon Aug 28, 2016
OK, having worked on the documentation, I think you are right, and there is no way to apply flags to ALL packages that are transitively reachable, and it seems like it would be useful.
Some thoughts:
package *.) I'm trying to think of a case where this is NOT what you want and I'm having a hard time.package base, but it's something to be aware of, e.g., re documentation.cabal.project?package *is obvious and not a bad choice. The only thing I dislike is it implies that wildcards are available inpackage, which they are not. But maybe that's not a big deal.quyse commentedon Aug 28, 2016
split-objsandoptimizationsettings applied to basically all packages my executable depends on.However I think it makes sense to have a distinction and be able to apply some settings only to local (or in-place? didn't get the difference yet) packages, and some settings only to non-local packages (packages from Hackage). For example, what about minor GHC options in project file, like warning suppression options? If I put
ghc-options: -fno-warn-tabsinto project file, I probably prefer to not apply this option to non-local (Hackage) packages, hence reusing stored binaries for them instead of building them second time, because I'm not going to look into their build logs anyway.base, though I thought they are already built quite optimal (with optimization, documentation and split-objs enabled).local-package-optionsandnon-local-package-optionsor smth like that may be used if local/non-local distinction is deemed useful. And thenall-package-optionsmay be used instead ofpackage *if it's looking better.ulysses4ever commentedon Nov 19, 2024
I know this is a rather old issue. It's not very precise about the intended use case too. It says:
package *has been working fine for some time now. See the docs. Only it applies to all local and non-local packages. So technically, it doesn't deliver on the ask in the issue title: "flags for all non-local packages (only)". But in practice "all local and non-local" works fine I think. Should we close it then?