Bug 13631 – No-op module ctors cause circular dependencies.

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-10-18T10:09:06Z
Last change time
2024-12-13T18:31:37Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Marco Leise
Moved to GitHub: dmd#18899 →

Comments

Comment #0 by Marco.Leise — 2014-10-18T10:09:06Z
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
Comment #1 by Marco.Leise — 2014-10-18T10:47:15Z
Actually it happens with with 2.066.1 release, too.
Comment #2 by Marco.Leise — 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.
Comment #3 by robert.schadek — 2024-12-13T18:31:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18899 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB