xcode/sdk-pkgs.nix: set -platform_version in addition to -miphoneos-version-min

The App Store looks at LC_VERSION_MIN_IPHONEOS to verify you have a
new enough SDK version. This is not just the minimum version, but also
the sdk version used. When the linker can’t figure it out, it tries to
infer it from the sdk path[1]. When no sdk version is found, it
defaults to just using the -miphoneos-version-min value[2]. So, to make
sure we don’t rely on inference (which doesn’t work in the current
directory structure), we have to specify -platform_version.

[1]:
43f32a4c61/cctools/ld64/src/ld/Options.cpp (L5355-L5376)
[2]: 43f32a4c61/cctools/ld64/src/ld/ld.hpp (L58)
This commit is contained in:
Matthew Bauer 2020-07-22 10:54:11 -05:00
parent 753e80125f
commit 95eabdfd5f

View File

@ -12,7 +12,7 @@
let
minSdkVersion = "9.0";
minSdkVersion = targetPlatform.minSdkVersion or "9.0";
iosPlatformArch = { parsed, ... }: {
armv7a = "armv7";
@ -37,6 +37,10 @@ rec {
bintools = binutils-unwrapped;
extraBuildCommands = ''
echo "-arch ${iosPlatformArch targetPlatform}" >> $out/nix-support/libc-ldflags
'' + stdenv.lib.optionalString (sdk.platform == "iPhoneSimulator") ''
echo "-platform_version ios-sim ${minSdkVersion} ${sdk.version}" >> $out/nix-support/libc-ldflags
'' + stdenv.lib.optionalString (sdk.platform == "iPhoneOS") ''
echo "-platform_version ios ${minSdkVersion} ${sdk.version}" >> $out/nix-support/libc-ldflags
'';
};