Have you ever tried to compile for esp32/8266?

Paul Freund freund.paul at lvl3.org
Tue Nov 26 12:17:51 UTC 2019


On Tuesday, 26 November 2019 at 04:38:17 UTC, dangbinghoo wrote:
> On Tuesday, 26 November 2019 at 04:34:44 UTC, dangbinghoo wrote:
>> On Tuesday, 19 November 2019 at 12:51:06 UTC, Andrea Fontana 
>> wrote:
>>> I see expressif released a fork of llvm with a new target: 
>>> extensa.
>>> This allows you to write code for esp8266 and esp32 using 
>>> clang [1]
>>>
>>> I wonder if we can use ldc (using -betterC I guess) to build 
>>> code for these platforms as well.
>>>
>>
>> And you will have betterC d code compiles and linking:
>>
>> ```
>> $ cat dcode.d
>>
>> module dcode;
>>
>> extern(C) int printf (scope const char * fmt, ...);
>>
>> char[8] a = ['a'];
>>
>> extern (C) void dlang_main()
>> {
>>     uint i = 0;
>>
>>
>>     printf("hello, dlang says : i = %d, char a len = %d\r\n", 
>> i, a.length);
>> }
>
> PS: and in other place of you esp32 IDF C code, just call 
> dlang_main as a pain c function, you will probably see Dlang is 
> saying hello.
>
> ^_^
>
> Hope these helps!
>
> Thanks!
>
> ----
> Binghoo Dang

Thank you very much for your fantastic work! I did your 
instructions on WSL Debian but had to change the build 
configuration for llvm-xtensa according to the link you posted

cmake ../llvm-xtensa -DLLVM_TARGETS_TO_BUILD="Xtensa;X86" 
-DCMAKE_BUILD_TYPE=Release -G "Ninja" 
-DCMAKE_INSTALL_PREFIX=/opt/llvm-xtensa

without the X86 build target llvm-config complains about a 
missing X86disassembler component. I am currently working on a 
template project for ESP-IDF with D support that makes 
compilation very easy and includes instructions/scripts to get it 
working, you saved me from a lot of work :)



More information about the digitalmars-d-ldc mailing list