On Thursday, 19 July 2018 at 11:35:00 UTC, Seb wrote:
On Thursday, 19 July 2018 at 10:27:36 UTC, Zheng (Vic) Luo wrote:
Current implementation of d-runtime relies on a lot of symbols from libc, librt, libpthread, which makes it hard to create a minimal runtime used for embedded devices. Although there are some unofficial minimal versions of d-runtime, many of them lack maintenance and outdates rapidly. I was wondering that is there any plan for a https://doc.rust-lang.org/core/ library in D world, which only depends several explicitly-defined symbols?

Well, since 2.079 it's actually possible to use D without a dependency any runtime (even libc):

https://dlang.org/changelog/2.079.0.html#minimal_runtime

Also with -betterC you can actually use lots of things from core that don't depend on the runtime. For example, std.algorithm/range works in betterC:

https://run.dlang.io/is/38yowj

Now, I assume you are asking whether there are plans for a minimal -betterC runtime? There aren't "official" plans, but AFAICT a few people are independently working on this. It might be a good idea to join efforts with them.

Just tried something similar with new LDC Webassembly support [1] and it fails to compile

---
int foo()
{
    import std.algorithm, std.range;
    auto r = 100.iota.stride(2).take(5);
    return r.sum();
}
---
ldc2 -mtriple=wasm32-unknown-unknown-wasm -betterC -link-internally -L-allow-undefined -release -Os wasm.d ldc\bin\..\import\core\stdc\stdio.d(31): Error: module `core.stdc.stdint` import intptr_t not found ldc\bin\..\import\core\stdc\stdio.d(1149): Error: undefined identifier FILE
....

This is a prime example of stuff that should just workTM on targets like that. I would like to submit some fixes but I think there needs to be a more systematic approach on making more core APIs modular. Also, CI support to make sure core API compile on such targets and there are no regressions. Webassembly would be an excellent target as it is both constrained and portable.

1 - https://wiki.dlang.org/Generating_WebAssembly_with_LDC

Reply via email to