Going nurt
Probably would fix #912 , the other benefits being:
- a lack of #912 in the future, this was always a bit fishy ever since we left druntume uninitialized in 2016, however the new druntime hook itself with the C runtime in a way we can't avoid in a shared lib
- [x] possibly less binary size => yes
Current nurt is >= LDC 1.38, which would work ok probably (EDIT: and very hard to bring support for earlier compilers)
=> Must be possible, of course, to build the same plugin with and without nurt
OK, got a first executable that print hello world.
Final executable must have the hookset dependency, and should also coerce the right subConfiguration it seems, else DUB will try (and fail) to create a nurt.dll
"dependencies":
{
"nurt": ">=0.1.4 <2.0.0",
"numem": ">=0.2.0",
"numem:hookset-libc": ">=0.2.0"
},
"subConfigurations": {
"nurt": "ldc-static"
}
main.d
import core.stdc.stdio;
import core.stdc.stdlib;
void main(string[] args)
{
printf("Hello\n");
}
Calling core.stdc stuff seems to work ok, but defeat a bit the portability goal of nurt. Still as a first step it's kinda useful to remove all traces of druntime and Phobos.
That hello world builds fast and is only 142kb!
Nowadays, nurt can be disabled until only nurt is used.
Transition will go down as follow:
-
- Dplug and libraries start depending on ~~nurt~~ nulib, which becomes a dependency of most things in dplug.
-
- Transition period
-
- Individual project can depend and enable nurt
Trying to do a regular executable with nurt, there is a crash in audioformats at stream destruction it seems. => OK, it was the use of emplace/destroy
Better understanding now of the plan.
- [x] extern(C++) classes don't build with nogc_trydelete, the FLP client is an extern(C++) class that was allocated with malloc not the C++ runtime, but numem want to do it differently. And it's not C++ but Delphi interface. Do we need this extern(C++), probably yes, and can we emplace it like before?
- [ ] It works when constructed by the C++ runtime, on Windows. Which was unexpected. Still, we may need in the future to call
nogc_constructfor emplace.mallocNewwill provide that distinction :) not sure what else in Dplug uses extern(C++) like that, probably nothing when making new extern(C++) objects, or call a separate function.
- [ ] It works when constructed by the C++ runtime, on Windows. Which was unexpected. Still, we may need in the future to call
- [x] Need to check the Linux build order since allegedly numem would need a special link order to work. Need to check a working program on Linux. (with both dub and redub). "Redub solves circular linker issues while dub does not", I'm told. => not seeing that, instead it's redub that has a few difficulties with numem. In my tests using redub wasn't necessary, but Luna told otherwise... 🤔
- [ ] Evaluate carefully each use of exp/pow/log/exp2/log10/log2/ldexp, since Phobos has its own implementation with unknown precision characteristics, it's a bad practice to rely on that though it's perfectly possible that it sounds different or even better... annoying task
~~I think it's going to be way smoother than expected.~~ We only have to transition to numem, wait until eliminating old stuff, and then enable nurt.
- [x] Adding nurt+numem+nulib is adding 5 packages, which is a bit much. :/ Only adding numem+nurt would be a perhaps leaner, since they all depend on libc anyway for the foreseeable future.
- [x] Is nulib working on macOS? The sub-package dependency is seemingly gone. => not using it
- [x] redub can't build dplug:vst2 for now (envvar stuff)
- [x] redub can't build plugins in Windows (fixed)
- [x] Give access to --breadth flag from dplug-build
- [x] adapt dplug-build heuristic to find the binary that redub output => no need
- [x] remove Ddoc warning from dplug:x11
- [x] remove Ddoc warning from wren-port
- [x] can build existing DPlug plugins with redub on Linux => OK
- [x] can build DPlug plugin + numem on Linux => not OK in --final, error. =>Fix and PR in numem
- [x] Check built plugins with dub and redub => both works on Linux, stripped size OK
- [x] numem working on macOS within a plug-in, no issue with redub there either, stripped size OK