June 26, 2020
On Friday, 26 June 2020 at 13:48:34 UTC, JN wrote:
> Is there a guide for how to create a binary working on Raspberry Pi from Windows?

I have never actually tried it, but a process similar to how the android cross compiles work should do this as well.

1) get your Windows ldc set up

2) grab the arm-linux ldc package as well.

3) change your ldc.conf to use the libraries from the arm-linux package when targeting arm-linux

4) Compile with the argument to ldc `-mtriple arm-unknown-linux-gnueabi` or `-mtriple aarch64-unknown-linux-gnu` (32 vs 64 bit target) and you should be all set. (note you just use your normal Windows ldc, all that changes is this -mtriple argument to change the target. Or if compiling with dub, it is `dub -a platform_specifier_here`.)


Step 3 is the relatively painful one, for android, i made a program to do it automatically https://github.com/adamdruppe/d_android/blob/master/android-setup.d#L232


But we should lobby the ldc upstream to just include all the configs out of the box on all systems. Maybe the libraries are a separate download, but no reason not to put the config in so it just works out of the box for cross compile too.
June 26, 2020
On Friday, 26 June 2020 at 14:02:05 UTC, Adam D. Ruppe wrote:
> On Friday, 26 June 2020 at 13:48:34 UTC, JN wrote:
>> Is there a guide for how to create a binary working on Raspberry Pi from Windows?
>
> I have never actually tried it, but a process similar to how the android cross compiles work should do this as well.
>
> 1) get your Windows ldc set up
>
> 2) grab the arm-linux ldc package as well.
>
> 3) change your ldc.conf to use the libraries from the arm-linux package when targeting arm-linux
>
> 4) Compile with the argument to ldc `-mtriple arm-unknown-linux-gnueabi` or `-mtriple aarch64-unknown-linux-gnu` (32 vs 64 bit target) and you should be all set. (note you just use your normal Windows ldc, all that changes is this -mtriple argument to change the target. Or if compiling with dub, it is `dub -a platform_specifier_here`.)
>
>
> Step 3 is the relatively painful one, for android, i made a program to do it automatically https://github.com/adamdruppe/d_android/blob/master/android-setup.d#L232
>
>
> But we should lobby the ldc upstream to just include all the configs out of the box on all systems. Maybe the libraries are a separate download, but no reason not to put the config in so it just works out of the box for cross compile too.

Sounds like fun! An it's been like this for years. Well, water, firewood, stick, stones, sparks...The D community should think outside the hacker box.

Also, the point that has been raised remains. DMD is a good dev tool. LDC would be fatal for your average debug-run cycles. But DMD for ARM will probably not happen, realistically seen. Apart from that it's important that ARM becomes a first-class citizen in the D world. It is important and you won't be able to put it on the long finger for ever.
June 26, 2020
On Friday, 26 June 2020 at 14:01:58 UTC, Chris wrote:
> There you go. That was exactly my point. There's a difference between "can be done" and just press enter and compile it. This is very important.

Well, cross-compiling takes a few extra steps (one of which (the config file) could be eliminated and one (the lib download) could be automated). But if building on the device itself it really is "just press enter".

Even this is a lot nicer than it was just one year ago btw.
June 26, 2020
On Friday, 26 June 2020 at 15:04:11 UTC, Adam D. Ruppe wrote:
> On Friday, 26 June 2020 at 14:01:58 UTC, Chris wrote:
>> There you go. That was exactly my point. There's a difference between "can be done" and just press enter and compile it. This is very important.
>
> Well, cross-compiling takes a few extra steps (one of which (the config file) could be eliminated and one (the lib download) could be automated). But if building on the device itself it really is "just press enter".
>
> Even this is a lot nicer than it was just one year ago btw.

Or maybe we need something like this...

https://wiki.lazarus.freepascal.org/fpcupdeluxe

-=mike=-
June 26, 2020
On Fri, Jun 26, 2020 at 02:02:05PM +0000, Adam D. Ruppe via Digitalmars-d wrote: [...]
> 3) change your ldc.conf to use the libraries from the arm-linux package when targeting arm-linux
[...]
> Step 3 is the relatively painful one, for android, i made a program to do it automatically https://github.com/adamdruppe/d_android/blob/master/android-setup.d#L232
> 
> But we should lobby the ldc upstream to just include all the configs out of the box on all systems. Maybe the libraries are a separate download, but no reason not to put the config in so it just works out of the box for cross compile too.

+1.  It would be nice to have a default config that assumes some default paths so that it will Just Work(tm) once you download the requisite optional libraries.  Finding the information on what exactly to write in the config file was not an easy experience for me -- there's conflicting information online, and no clear instructions on what will work for my case.  If nothing else, even a bunch of commented-out sample sections for common target platforms in the shipped config file would have helped a lot.


T

-- 
The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
June 26, 2020
On Friday, 26 June 2020 at 16:03:32 UTC, H. S. Teoh wrote:
> On Fri, Jun 26, 2020 at 02:02:05PM +0000, Adam D. Ruppe via Digitalmars-d wrote: [...]
>> [...]
> [...]
>> [...]
>
> +1.  It would be nice to have a default config that assumes some default paths so that it will Just Work(tm) once you download the requisite optional libraries.  Finding the information on what exactly to write in the config file was not an easy experience for me -- there's conflicting information online, and no clear instructions on what will work for my case.  If nothing else, even a bunch of commented-out sample sections for common target platforms in the shipped config file would have helped a lot.
>
>
> T

+1 also for me ...

... and if someone has a "big zip" (tm) with everything included and in the right position .. for a macOS host ... wow ...
June 26, 2020
On Friday, 26 June 2020 at 14:01:58 UTC, Chris wrote:
> On Friday, 26 June 2020 at 13:48:34 UTC, JN wrote:
>> On Friday, 26 June 2020 at 13:37:19 UTC, Adam D. Ruppe wrote:
>>> On Friday, 26 June 2020 at 13:17:10 UTC, Chris wrote:
>>>> But do it properly with tooling (no complicated scripts as in "yeah it can be done somehow").
>>>
>>> D just works on plenty of arm devices, including compilers in the upstream package manager (e.g. gdc on raspberry pi) or plain pre-packaged downloads that work out of the box (e.g. ldc on android).
>>>
>>> I'm a dmd die-hard on pc but it doesn't really need to be the only compiler used.
>>
>> Is there a guide for how to create a binary working on Raspberry Pi from Windows? I guess LDC will work, but I don't know how to configure it to build for ARM. I needed something like that few months ago but decided to just write a Python script instead.
>
> There you go. That was exactly my point. There's a difference between "can be done" and just press enter and compile it. This is very important. You shouldn't have to think about things like that (it's 2020). If you need hot water for your tea you use an electric kettle or a cooker. You shouldn't have to go and collect fire wood, go to the well to fetch water, light the fire and so on.

ARM that you need to cross-compile to is old news (and D hasn't done a great job making that super-easy, for sure).

Today/tomorrow's shift is about ARM that you develop *on*. So I'm not sure the current state of affairs (download the compiler on the target platform and it just works) is a disaster.

Cross-compilation should be easier though, of course. Maybe you could help the LDC guys out there?
June 26, 2020
On 2020-06-26 18:12, Paolo Invernizzi wrote:
> On Friday, 26 June 2020 at 16:03:32 UTC, H. S. Teoh wrote:
>> On Fri, Jun 26, 2020 at 02:02:05PM +0000, Adam D. Ruppe via Digitalmars-d wrote: [...]
>>> [...]
>> [...]
>>> [...]
>>
>> +1.  It would be nice to have a default config that assumes some default paths so that it will Just Work(tm) once you download the requisite optional libraries.  Finding the information on what exactly to write in the config file was not an easy experience for me -- there's conflicting information online, and no clear instructions on what will work for my case.  If nothing else, even a bunch of commented-out sample sections for common target platforms in the shipped config file would have helped a lot.
>>
>>
>> T
> 
> +1 also for me ...
> 
> ... and if someone has a "big zip" (tm) with everything included and in the right position .. for a macOS host ... wow ...

I've been thinking about writing such a tool for some time now. Just too much other things to do.

-- 
/Jacob Carlborg
June 26, 2020
> On 2020-06-26 18:12, Paolo Invernizzi wrote:
[...]
> > ... and if someone has a "big zip" (tm) with everything included and in the right position .. for a macOS host ... wow ...
[...]

Y'know what would be a total killer combo?  An all-in-one LDC package that contains everything you need to cross compile from any platform to any other platform.  Including full linkers and/or system libraries necessary to generate fully-runnable executables (this point is important, because e.g. I can't cross-compile from Linux to MacOS without separately installing a MacOS dev environment, because LDC doesn't come with a linker for that, unlike LDC-windows).

Think about it.  Install a single package on any OS, and you can instantly cross-compile to all supported LDC targets just by specifying the right -m triple without needing to install/configure anything else. Build your code for all targeted platforms all in one go, without needing to fuss and muss with low-level config file tweaking and manually installing stuff.  *That* would be a total killer combo for D.


T

-- 
People walk. Computers run.
June 26, 2020
On Friday, 26 June 2020 at 17:54:08 UTC, H. S. Teoh wrote:
>> On 2020-06-26 18:12, Paolo Invernizzi wrote:
> [...]
>> > ... and if someone has a "big zip" (tm) with everything included and in the right position .. for a macOS host ... wow ...
> [...]
>
> Y'know what would be a total killer combo?  An all-in-one LDC package that contains everything you need to cross compile from any platform to any other platform. Including full linkers and/or system libraries necessary to generate fully-runnable executables (this point is important, because e.g. I can't cross-compile from Linux to MacOS without separately installing a MacOS dev environment, because LDC doesn't come with a linker for that, unlike LDC-windows).

The linker would be the simple part; LLD isn't ready for macOS yet though, most likely because Apple prefers a totally closed ecosystem with everything under their control. But it's being worked on.
Redistributing their libraries is probably much harder, I doubt they'll allow that, just like Microsoft doesn't allow that. The MinGW-based libs shipped with DMD and LDC, to provide the out-of-the-box experience for Windows targets, have been *a lot* of work from Rainer's and my side (we're talking unpaid man-weeks).

Some years ago, I've posted an unfinished Dockerfile going into this direction, merging the available prebuilt LDC packages to a fat Docker image. No feedback at all IIRC.

Wrt. automating the last mile (actually, the last few inches), setting up ldc2.conf, I've repeatedly stated that generalizing Adam's little Android tool would clearly be my choice. Sebastian Koppe promised to do that, but he's probably quite busy at the moment.

Anyone can do that though, it's absolutely no rocket science, and if help is needed, don't hesitate to ask us LDC people.

But as long as people prefer to hang out in the forum instead of getting actual stuff done in form of contributing code, nothing will improve.