diff --git a/druntime/src/core/internal/array/utils.d b/druntime/src/core/internal/array/utils.d index 40caa39c89e8..e9c351cd3a50 100644 --- a/druntime/src/core/internal/array/utils.d +++ b/druntime/src/core/internal/array/utils.d @@ -21,23 +21,15 @@ auto gcStatsPure() nothrow pure return impureBypass(); } -ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure +version (D_ProfileGC) { - static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow - { - import core.internal.traits : externDFunc; + // Cannot use `externD` template, because then it will cause + // cyclic dependencies (and error out) as CTFE string appending + // expands runtime hooks, which on -profilegc call this. + pragma(mangle, "_D2rt9profilegc14accumulatePureFNaNbNiAyaiQeQgmZm") + ulong accumulatePure(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure; - alias accumulate = externDFunc!("rt.profilegc.accumulate", void function(string file, uint line, string funcname, string type, ulong sz) @nogc nothrow); - accumulate(file, line, funcname, name, size); - return size; - } - auto func = cast(ulong function(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure)&impureBypass; - return func(file, line, funcname, name, size); -} - -version (D_ProfileGC) -{ /** * TraceGC wrapper generator around the runtime hook `Hook`. * Params: diff --git a/druntime/src/rt/profilegc.d b/druntime/src/rt/profilegc.d index dd12995f4226..aaa37833d8ef 100644 --- a/druntime/src/rt/profilegc.d +++ b/druntime/src/rt/profilegc.d @@ -89,6 +89,18 @@ public void accumulate(string file, uint line, string funcname, string type, ulo } } +public ulong accumulatePure(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure +{ + static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow + { + accumulate(file, line, funcname, name, size); + return size; + } + + auto func = cast(ulong function(string file, int line, string funcname, string name, ulong size) @nogc nothrow pure)&impureBypass; + return func(file, line, funcname, name, size); +} + // Merge thread local newCounts into globalNewCounts static ~this() {