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

Fix Issue 7016 - local import does not create -deps dependency #6468

Closed
wants to merge 3 commits into from

Conversation

RazvanN7
Copy link
Contributor

@RazvanN7 RazvanN7 commented Jan 18, 2017

Semantic3 wasn't called on module dependencies, so I added a function which recursively calls it on the import tree. I may need some help adding tests

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
7016 local import does not create -deps dependency

@timotheecour
Copy link
Contributor

Awesome, been waiting for this for a long time.

  • Could you add a flag (off by default) to control this? (so no breaking change ; it is a breaking change because suddenly (because of recursion), it can lead to much longer compile time or broken compiles (say if a dependent import which previously wasn't going to be compiled has to be compiled)
  • rdmd has --exclude=package and --include=package to control which dependency gets recursively compiled; i think the same logic can be used here for same reasons as 1st argument (maybe in a 2nd commit though, no point in delaying this)

@RazvanN7
Copy link
Contributor Author

RazvanN7 commented Jan 25, 2017

This commit solves the problem of infinite recursion caused by cyclic imports. I am not sure if this feature should be activated by another flag since by definition the "-deps" flag should list all dependencies (either local or global). A problem which I noticed is that if a module imports the same module N times in different scopes, the import is printed N times (this was true for the older version also). I am not sure if this is the de facto standard or it should be fixed, but either way that is a different problem.

A different question is : should std.* core.* and etc.* imports be ignored? Or should an --include/--exclude flag be added?

Any suggestions are welcome.

*/
private void semantic3OnDependencies(Module m, bool[string] importArray)
{
import std.conv : to;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling phobos inside dmd is a nono.
Since you are already using AA's you might as well use the dmd internal hash-table for strings.
it's in root.

/**
* Recursevely call semantic3() on import tree nodes.
*/
private void semantic3OnDependencies(Module m, bool[string] importArray)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh noes,
this is going to slow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the AA with the string-key hashtable in root.springtable. Hope it's ok now. Thanks for the tip

@RazvanN7
Copy link
Contributor Author

I made a separate pool request that erases all ddmd. prefixes. For this PR I needed to import ddmd.root.stringtable, so I'm guessing there's gonna be some conflicts. I think that the faster #6489 is merged, the better.

@RazvanN7
Copy link
Contributor Author

@MartinNowak I have no idea why the tests are failing. Locally, I don't have any problems when running the tests.

@RazvanN7
Copy link
Contributor Author

RazvanN7 commented Feb 3, 2017

@timotheecour do you think that if -deps is used in conjunction with -unittest, should the dependencies of unittests be printed too?

@timotheecour
Copy link
Contributor

@timotheecour do you think that if -deps is used in conjunction with -unittest, should the dependencies of unittests be printed too?

unittest blocks should be treated as normal functions in that regard, so yes. That way, when rdmd uses -rdeps, rdmd -unittest foo.d will work as well as rdmd foo.d without giving link errors.

dmd -rdeps-include=package
dmd -rdeps-exclude=package

@RazvanN7 RazvanN7 closed this May 7, 2017
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 this pull request may close these issues.

4 participants