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

kernel: fix cross compilation after switch to gcc 7 #35091

Merged
merged 1 commit into from Feb 18, 2018

Conversation

lopsided98
Copy link
Contributor

@lopsided98 lopsided98 commented Feb 18, 2018

Motivation for this change

Kernel cross compilation no longer works after switching to gcc 7, because it uses the host's gcc7 package. This causes the derivation to attempt to cross-compile gcc, rather than building a cross compiler.

Things done

Switching to buildPackages.gcc7 causes the build to use a compiler with the correct combination of platforms.

  • 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.

@shlevy
Copy link
Member

shlevy commented Feb 18, 2018

@Ericson2314 @bgamari Is this the right thing to do here? I'm not quite sure with respect to cross-compilers what set they should be coming from.

@vcunat
Copy link
Member

vcunat commented Feb 18, 2018

Oh, right, I think, though I'm not very certain either. Plain gcc7 would be compiler runnable on the host.

@vcunat
Copy link
Member

vcunat commented Feb 18, 2018

BTW, the lines you're fixing are reverted on the gcc-7 branch, and I expect it will be soon merged to master.

@dtzWill
Copy link
Member

dtzWill commented Feb 18, 2018

Perhaps "overrideCC" (or a new variant) should check the platform of the compiler?

As-is I think more or less all of its usage will result in this sort of breakage, and generally not be very clear why :).

If nothing else, I think it'd make sense to replace all uses of "overrideCC X Y" with "overrideCC X buildPackages.Y"; although perhaps there are a few exceptions. Does that sound good? I can put together a PR doing so if that'd be useful.

EDIT: I had overrideCC argument order wrong :)

@bgamari
Copy link
Contributor

bgamari commented Feb 19, 2018

Hmm, I'll admit I'm not certain; it looks plausible but I think @Ericson2314 is probably best equipped to answer this.

@dtzWill
Copy link
Member

dtzWill commented Feb 19, 2018

Oh, wait buildPackages is wrong in most circumstances anyway, nevermind. Want nativeBuildInputs but no package set for that :(.

@Ericson2314
Copy link
Member

Hi I'm back. Uh oh, I think I need to write more docs if nobody knows the answer :D. This is exactly correct, buildPackages does correspond to nativeBuildInputs, everything is good.

Only issue is buildPackages.stdenv.cc might also be in use, but whatever. We don't care if temporary tools are made with that.

@bgamari
Copy link
Contributor

bgamari commented Feb 20, 2018

Also, I should mention that I have noticed that the gcc7 build segmentation faults when cross-compiled for ARMv7.

@lopsided98 lopsided98 deleted the kernel-gcc7-cross branch February 21, 2018 00:01
@vcunat
Copy link
Member

vcunat commented Feb 21, 2018

That's sad, as gcc7 is now the default on master.

@dtzWill
Copy link
Member

dtzWill commented Feb 22, 2018

Time to fix things, then! 😁

@lopsided98
Copy link
Contributor Author

@bgamari How do you reproduce this? Building a cross compiler or cross compiling GCC?

I've successfully cross compiled a kernel for armv7l after the GCC 7 merge earlier today.

@vcunat
Copy link
Member

vcunat commented Feb 22, 2018

Cross-compiling gcc, i.e. compiler runnable on armv7, if I understand him correctly.

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

7 participants