[GHC] #12147: GHC's Linker Should Support Relocation Type 42

#12147: GHC's Linker Should Support Relocation Type 42 ----------------------------------------+--------------------------------- Reporter: gershomb | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Linux Architecture: Unknown/Multiple | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------------- As per: https://github.com/DanielG/ghc- mod/issues/762#issuecomment-213743585 "gas >= 2.26 uses some new relocation types (in particular type 42, aka R_X86_64_REX_GOTPCRELX), which are not supported by ghc's linker." This causes problems when linking in libs with certain sorts of c bits via the GHC API (at the very least). Support should be added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * component: Compiler => Runtime System (Linker) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * owner: => Phyx- Comment: Thanks for the report, this should be simple enough to fix -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => patch * differential: => Phab:D2303 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * priority: normal => high * milestone: => 8.0.2 Comment: I'm bumping the priority for this to 'high' (as GHC is technically broken on a new binutils in the static linker configuration) and moving it to 8.0.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): I have "GNU assembler (GNU Binutils for Debian) 2.26" on my Debian system. but have not yet hit this issue. Is there a test case? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Tried this: {{{ $ cabal get cipher-aes $ cd cipher-aes-0.2.11 $ cabal sandbox init $ cabal install --dependencies-only --enable-tests $ cabal install $ cabal exec -- ghci -i:Tests Tests/Tests.hs ghci > main GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help Ok, modules loaded: Crypto.Cipher.AES, Main, KATECB, KATCBC, KATXTS, KATGCM, KATOCB3. ghci > main ghc: panic! (the 'impossible' happened) (GHC version 7.10.3 for x86_64-unknown-linux): Loading temp shared object failed: /tmp/ghcc0a8_0/libghc_9.so: undefined symbol: aes_decrypt_ecb Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} That doesn't seem to be quite the same problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42
-------------------------------------+-------------------------------------
Reporter: gershomb | Owner: Phyx-
Type: bug | Status: patch
Priority: high | Milestone: 8.0.2
Component: Runtime System | Version: 8.0.1
(Linker) |
Resolution: | Keywords:
Operating System: Linux | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2303
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Phyx-):
I haven't written a testcase since you need `binutils-2.26` for it to
trigger and I don't think I can force the test only then.
In any case, simplest case to reproduce this is to compile `GHC` with
`DYNAMIC_GHC_PROGRAMS=NO`
I use this assembly file as input:
{{{
# x86_64
# as as_test.s -o as_test.o && objdump -Dr as_test.o
# ghc --interactive hs_test as_test.o
.text
.globl foo
foo:
push %rbp
mov %rsp, %rbp
mov msg@GOTPCREL(%rip), %rdi
call puts@PLT
pop %rbp
ret
.data
msg:
.ascii "Hello World!\0"
len = . - msg
}}}
Which with
{{{
[phyx@localhost ~]$ as --version
GNU assembler (GNU Binutils) 2.26.20160125
}}}
returns the expected relocation
{{{
[phyx@localhost ~]$ as as_test.s -o as_test.o && objdump -Dr as_test.o
as_test.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <foo>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 8b 3d 00 00 00 00 mov 0x0(%rip),%rdi # b

#12147: GHC's Linker Should Support Relocation Type 42
-------------------------------------+-------------------------------------
Reporter: gershomb | Owner: Phyx-
Type: bug | Status: patch
Priority: high | Milestone: 8.0.2
Component: Runtime System | Version: 8.0.1
(Linker) |
Resolution: | Keywords:
Operating System: Linux | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2303
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Tamar Christina

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: fixed | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: patch => closed * resolution: => fixed Comment: NOTE: The bindist for elf platforms need to be build using a system that has `glibc >= 2.23` in order for `elf.h` to contain these constants and for GHC to then be able to use them. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * owner: Phyx- => * status: closed => new * resolution: fixed => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): @bgamari, is the a big enough issue to consider doing a 7.10.4 release? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Quoting @erikd in https://phabricator.haskell.org/D2303#67070:
I'm pretty sure that will be handled by the Linux distros. They wouldn't ship an GNU `as` until their `glibc` handled these new relocations.
We have our first victim of this assumption: https://github.com/snowleopard/hadrian/issues/259#issuecomment-224618414. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by kaiha): Replying to [comment:13 thomie]:
Quoting @erikd in https://phabricator.haskell.org/D2303#67070:
I'm pretty sure that will be handled by the Linux distros. They
wouldn't ship an GNU `as` until their `glibc` handled these new relocations.
We have our first victim of this assumption:
https://github.com/snowleopard/hadrian/issues/259#issuecomment-224618414. This is the victim speaking. I experienced this problem on a Debian testing. So I think that the assumption of @erikd remains valid as long as we consider only stable Linux distributions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomasjm): I'm another victim: this has been failing for me on Ubuntu 16.04 when trying to use IHaskell and IHaskell's display libraries--both the cryptonite package and the glib package are triggering this problem. (The stack resolver is lts-6.2.) I think there are some workarounds I could use where I compile these packages with some stack settings like ghc-options: glib: -opta-Wa,-mrelax-relocations=no rebuild-ghc-options: true apply-ghc-options: everything but I'd really appreciate if there were a 7.10.4 release that fixes this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Can you just build IHaskell as a dynamically linked executable? Then you would be off the dreaded ghci linker completely. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Yes, what rwbarton says. I can reproduce the problem with a statically linked `ihaskell`, but `--enable-executable-dynamic` solves it: {{{ $ cabal install -w ghc-7.10.3 ihaskell --enable-executable-dynamic $ jupyter console --kernel haskell Jupyter Console 4.1.1 In [1]: }}} You need to build all dependencies with `--enabled-shared` as well (set `shared: True` in `.cabal/config`). Other things I had to install: {{{ $ sudo apt-get install libzmq3-dev $ pip install jupyter }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by dkasak): I'm also affected on Arch Linux. If at all possible, please do release a 7.10.4 since there is no easy workaround. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: fixed | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: comment:8 merged to `ghc-8.0` as efc7ef67d3fe2064dc8f40e73d88026d57bd836f. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12147#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC