www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Possible to cross-compile from Linux to OSX?

reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
So far, cross-compiling from Linux to Windows has been awesome, thanks
to LDC2's awesome cross-compiling capabilities. All I needed to do was
to download the Windows ldc2 release, edit ldc2.conf to point to it,
then compile with -mtriple=x86_64-windows-msvc, and it magically all
works.

However, I'm having a tougher time cross-compiling to OSX... downloaded
the ldc2 osx release, setup ldc2.conf, and compile with
-mtriple=x86_64-apple-darwin, but it appears to be trying to invoke my
local Linux linker, which chokes on the OSX object file format and dies
horribly. :-P  I'm guessing I need to somehow install an OSX toolchain
for this to work?


T

-- 
Computers shouldn't beep through the keyhole.
Feb 04 2020
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2020-02-04 20:30, H. S. Teoh wrote:
 So far, cross-compiling from Linux to Windows has been awesome, thanks
 to LDC2's awesome cross-compiling capabilities. All I needed to do was
 to download the Windows ldc2 release, edit ldc2.conf to point to it,
 then compile with -mtriple=x86_64-windows-msvc, and it magically all
 works.
 
 However, I'm having a tougher time cross-compiling to OSX... downloaded
 the ldc2 osx release, setup ldc2.conf, and compile with
 -mtriple=x86_64-apple-darwin, but it appears to be trying to invoke my
 local Linux linker, which chokes on the OSX object file format and dies
 horribly. :-P  I'm guessing I need to somehow install an OSX toolchain
 for this to work?
Here's a Dockerfile that can cross-compile to macOS [1]. You might want to update to a newer version of LDC. You can do that when building the Docker image using the `--build-arg` flag. Note, the SDK is pulled from someones Dropbox account (in the base image multiarch/crossbuild). [1] https://github.com/jacob-carlborg/docker-ldc-darwin/blob/master/Dockerfile -- /Jacob Carlborg
Feb 04 2020
prev sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Tuesday, 4 February 2020 at 19:30:13 UTC, H. S. Teoh wrote:
 So far, cross-compiling from Linux to Windows has been awesome, 
 thanks to LDC2's awesome cross-compiling capabilities. All I 
 needed to do was to download the Windows ldc2 release, edit 
 ldc2.conf to point to it, then compile with 
 -mtriple=x86_64-windows-msvc, and it magically all works.

 However, I'm having a tougher time cross-compiling to OSX... 
 downloaded the ldc2 osx release, setup ldc2.conf, and compile 
 with -mtriple=x86_64-apple-darwin, but it appears to be trying 
 to invoke my local Linux linker, which chokes on the OSX object 
 file format and dies horribly. :-P  I'm guessing I need to 
 somehow install an OSX toolchain for this to work?


 T
In case you have an open source project you also could have a look at Github Actions. It should allow you to compile your project for free to MacOS. Kind regards Andre
Feb 04 2020
parent Jacob Carlborg <doob me.com> writes:
On 2020-02-04 22:19, Andre Pany wrote:

 In case you have an open source project you also could have a look at 
 Github Actions. It should allow you to compile your project for free to 
 MacOS.
Yes. Assuming it's a public project it should definitely have a CI pipeline. Travis CI, Azure Pipelines and Circle CI also support macOS. Then of course, one should probably do some manual testing on the target platform as well. So I'm not so sure how much gain it is to cross-compile. I created the Docker images for work, were we had self hosted GitLab and were building using GitLab CI runners hosted on Linux machines. -- /Jacob Carlborg
Feb 05 2020