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

No-op module ctors cause circular dependencies. #18899

Open
dlangBugzillaToGithub opened this issue Oct 18, 2014 · 2 comments
Open

No-op module ctors cause circular dependencies. #18899

dlangBugzillaToGithub opened this issue Oct 18, 2014 · 2 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Marco Leise (@mleise) reported this on 2014-10-18T10:09:06Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=13631

Description

Based on commit 15b68997d0ae2332ed653658e5d7643fcf0d354f

In some cases dmd now seems to emit module ctors/dtors for empty modules just depending on what they import. This in turn causes new circular dependency conflicts that weren't there previously.

I didn't reduce my code base, but it probably rings a bell already when I say that this file now gets an auto-generated(?) module ctor:

------------------
module Lib.Audio.Sample;

import Lib.Audio.AudioLoader;
------------------

(AudioLoader itself also imports Lib.Audio.Sample.)

The generated file is ~810 KiB large and the output of nm for `Lib.Audio.Sample.o` contains as well as a lot of symbols from Phobos like std.parallelism or std.container:

0000000000000000 T _D3Lib5Audio6Sample9__modctorFZv
0000000000000000 T _D3Lib5Audio6Sample9__moddtorFZv

objdump further reveals that DMD now emulates -ffunction-sections and that the code it generates for the module ctor/dtor is a glorified no-op.

Disassembly of section .text._D3Lib5Audio6Sample9__modctorFZv:

0000000000000000 <_D3Lib5Audio6Sample9__modctorFZv>:
   0:   push   rbp
   1:   mov    rbp,rsp
   4:   push   rbx
   5:   mov    rax,QWORD PTR fs:0x0
   e:   mov    rcx,QWORD PTR [rip+0x0]
  15:   inc    DWORD PTR [rax+rcx*1]
  18:   mov    rdx,QWORD PTR fs:0x0
  21:   mov    rbx,QWORD PTR [rip+0x0]
  28:   inc    DWORD PTR [rdx+rbx*1]
  2b:   pop    rbx
  2c:   pop    rbp
  2d:   ret    
  2e:   xchg   ax,ax

Disassembly of section .text._D3Lib5Audio6Sample9__moddtorFZv:

0000000000000000 <_D3Lib5Audio6Sample9__moddtorFZv>:
   0:   push   rbp
   1:   mov    rbp,rsp
   4:   call   9 <_D3Lib5Audio6Sample9__moddtorFZv+0x9>
   9:   call   e <_D3Lib5Audio6Sample9__moddtorFZv+0xe>
   e:   pop    rbp
   f:   ret
@dlangBugzillaToGithub
Copy link
Author

Marco.Leise commented on 2014-10-18T10:47:15Z

Actually it happens with with 2.066.1 release, too.

@dlangBugzillaToGithub
Copy link
Author

Marco.Leise commented on 2014-10-18T13:08:54Z

The issue is actually present in 2.066.0, so not a new regression. Maybe no regression at all. It just happens in -debug builds and maybe would have happened in earlier version of dmd, too. But I can't easily test this with the code already depending on 2.066.1 fixes.

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

No branches or pull requests

1 participant