Thread overview
is the runtime implemented in betterC?
4 days ago
dangbinghoo
4 days ago
Adam D. Ruppe
4 days ago
kinke
4 days ago
dangbinghoo
4 days ago
Adam D. Ruppe
3 days ago
Jacob Carlborg
3 days ago
kinke
2 days ago
dangbinghoo
4 days ago
hi,

is the runtime d code implemented purely with betterC?

i was thinking that what's happening when we building ARM dlang compiler, when the dlang compiler ready in the first, there's no ARM version of the runtime lib and phobos, so, it's likely we are using bare metal D and trying to build the runtime.

is this true?


thanks!

---
binghoo
4 days ago
On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote:
> is the runtime d code implemented purely with betterC?

It is actually implemented in regular D!

> i was thinking that what's happening when we building ARM dlang compiler, when the dlang compiler ready in the first, there's no ARM version of the runtime lib and phobos, so, it's likely we are using bare metal D and trying to build the runtime.

There's ARM/Linux druntime builds... but the real question is the operating system because the druntime heavily relies on an underlying OS.
4 days ago
On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote:
> hi,
>
> is the runtime d code implemented purely with betterC?
>
> i was thinking that what's happening when we building ARM dlang compiler, when the dlang compiler ready in the first, there's no ARM version of the runtime lib and phobos, so, it's likely we are using bare metal D and trying to build the runtime.

druntime is not compiled as `-betterC`, because the entire point of `-betterC` is to prevent a dependency on druntime, at least at link-time [so C forward declarations and some templates can be used by code compiled as `-betterC`].

I'm not sure what you are trying to achieve; you can easily cross-compile druntime & Phobos with LDC, see https://wiki.dlang.org/Building_LDC_runtime_libraries.
4 days ago
On Friday, 8 November 2019 at 13:52:18 UTC, kinke wrote:
> On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote:
>> hi,
>
> I'm not sure what you are trying to achieve; you can easily cross-compile druntime & Phobos with LDC, see https://wiki.dlang.org/Building_LDC_runtime_libraries.

hmm, if runtime is implemented in regular D, how could the regular D code depends on regular D runtime be compiled when we doesn't have a D runtime even exists? thinking thant we just have xtensa-llvm, and building ldc for xtensa CPU,  the runtime will simply just not compiled.

it's an egg-chicken problem?


--
thanks!


4 days ago
On Friday, 8 November 2019 at 15:25:40 UTC, dangbinghoo wrote:
> hmm, if runtime is implemented in regular D, how could the regular D code depends on regular D runtime be compiled when we doesn't have a D runtime even exists?

Think of a file like this:

// test.d
void foo() { }
void bar() { foo(); }

The code in that file depends on code in that file... but of course it works since it is all there.

The D runtime is similar. All it really is is a list of bunch of functions that might be called. If you define those functions in your build when you use them, it works as a unit.


But like I said in my other message, the hard part is sometimes cpu arch but most the coupling is to an existing operating system...
3 days ago
On 2019-11-08 16:25, dangbinghoo wrote:

> hmm, if runtime is implemented in regular D, how could the regular D code depends on regular D runtime be compiled when we doesn't have a D runtime even exists? thinking thant we just have xtensa-llvm, and building ldc for xtensa CPU,  the runtime will simply just not compiled.
> 
> it's an egg-chicken problem?

One needs to be a bit careful. For example, to not use the garbage collector before it's initialized.

-- 
/Jacob Carlborg
3 days ago
On Friday, 8 November 2019 at 15:25:40 UTC, dangbinghoo wrote:
> On Friday, 8 November 2019 at 13:52:18 UTC, kinke wrote:
>> On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote:
>>> hi,
>>
>> I'm not sure what you are trying to achieve; you can easily cross-compile druntime & Phobos with LDC, see https://wiki.dlang.org/Building_LDC_runtime_libraries.
>
> hmm, if runtime is implemented in regular D, how could the regular D code depends on regular D runtime be compiled when we doesn't have a D runtime even exists? thinking thant we just have xtensa-llvm, and building ldc for xtensa CPU,  the runtime will simply just not compiled.
>
> it's an egg-chicken problem?

This is getting confusing. You definitely don't need a prebuilt druntime to build the static druntime library, the dependency is at link-time, and then druntime just depends on other parts of itself. No chicken-egg problem.

It's still not clear to me what you are actually trying to achieve. If you are working on an x64 machine, have built a special xtensa-LLVM and built an LDC linked against that LLVM, you can cross-compile to that CPU. You can use the mentioned ldc-build-runtime tool to try to cross-compile druntime and Phobos (and optionally the testrunners). Then it's all about fixing the resulting compile errors (and link errors for the testrunners); most of the adaptations are in druntime, but you'll also have to slightly adapt the compiler (at least adding a new predefined version for the new CPU architecture).

druntime depends on OS, architecture and coupled C runtime - what OS are you going to target?
2 days ago
On Saturday, 9 November 2019 at 22:46:16 UTC, kinke wrote:
> druntime depends on OS, architecture and coupled C runtime - what OS are you going to target?

thank you all first! I just made a basic mistake and didn't realized that druntime is just libraries and onlymatter when linking the final executebals.

and for xtensa cpu, most used chip is the esp32 mcu, it only has support of freeRTOS, and implemented just few posix api for stdio and threads.

so, basically i can only use betterC set of normal D.

thanks!