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
Cross-library fragile base class problem #541
Comments
Good to hear! |
Alrighty in fact the problem doesn't seem too hard to fix anymore in rock's 95x branch (which is pretty much the edge of clean rock code anyway). Once you realize that structuralDirties is local to a single Archive, the problem is easy to grasp: I'm pretty sure Archive (or some other class) could have a map from module to Archive to make sure we query the right 'structuralDirties' list. In fact, responsibilities probably need to be decoupled some more - knowing what depends on what and what needs to be recompiled seems to be overboard for an Archive class - but it could be made to work in the short term with a not-so-horrible solution in Archive. |
Looks like a biggie, post-poning to 0.9.8. |
Test caseSourceFolderslibaA
And source/liba/klass.ooc: Klass: class {
a := 1
b := 2
c := 3
} projectbA
And use liba
import liba/klass
Klazz: class extends Klass {
init: func {
"a, b, c = #{a}, #{b}, #{c}" println()
}
}
Klazz new() Running itFollow the steps:
Expected resultsThe compiled program should display '1, 2, 3' both times Observed resultsBefore the fix, it displays '1, 2, 3' first, and then '1, 3, 2'. After the fix, the observed result is as expected. |
The fixAs I mentioned earlier, the idea is that dirtyModules is local to an Archive, and they're collected by the SequenceDriver, when it generates C sources. Even though there was code to mark modules as dirty in case imports had structural changes, it only worked between two modules of the same SourceFolder, not across them: dirtyModules := ArrayList<Module> new()
structuralDirties := ArrayList<Module> new()
// `modules` is all modules in the Archive / SourceFolder
for (module in modules) {
// some logic to mark some modules as structuralDirties directly
ImportClassifier classify(module)
for(imp in module getAllImports()) {
candidate := imp getModule()
if(structuralDirties contains?(candidate)) {
// at this point, module is dirty because it imports candidate
}
} To make it work across them, one has to use the If we're going to have So we need a way to know in which order we should check for modules... thankfully, since February 2013, we have In that case, the generated graph looks something like this:
Which is reduced to a list:
This it the correct order for linker flags, e.g.:
As for us, it's exactly the reverse of what we need. If we check dependencies in ImplementationFor implementation details, I'll let you look at the diff. It's still pretty elegant - we could probably refactor to get rid of the big ugly 'map', 'dirtyModules' and 'structuralDirties' instance variables in Archive, but for our current purposes, they don't hurt a lot, except my pride. AfterwordCould this be the end of all libcache woes? That would be pretty neat. When 0.9.8 is out, we should encourage people to not clean everytime, to see if there are still edge cases - but I doubt it. The libcache system was pretty well thought out, then cleaned up in 0.9.5, and the fact that such a simple change could fix it completely boggles the mind. I'm happy though :) |
I'm murdering my way through the old rock codebase (it's happening in branch issue524, for those who don't follow), and there's many bugs that were fixed, but something's still amiss.
Here's what happened previously:
Here's what happens now:
So I'm thinking of clearer data structures to figure out exactly what changed and how we manage that strategy.
Anyway, it's going to be a wild ride, but rock is getting cleaner, heinous commit by heinous commit!
(That's a free Sonic 2 image for you, I don't know why GitHub decided to upload the content of my clipboard but I'm glad it's not more embarassing).
The text was updated successfully, but these errors were encountered: