Skip to content
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

apple_sdk_11_0.stdenv: replace extraBuildInputs with CF from 11.0 SDK #234863

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

reckenrode
Copy link
Contributor

Description of changes

This can result in swift-corefoundation being included even when a derivation uses apple_sdk_11_0.stdenv directly, which may result in hard to debug compiler errors (unless you just happen to know cryptic compiler errors means the 10.12 and 11.0 SDKs have been mixed).

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@toonn toonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a convenient test case where I can observe the wrong CF ending up in a build?

@@ -61,7 +61,9 @@ let
mkStdenv = stdenv:
if stdenv.isAarch64 then stdenv
else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an updated commit without the newline. I’m not sure how it ended up there, but it’s gone.

@reckenrode
Copy link
Contributor Author

This test case demonstrates the issue. It’s mostly theoretical, but the idea is to avoid mixing SDKs at all to save having to troubleshoot cryptic build failures in the future.

Given test.nix

{ flake ? "github:NixOS/nixpkgs/nixos-23.05", pkgs ? (builtins.getFlake flake).legacyPackages.x86_64-darwin, ... }:

pkgs.darwin.apple_sdk_11_0.stdenv.mkDerivation {
  pname = "test";
  version = "test";
  buildInputs = [ pkgs.darwin.apple_sdk_11_0.frameworks.IOKit ];
  dontUnpack = true;
  dontBuild = true;
  installPhase = ''
    mkdir -p $out/bin
    cat <<-PROGN > $out/bin/vars
    #!/bin/bash
    echo NIX_CFLAGS_COMPILE: $NIX_CFLAGS_COMPILE
    PROGN
    chmod a+x $out/bin/vars
  '';
}
$ nix build --impure --expr 'import ./test.nix { }' && ./result/bin/vars | grep "swift-corefoundation-unstable-2018-09-14"
# Should yield something like:
NIX_CFLAGS_COMPILE: -F/nix/store/9dw29sl9gsl8090cf6qkmhj2pprl3z5z-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -frandom-seed=8jlsd4n2sw -isystem /nix/store/skgy80h81jcd1cq53zpy5b8fcx8mlfxd-libcxx-11.1.0-dev/include -isystem /nix/store/m8q0nis3rksxgdz0887ih8vyfsa0n1y5-libcxxabi-11.1.0-dev/include -isystem /nix/store/ar6k6z685qzcvw4kxf6zyv7alx468paj-compiler-rt-libc-11.1.0-dev/include -iframework /nix/store/24szwa3c5sxbvxd999xg7b53cnn37zm0-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/9dw29sl9gsl8090cf6qkmhj2pprl3z5z-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/8vsm3nrvvwm65gkvhv14wccfqhy1q7aj-libobjc-11.0.0/include -iframework /nix/store/1ds96f193bdf7f3kz295rwf66q90vi71-swift-corefoundation-unstable-2018-09-14/Library/Frameworks -isystem /nix/store/skgy80h81jcd1cq53zpy5b8fcx8mlfxd-libcxx-11.1.0-dev/include -isystem /nix/store/m8q0nis3rksxgdz0887ih8vyfsa0n1y5-libcxxabi-11.1.0-dev/include -isystem /nix/store/ar6k6z685qzcvw4kxf6zyv7alx468paj-compiler-rt-libc-11.1.0-dev/include -iframework /nix/store/24szwa3c5sxbvxd999xg7b53cnn37zm0-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/9dw29sl9gsl8090cf6qkmhj2pprl3z5z-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/8vsm3nrvvwm65gkvhv14wccfqhy1q7aj-libobjc-11.0.0/include -iframework /nix/store/1ds96f193bdf7f3kz295rwf66q90vi71-swift-corefoundation-unstable-2018-09-14/Library/Frameworks
$ nix build --impure --expr 'import ./test.nix { flake = "github:NixOS/nixpkgs/pull/234863/head"; }' && ./result/bin/vars | grep "swift-corefoundation-unstable-2018-09-14"
# Should return nothing

This can result in swift-corefoundation being included even when a
derivation uses `apple_sdk_11_0.stdenv` directly, which may result in
hard to debug compiler errors (unless you just happen to know cryptic
compiler errors means the 10.12 and 11.0 SDKs have been mixed).
Copy link
Contributor

@toonn toonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@toonn toonn merged commit e23fe5c into NixOS:staging Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants