Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 05, 2020 C backend for D | ||||
---|---|---|---|---|
| ||||
Has there ever been an attempt to create a C backend for D? |
March 05, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar wrote:
> Has there ever been an attempt to create a C backend for D?
Indeed.
If I recall correctly Daniel Murphy did work on one.
newCTFE has a C backend as well, which of course will only work for CTFEable code.
There are also approaches which use the unofficial LLVM C backend via a custom build of LDC.
|
March 05, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Thursday, 5 March 2020 at 21:43:45 UTC, Stefan Koch wrote: > On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar wrote: >> Has there ever been an attempt to create a C backend for D? > There are also approaches which use the unofficial LLVM C backend via a custom build of LDC. Yep, I've experimented with using using this with (plain) LDC: https://github.com/JuliaComputing/llvm-cbe I got "Hello World" to work, but unfortunately llvm-cbe's forward reference generation is buggy, so I gave up trying to get anything more complicated to compile. Credit goes to this post for the original inspiration: https://qiita.com/mono_shoo/items/81b98ac5656a47617232 (Post from the Japanese D community about using llvm-cbe to run D on a microcontroller.) |
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote: > Has there ever been an attempt to create a C backend for D? https://news.ycombinator.com/item?id=22402123 |
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Friday, 6 March 2020 at 11:02:36 UTC, Walter Bright wrote:
> On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
>> Has there ever been an attempt to create a C backend for D?
>
> https://news.ycombinator.com/item?id=22402123
Well most reasons stated in that thread appear to be spurious? Only one that is perhaps a valid issue is debug info.
What would real issues for the better C dialect to have a C backend?
|
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On Friday, 6 March 2020 at 13:08:47 UTC, Dibyendu Majumdar wrote:
> What would real issues for the better C dialect to have a C backend?
Wrong question - what would be the point of such a backend?
|
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar wrote:
> Has there ever been an attempt to create a C backend for D?
None, there is simply no good reason for dmd to have a c backend. Once the backend has been open sourced, effort has been made to port it to d via dbetterC.
|
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to 12345swordy | On Friday, 6 March 2020 at 19:24:13 UTC, 12345swordy wrote:
> On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar wrote:
>> Has there ever been an attempt to create a C backend for D?
>
> None, there is simply no good reason for dmd to have a c backend. Once the backend has been open sourced, effort has been made to port it to d via dbetterC.
With LLVM, intermediate languages or "transpilers" has become less usual simply because they are less and less necessary. Also debugging becomes more difficult as you have an intermediate language that will fill up the debugging information rather than the actual language that you are using.
Nim, is the language that stands out that uses C as the main backend. It has benefits as well as drawbacks.
With LDC and GDC, a C backend is more or less obsolete and pointless.
|
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On 3/6/2020 5:08 AM, Dibyendu Majumdar wrote:
> On Friday, 6 March 2020 at 11:02:36 UTC, Walter Bright wrote:
>> On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
>>> Has there ever been an attempt to create a C backend for D?
>>
>> https://news.ycombinator.com/item?id=22402123
>
> Well most reasons stated in that thread appear to be spurious? Only one that is perhaps a valid issue is debug info.
I know people like to argue with me about the validity of the points. Most of them are value judgements, and I consider it compelling. With enough effort, one can make anything work.
|
March 06, 2020 Re: C backend for D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Thursday, 5 March 2020 at 21:43:45 UTC, Stefan Koch wrote: > On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar wrote: >> Has there ever been an attempt to create a C backend for D? > > Indeed. > > If I recall correctly Daniel Murphy did work on one. Is it this one you mean: https://github.com/yebblies/dmd/tree/microd > newCTFE has a C backend as well, which of course will only work for CTFEable code. Cool, is there an example C output? Regards |
Copyright © 1999-2021 by the D Language Foundation