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

Fix GHC bootstrap in pkgsMusl and include patch for binutils/16177 #103183

Merged
merged 2 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions pkgs/development/compilers/ghc/8.6.5-binary.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv
, fetchurl, perl, gcc
, ncurses5, gmp, glibc, libiconv
, ncurses5, ncurses6, gmp, glibc, libiconv
, llvmPackages
}:

Expand All @@ -10,8 +10,12 @@ assert stdenv.targetPlatform == stdenv.hostPlatform;
let
useLLVM = !stdenv.targetPlatform.isx86;

useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux";

ourNcurses = if useNcurses6 then ncurses6 else ncurses5;

libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp
ourNcurses gmp
] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);

libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
Expand All @@ -34,12 +38,16 @@ stdenv.mkDerivation rec {
# https://downloads.haskell.org/~ghc/8.6.5/
src = fetchurl ({
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";
sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
};
x86_64-linux = {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb9-linux.tar.xz";
sha256 = "1pqlx6rdjs2110g0y1i9f8x18lmdizibjqd15f5xahcz39hgaxdw";
# This is the Fedora build because it links against ncurses6 where the
# 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";
expipiplus1 marked this conversation as resolved.
Show resolved Hide resolved
sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
};
aarch64-linux = {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
Expand Down Expand Up @@ -88,9 +96,12 @@ stdenv.mkDerivation rec {
'' +
# Rename needed libraries and binaries, fix interpreter
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 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} {} \;

sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
Expand Down
29 changes: 29 additions & 0 deletions pkgs/development/tools/misc/binutils/R_ARM_COPY.patch
Original file line number Diff line number Diff line change
@@ -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);

8 changes: 8 additions & 0 deletions pkgs/development/tools/misc/binutils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ stdenv.mkDerivation {
./patches/2.31/0001-x86-Properly-add-X86_ISA_1_NEEDED-property.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.
expipiplus1 marked this conversation as resolved.
Show resolved Hide resolved
# 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" ];
Expand Down