Your message dated Wed, 18 Jul 2018 23:19:21 +0000
with message-id <[email protected]>
and subject line Bug#904055: fixed in ghc 8.2.2-5
has caused the Debian Bug report #904055,
regarding ghc: Please backport important fix for unregisterised compiler
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
904055: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=904055
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: ghc
Version: 8.2.2-4
Severity: normal
Tags: patch upstream
User: [email protected]
Usertags: m68k

Hi!

I recently reported a GHC bug upstream which resulted in miscompiled
code when using an unregisterised compiler [1]. Upstream has managed
to track down the issue to GHC producing code that the C compiler
doesn't like. The bug was observed on m68k and sh4 in Debian, but
according to upstream, can affect any other target using an unregisterised
compiler.

The patch can be found in [2], I'm also attaching it. It would be
highly appreciated if the patch could be included in the next upload
so that future uploads of GHC 8.2.x will continue to work on the
affected architectures.

Thanks,
Adrian

> [1] https://ghc.haskell.org/trac/ghc/ticket/15338
> [2] 
> https://git.haskell.org/ghc.git/commitdiff/8ec48990fee9e245bb2fe40dc6f65b61b8612157

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: driver: skip -Bsymbolic on unregisterised targets
 Trac #15338 is yet another example where -Bsymbolic breaks
 semantics of a C program: global variable duplication happens
 and unsafePerformIO creates two stdout copies.
 .
 When -Bsymbolic is not used both C compiler and linker agree
 on how global variables are handled. In case of sh4 it consists
 on a few assertions:
 .
 1. global variable is exported from shared library
 2. code is referred to this variable via GOT-like mechanism to allow
    interposition
 3. global variable is present .bss section on an executable
    (as an R_*_COPY relocation: symbol contents is copied at executable
    startup time)
 4. and symbol in executable interposes symbol in shared library.
 .
 This way both code in shared library and code in executable refer
 to a copy of global variable in .bss section of an executable.
 .
 Unfortunately -Bsymbolic option breaks assumption [2.] and generates
 direct references to the symbol. This causes mismatch between
 values seen from executable and values seen from shared library code.
 .
 This change disables '-Bsymbolic' for unregisterised targets.

--- ghc-8.2.2.orig/compiler/main/SysTools.hs
+++ ghc-8.2.2/compiler/main/SysTools.hs
@@ -1741,9 +1741,12 @@ linkDynLib dflags0 o_files dep_packages
             -------------------------------------------------------------------
 
             let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
+                unregisterised = platformUnregisterised (targetPlatform dflags)
             let bsymbolicFlag = -- we need symbolic linking to resolve
-                                -- non-PIC intra-package-relocations
-                                ["-Wl,-Bsymbolic"]
+                                -- non-PIC intra-package-relocations for
+                                -- performance (where symbolic linking works)
+                                -- See Note [-Bsymbolic assumptions by GHC]
+                                ["-Wl,-Bsymbolic" | not unregisterised]
 
             runLink dflags (
                     map Option verbFlags
@@ -1800,3 +1803,27 @@ getFrameworkOpts dflags platform
     -- reverse because they're added in reverse order from the cmd line:
     framework_opts = concat [ ["-framework", fw]
                             | fw <- reverse frameworks ]
+
+{-
+Note [-Bsymbolic assumptions by GHC]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+GHC has a few assumptions about interaction of relocations in NCG and linker:
+
+1. -Bsymbolic resolves internal references when the shared library is linked,
+   which is important for performance.
+2. When there is a reference to data in a shared library from the main program,
+   the runtime linker relocates the data object into the main program using an
+   R_*_COPY relocation.
+3. If we used -Bsymbolic, then this results in multiple copies of the data
+   object, because some references have already been resolved to point to the
+   original instance. This is bad!
+
+We work around [3.] for native compiled code by avoiding the generation of
+R_*_COPY relocations.
+
+Unregisterised compiler can't evade R_*_COPY relocations easily thus we disable
+-Bsymbolic linking there.
+
+See related Trac tickets: #4210, #15338
+-}

--- End Message ---
--- Begin Message ---
Source: ghc
Source-Version: 8.2.2-5

We believe that the bug you reported is fixed in the latest version of
ghc, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Clint Adams <[email protected]> (supplier of updated ghc package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Wed, 18 Jul 2018 18:56:46 -0400
Source: ghc
Binary: ghc ghc-prof ghc-doc
Architecture: source
Version: 8.2.2-5
Distribution: unstable
Urgency: medium
Maintainer: Debian Haskell Group 
<[email protected]>
Changed-By: Clint Adams <[email protected]>
Description:
 ghc        - The Glasgow Haskell Compilation system
 ghc-doc    - Documentation for the Glasgow Haskell Compilation system
 ghc-prof   - Profiling libraries for the Glasgow Haskell Compilation system
Closes: 904055
Changes:
 ghc (8.2.2-5) unstable; urgency=medium
 .
   * Apply patch to disable -Bsymbolic on unregisterised
     architectures.  closes: #904055.
   * Add autopkgtest.
Checksums-Sha1:
 c5ff106437a23f2e5598da6390798a1c80029ab7 2556 ghc_8.2.2-5.dsc
 a33222646c440826af744ad70447446fb82b74cf 10753272 ghc_8.2.2.orig.tar.xz
 e858d4fc6826dc9fe0330764552f474c48640c2f 52576 ghc_8.2.2-5.debian.tar.xz
 1fd41e8e51bf7480ad1a8e1641a023330179fc01 8174 ghc_8.2.2-5_source.buildinfo
Checksums-Sha256:
 7f9fe7dc87f999ebcbb6f5ec070ba79b53692c7ea75d71dbde22d9ce2cca5208 2556 
ghc_8.2.2-5.dsc
 bb8ec3634aa132d09faa270bbd604b82dfa61f04855655af6f9d14a9eedc05fc 10753272 
ghc_8.2.2.orig.tar.xz
 9e16a4e8a5146beff5eb5b870d36a83935e1f5de29b4bc45724ae90550c91691 52576 
ghc_8.2.2-5.debian.tar.xz
 4740fe032674942c0d550d2e11f9bcf596bfe55bf487830463348774e3753d48 8174 
ghc_8.2.2-5_source.buildinfo
Files:
 8a2af9b6f6979292770addc06406729f 2556 haskell optional ghc_8.2.2-5.dsc
 cd25f62e85f4e0343fd4655bbd52f3e7 10753272 haskell optional 
ghc_8.2.2.orig.tar.xz
 b55d6e5bbf1bf1928137cef34d5a80dc 52576 haskell optional 
ghc_8.2.2-5.debian.tar.xz
 e6045aad9911097e482b77d2eef4a609 8174 haskell optional 
ghc_8.2.2-5_source.buildinfo

-----BEGIN PGP SIGNATURE-----
Comment: Debian!

iQKlBAEBCgCPFiEEdYHsh0BT5sgHeRubVZIzHhmdOKgFAltPx5pfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1
ODFFQzg3NDA1M0U2QzgwNzc5MUI5QjU1OTIzMzFFMTk5RDM4QTgRHGNsaW50QGRl
Ymlhbi5vcmcACgkQVZIzHhmdOKg4nxAAg717Ln/frLGNmXDsz1zRMnCp1kS4Zmhe
2N7FQiBcYU7oIXsO+VNrdmc32rhxWLNXG9H8V1Zl8HE1JJeKCX796m2sJPDvprFZ
t//mBvit9DZ1yoKfgusKBaEpwVVr9QmTu4s8cl+PN6G11frSnflHT3dMzCyf13M/
Y9fMq5lkiXFAq6GTEcqUecG6pSnRsYRYKJlbzTDhTRxziNk/qCR5fwepL/UHIwY3
SHlw93GAVx6rcXfH294sDJJqDa+D+fW8/F/6POXi5KnijADfhq1CTADNoIch2T0y
H61E5xG1Gcj7nyoHOZgBc3xntOy1/XeO7jui7od9+jkOFTJlWFdpOuOBkMH4xpCR
gBg7mjNqBQKU5FmLZ7PUGb2y9RHNO4GNE+nMPkz0VVYOkzE+tqai8/kB8NBAivNF
kN/UT8ZxZT+rGjAuCafFH7Qmeb2T9E86akDsnKXBjQR64JsnmkfzpKercqMwfVgT
591eRXihs8er4wPFxojfCe66dbIdKlFKqzAHTncA3rhT/NCe8QgbO0eOEGl0Onrx
ukBVLZz5E9cOU390Axnp7FSMyjh30ULD+U1wDDlhKDgUVVLPBxrc+qJm/emW9cjL
jyFYxKuyrv99d/w+zfsLyigO4yT7xhChham45D368ROC2eb5kJ5nJhkCK3i14aQE
pN97vAZerrE=
=CSWl
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to