Closed etcimon closed 10 months ago
✅ PR OK, no changes in deprecations or warnings
Total deprecations: 11
Total warnings: 0
Build statistics:
statistics (-before, +after)
-executable size=5371736 bin/dub
-rough build time=62s
+executable size=5375832 bin/dub
+rough build time=63s
Duplicate of: https://github.com/dlang/dub/pull/2699
My solution involves minor changes and reverts to old behaviour, easier to approve.
Just to be sure I follow: Do we need the -betterC
flag if we make it -betterC
-compliant ? As in, if you get it to a point it does not pull anything from the runtime, the flag becomes superfluous, doesn't it ?
Just to be sure I follow: Do we need the
-betterC
flag if we make it-betterC
-compliant ? As in, if you get it to a point it does not pull anything from the runtime, the flag becomes superfluous, doesn't it ?
No, it doesn't.
You will still be linking against druntime, and that has cost.
The probePlatform
routine takes ~25ms (vs ~38ms previously) for me using a StopWatch
when building with these improvements. It's now also compatible with projects that don't include druntime.
If I benchmark only the first run on windows arch x86_64, it goes from 52ms to 24ms
On dmd removing the -betterC
flag improves it to 18ms, but with ldc it worsens it to 40ms.
You will still be linking against druntime, and that has cost.
Why do we need to link ?
It wouldn't link, it doesn't write an object file, compile flag -o-
. It's mostly dmd.dinterpret in the compiler doing most of the work and returning after.
It's mostly dmd.dinterpret in the compiler doing most of the work and returning after.
So why is -betterC
relevant here ? That's what I'm confused about. I would like to solve your issue, but I'm not sure I fully understand it.
Originally it's because this project https://github.com/etcimon/libwasm implements its own druntime and for it you must remove the includes in ldc2.conf, but probing fails on that configuration if it depends on druntime.
but probing fails on that configuration if it depends on druntime.
I assume that probing fails because it tries to import druntime, rather than link it ?
It complains that there is no module object
@kinke : Any chance you could have a look at this ? I think the use case is good, but I would like to make sure it keeps on working with newer versions of DMD/LDC with minimal maintenance.
So why is
-betterC
relevant here ?
It works without -betterC
, but it does help with both performance and guarantees.
Are we waiting on @kinke for a follow-up?
AFAICT after a quick glance, the main change here is that the generated probe module becomes the special object
module, only defining the string
alias (not even size_t
), so that the (fat) druntime one isn't imported. -betterC
then shouldn't really make a difference, as its effects should be enabled automatically without TypeInfo
class etc. in object
.
While such a minimalistic, fully self-contained D module is surely fast to analyze with -o-
and working for ~all exotic targets too, the cost is the ugly duplication in source/dub/platform.d
. I guess that could be improved though by post-processing the existing string, e.g., replacing ret ~= <literal>;
by pragma(msg, ´ <literal>´);
and stripping off string[] ret;
and return ret;
.
I guess that could be improved though by post-processing the existing string
The post-processing using regex, matchAll and replace makes it impossible to evaluate the string with ctfe, but I doubt this would make it slower.
nvm I got it working in ctfe
Should I squash it?
This improves performance and also allows me to compile a custom druntime with my application. (post-switches = [] in the ldc2.conf)