Merge pull request #103183 from expipiplus1/joe-haskell-cross-2

Fix GHC bootstrap in pkgsMusl and include patch for binutils/16177
This commit is contained in:
Frederik Rietdijk 2020-11-28 13:40:47 +01:00 committed by GitHub
commit e239c8b340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ stdenv { stdenv
, fetchurl, perl, gcc , fetchurl, perl, gcc
, ncurses5, gmp, glibc, libiconv , ncurses5, ncurses6, gmp, glibc, libiconv
, llvmPackages , llvmPackages
}: }:
@ -10,8 +10,12 @@ assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
useLLVM = !stdenv.targetPlatform.isx86; useLLVM = !stdenv.targetPlatform.isx86;
useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux";
ourNcurses = if useNcurses6 then ncurses6 else ncurses5;
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ourNcurses gmp
] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv); ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY" libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
@ -34,12 +38,16 @@ stdenv.mkDerivation rec {
# https://downloads.haskell.org/~ghc/8.6.5/ # https://downloads.haskell.org/~ghc/8.6.5/
src = fetchurl ({ src = fetchurl ({
i686-linux = { i686-linux = {
# Don't use the Fedora27 build (as below) because there isn't one!
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb9-linux.tar.xz"; url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w"; sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
}; };
x86_64-linux = { x86_64-linux = {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb9-linux.tar.xz"; # This is the Fedora build because it links against ncurses6 where the
sha256 = "1pqlx6rdjs2110g0y1i9f8x18lmdizibjqd15f5xahcz39hgaxdw"; # deb9 one links against ncurses5, see here
# https://github.com/NixOS/nixpkgs/issues/85924 for a discussion
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
}; };
aarch64-linux = { aarch64-linux = {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz"; url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
@ -88,9 +96,12 @@ stdenv.mkDerivation rec {
'' + '' +
# Rename needed libraries and binaries, fix interpreter # Rename needed libraries and binaries, fix interpreter
stdenv.lib.optionalString stdenv.isLinux '' stdenv.lib.optionalString stdenv.isLinux ''
find . -type f -perm -0100 -exec patchelf \ find . -type f -perm -0100 \
-exec patchelf \
--replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \ --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
--replace-needed libtinfo.so libtinfo.so.5 \ ${ # This isn't required for x86_64-linux where we use ncurses6
stdenv.lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
} \
--interpreter ${glibcDynLinker} {} \; --interpreter ${glibcDynLinker} {} \;
sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2

View File

@ -0,0 +1,29 @@
@@ -, +, @@
---
bfd/elf32-arm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/bfd/elf32-arm.c
+++ a/bfd/elf32-arm.c
@@ -15398,7 +15398,11 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
linker to copy the initial value out of the dynamic object and into
the runtime process image. We need to remember the offset into the
.rel(a).bss section we are going to use. */
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (info->nocopyreloc == 0
+ && (h->root.u.def.section->flags & SEC_ALLOC) != 0
+ /* PR 16177: A copy is only needed if the input section is readonly. */
+ && (h->root.u.def.section->flags & SEC_READONLY) != 0
+ && h->size != 0)
{
s = globals->root.sdynrelro;
srel = globals->root.sreldynrelro;
@@ -15410,6 +15414,8 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
}
if (info->nocopyreloc == 0
&& (h->root.u.def.section->flags & SEC_ALLOC) != 0
+ /* PR 16177: A copy is only needed if the input section is readonly. */
+ && (h->root.u.def.section->flags & SEC_READONLY) != 0
&& h->size != 0)
{
elf32_arm_allocate_dynrelocs (info, srel, 1);

View File

@ -101,6 +101,14 @@ stdenv.mkDerivation {
./patches/2.31/0001-x86-Properly-add-X86_ISA_1_NEEDED-property.patch ./patches/2.31/0001-x86-Properly-add-X86_ISA_1_NEEDED-property.patch
] ]
++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch
++ # This patch was suggested by Nick Clifton to fix
# https://sourceware.org/bugzilla/show_bug.cgi?id=16177
# It can be removed when that 7-year-old bug is closed.
# This binutils bug causes GHC to emit broken binaries on armv7, and
# indeed GHC will refuse to compile with a binutils suffering from it. See
# this comment for more information:
# https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
lib.optional stdenv.targetPlatform.isAarch32 ./R_ARM_COPY.patch
; ;
outputs = [ "out" "info" "man" ]; outputs = [ "out" "info" "man" ];