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

Build failure: linux (powerpc) #224694

Closed
alyssais opened this issue Apr 4, 2023 · 8 comments · Fixed by #245449
Closed

Build failure: linux (powerpc) #224694

alyssais opened this issue Apr 4, 2023 · 8 comments · Fixed by #245449
Labels
0.kind: build failure A package fails to build 6.topic: exotic Exotic hardware or software platform

Comments

@alyssais
Copy link
Member

alyssais commented Apr 4, 2023

Building powerpc kernels (I only tested pkgsCross.powernv, but examination of the kernel source code suggests to me that 32-bit powerpc, and well as big-endian 64-bit will be the same) is broken since #221707. This happens because on powerpc, the kernel target we install is vmlinux, rather than any derivative of it like zImage. The kernel build system will strip when creating such a derivative image, but because we install vmlinux directly, we get an unstripped image. This means the kernel contains references to its build directory, which since that PR will be the $dev output.

AIUI, 64-bit POWER boots via kexec, and a zImage is a self-extracting kernel ELF image, so hopefully the fix would just be to switch the kernel target for powerpc to zImage, and things will work again, and POWER users will get smaller kernel images as a bonus.

I'm not sure about 32-bit PowerPC, but this kernel documentation might be helpful.

If we can't use an *Image target for any powerpc targets, there is also a target called vmlinux.strip that we could fall back to, but let's take the opportunity to evaluate whether anything else is more suitable first, when we're changing this stuff anyway.

Apart from powerpc, the only target we have that uses vmlinux as its kernel target is a MIPS machine called the Fuloong 2.0. I don't know how it boots.

@alyssais alyssais added the 0.kind: build failure A package fails to build label Apr 4, 2023
@ghost ghost self-assigned this Apr 4, 2023
@ghost
Copy link

ghost commented Apr 4, 2023

I'll handle this.

I don't have big-endian POWER hardware, but @alyssais pointed out that qemu can probably boot a BE kernel under emulation at full hardware speeds. So if that works I can take care of the 32-bit POWER (which is mostly BE) too.

@alyssais alyssais added the 6.topic: exotic Exotic hardware or software platform label Apr 4, 2023
@vkleen
Copy link
Contributor

vkleen commented Apr 4, 2023

For reference, I managed to get a working kernel derivation for Power9 with

kernelPackages = pkgs.linuxKernel.packageAliases.linux_latest.extend
    (final: prev: lib.optionalAttrs pkgs.stdenv.hostPlatform.isPower64 {
      kernel = lib.makeOverridable
        (args:
          let
            kernel = prev.kernel.override args;
          in
          kernel.overrideAttrs (o: {
            buildFlags = o.buildFlags ++ [ "modules" "zImage" ];
            installFlags = o.installFlags ++ [ "KBUILD_IMAGE=$(boot)/zImage" ];
            installTargets = [ "install" ];
            postFixup = (o.postFixup or "") + ''
              strip -s $out/zImage
            '';
            inherit (kernel) passthru;
          }))
        { };
    });

Just setting building a zImage without fully stripping it afterwards wasn't enough. There still was a reference to $dev in the debug info somewhere.

@alyssais
Copy link
Member Author

alyssais commented Apr 4, 2023

Yep, very plausible that there are other references as well. We had some of those for x86 and RISC-V, although that specific issue didn't apply to other architectures.

@ghost
Copy link

ghost commented Apr 4, 2023

I'll dig into this this evening. @vkleen thank you for the tip!

Also putting this link here so I don't lose it: https://lore.kernel.org/linux-kbuild/[email protected]/

@ghost
Copy link

ghost commented Apr 24, 2023

Verified (after fixing a bunch of other things) that mips64el is affected too. Thanks again for the heads up @alyssais. Working on a fix.

@ghost
Copy link

ghost commented Apr 24, 2023

#228018

@alyssais
Copy link
Member Author

alyssais commented May 23, 2023

Edit: I meant to post this here.

@ghost ghost closed this as completed in 2458c94 Jul 20, 2023
@ghost ghost mentioned this issue Jul 20, 2023
12 tasks
@ghost ghost reopened this Jul 20, 2023
@ghost ghost mentioned this issue Jul 25, 2023
2 tasks
@ghost
Copy link

ghost commented Nov 4, 2023

@ghost ghost closed this as completed Nov 4, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build 6.topic: exotic Exotic hardware or software platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants