-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Darwin platform versions #111988
Darwin platform versions #111988
Conversation
FYI, I was working on #111658 which could support multiple versions of sdk (by generating several info lists). I'm not sure if you need it, but I will pause here. |
04f73ec
to
45862be
Compare
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.hostPlatform.darwinMinVersion}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' | |
substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.hostPlatform.darwinMinVersion}' | |
postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' | |
substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' |
because we should do this for other -> darwin cross too, I believe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if nixpkgs has has working cross compilation for lua packages, but assuming it does, targetPackages
seems correct here 👍.
45862be
to
ba31b0f
Compare
With the debugging commit the evaluation error is visible:
Is there an idiom for platform configuration that doesn't apply to all platforms? |
This ensures |
ff8e80e
to
dcfd17a
Compare
This is ready for review. Still outstanding: how to represent the absence of value for |
dcfd17a
to
da49f21
Compare
@thefloweringash This does not evaluate btw. |
da49f21
to
b3b3905
Compare
I didn't know a nice way to have the |
|
@thefloweringash Are you going to change https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/xcode/sdk-pkgs.nix later then? Also, was the |
914dcdc
to
672eb33
Compare
Instead of always supplying flags, apply the flags as defaults. Use clang's native flags instead of lifting the linker flags from binutils with `-Wl,`. If a project is using clang to drive linking, make clang do the right thing with MACOSX_DEPLOYMENT_TARGET. This can be overridden by command line arguments. This will cause modern clang to pass `-platform_version 10.12 0.0.0`, since it doesn't know about the SDK settings. Older versions of clang will pass down `-macos_version_min` flags with no sdk version. At the linker layer, apply a default value for anything left ambiguous. If nothing is specified, pass a full `-platform_version`. If only `-macos_version_min` is specified, then lock down the sdk_version explicitly with `-sdk_version`. If a min version and sdk version is passed, do nothing.
This avoids contamination via MACSOX_DEPLOYMENT_TARGET when cross compiling.
…oles In a typical build environment the toolchain will use the value of the MACOSX_DEPLOYMENT_TARGET environment variable to determine the version of macOS to support. When cross compiling there are two distinct toolchains, but they will look at this single environment variable. To avoid contamination, we always set the equivalent command line flag which effectively disables the toolchain's internal handling. Prior to this change, the MACOSX_DEPLOYMENT_TARGET variable was ignored, and the toolchains always used the Nix platform definition (`darwinMinVersion`) unless overridden with command line arguments. This change restores support for MACOSX_DEPLOYMENT_TARGET, and adds nix-specific MACOSX_DEPLOYMENT_TARGET_FOR_BUILD and MACOSX_DEPLOYMENT_TARGET_FOR_TARGET for cross compilation.
These variables are the ones that the standard toolchain uses, so we should use those and not always use MACOSX_DEPLOYMENT_TARGET. See https://github.com/tpoechtrager/cctools-port/blob/236a426c1205a3bfcf0dbb2e2faf2296f0a100e5/cctools/ld64/src/ld/PlatformSupport.cpp#L54-L55
These are now provided by the standard bintools and cc wrappers.
672eb33
to
33265e0
Compare
Is this ready now? |
Updated to include this. I don't know of any example that uses it in the nixpkgs tree so I haven't tested it. If anyone that relies on cross compiling to iPhone has a chance to test it, it would be appreciated.
I've now added support for the
I believe so. |
@Ericson2314 feel free to merge if this looks good to you. |
Took me a second to figure out what |
(As to iOS cross, I will someday need to bump our stuff to use this version of Nixpkgs, but i don't have the phones to test with me. I like this design better so if there are regressions they should be plenty easy to fix and totally worth it :).) |
I am taking the non-invasive parts of NixOS#110914 to hopefully help out with NixOS#111988. In particular: - Use `lib.makeScopeWithSplicing` to make the `darwin` package set have a proper `callPackage`. - Adjust Darwin `stdenv`'s overlays keeping things from the previous stage to not stick around too much. - Expose `binutilsNoLibc` / `darwin.binutilsNoLibc` to hopefully get us closer to a unified LLVM and GCC bootstrap.
Motivation for this change
Implement the reproducibility of #77632, without the warnings that were introduced by cctools (#93596 (comment)), with support for cross compilation by moving sdk versions and deployment targets out of the darwin stdenv and onto
targetPlatform
.Effectively reverts: #110140 by @holymonson. When working on
aarch64-darwin
the SDK version provided (and embedded inLC_BUILD_VERSION
) controls some kind of compatibility layer, see gist, so I think we need to support an idea of "SDK version" even though nixpkgs generally treats darwin as a set of independent and overridable packages.Also tries to define a platform definition structure for all darwin targets including ios. Currently these have platforms have equivalent attributes which I would like to unify with the rest of darwin. The extra configuration here pkgs/os-specific/darwin/xcode/sdk-pkgs.nix should be able to entirely removed, and instead be provided by the standard darwin stdenv and binutils.
Original PR: #77632
Related: #103053, #83180
Motivation: #105026 (comment)
Tested:
Untested:
Motivating test case
The following set of test cases should include no information from the building host and produce no linker warnings.
See results in
$(nix-build version-test-case.nix)/summary
.version-test-case.nix
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)