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

Disallow references to nativeBuildInputs #49417

Merged
merged 18 commits into from Nov 3, 2018

Conversation

matthewbauer
Copy link
Member

Motivation for this change

Someone at NixCon asked why we don't disallow references to GCC by default. I thought that was a good idea but realized it could be generalized to disallowing any native build input from appearing in the outputs. With strictDeps separation of native & non-native inputs, this is pretty straightforward and pretty generalizable.

If your package does need for instance "gcc" in the output (for instance a wrapper around gcc), you just need to also list it in buildInputs & it will no longer be in disallowed references.

@matthewbauer matthewbauer changed the base branch from master to staging October 29, 2018 18:52
@matthewbauer matthewbauer changed the title disallowReferences to native build inputs Disallow references to nativeBuildInputs Oct 29, 2018
@Ericson2314
Copy link
Member

Wooo! Long wanted to do this; it's a huge benefit to native users on this. The one thing is actually I think we need to do allowedReferences on the other deps, rather than disallowedReferences on those deps, because of the case where something is a both a build-time and run-time dep in the native build.

The other issue was that dev inputs sometimes do depend on build time, as @vcunat and @dezgeg. But I'd love to see how bad the damage is empirically, first. For example if fix patchShebangs (again!) first so bash shebanges would say unpatched (or use /usr/bin/env) rather than be the stdenv.shell defaultNativeBuildInput, we'd avoid that problem.

@matthewbauer
Copy link
Member Author

The one thing is actually I think we need to do allowedReferences on the other deps, rather than disallowedReferences on those deps, because of the case where something is a both a build-time and run-time dep in the native build.

I think this addresses that. We do "build time deps" - "runtime deps" with lib.subtractLists. The dev output thing could be an issue still.

@Ericson2314
Copy link
Member

Ericson2314 commented Oct 29, 2018

Oh haha. I completely missed the lib.subtractLists call. Oops!

Then the question is whether this is blacklist approach better than the whitelist approach. My guess is what we really want is nix-level propagation logic and a whitelist based on that. (Note that bootstrap-tools would never be run-time dependency through propagatation.) In the meantime, the blacklist approach is more permissive in not disallowing things that should be propagated, so 👍 from me.

I really need to a get a hydra job up where I a) do strictDeps everywhere b) ensure all stdenv deps can be cross compiled too :). Time to write the RFC!

@symphorien
Copy link
Member

I support this idea, but it seems nix has problems with disallowed references and multiple outputs derivations: NixOS/nix#2310

@matthewbauer
Copy link
Member Author

I support this idea, but it seems nix has problems with disallowed references and multiple outputs derivations: NixOS/nix#2310

That only appears to happen with disallowedRequisites.

@jtojnar jtojnar mentioned this pull request Oct 30, 2018
9 tasks
@symphorien
Copy link
Member

Ah sorry. So hopefully it can work :)

@matthewbauer
Copy link
Member Author

But I should probably remove the reference to disallowRequisites though just to be safe 😄

worldofpeace and others added 7 commits October 31, 2018 18:49
* uses meson now
* crashes on start complaining schema not installed,
  so I added a postInstall that compiles the schema?
  Fixes the problem but I'm not particularly familiar
  with these bits so review appreciated.
It will only build on avr architectures.
Vanilla newlib doesn’t install nano.
Some of these paths are not in gcc-arm-embedded (instead binutils-arm-embedded).
not in newlib
@matthewbauer matthewbauer changed the base branch from staging to master November 2, 2018 23:27
@matthewbauer matthewbauer force-pushed the disallow-native-build-inputs branch 3 times, most recently from adf52e4 to f4077af Compare November 3, 2018 00:15
When strictDeps = true, we don’t want native build inputs to end up in
the output. For instance gcc is a builtin native build input and
should only show up in an output if it is also listed in buildInputs.

/cc @Ericson2314
@matthewbauer
Copy link
Member Author

@GrahamcOfBorg eval

@Ericson2314
Copy link
Member

Woo!!!

@FRidh
Copy link
Member

FRidh commented Nov 18, 2018

If a derivation sets disallowedReferences, then it is clear what is not allowed. If mkDerivation sets it, then it can be quite surprising to get the message: output ... is not allowed to refer to the following paths:. What can we do to improve this?

@lopsided98
Copy link
Contributor

This appears to be breaking kernel cross compilation (see #50915 (comment)), because the dev output refers to build perl, gcc and openssl. We could try to substitute these with host deps, but that really doesn't make sense.

If something depends on the cross compiled kernel's dev output, it is going to be cross compiled as well, and it is likely going to run the scripts in the dev output at build time. Therefore these scripts need to refer to build packages or they will probably fail.

This is not just true for the kernel; any cross compiled dev output is probably only going to be used on the build system, and therefore it doesn't make sense to disallow build references. Normally, this isn't a problem because the dev output is just headers that don't refer to anything. When there are scripts or makefiles that refer to other dependencies, this PR incorrectly breaks the build or we have to use hacks like putting /usr/bin/env in shebangs, like @Ericson2314 mentioned.

It seems to me that disallowing native build inputs in dev outputs is conceptually incorrect.

@matthewbauer
Copy link
Member Author

Agreed. Dev outputs are usually juts headers but there are enough corner cases to cause issues. I think the information from this is extremely valuable still - we just need to find a way to avoid the breakages. Anyway the cross-patch-shebangs branch has been reverted again! So we need to get that straightened out before we can do something like this either way. We will probably need to wait until something like NixOS/nix@3cd15c5 is widely available.

Sorry for any inconveniences! Reverted in 7eeb02d.

@matthewbauer matthewbauer deleted the disallow-native-build-inputs branch February 22, 2019 04:23
@FRidh FRidh mentioned this pull request Jan 16, 2020
10 tasks
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.

None yet