Commit 0f420e96 authored by Ben Siraphob's avatar Ben Siraphob
Browse files

gcc, libgcc: fix cross-compilation for SH4

- Pass --with-multilib-list=m4,m4-nofpu for SH4 so the kernel can use
  -m4-nofpu. Move libraries out of !m4/ multilib subdirectory in
  postInstall before moveToOutput.
- Generate sysroot-suffix.h for SH4 in the standalone libgcc builder.
- Add linux-kernel.target = "vmlinux" and installTarget for SH4.

All changes scoped to isSh4 to avoid rebuilds on other platforms.
parent 0fcb031c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -632,6 +632,15 @@ rec {
    else if platform.isPower64 then
      if platform.isLittleEndian then powernv else ppc64

    else if platform.isSh4 then
      {
        linux-kernel = {
          target = "vmlinux";
          # SH arch doesn't have a 'make install' target.
          installTarget = "vmlinux";
        };
      }

    else
      { };
}
+111 −100
Original line number Diff line number Diff line
@@ -278,7 +278,18 @@ originalAttrs:
          makeCompatibilitySymlink lib $targetConfig/lib64
        '';

    postInstall = ''
    postInstall =
      # SH installs libraries into a multilib subdirectory (e.g. lib/!m4/)
      # even with --disable-multilib; move them to the expected location.
      lib.optionalString stdenv.targetPlatform.isSh4 ''
        for _mdir in $out/''${targetConfig+$targetConfig/}lib/!*/; do
          if [ -d "$_mdir" ]; then
            mv "$_mdir"/* $out/''${targetConfig+$targetConfig/}lib/
            rmdir "$_mdir"
          fi
        done
      ''
      + ''
        # Clean up our compatibility symlinks (see above)
        for link in "''${compatibilitySymlinks[@]}"; do
          echo "Removing compatibility symlink: $link"
+3 −0
Original line number Diff line number Diff line
@@ -227,6 +227,9 @@ let
        ]
      else
        [ "--disable-multilib" ]
        # SH targets need m4 and m4-nofpu variants (the kernel uses -m4-nofpu).
        # An empty list disables -m4-nofpu entirely.
        ++ lib.optional targetPlatform.isSh4 "--with-multilib-list=m4,m4-nofpu"
    )
    ++ lib.optional (!enableShared) "--disable-shared"
    ++ lib.singleton (lib.enableFeature enablePlugin "plugin")
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ stdenv.mkDerivation (finalAttrs: {
        options.h \
        insn-constants.h \
  ''
  + lib.optionalString stdenv.targetPlatform.isM68k ''
  + lib.optionalString (stdenv.targetPlatform.isM68k || stdenv.targetPlatform.isSh4) ''
    sysroot-suffix.h \
  ''
  + lib.optionalString stdenv.targetPlatform.isAarch32 ''