Thread overview |
---|
October 08, 2017 LLVM BC as library | ||||
---|---|---|---|---|
| ||||
Some time ago I was able to compile simple library into BC (pure C) and load it with my application and use across different operating systems with re-compilation having those external code running in a sandbox. How much difficult it would be to try with D? Means application is in C++ and I want to load BC made from D code? The idea itself comes from something like sandboxed Quake 3 QVM and used for game logic, it's pretty easy to replicate that behavior with C/C++ with LLVM BC. I wonder how much pain it would be to make that with D instead. |
October 08, 2017 Re: LLVM BC as library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Void-995 | On Sunday, 8 October 2017 at 10:30:22 UTC, Void-995 wrote:
> Some time ago I was able to compile simple library into BC (pure C) and load it with my application and use across different operating systems with re-compilation having those external code running in a sandbox.
>
> How much difficult it would be to try with D? Means application is in C++ and I want to load BC made from D code?
>
> The idea itself comes from something like sandboxed Quake 3 QVM and used for game logic, it's pretty easy to replicate that behavior with C/C++ with LLVM BC. I wonder how much pain it would be to make that with D instead.
Compiling to LLVM bitcode with LDC is as simple as adding `-output-bc` to the command line. If you depend on the runtime library (druntime) and standard library (Phobos), you should be able to compile them to bitcode libraries by compiling LDC yourself using CMake option BUILD_BC_LIBS=ON.
|
October 08, 2017 Re: LLVM BC as library | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Sunday, 8 October 2017 at 11:57:01 UTC, kinke wrote:
> On Sunday, 8 October 2017 at 10:30:22 UTC, Void-995 wrote:
>> Some time ago I was able to compile simple library into BC (pure C) and load it with my application and use across different operating systems with re-compilation having those external code running in a sandbox.
>>
>> How much difficult it would be to try with D? Means application is in C++ and I want to load BC made from D code?
>>
>> The idea itself comes from something like sandboxed Quake 3 QVM and used for game logic, it's pretty easy to replicate that behavior with C/C++ with LLVM BC. I wonder how much pain it would be to make that with D instead.
>
> Compiling to LLVM bitcode with LDC is as simple as adding `-output-bc` to the command line. If you depend on the runtime library (druntime) and standard library (Phobos), you should be able to compile them to bitcode libraries by compiling LDC yourself using CMake option BUILD_BC_LIBS=ON.
I think second part was most important information, thank you. Can I build Phobos partly (or just runtime)? I would like to expose my own API for file system, for example, meaning restricting usage of built-in IO, same goes for allocations.
|
October 08, 2017 Re: LLVM BC as library | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Sunday, 8 October 2017 at 11:57:01 UTC, kinke wrote:
> On Sunday, 8 October 2017 at 10:30:22 UTC, Void-995 wrote:
>> [...]
>
> Compiling to LLVM bitcode with LDC is as simple as adding `-output-bc` to the command line. If you depend on the runtime library (druntime) and standard library (Phobos), you should be able to compile them to bitcode libraries by compiling LDC yourself using CMake option BUILD_BC_LIBS=ON.
But I need GC anyway as I would like to use D classes.
|
Copyright © 1999-2021 by the D Language Foundation