digitalmars.D.learn - Transform/Compile to C/CPP as a target
- ParticlePeter (2/2) Jul 23 2016 Is there any kind of project or workflow that converts D (subset)
- rikki cattermole (3/5) Jul 23 2016 This probably will interest you for ldc:
- ParticlePeter (6/12) Jul 23 2016 Cool, I didn't know that one but I also didn't invest time in
- Jacob Carlborg (5/7) Jul 23 2016 No idea about the status but:
- ParticlePeter (4/10) Jul 24 2016 Thanks, I am looking into this, but I think its still not that
- Stefan Koch (2/4) Jul 25 2016 The short answer is no, not for any recent version of D.
- Sebastien Alaiwan (29/33) Jul 28 2016 The long answer is it's kind of possible, but the resulting C
- Seb (3/10) Jul 28 2016 https://github.com/Syniurge/Calypso
Is there any kind of project or workflow that converts D (subset) to C/CPP ?
Jul 23 2016
On 24/07/2016 12:27 AM, ParticlePeter wrote:Is there any kind of project or workflow that converts D (subset) to C/CPP ?This probably will interest you for ldc: http://stackoverflow.com/questions/5180914/llvm-ir-back-to-human-readable-source-language
Jul 23 2016
On Saturday, 23 July 2016 at 12:29:45 UTC, rikki cattermole wrote:On 24/07/2016 12:27 AM, ParticlePeter wrote:Cool, I didn't know that one but I also didn't invest time in LLVM till now. However, this converts bitcode to C/CPP, my guess would be that the job can be done much better if the original D source would be used in tandem.Is there any kind of project or workflow that converts D (subset) to C/CPP ?This probably will interest you for ldc: http://stackoverflow.com/questions/5180914/llvm-ir-back-to-human-readable-source-language
Jul 23 2016
On 2016-07-23 14:27, ParticlePeter wrote:Is there any kind of project or workflow that converts D (subset) to C/CPP ?No idea about the status but: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d -- /Jacob Carlborg
Jul 23 2016
On Saturday, 23 July 2016 at 19:20:10 UTC, Jacob Carlborg wrote:On 2016-07-23 14:27, ParticlePeter wrote:Thanks, I am looking into this, but I think its still not that what I am searching, it seems to create only C/CPP headers for D libs. I would like to have the whole source code transformed.Is there any kind of project or workflow that converts D (subset) to C/CPP ?No idea about the status but: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d
Jul 24 2016
On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote:Is there any kind of project or workflow that converts D (subset) to C/CPP ?The short answer is no, not for any recent version of D.
Jul 25 2016
On Monday, 25 July 2016 at 07:53:17 UTC, Stefan Koch wrote:On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote:The long answer is it's kind of possible, but the resulting C code is not human-readable. I just managed today to achieve some transformation to C with the below script: $ ldc2 hello.d -c -output-ll -ofhello.ll $ ldc2 lib.d -c -output-ll -oflib.ll $ llvm-link-3.8 hello.ll lib.ll -o full.bc $ llvm-dis-3.8 full.bc -o=full.ll $ llvm-cbe full.ll $ sed -i "s/.*APInt.*//" full.cbe.c $ sed -i "s/^uint32_t main(uint32_t llvm_cbe_argc_arg, uint8_t\*\* llvm_cbe_argv_arg)/int main(int llvm_cbe_argc_arg, char** llvm_cbe_argv_arg)/" full.cbe.c $ sed -i "s/^uint32_t main(uint32_t, uint8_t\*\*)/int main(int, char**)/" full.cbe.c $ gcc -w full.cbe.c -o full.exe -lphobos2 $ ./full.exe Hello, world: 46 I only tried this with a very minimalistic subset of D at the moment. Most of the magic occurs in the "llvm-cbe" program, which is a "resurrected LLVM C backend" ( https://github.com/JuliaComputing/llvm-cbe ).Is there any kind of project or workflow that converts D (subset) to C/CPP ?The short answer is no, not for any recent version of D.
Jul 28 2016
On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote:Is there any kind of project or workflow that converts D (subset) to C/CPP ?Just FYI there is a project that does the reverse.Calypso creates a bridge between DMD/LDC and Clang, both at the AST level (DMD <=> Clang's AST, Sema, ...) and at the code generation level (LDC <=> Clang's Codegen) to make D interface directly with the almost full set of C++ features, and no binding is needed.https://github.com/Syniurge/Calypso
Jul 28 2016