Thread overview
warning: overriding '-mmacosx-version-min=10.14' option
Jan 11, 2020
Jacob Carlborg
Jan 12, 2020
kinke
Jan 15, 2020
Jacob Carlborg
Jan 15, 2020
Jacob Carlborg
January 11, 2020
When compiling the runtime for iOS using `ldc-build-runtime` using the following command:

ldc-build-runtime \
--cFlags='-target arm64-apple-ios12.0;-isysroot $IOS_SDK_PATH' \
--linkerFlags='-target arm64-apple-ios12.0;-isysroot $IOS_SDK_PATH' \
--dFlags='-mtriple=arm64-apple-ios12.0;-w;-de;-dip1000' \
--ldc=~/ldc/build/bin/ldc2 \
--ldcSrcDir=~/ldc \
--ninja \
--testrunners

I get warnings like this:

clang: warning: overriding '-mmacosx-version-min=10.14' option with '--target=arm64-apple-ios12.0' [-Woverriding-t-option]

Looking at the `build.ninja` file that is generated there are 72 targets (or whatever they're called) that contains the following:

FLAGS = -DHAVE_UNISTD_H -isysroot $MAC_OSX_SDK_PATH -mmacosx-version-min=10.14   -target arm64-apple-ios12.0 -isysroot $IOS_SDK_PATH

(I've replaced the actual SDK paths with $MAC_OSX_SDK_PATH and $IOS_SDK_PATH to reduce the text).

-- 
/Jacob Carlborg
January 12, 2020
On Saturday, 11 January 2020 at 11:15:52 UTC, Jacob Carlborg wrote:
> I get warnings like this:
>
> clang: warning: overriding '-mmacosx-version-min=10.14' option with '--target=arm64-apple-ios12.0' [-Woverriding-t-option]
>
> Looking at the `build.ninja` file that is generated there are 72 targets (or whatever they're called) that contains the following:
>
> FLAGS = -DHAVE_UNISTD_H -isysroot $MAC_OSX_SDK_PATH -mmacosx-version-min=10.14   -target arm64-apple-ios12.0 -isysroot $IOS_SDK_PATH
>
> (I've replaced the actual SDK paths with $MAC_OSX_SDK_PATH and $IOS_SDK_PATH to reduce the text).

Without specifying a C cross-compiler directly, either via setting the CC env variable or by using a CMake toolchain file, CMake will probe and configure the compiler for the host.

There are probably guides for how to set up CMake cross-compilation from macOS to iOS. There might even be some builtin CMake support in the meantime: https://gitlab.kitware.com/cmake/cmake/issues/17870

> --cFlags='-target arm64-apple-ios12.0;-isysroot $IOS_SDK_PATH' \
> --linkerFlags='-target arm64-apple-ios12.0;-isysroot $IOS_SDK_PATH' \

The spaces here should be replaced by semicolons.
January 15, 2020
On 2020-01-12 13:02, kinke wrote:

> Without specifying a C cross-compiler directly, either via setting the CC env variable or by using a CMake toolchain file, CMake will probe and configure the compiler for the host.

Aha, I see. So I've been lucky so far that is has worked. Probably because the Posix layer on macOS and iOS is basically the same.

Originally I did what Xcode is doing. It invokes the same compiler regardless the target platform. I just specifies different target triples with the `-target` flag and different SDKs with the `-isysroot` flag. As far as I know there's never been a compiler that targets a specific platform by Apple. They have always used flags like above mentioned.

> There are probably guides for how to set up CMake cross-compilation from macOS to iOS. There might even be some builtin CMake support in the meantime: https://gitlab.kitware.com/cmake/cmake/issues/17870

Yeah, I found some documentation now [1], seems to be officially supported. Seems to work like this:

* CMAKE_SYSTEM_NAME - Specifies the target platform. Will detect the correct SDK. This adds the `-isysroot` flag.

* CMAKE_OSX_ARCHITECTURES - Specifies the target architecture. This will add the `-arch` flag.

* CMAKE_OSX_DEPLOYMENT_TARGET - Specifies the minimal deployment target. This will (for iOS) add the `-miphoneos-version-min` flag.

The flags `-arch arm64 -miphoneos-version-min=12.0` will give the same binary as `-target arm64-apple-ios12.0`.

Although, I still need to specify `--cFlags='-target;arm64-apple-ios12.0'` otherwise the assembly files (threadasm.S and eh_asm.S) are compiled for macOS x86-64 instead of iOS ARM64. Not sure if that's a bug in CMake or in the LDC configuration.

> The spaces here should be replaced by semicolons.

Ok, I see.

[1] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos

-- 
/Jacob Carlborg
January 15, 2020
On 2020-01-15 20:55, Jacob Carlborg wrote:

> * CMAKE_SYSTEM_NAME - Specifies the target platform. Will detect the correct SDK. This adds the `-isysroot` flag.
> 
> * CMAKE_OSX_ARCHITECTURES - Specifies the target architecture. This will add the `-arch` flag.
> 
> * CMAKE_OSX_DEPLOYMENT_TARGET - Specifies the minimal deployment target. This will (for iOS) add the `-miphoneos-version-min` flag.

To be clear, when specifying these CMake variables the warning disappears. Thanks.

-- 
/Jacob Carlborg