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

linux-headers: Improve derivation, removing cross arg #28519

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Aug 23, 2017

Motivation for this change
  • Perl is used at build time, so must be in nativeBuildInputs. It's not used at run time so it should not be in buildInputs, too.

  • Don't treat headers like a compiler---use the build and host platforms not host and target. Perhaps that would make sense if every library's headers could be a separate derivation, but since that is not feasible, best to keep the implementation and interface in the same stage.

    To do this, we used stdenvNoCC to get rid of the normal toolchain, and added a dependency for the toolchain targeting the build platform --- buildPackages.stdenv.cc --- thus everything is effectively slid a stage black.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built stdenv on platform(s)
    • NixOS
    • macOS (unaffected)
    • Linux
  • 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.

@Ericson2314 Ericson2314 added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Aug 23, 2017
@Ericson2314 Ericson2314 added this to the 17.09 milestone Aug 23, 2017
@Ericson2314 Ericson2314 added this to Needed by the big PR---nice to move pick off pieces of it and move here, rebasing the big PR on top in Cross compilation Aug 23, 2017
@@ -12666,7 +12664,6 @@ with pkgs;
uclibc = callPackage ../os-specific/linux/uclibc { };

uclibcCross = lowPrio (callPackage ../os-specific/linux/uclibc {
inherit (buildPackages) linuxHeaders;
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that its built in the same stage.

Copy link
Contributor

@bjornfor bjornfor left a comment

Choose a reason for hiding this comment

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

Looks good, I didn't test it.

in

stdenv.mkDerivation {
stdenvNoCC.mkDerivation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Um, why would this use stdenvNoCC given that the build needs to compile some stuff?

Copy link
Member Author

Choose a reason for hiding this comment

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

Stdenv.cc is a build->host cc, but I need a build->build cc

Copy link
Contributor

Choose a reason for hiding this comment

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

Such thing also belongs to the standard build environment even when cross compiling (e.g Buildroot and Yocto do). If nixpkgs doesn't anymore then that needs fixing instead.

if stdenv.isArm then "arm" else
if stdenv.platform ? kernelArch then stdenv.platform.kernelArch else
abort "don't know what the kernel include directory is called for this platform";
platform = hostPlatform.platform.kernelArch or (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this fallback code (when kernelArch is not defined) should really go away.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried not to change any interfaces. Mind doing this in a follow up commit?

Note that for native kernelArch isn't currently defined by default. There is hostPlatform.parsed.cpu.name however.

Copy link
Contributor

Choose a reason for hiding this comment

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

kernelArch is always defined because the kernel derivation uses it unconditionally. And it must not be something else than kernelArch because the name we need to pass here is not something standard but an implementation detail of the Linux kernel.

 - Perl is used at build time, so must be in `nativeBuildInputs`. It's
   not used at run time so it should not be in `buildInputs`, too.

 - Don't treat headers like a compiler---use the build and host
   platforms not host and target. Perhaps that would make sense if every
   library's headers could be a separate derivation, but since that is
   not feasible, best to keep the implementation and interface in the
   same stage.

   To do this, we used `stdenvNoCC` to get rid of the normal toolchain,
   and added a dependency for the toolchain targeting the build platform
   --- `buildPackages.stdenv.cc` --- thus everything is effectively slid
   a stage black.
Copy link
Member Author

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

With that note, I think I'll merge for the same reasons of unblocking everything else I want to do for 17.09.

@dezgeg We can move the kernelArch fallback code to https://github.com/NixOS/nixpkgs/blob/master/lib/systems/default.nix#L17 if you like.


buildInputs = [perl];
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
Copy link
Member Author

Choose a reason for hiding this comment

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

@dezgeg Added this explanatory comment, as it does indeed look weird at first glance.

@Ericson2314 Ericson2314 merged commit 3964990 into NixOS:staging Aug 24, 2017
@Ericson2314 Ericson2314 deleted the linux-headers-improve branch August 24, 2017 15:35
Ericson2314 added a commit to obsidiansystems/nixpkgs that referenced this pull request Sep 21, 2017
In NixOS#28519 / 791ce59 I made linux
headers be intended to be used from the stage stage, as it would be if
it were a library containing headers and code. I forgot to update glibc,
however, so it was incorrectly using headers for the build platform, not
host platform.

This fixes that, basically reverting a small portion of changes I made a
few months ago in 25edc47 and its
parent.

No native hashes are changed.
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
Projects
No open projects
Cross compilation
Needed by the big PR---nice to move p...
Development

Successfully merging this pull request may close these issues.

None yet

3 participants