Thread overview | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 13, 2014 Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Hello all, I decided to start trying out the ARM embedded programming ideas in Adam Ruppe's D Cookbook. Speaking as a complete newcomer to this area of programming, I was wondering: although Adam advises using GDC in his tutorials, would it be possible to use LDC instead -- and if so, what to use in place of the calls to arm-gdcproject-linux-gnueabi-gdc, arm-gdcproject-linux-gnueabi-as, arm-gdcproject-linux-gnueabi-ld, and arm-gdcproject-linux-gnueabi-objcopy ... ? I'm building LDC on top of llvm 3.4, so is the ARM support here adequate in any case? Thanks & best wishes, -- Joe |
July 13, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | On Sunday, 13 July 2014 at 10:16:36 UTC, Joseph Rushton Wakeling wrote:
> Hello all,
>
> I decided to start trying out the ARM embedded programming ideas in Adam Ruppe's D Cookbook. Speaking as a complete newcomer to this area of programming, I was wondering: although Adam advises using GDC in his tutorials, would it be possible to use LDC instead -- and if so, what to use in place of the calls to arm-gdcproject-linux-gnueabi-gdc, arm-gdcproject-linux-gnueabi-as, arm-gdcproject-linux-gnueabi-ld, and arm-gdcproject-linux-gnueabi-objcopy ... ?
>
> I'm building LDC on top of llvm 3.4, so is the ARM support here adequate in any case?
>
> Thanks & best wishes,
>
> -- Joe
Are you targeting ARM (e.g. Cortex-A), or ARM Thumb (e.g Cortex-M)?
|
July 13, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Sunday, 13 July 2014 at 10:53:06 UTC, Mike wrote:
> Are you targeting ARM (e.g. Cortex-A), or ARM Thumb (e.g Cortex-M)?
Cortex-M, I believe. But as all I'm doing for now is qemu-based I guess I can adapt to either.
|
July 13, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | On Sunday, 13 July 2014 at 12:42:41 UTC, Joseph Rushton Wakeling wrote: > On Sunday, 13 July 2014 at 10:53:06 UTC, Mike wrote: >> Are you targeting ARM (e.g. Cortex-A), or ARM Thumb (e.g Cortex-M)? > > Cortex-M, I believe. But as all I'm doing for now is qemu-based I guess I can adapt to either. The very first compiler I used to make my semihosted hello world (http://wiki.dlang.org/Minimal_semihosted_ARM_Cortex-M_%22Hello_World%22) was LDC. I haven't used it in while, though I intend to when I get a little farther with my project. Once again, my goal was to have a compiler that I could use to create a D runtime, so I didn't need phobos or the D Runtime. I don't know how many people know this, but you don't actually need the D Runtime to program in D. You just have to keep yourself limited to a C-like subset of D. If you want to use structs, however, you will need to give the compiler some phony TypeInfo stuff from the object.d/di file. See my example here: (https://github.com/JinShil/D_Runtime_ARM_Cortex-M_study/blob/master/1.3-structs/source/object.d). I wrote a wiki about this too (https://github.com/JinShil/D_Runtime_ARM_Cortex-M_study/wiki/1.3-Structs). This also needs to be done for GDC. LDC would crash if I did not provide them (https://github.com/ldc-developers/ldc/issues/552). Some of these issues seem to have been fixed (https://github.com/ldc-developers/ldc/issues/551), but I haven't gotten around to testing them and providing feedback. Adam Ruppe actually recommended a potential solution to this nonsense (https://issues.dlang.org/show_bug.cgi?id=12270). Also with LDC, I don't think there is a linker capable of creating an executable for ARM Cortex-M. You can build binutils, or you can use the linker from here GNU Tools for ARM Embedded (https://launchpad.net/gcc-arm-embedded). LDC folks, Does LLVM have its own linker? LDC also needs to be built with an ARM Thumb LLVM backend. I did this, but I lost my script files :( I'll have to recreate them. I remember it being much simpler than GDC. I've asked the LDC folks to include an ARM Thumb backend in their release, but I don't think they've done it yet. On Arch Linux, the LDC package seems to already include ARM Thumb: ldc2 --version LDC - the LLVM D compiler (0.13.0): based on DMD v2.064 and LLVM 3.4.2 Default target: x86_64-unknown-linux-gnu Host CPU: corei7 http://dlang.org - http://wiki.dlang.org/LDC Registered Targets: aarch64 - AArch64 (ARM 64-bit target) arm - ARM cpp - C++ backend hexagon - Hexagon mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel msp430 - MSP430 [experimental] nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit ppc32 - PowerPC 32 ppc64 - PowerPC 64 ppc64le - PowerPC 64 LE r600 - AMD GPUs HD2XXX-HD6XXX sparc - Sparc sparcv9 - Sparc V9 systemz - SystemZ thumb - Thumb x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 xcore - XCore Mike |
July 13, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | > LDC folks, Does LLVM have its own linker? http://lld.llvm.org/#current-status |
July 13, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Sunday, 13 July 2014 at 13:35:19 UTC, Mike wrote: > On Arch Linux, the LDC package seems to already include ARM Thumb btw if you have any suggestions for building default gdc / ldc packages in Arch Linux to make those better suitable for embedded experiments, please either write me via public@dicebot.lv or add an issue here : https://github.com/Dicebot/Arch-PKGBUILDs I am very interested in making this experience as easy to try out as possible for random intrigued by-passers. |
July 14, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | Hi Joe!
On Sunday, 13 July 2014 at 10:16:36 UTC, Joseph Rushton Wakeling wrote:
> I decided to start trying out the ARM embedded programming ideas in Adam Ruppe's D Cookbook. Speaking as a complete newcomer to this area of programming, I was wondering: although Adam advises using GDC in his tutorials, would it be possible to use LDC instead -- and if so, what to use in place of the calls to arm-gdcproject-linux-gnueabi-gdc, arm-gdcproject-linux-gnueabi-as, arm-gdcproject-linux-gnueabi-ld, and arm-gdcproject-linux-gnueabi-objcopy ... ?
>
> I'm building LDC on top of llvm 3.4, so is the ARM support here adequate in any case?
You can build LDC on an ARM system without problem. Most stuff works out of the box. Prominent exceptions are exception handling and some std.math stuff. Most annoying: there is a bug(?) in dso_ctor()/dso_dtor() which prevents compiling with -O0. If you use -O1 or higher everything works.
More likely you want to cross compile to ARM. The problem here is floating point support as ARM does not have a real (80-bit) floating point type. Currently, you can't change this without recompiling LDC. (Change real_t to double and use the double constants instead of the long double ones.) This is the reason why the binary distributions do not contain an ARM backend.
llvm 3.4 is ok for code generation. As far as I remember wrong relocations are generated for debug info of TLS variables.
Just give it a try. :-)
Regards,
Kai
|
July 15, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Sunday, 13 July 2014 at 15:29:19 UTC, Dicebot wrote:
> On Sunday, 13 July 2014 at 13:35:19 UTC, Mike wrote:
>> On Arch Linux, the LDC package seems to already include ARM Thumb
>
> btw if you have any suggestions for building default gdc / ldc packages in Arch Linux to make those better suitable for embedded experiments, please either write me via public@dicebot.lv or add an issue here : https://github.com/Dicebot/Arch-PKGBUILDs
>
> I am very interested in making this experience as easy to try out as possible for random intrigued by-passers.
I think if users are somehow aware that there will be no runtime or phobos it may be ok to create a distributable package. But if user's expect everything to just work, they may come away disappointed.
We may be able to bundle the newlib C library and a phony object.d for the runtime. But, I wouldn't want users' first experience with D on microcontrollers to leave them with a bad taste in their mouth. I'll have to think about it some more. I'm not sure right now.
|
July 15, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Tuesday, 15 July 2014 at 00:56:31 UTC, Mike wrote:
> I think if users are somehow aware that there will be no runtime or phobos it may be ok to create a distributable package. But if user's expect everything to just work, they may come away disappointed.
>
> We may be able to bundle the newlib C library and a phony object.d for the runtime. But, I wouldn't want users' first experience with D on microcontrollers to leave them with a bad taste in their mouth. I'll have to think about it some more. I'm not sure right now.
I currently define runtime/phobos as virtual dependencies so it is perfectly possible to provide alternative runtime package tuned for microcontrollers.
|
July 17, 2014 Re: Building for ARM with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | On Sunday, 13 July 2014 at 14:33:57 UTC, Trass3r wrote:
>> LDC folks, Does LLVM have its own linker?
>
> http://lld.llvm.org/#current-status
Does LDC employ this linker, and is it possible to provide custome linker scripts?
|
Copyright © 1999-2021 by the D Language Foundation