[GHC] #8156: amd64 + in-tree gmp build broken

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: x86_64 (amd64) | Type of failure: Building GHC Difficulty: Easy (less than 1 | failed hour) | Test Case: Blocked By: | Blocking: Related Tickets: #4022 #4366 #4374 | -------------------------------------+------------------------------------- Currently, the GHC build system has an in-tree GMP. This GMP seems to be used only if there is no usable GMP found on the system and the user didn't provide one using configure flags. When we build GHC using an external shared version of GMP, the resulting GHC is dynamically linked against GMP and also the generated programs are linked dynamically against GMP. When the in-tree GMP is used, it is built statically, even if the GHC we are building is shared GHC on GNU/Linux. This feature is currently broken on amd64 (#4366, #4022), but is working currently very well on Linux i686. Apart from the breakage this setting is very flexible and I'd be very happy if it were possible to keep it, in spite of removeal requests like #4374. When there is a system GMP, nothing would change, this is the most typical usage, e.g. distributions are all building this way. On the other hand, if the user removes his GMP (maybe we should provide an option to explicity trigger this in ./configure, instead of having to remove GMP); she can build a GHC that is not linked dynamically against GMP and the resulting programs are not linked either. This makes it possible to generate binaries that link dynamically against libc (no -static) which is quite compatible amongst versions, but doesn't require a libgmp.so to run. For binary deployments this seems to be the best kind of setup nowadays. Now, if we were only able to fix this for amd64. See this: https://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3 On amd64 we can continue to compile GMP statically and link into the binary library, we just have to compile GMP with the fPIC. I attached the patch to fix this. Previously a similar patch has been rejected in #4022 because "this shouldn't be platform specific", but this is clearly not the case, this is specific to amd64. Tadaaaam: {{{ errge@sid64:~/ghc/inplace/bin$ cat test.hs main = print (2^100) errge@sid64:~/ghc/inplace/bin$ ./ghc-stage2 test.hs [1 of 1] Compiling Main ( test.hs, test.o ) Linking test ... errge@sid64:~/ghc/inplace/bin$ ./test 1267650600228229401496703205376 errge@sid64:~/ghc/inplace/bin$ ldd ./test linux-vdso.so.1 (0x00007fff79962000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe4b9a83000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe4b987a000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe4b9676000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe4b92c6000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe4b90a6000) /lib64/ld-linux-x86-64.so.2 (0x00007fe4b9d83000) }}} No GMP! I attach the build file patch to the bugreport. So, can we please apply this patch and just keep the in-tree GMP? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Resolution: | Keywords: patch Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Changes (by ezyang): * keywords: => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Resolution: | Keywords: patch Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Comment (by jstolarek): Errge, I don't know much about linking libraries, so I don't fully understand all that you wrote. Hence my question: would this patch allow us to build a binary distribution of GHC in such a way that it does not depend on a specific version of GMP being installed in the system? If yes then I fully support having this. Dependency of specific version of GMP is a major pain. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Resolution: | Keywords: patch Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jan.stolarek@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Resolution: | Keywords: patch Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Comment (by errge): Yes, it means that. I forgot to show that it in the test output, but not just the resulting binary is independent of GMP, but the GHC itself is too. BTW, is there some legal issues if a distribution decides to "distribute" GMP statically linked into a GHC binary? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.8.1 Component: Build System | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Changes (by jstolarek): * keywords: patch => * status: new => patch Comment: Replying to [comment:4 errge]:
I forgot to show that it in the test output, but not just the resulting binary is independent of GMP, but the GHC itself is too. This is great. I hope someone with more knowledge than me will have time to look into this ticket before 7.8 release. I'm marking status of this report as 'patch'.
BTW, is there some legal issues if a distribution decides to "distribute" GMP statically linked into a GHC binary? GMP is on LGPL, GHC is on BSD - I think these are compatible, so there shouldn't be any problems. We already include some code on GPL.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: patch Priority: low | Milestone: 7.10.1 Component: Build System | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Changes (by errge): * priority: normal => low * milestone: 7.8.1 => 7.10.1 Comment: Changing to 7.10.1 and low, as we are close to the release and this is not that important, maybe we can more bravely apply this after the release and see how it goes. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: patch Priority: low | Milestone: 7.10.1 Component: Build System | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Comment (by carter): @Jan, LGPL is only compatible with BSD when we dynamically link it, statically linked LGPL forces the rest of the project (allegedly) to be GPL, which is incompatible with a parent project that is BSD, at least according to the FSF's overly aggressive reading of (L)GPL. We could expose the option for end users (with a flag) to statically link a GMP, but we can't distribute ourselves libs that are statically linked to GMP. basically, we could have a gmp dylib in our disto, but we'd still need to make sure we could dylink to other gmps, otherwise we'd be violating the LGPL (as i understand it.). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: patch Priority: low | Milestone: 7.10.1 Component: Build System | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: Building GHC | Difficulty: Easy (less than 1 failed | hour) Test Case: | Blocked By: Blocking: | Related Tickets: #4022 #4366 #4374 -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:7 carter]:
@Jan, LGPL is only compatible with BSD when we dynamically link it, statically linked LGPL forces the rest of the project (allegedly) to be GPL, which is incompatible with a parent project that is BSD, at least according to the FSF's overly aggressive reading of (L)GPL.
...are you sure? Can you provide examples where the FSF used "overly agressive reading of the LGPL"? Afaik, simply stated, the LGPL just requires you to provide some mechanism (using dynamic linking is the most common way to achieve this) to allow ppl to replace the linked LGPL'ed library with a modified version. It does not force you to release or relicense the source code of the non-LGPLed components you used for the combined work. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: infoneeded Priority: low | Milestone: 7.10.1 Component: Build | Version: 7.7 System | Keywords: Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: Building | Blocked By: GHC failed | Related Tickets: #4022 #4366 #4374 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => infoneeded Comment: OK, with `integer-gmp2` on the horizon (Phab:D82), these changes will need to be revisited, and we really should have a coherent discussion about what to do for the `in-tree` GMP. So I'm bumping this out of `patch` status since it still hasn't gone anywhere. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: infoneeded Priority: low | Milestone: 8.0.1 Component: Build System | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: #4022 #4366 | Differential Revisions: #4374 | -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jan.stolarek@… (removed) * cc: jstolarek (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8156: amd64 + in-tree gmp build broken -------------------------------------+------------------------------------- Reporter: errge | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Build System | Version: 7.7 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: #4022 #4366 | Differential Rev(s): #4374 | Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: infoneeded => closed * resolution: => fixed Comment: This was fixed by the new integer-gmp library in 7.10, which applies the following patch (part of `libraries/integer-gmp/gmp/gmpsrc.patch`) to build GMP with `-fPIC` unconditionally: {{{#!diff --- gmp-5.0.3/configure 2012-02-03 16:52:49.000000000 +0100 +++ gmpbuild/configure 2014-11-07 23:46:33.629758238 +0100 @@ -3937,8 +3937,8 @@ # cclist="gcc cc" -gcc_cflags="-O2 -pedantic" -gcc_64_cflags="-O2 -pedantic" +gcc_cflags="-O2 -pedantic -fPIC" +gcc_64_cflags="-O2 -pedantic -fPIC" cc_cflags="-O" cc_64_cflags="-O" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8156#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC