-
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
Moving location where library build files are generated #3545
Comments
Could this be done for |
Will this still work when there's an executable with the same name as library (example)? Otherwise +1. |
@phadej : No, it affects both new-build and build; it's a modification to how Setup scripts work. @23Skidoo: Oh right. You'll need to disambiguate the public library somehow. The |
OK, I came up with another "more BC" scheme:
So, no library files move, and the executables are where you expect them. |
The bug that motivated this is present in |
See the comment in the code. I don't like it but it's BC! Signed-off-by: Edward Z. Yang <[email protected]>
btw, just today I run into situations where two executables in the same package use the same EDIT in particularly I cannot have a source file with "clever" So the fix for this is very welcome! |
I'd prefer not to add a |
@23Skidoo But your proposal exhibits a displeasing asymmetry where the library is called So if we are rearranging the directory, we might as well do it right, and put the executable in |
I agree that this is cleaner, but people are used to having exes in |
OK... so how about the opposite: let's put the library build files in a different place than |
Well, that's basically what I proposed in #3545 (comment). |
I mean, at the end of the day all the proposals are the same because we're just suggesting different locations to put things, but the original proposal was not so good because it caused there to be a reserved name that other components are not allowed to use. I agree it is certainly logical to keep all build artifacts under |
I won't protest too much against |
See the comment in the code. I don't like it but it's BC! Signed-off-by: Edward Z. Yang <[email protected]>
I summarized the discussion up top. |
I just realized there is another consideration if we go for This is quite difficult because either choice will break many setup scripts. Here is some quick grepping on Hackage:
Here
And this repeats over and over again repeatedly all over many packages with custom |
That's a bummer. My vote is for making this change anyway and setting the default Cabal upper bound for |
OK, well, if we are going to release Cabal 2.0 next release, this affects a number of other BC decisions. E.g., #3574 and @ttuegel's #3572. If we are changing the default upper bound (I like this idea more and more, since the preprocessor interface changed backwards incompatibly and I don't think it's possible to keep BC here), what is our policy for BC-breaking changes? I guess the answer is something like, "Please still try to keep BC, so that it's easier for applications to migrate" but minor incompatibility's like #3572 are still fine. |
Yes, something like this. Plus there should be a mention in the changelog when a part of the API gets changed. |
As a data point, in stack we would also prefer to preserve BC here. I'm don't have the details here. But it seems like part of the topic post suggests a third, potentially viable approach
How about making this what Cabal does, instead of hacking around the current design? Deprecate the old interface and transition all the pre-processors to the new system. |
OK, well, I will have to look at the preprocessor interface and propose a design. |
See the comment in the code. I don't like it but it's BC! Signed-off-by: Edward Z. Yang <[email protected]>
OK, so let's say how preprocessors work today. Presently, preprocessors are represented using the following data structure:
A preprocessor takes in an input source file, and an output destination, and arranges for something to be written to that file name. In general, the output file name is always However, some preprocessors can generate extra files. There are two situations which are handled by Cabal today:
The way they are handled is via Intuitively, we should be able to determine precisely what the possible generated files are simple from the list of module names that were preprocessed under some preprocessor. But where should we return this information?
Since the extra files are preprocessor specific, we need a hook in
Other BC considerations:
OK, so concrete proposal in next comment. |
I'm pretty sure we moved to a much more granular layout similar to this with new-build? |
This topic (the structure under directory |
Summary by @ezyang. We considered the following options for restructuring
dist/build
such that component build directories are not a subdirectory of the library build directory:dist/build/pkgname
. Problem: This will conflict with an executable that is named the same as the package.dist/subbuild/compname
. Problem: This moves where executables are, and many people (including this author) are used to accessing the executable atdist/build/exename/exename
. One way to patch over this is to copy the executables back to the old locations.dist/build/lib-pkgname
. Problem: This will still conflict with a component namedlib-pkgname
.dist/build/exe-exename
. Problem: This moves where the executables are.dist/libbuild
. No major problems, although @23Skidoo would prefer all build products be indist/build
.We are going to go with proposal (5).
Hey guys. I want to propose a BC-breaking change to the
dist
directory layout. I'll first explain what the change is, and then why I need it. I'd like to know if people are OK with it. It WILL break code which needs to know where Cabal puts build products. CC @mgsloan, @23Skidoo , @dcouttsCabal-1.24 behavior. Suppose we are building a Haskell module M.hs. If this module is in the public library, the interface file is placed in
dist/build/M.hi
. If the module is in any other component (e.g., a test suite) namedcomp
, the interface file is placed indist/build/comp/M.hi
)Proposed new behavior. I propose that libraries also get their own subdirectory:
dist/build/pkgname
; thus if we buildM.hs
in a library namedfoobar
it will be placed indist/build/foobar/M.hi
. Obviously, this will break any scripts which rely on the interface files/object files having been placed in the old location.Motivation. Cabal supports pre-processors which may generate extra object files that need to be linked into the final libraries/executables we build. This is tested by the
PreProcessExtraSources
cabal:package-test
. For example, if we buildFoo.hsc
, this results in aFoo_hsc.o
in our build directory.If a preprocessor generates this extra object file, how does Cabal know to link it in? The "obvious" design is that when you run the preprocessor, it tells you what extra files need to be compiled and you go ahead and compile them. But this is not what Cabal does. Instead, what it does is simply look in the build directory for any files which look like ones that the preprocessor generated, and make sure to link them in. (ian-ross@e38cb0c)
Now here is the problem with Cabal-1.24's behavior: the build directories for the test suites/benchmarks/etc are all INSIDE the library's build directory. So clearly the search code will pick up the extra build products: disaster! And so the most obvious fix (without completely changing the preprocessor interface) is to move the directory out of the way.
The bug got uncovered by #3542 although I am not really sure why it didn't manifest earlier.
Alternatives. I think there are two plausible alternatives which avoid moving the location of library files:
These two Foos clobber each other! Ouch!
The text was updated successfully, but these errors were encountered: