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 17898 - Segfault in compile with -deps and -debug/unittest #9122

Closed
wants to merge 2 commits into from

Conversation

MartinNowak
Copy link
Member

@MartinNowak MartinNowak commented Dec 23, 2018

Revert "Merge pull request #6748 from RazvanN7/Fix_Issue_7016"

This reverts commit afebe0c, reversing
changes made to a91bc97.

The original change was apparently never used for rdmd and made -deps unusable
due to causing segfaults during IR-gen. Furthermore the PR killed a common
use-case for the -deps switch, collecting shallow dependencies for make et.al.

And lastly https://dlang.org/changelog/2.079.0.html#includeimports added an
alternative implementation for recursive compilation, so recursive dependencies
are no longer needed for rdmd. I'm also not aware of any other user of
recursive dependencies.

@dlang-bot
Copy link
Contributor

dlang-bot commented Dec 23, 2018

Thanks for your pull request, @MartinNowak!

Bugzilla references

Auto-close Bugzilla Severity Description
17898 regression Segfault in compile with -deps and -unittest

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "stable + dmd#9122"

Revert "Merge pull request dlang#6748 from RazvanN7/Fix_Issue_7016"

This reverts commit afebe0c, reversing
changes made to a91bc97.

The original change was apparently never used for rdmd and made `-deps` unusable
due to causing segfault during IR-gen. Furthermore the PR killed a common
use-case for the `-deps` switch, collecting shallow dependencies for make et.al.

And lastly https://dlang.org/changelog/2.079.0.html#includeimports added an
alternative implementation for recursive compilation, so recursive dependencies
are no longer needed for rdmd. I'm also not aware of any other user of
recursive dependencies.
@UplinkCoder
Copy link
Member

sociomantic codes uses it. It's not a the majority of code but there is a usecase.

MartinNowak added a commit to MartinNowak/dub that referenced this pull request Dec 23, 2018
- based on parallel single file compilation
- writes object files to local .dub/ninja/<package> folder
  (use `ninja -t clean` to cleanup)
- different build types require regeneration of .ninja files
  (see https://ninja-build.org/manual.html#_philosophical_overview)
- requires dlang/dmd#9122 for non-segfaulting `-deps`
@thewilsonator
Copy link
Contributor

cc @RazvanN7

@MartinNowak
Copy link
Member Author

MartinNowak commented Dec 23, 2018

sociomantic codes uses it. It's not a the majority of code but there is a usecase.

Could you please elaborate a bit on this @UplinkCoder. What build-tool do you use that requires recursive dependencies from a single entry point? Could you switch to a lazy per-object dependency file or compile all sources instead? How do you avoid compiler segfaults for debug and unittest builds with -deps?
I've seen that it was ported to D1 (#8163). That might not suffer from the complex semantic-ordering in dmd-d2 that's likely responsible for the segfaults. Are you using recursive dependencies for D2 builds?

NB: It seems that surrounding this change 2 separate use-cases got often conflated. The build models of rdmd (single entry point source, trying to get recursive dependencies for the actual compile) and make et.al. (generating shallow dependencies during compilation to later trigger incremental rebuilds).

@RazvanN7
Copy link
Contributor

Maybe after all we need a new switch for recursive dependencies? Both use cases are valid and the segfault in IR is most likely due to an enormous dependency chain.

@UplinkCoder
Copy link
Member

UplinkCoder commented Dec 24, 2018

We don't use phobos, we use ocean and that works fine.

our build system it called makd and it needs all dependencies.

@WalterBright
Copy link
Member

I don't understand Sociomatic's needs here. Do they want this PR, or does this PR break their code?

@UplinkCoder
Copy link
Member

This PR could break our code. I am on holiday right now, and so are most of our developers.
Therefore we cannot give immediate feedback on whether it does.

@MartinNowak
Copy link
Member Author

One point here is that recursive dependencies never worked together with codegen except for trivial examples, as semantic3 order issues trigger bugs in IR and codegen.

Apparently Sociomantic only uses -o- -deps=file (see here) to list recursive dependencies of their allunitests.d file to display a dependency graph.

Dependencies for their build targets rely on rdmd's --makedepfile mechanism, https://github.com/sociomantic-tsunami/makd/blob/034a1f22efab1db08551f16dc283656891b6b935/Makd.mak#L496-L497. As mentioned in the OP, rdmd never used dmd's --deps switch, but parses the -v output to obtain all imports (see here). This has always been a working alternative to obtain all recursive dependencies, hence I think we should revert the broken semantic3 hack for the -deps switch.

@MartinNowak
Copy link
Member Author

Maybe after all we need a new switch for recursive dependencies? Both use cases are valid and the segfault in IR is most likely due to an enormous dependency chain.

It's rather due to the fragile backend/IR-gen that cannot deal with semantic3 calls on arbitrary modules which might not even be part of the compilation.

@wilzbach
Copy link
Member

wilzbach commented Jan 4, 2019

This PR could break our code. I am on holiday right now, and so are most of our developers.Therefore we cannot give immediate feedback on whether it does.

Ping @UplinkCoder

@wilzbach
Copy link
Member

This PR could break our code. I am on holiday right now, and so are most of our developers.Therefore we cannot give immediate feedback on whether it does.

Ping @UplinkCoder

Ping @UplinkCoder ;-)

@codecov
Copy link

codecov bot commented May 19, 2019

Codecov Report

Merging #9122 into stable will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           stable   #9122      +/-   ##
=========================================
- Coverage    85.8%   85.8%   -0.01%     
=========================================
  Files         141     141              
  Lines       72285   72276       -9     
=========================================
- Hits        62026   62018       -8     
+ Misses      10259   10258       -1
Impacted Files Coverage Δ
src/dmd/dmodule.d 84.42% <ø> (+0.17%) ⬆️
src/dmd/mars.d 76.9% <ø> (-0.05%) ⬇️
src/dmd/dtemplate.d 88.44% <0%> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cb179f...5650860. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented May 19, 2019

Codecov Report

Merging #9122 into stable will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           stable   #9122      +/-   ##
=========================================
- Coverage    85.8%   85.8%   -0.01%     
=========================================
  Files         141     141              
  Lines       72285   72276       -9     
=========================================
- Hits        62026   62018       -8     
+ Misses      10259   10258       -1
Impacted Files Coverage Δ
src/dmd/dmodule.d 84.42% <ø> (+0.17%) ⬆️
src/dmd/mars.d 76.9% <ø> (-0.05%) ⬇️
src/dmd/dtemplate.d 88.44% <0%> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cb179f...5650860. Read the comment docs.

@Geod24
Copy link
Member

Geod24 commented Sep 8, 2019

How come Sociomantic uses this @UplinkCoder ? This was introduced in 2.075, which Sociomantic didn't use at the time.

@WalterBright
Copy link
Member

I fixed the merge conflicts.

@WalterBright
Copy link
Member

@UplinkCoder ping?

@stefan-koch-sociomantic

@Geod24 I've back-ported this to dmd-transitional

I can't recall which code only that it was
@don-clugston-sociomantic
who ran into a problem with -deps.

If you think making the the -deps switch miss more dependencies than it before is a good idea go right ahead and merge this.

@RazvanN7
Copy link
Contributor

RazvanN7 commented Dec 17, 2019

I agree that the original fix is broken and needs to be fixed somehow, but simply reverting it is not a solution. As I see it, if you want the full dependencies that would require to do all the semantic passes (in order to fix the existing breakages) and that would make deps unusable in certain situations where only the shallow dependencies are needed.

The solution I am proposing is the following: make the -deps switch receive a string parameter that may have the values shallow/recursive (e.g. -deps=shallow). Not providing anything means you simply want the shallow dependencies. If you specifically ask for recursive dependencies then you knowingly accept the performance penalties of running all the semantic passes.

I don't see any other way of solving this conflict, since there are parties that are interested in getting the recursive dependencies.

@rainers
Copy link
Member

rainers commented Dec 17, 2019

-deps=shallow

This currently creates a file "shallow".

If the current behavior is reverted, you should get the recursive dependencies by combining -deps and -i.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 25, 2020

Breaking sociomantic code is no longer a blocker. The comment on -deps - i is still valid.

Can the tests be kept, but the compile args fixed up accordingly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet