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

make-derivation: Don't add host-suffix to fixed-output derivations names #33589

Merged
merged 1 commit into from Jul 9, 2018

Conversation

dtzWill
Copy link
Member

@dtzWill dtzWill commented Jan 8, 2018

Not only does the suffix unnecessarily reduce sharing, but it also breaks
unpacker setup hooks (e.g. that of unzip) which identify interesting tarballs
using the file extension.

Motivation for this change

Fixes #32986.

(another from #30882!)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

# host suffix. See #32986.
isHostSensitive =
stdenv.hostPlatform != stdenv.buildPlatform &&
(builtins.length buildInputs != 0 ||
Copy link
Member

Choose a reason for hiding this comment

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

Ah so this part isn't actually true. Say we are building compiler-rt; it run-time depends on nothing, but cares about the host platform as much as any other platform.

In that thread, I instead meant that separately we should do a check like:

let
  fixedOutputDrv = args ? outputHash;
  noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated
                                  ++ depsHostHost ++ depsHostHostPropagated
                                  ++ buildInputs ++ propagatedBuildInputs
                                  ++ depsTargetTarget ++ depsTargetTargetPropagated) == 0;
in
assert fixedOutputDrv -> noNonNativeDeps;

Copy link
Member

Choose a reason for hiding this comment

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

Technically, even that isn't always necessarily true. Yes, any of those deps mean we now need host- or target-platform-specific hashes, but for pre-built stuff (bootstrapping, proprietary, etc) we do just that. So I suppose pre-built stuff could have such deps. But unless all transitive deps were also fixed-output, it would be a total pain to keep the hash correct.

In practice, for the platform-specific deps we do use, run-time deps are hooked up in a downstream deriving, e.g. with substituteAll or makeWrapper, so I don't there's a practical reason not to have that assertion. But it would be fine to leave it for a separate PR if you like, as it might require fixing miscategorized deps / is a separate issue from this one.

@Ericson2314
Copy link
Member

Oh also with this change, we can remove hacks in https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/splice.nix#L34-L40 and knock off that todo.

Sorry the conversation wasn't the clearest thing to follow, but thanks for tackling this!

@Ericson2314
Copy link
Member

Ericson2314 commented Jan 8, 2018

Lastly, not sure weather its worth it until we go back to staging mass rebuilds, but I've been trying to linearizing the history of my PRs under https://github.com/obsidiansystems/nixpkgs/tree/ericson2314-cross-master, for easy diffing and bisecting if anything goes wrong. I just rebased this on top of that.

@Ericson2314 Ericson2314 force-pushed the fix/fixed-output-cross-name branch 8 times, most recently from 0072eb5 to 6fd63d0 Compare January 9, 2018 23:22
@Ericson2314 Ericson2314 added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Jan 9, 2018
@Ericson2314 Ericson2314 dismissed their stale review January 9, 2018 23:24

I fixed my own issues

@Ericson2314
Copy link
Member

phobosUnittests is a very odd thing I'm not sure what to do about.

@dtzWill
Copy link
Member Author

dtzWill commented Jan 10, 2018

@Ericson2314 sounds like a test that should be disabled on cross! Right?

@Ericson2314
Copy link
Member

Ericson2314 commented Jan 10, 2018

@dtzWill well I disabled fixed output derivations with run-time dependencies across the board. But those test drvs' deps shouldn't be nativeBuildInputs because they're run-time dependencies....of the thing which isn't actually being built because we just run the tests and through everything away.
They're fixed output derivations which are more or less just being used for their side affects.

@Ericson2314
Copy link
Member

I suppose while we decide whether or not to reflex the restriction, we can still clean up the deps that unequivocally need it #33681 .

@vcunat
Copy link
Member

vcunat commented Jan 10, 2018

I disabled fixed output derivations with run-time dependencies across the board.

This confuses me. I don't think nix allows fixed-output derivations to retain any rutime references. EDIT: ah, eval-time check for buildInputs, right...

@Ericson2314 Ericson2314 force-pushed the fix/fixed-output-cross-name branch 2 times, most recently from f28f4e0 to 53a4027 Compare January 11, 2018 16:42
@Ericson2314 Ericson2314 added this to After big PR in Cross compilation Jan 11, 2018
@Ericson2314
Copy link
Member

@vcunat what do you think now? Switched back to keeping hash with run-time deps, and just making a warning.

@vcunat
Copy link
Member

vcunat commented Jan 14, 2018

Changes in laziness of derivation attributes #33057 conflicted this, and it makes me wonder why you chose to do this warning so strictly. I think it's just another way of broken-ness and would better be evaluated in the same "cases" (i.e. with the same "laziness"). Maybe it would even be worth to move it to ./check-meta.nix, even though it's not about meta – but we haven't checked anything else so far, so perhaps just the name doesn't fit.

@dtzWill
Copy link
Member Author

dtzWill commented Jan 18, 2018

(I'm more or less disowning this PR, looks like @Ericson2314 is leading the way, thank you! 👍)

Not only does the suffix unnecessarily reduce sharing, but it also breaks
unpacker setup hooks (e.g. that of `unzip`) which identify interesting tarballs
using the file extension.

This also means we can get rid of the splicing hacks for fetchers.
@@ -77,8 +77,13 @@ rec {

, ... } @ attrs:

# TODO(@Ericson2314): Make this more modular, and not O(n^2).
Copy link
Member

Choose a reason for hiding this comment

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

I believe this about the hardening flags, but it's quite unclear so I just removed it.

@Ericson2314 Ericson2314 merged commit cf72af3 into NixOS:master Jul 9, 2018
@Ericson2314
Copy link
Member

I just skipped the warning for now, avoiding what @vcunat was concerned about entirely.

@edolstra
Copy link
Member

edolstra commented Jul 9, 2018

What is the impact of this change on evaluation performance?

(Asking because there has been a pretty awful slowdown in Nixpkgs evaluation speed in the last year, and I suspect it's due to all the stdenv changes.)

@Ericson2314
Copy link
Member

Ericson2314 commented Jul 9, 2018

@edolstra I did think about that here. There should be no effect on native, since the && will short circuit. [On cross it's unclear, with the length check per derivation, but the splicing nasty fetcher filtering removed.]

# suffix. But we have some weird ones with run-time deps that are
# just used for their side-affects. Those might as well since the
# hash can't be the same. See #32986.
(stdenv.hostPlatform != stdenv.buildPlatform && runtimeSensativeIfFixedOutput)
Copy link
Member

Choose a reason for hiding this comment

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

@edolstra this is the && I'm referring to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different sort platform than than they will be run on 6.topic: stdenv Standard environment 10.rebuild-darwin: 0 10.rebuild-linux: 0
Projects
No open projects
Cross compilation
After big PR
Development

Successfully merging this pull request may close these issues.

Target suffix added to source file names when cross-compiling breaks unzip setupHook
5 participants