GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2024-02-14T02:59:45Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/22614Use 64-bit GMP limbs on wasm322024-02-14T02:59:45ZCheng ShaoUse 64-bit GMP limbs on wasm32This is a rather low priority feature request, filed since I noticed a fact in GMP configure system: it's possible to forcibly use 64-bit limbs on 32-bit host archs. Our `ghc-bignum` has the assumption that limb size must equals word siz...This is a rather low priority feature request, filed since I noticed a fact in GMP configure system: it's possible to forcibly use 64-bit limbs on 32-bit host archs. Our `ghc-bignum` has the assumption that limb size must equals word size, though I think it's possible to relax that restriction.
Using 64-bit GMP limbs likely improves performance on wasm32 when dealing with large `Integer`s, since wasm32 supports i64 arithmetic perfectly, and in general the same amount of computation can be achieved by less i64 instructions than their i32 equivalents.https://gitlab.haskell.org/ghc/ghc/-/issues/601Replace GMP2023-08-03T00:06:42ZSimon MarlowReplace GMPGMP is a great multi-precision integer library, but its LGPL license is problematic for users of GHC (it prohibits static linking of GHC-compiled programs, for example).
One possible alternative would be to use the bignum library from O...GMP is a great multi-precision integer library, but its LGPL license is problematic for users of GHC (it prohibits static linking of GHC-compiled programs, for example).
One possible alternative would be to use the bignum library from OpenSSL, which is available under a BSD-style license.https://gitlab.haskell.org/ghc/ghc/-/issues/22789In-tree GMP tarballs lacks the CVE-2021-43618 patch2023-04-11T11:15:23ZCheng ShaoIn-tree GMP tarballs lacks the CVE-2021-43618 patchMost linux distros patch GMP-6.2.1 with https://gmplib.org/repo/gmp-6.2/rev/561a9c25298e, which fixes [CVE-2021-43618](https://github.com/advisories/GHSA-mfg4-w44m-wr4g) that affects 32-bit platforms. Before GMP does another release, we ...Most linux distros patch GMP-6.2.1 with https://gmplib.org/repo/gmp-6.2/rev/561a9c25298e, which fixes [CVE-2021-43618](https://github.com/advisories/GHSA-mfg4-w44m-wr4g) that affects 32-bit platforms. Before GMP does another release, we should also include this patch into `gmp-tarballs` and bump the submodule accordingly.Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/22602Wasm backend testsuite failure: foundation2023-02-01T11:08:16ZCheng ShaoWasm backend testsuite failure: foundation`foundation` fails on unreg+int_gmp with:
```
Group Precedence
Running + and - (1)
Passed 100 iterations
Running + and - (2)
Passed 100 iterations
Running + and * (1)
Passed 100 iterations
...`foundation` fails on unreg+int_gmp with:
```
Group Precedence
Running + and - (1)
Passed 100 iterations
Running + and - (2)
Passed 100 iterations
Running + and * (1)
Passed 100 iterations
Running + and * (2)
Passed 100 iterations
Running - and * (1)
Passed 100 iterations
Running - and * (2)
Passed 100 iterations
Running * and ^ (1)
Error: failed to run main module `foundation.wasm`
Caused by:
0: failed to invoke command default
1: error while executing at wasm backtrace:
0: 0x1667db - <unknown>!__gmpn_toom6h_mul
1: 0x144b02 - <unknown>!__gmpn_mul_n
2: 0x162f1f - <unknown>!__gmpn_toom53_mul
3: 0x11fb0c - <unknown>!__gmpn_mul
4: 0x11f3c8 - <unknown>!__gmpn_mul
5: 0x18aa4d - <unknown>!_blk_c65B
6: 0x1d1f13 - <unknown>!StgRun
7: 0x1b2544 - <unknown>!scheduleWaitThread
8: 0x1a7c27 - <unknown>!rts_evalLazyIO
9: 0x1a7dbf - <unknown>!hs_main
10: 0x2099d - <unknown>!main
11: 0x1f76f1 - <unknown>!__main_void
12: 0x90d1 - <unknown>!_start
2: wasm trap: out of bounds memory access
```
On unreg+int_native, it passes, but the steps `Running * and ^ (1)`/`Running * and ^ (2)` still take pretty long time, around `2m40s` for `wasmtime`.9.6.1Cheng ShaoCheng Shaohttps://gitlab.haskell.org/ghc/ghc/-/issues/20073GHC Alpine bindist is linked against libgmp but the download page says it's not2022-08-28T16:51:00ZNiklas Hambüchenmail@nh2.meGHC Alpine bindist is linked against libgmp but the download page says it's nothttps://www.haskell.org/ghc/download_ghc_8_10_5.html#binaries claims:
> Alpine Linux 3.10 for x86-64. This is a complete build, including interactive system, profiling libraries and documentation. Unlike our other binary distributions, ...https://www.haskell.org/ghc/download_ghc_8_10_5.html#binaries claims:
> Alpine Linux 3.10 for x86-64. This is a complete build, including interactive system, profiling libraries and documentation. Unlike our other binary distributions, this links against the `integer-simple` big-integer backend and therefore does not require `libgmp`.
But it is apparently linked against `libgmp`:
```
$ readelf -d ghc-8.10.5-x86_64-unknown-linux/bin/ghc | grep gmp
0x0000000000000001 (NEEDED) Shared library: [libHSinteger-gmp-1.0.3.0-ghc8.10.5.so]
0x0000000000000001 (NEEDED) Shared library: [libgmp.so.10]
```
Same thing for the [8.10.2 bindist](https://www.haskell.org/ghc/download_ghc_8_10_2.html#binaries); I haven't checked other ones.
CC @bgamariZubinZubinhttps://gitlab.haskell.org/ghc/ghc/-/issues/7860Add more bit fiddling functions to 'integer-gmp'2022-03-11T16:28:18ZlebedevAdd more bit fiddling functions to 'integer-gmp'Current implementation of 'integer-gmp' uses only a subset of "bit fiddling" features, [provided](http://gmplib.org/manual/Integer-Logic-and-Bit-Fiddling.html) by the GMP library. The ones missing are:
```
* mpz_popcount
* mpz_setbit
* ...Current implementation of 'integer-gmp' uses only a subset of "bit fiddling" features, [provided](http://gmplib.org/manual/Integer-Logic-and-Bit-Fiddling.html) by the GMP library. The ones missing are:
```
* mpz_popcount
* mpz_setbit
* mpz_clrbit
```
I think it would be nice to add these functions in addition to 'testBitInteger'. Would you accept a patch?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 7.6.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | #3489 |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Add more bit fiddling functions to 'integer-gmp'","status":"New","operating_system":"","component":"Compiler","related":[3489],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.6.3","keywords":["gmp"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Current implementation of 'integer-gmp' uses only a subset of \"bit fiddling\" features, [http://gmplib.org/manual/Integer-Logic-and-Bit-Fiddling.html provided] by the GMP library. The ones missing are:\r\n\r\n{{{\r\n* mpz_popcount\r\n* mpz_setbit\r\n* mpz_clrbit\r\n}}}\r\n\r\nI think it would be nice to add these functions in addition to 'testBitInteger'. Would you accept a patch?","type_of_failure":"OtherFailure","blocking":[]} -->⊥https://gitlab.haskell.org/ghc/ghc/-/issues/4022GHC Bindist is Broken on FreeBSD/amd642021-12-03T17:50:15ZpgjGHC Bindist is Broken on FreeBSD/amd64After correcting the name of the FreeBSD/amd64 platform in `PlatformSupportsSharedLibs` it turned out that shared libraries do not build on that platform at all. Log shows that the problem is with the integer-gmp library where the source...After correcting the name of the FreeBSD/amd64 platform in `PlatformSupportsSharedLibs` it turned out that shared libraries do not build on that platform at all. Log shows that the problem is with the integer-gmp library where the sources are not compiled with the `-fPIC` flag.
Excerpt from the build log:
```
...
"inplace/bin/ghc-stage1" libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o libraries/integer-gmp/gmp/objs/*.o `/usr/bin/find libraries/integer-gmp/dist-install/build -name "*_stub.dyn_o" -print` -shared -dynamic -dynload deploy -dylib-install-name /usr/local/lib/ghc-6.13.20100427/`basename "libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so" | sed 's/^libHS//;s/[-]ghc.*//'`/`basename "libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so"` -no-auto-link-packages -packageghc-prim-0.2.0.0 -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so
/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
libraries/integer-gmp/gmp/objs/abs.o: could not read symbols: Bad value
...
```
According to Simon Marlow, it looks like it is building the in-tree gmp library rather than using a local one, and perhaps there is no shared version, so `gcc` picks up the static one and complains. There should be a shared gmp library when shared Haskell libraries are being built.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 6.13 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries (other) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | Unknown/Multiple |
</details>
<!-- {"blocked_by":[],"summary":"GHC Bindist is Broken on FreeBSD/amd64","status":"New","operating_system":"","component":"libraries (other)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"pgj"},"version":"6.13","keywords":["FreeBSD,","GMP,integer-gmp,","sharedlibs","x86_64,"],"differentials":[],"test_case":"","architecture":"Unknown/Multiple","cc":[""],"type":"Bug","description":"After correcting the name of the FreeBSD/amd64 platform in `PlatformSupportsSharedLibs` it turned out that shared libraries do not build on that platform at all. Log shows that the problem is with the integer-gmp library where the sources are not compiled with the `-fPIC` flag.\r\n\r\nExcerpt from the build log:\r\n\r\n{{{\r\n...\r\n\"inplace/bin/ghc-stage1\" libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o libraries/integer-gmp/gmp/objs/*.o `/usr/bin/find libraries/integer-gmp/dist-install/build -name \"*_stub.dyn_o\" -print` -shared -dynamic -dynload deploy -dylib-install-name /usr/local/lib/ghc-6.13.20100427/`basename \"libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so\" | sed 's/^libHS//;s/[-]ghc.*//'`/`basename \"libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so\"` -no-auto-link-packages -packageghc-prim-0.2.0.0 -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.0-ghc6.13.20100427.so\r\n/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC\r\nlibraries/integer-gmp/gmp/objs/abs.o: could not read symbols: Bad value\r\n...\r\n}}}\r\n\r\nAccording to Simon Marlow, it looks like it is building the in-tree gmp library rather than using a local one, and perhaps there is no shared version, so `gcc` picks up the static one and complains. There should be a shared gmp library when shared Haskell libraries are being built.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1pgjpgjhttps://gitlab.haskell.org/ghc/ghc/-/issues/17231Incorrect rounding mode used for fromIntegral :: Integer -> Double/Float2021-03-17T23:40:38ZLevent ErkökIncorrect rounding mode used for fromIntegral :: Integer -> Double/Float## Summary
When converting from `Integer` to `Double` (or `Float`), GHC uses round-toward-zero rounding mode. It should use the default mode round-toward-nearest-ties-to-even instead.
It appears up till GHC 7.8.3, GHC did indeed use th...## Summary
When converting from `Integer` to `Double` (or `Float`), GHC uses round-toward-zero rounding mode. It should use the default mode round-toward-nearest-ties-to-even instead.
It appears up till GHC 7.8.3, GHC did indeed use this default mode, but something changed after that at some point, and at least in 8.6.5, the incorrect mode is used.
## Steps to reproduce
As discussed in https://stackoverflow.com/questions/58035248/a-haskell-floating-point-calculation-anomaly/58037815#58037815
This expression:
```haskell
*Main> (fromIntegral $ 4141414141414141*4141414141414141) :: Double
1.7151311090705025e31
```
Produces an unexpected result since the resulting integer is converted using round-toward-zero. While the report is rather silent on rounding-modes, it's general accepted practice that round-nearest-ties-to-even is the default rounding mode to use. As discussed in the stack-overflow question linked, this results in bad results in diverges from other languages. For instance, the equivalent Python produces:
```python
>>> float(long(4141414141414141)*long(4141414141414141))
1.7151311090705027e+31
```
which is a much better result for this expression. (Note the final digit before the exponent, 5 vs 7.)
## Expected behavior
Produce the better conversion result by using round-nearest-ties-to-even rounding mode of IEEE754.
## Analysis
The issue goes to this function: https://hackage.haskell.org/package/integer-gmp-1.0.2.0/docs/src/GHC.Integer.Type.html#doubleFromInteger
which reads:
```haskell
doubleFromInteger :: Integer -> Double#
doubleFromInteger (S# m#) = int2Double# m#
doubleFromInteger (Jp# bn@(BN# bn#))
= c_mpn_get_d bn# (sizeofBigNat# bn) 0#
doubleFromInteger (Jn# bn@(BN# bn#))
= c_mpn_get_d bn# (negateInt# (sizeofBigNat# bn)) 0#
```
which in turn calls: https://github.com/ghc/ghc/blob/master/libraries/integer-gmp/cbits/wrappers.c#L183-L190:
```C
/* Convert bignum to a `double`, truncating if necessary
* (i.e. rounding towards zero).
*
* sign of mp_size_t argument controls sign of converted double
*/
HsDouble
integer_gmp_mpn_get_d (const mp_limb_t sp[], const mp_size_t sn,
const HsInt exponent)
{
```
This function decidedly uses round-towards-zero. Instead, a version that uses round-nearest-ties-to-even should be called.
`Integer -> Float` conversion suffers from the same problem, as it goes through the `Double` value. So, fixing the first would fix the second as well.
## Environment
* GHC version used: 8.6.5 and newer. On the stack-overflow discussion, people noted that GHC 7.8.3 returns the correct value. So, the behavior somehow changed in between these releases.
Optional:
* Operating System: N/A
* System Architecture: N/Ahttps://gitlab.haskell.org/ghc/ghc/-/issues/15262GHC and iserv cannot agree on what an Integer is; insanity ensues2020-06-19T14:35:19ZhowtonotwinGHC and iserv cannot agree on what an Integer is; insanity ensuesTested off `ghc-8.6.1-alpha1`, running on macOS 10.13.5.
1. Compile a GHC that uses `integer-gmp`.
2. Compile a GHC that uses `integer-simple`.
3. Make `Main.hs`:
> ```haskell
> {-# LANGUAGE TemplateHaskell #-}
...Tested off `ghc-8.6.1-alpha1`, running on macOS 10.13.5.
1. Compile a GHC that uses `integer-gmp`.
2. Compile a GHC that uses `integer-simple`.
3. Make `Main.hs`:
> ```haskell
> {-# LANGUAGE TemplateHaskell #-}
> main = print $([e| 0 |])
> ```
4. Try to compile the file with `integer-gmp` `ghc` and `integer-simple` `ghc-iserv`.
* Expected behavior: (compiles fine and executable prints `0`) or (outputs to-the-point error message)
* Actual:
```none
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:2:14: error:
• Exception when trying to run compile-time code:
ghc: ghc-iserv terminated (-11)
Code: [| 0 |]
• In the untyped splice: $([| 0 |])
|
2 | main = print $([e| 0 |])
| ^^^^^^^^^^^
```
4. Try to compile the file with `integer-simple` `ghc` and `integer-gmp` `ghc-iserv`.
* Expected behavior: (compiles fine and executable prints `0`) or (outputs to-the-point error message)
* Actual:
```none
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:2:14: error:
• Exception when trying to run compile-time code:
heap overflow
Code: [| 0 |]
• In the untyped splice: $([| 0 |])
|
2 | main = print $([e| 0 |])
| ^^^^^^^^^^^
```
For more fun, replace the `0` with a `1`. `gmp` `ghc` + `simple` `iserv` continues to explode. This is better than `simple` `ghc` + `gmp` `iserv`:
```bash
$ ./Main
283468057265
$ ./Main
283468057265
$ $simple_ghc -fexternal-interpreter -pgmi=$gmp_iserv Main.hs # again
# ...
$ ./Main
283468057105
```
Absolutely delicious. There is a similar situation for fractional literals.
It would be nice if there were at least a warning for situations like this.9.0.1John EricsonJohn Ericsonhttps://gitlab.haskell.org/ghc/ghc/-/issues/9835Add bindings for marshaling to/from mpz_t2020-06-19T13:05:44ZdfrankeAdd bindings for marshaling to/from mpz_tPlease add bindings to allow efficient marshaling between Haskell Integer and C mpz_t's, e.g.:
```
-- Wraps a (struct __mpz_struct*).
type Mpz = Ptr ()
toMpz :: Integer -> IO Mpz
fromMpz :: Mpz -> IO Integer
```
This would be ...Please add bindings to allow efficient marshaling between Haskell Integer and C mpz_t's, e.g.:
```
-- Wraps a (struct __mpz_struct*).
type Mpz = Ptr ()
toMpz :: Integer -> IO Mpz
fromMpz :: Mpz -> IO Integer
```
This would be useful for efficiently interfacing with foreign code that uses GMP.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 7.8.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries (other) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Add bindings for marshaling to/from mpz_t","status":"New","operating_system":"","component":"libraries (other)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.3","keywords":["integer-gmp"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"Please add bindings to allow efficient marshaling between Haskell Integer and C mpz_t's, e.g.:\r\n\r\n{{{\r\n -- Wraps a (struct __mpz_struct*).\r\n type Mpz = Ptr ()\r\n\r\n toMpz :: Integer -> IO Mpz\r\n fromMpz :: Mpz -> IO Integer\r\n}}}\r\n\r\nThis would be useful for efficiently interfacing with foreign code that uses GMP.","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/8666integer-gmp fails to compile on Debian Squeeze2020-04-17T09:01:06ZJan Stolarekjan.stolarek@ed.ac.ukinteger-gmp fails to compile on Debian SqueezeI get an error when compiling recent HEAD on Debian Squeeze:
```
"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -H64m -O0 -fasm -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/in...I get an error when compiling recent HEAD on Debian Squeeze:
```
"inplace/bin/ghc-stage1" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -H64m -O0 -fasm -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/. -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.3.1.0 -Wall -package-name integer-gmp -XHaskell2010 -O -fasm -no-user-package-db -rtsopts -Ilibraries/integer-gmp/mkGmpDerivedConstants/dist -odir libraries/integer-gmp/dist-install/build -hidir libraries/integer-gmp/dist-install/build -stubdir libraries/integer-gmp/dist-install/build -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-prim-0.3.1.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../rts-1.0' -optl-Wl,-zorigin libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Prim.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o libraries/integer-gmp/gmp/objs/*.o -shared -dynamic -dynload deploy -no-auto-link-packages -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so
Warning: -rtsopts and -with-rtsopts have no effect with -shared.
Call hs_init_ghc() from your main() function to set these options.
/usr/bin/ld: libraries/integer-gmp/gmp/objs/aors.o: relocation R_X86_64_32 against `__gmpz_sub' can not be used when making a shared object; recompile with -fPIC
libraries/integer-gmp/gmp/objs/aors.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so] Error 1
make: *** [all] Error 2
```
I can build in-tree `libgmp` by extracting it and running `./configure make`. Following Austin's and Herbert's suggestions I tried adding `-fPIC` to command line options but with no result - see attachements.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ----------------- |
| Version | 7.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries (other) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"integer-gmp fails to compile on Debian Squeeze","status":"New","operating_system":"","component":"libraries (other)","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I get an error when compiling recent HEAD on Debian Squeeze:\r\n\r\n{{{\r\n\"inplace/bin/ghc-stage1\" -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -H64m -O0 -fasm -package-name integer-gmp-0.5.1.0 -hide-all-packages -i -ilibraries/integer-gmp/. -ilibraries/integer-gmp/dist-install/build -ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/dist-install/build -Ilibraries/integer-gmp/dist-install/build/autogen -Ilibraries/integer-gmp/. -optP-include -optPlibraries/integer-gmp/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.3.1.0 -Wall -package-name integer-gmp -XHaskell2010 -O -fasm -no-user-package-db -rtsopts -Ilibraries/integer-gmp/mkGmpDerivedConstants/dist -odir libraries/integer-gmp/dist-install/build -hidir libraries/integer-gmp/dist-install/build -stubdir libraries/integer-gmp/dist-install/build -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-prim-0.3.1.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../rts-1.0' -optl-Wl,-zorigin libraries/integer-gmp/dist-install/build/GHC/Integer.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/GMP/Prim.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Logarithms/Internals.dyn_o libraries/integer-gmp/dist-install/build/GHC/Integer/Type.dyn_o libraries/integer-gmp/dist-install/build/cbits/gmp-wrappers.dyn_o libraries/integer-gmp/dist-install/build/cbits/cbits.dyn_o libraries/integer-gmp/gmp/objs/*.o -shared -dynamic -dynload deploy -no-auto-link-packages -o libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so\r\nWarning: -rtsopts and -with-rtsopts have no effect with -shared.\r\n Call hs_init_ghc() from your main() function to set these options.\r\n/usr/bin/ld: libraries/integer-gmp/gmp/objs/aors.o: relocation R_X86_64_32 against `__gmpz_sub' can not be used when making a shared object; recompile with -fPIC\r\nlibraries/integer-gmp/gmp/objs/aors.o: could not read symbols: Bad value\r\ncollect2: ld returned 1 exit status\r\nmake[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.5.1.0-ghc7.7.20140113.so] Error 1\r\nmake: *** [all] Error 2\r\n}}}\r\n\r\nI can build in-tree `libgmp` by extracting it and running `./configure make`. Following Austin's and Herbert's suggestions I tried adding `-fPIC` to command line options but with no result - see attachements.","type_of_failure":"OtherFailure","blocking":[]} -->Edward KmettEdward Kmetthttps://gitlab.haskell.org/ghc/ghc/-/issues/3564Drop-in replacements for integer library no longer work2020-04-17T08:58:23Zchevalier@alum.wellesley.eduDrop-in replacements for integer library no longer workI was trying to replace the integer-gmp library with integer-simple in a recent GHC tree, as described at:
http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes
Unfortunately, simply adding "INTEGER_LIBRARY=integer-simple" to the ...I was trying to replace the integer-gmp library with integer-simple in a recent GHC tree, as described at:
http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes
Unfortunately, simply adding "INTEGER_LIBRARY=integer-simple" to the build.mk no longer works, because compiler/PrelNames has a hard-wired reference to the module GHC.Integer.Internals, which integer-simple doesn't provide.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.10.4 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Drop-in replacements for integer library no longer work","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.10.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I was trying to replace the integer-gmp library with integer-simple in a recent GHC tree, as described at:\r\n\r\nhttp://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes\r\n\r\nUnfortunately, simply adding \"INTEGER_LIBRARY=integer-simple\" to the build.mk no longer works, because compiler/PrelNames has a hard-wired reference to the module GHC.Integer.Internals, which integer-simple doesn't provide.\r\n","type_of_failure":"OtherFailure","blocking":[]} -->https://gitlab.haskell.org/ghc/ghc/-/issues/17799In-tree GMP broken on x86-642020-04-13T21:57:33ZSylvain HenryIn-tree GMP broken on x86-64## Summary
GHC fails to build with in-tree GMP on x86-64 (link issue)
## Steps to reproduce
```bash
> make distclean && ./boot && ./configure --with-intree-gmp && make -j
[...]
ld.lld: error: can't create dynamic relocation R_X86_64_6...## Summary
GHC fails to build with in-tree GMP on x86-64 (link issue)
## Steps to reproduce
```bash
> make distclean && ./boot && ./configure --with-intree-gmp && make -j
[...]
ld.lld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libraries/integer-gmp/gmp/objs/mp_minv_tab.o
>>> referenced by libraries/integer-gmp/gmp/objs/bdiv_q_1.o:(__gmpn_bdiv_q_1)
ld.lld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libraries/integer-gmp/gmp/objs/mp_minv_tab.o
>>> referenced by libraries/integer-gmp/gmp/objs/dive_1.o:(__gmpn_divexact_1)
ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libraries/integer-gmp/gmp/objs/gcd_1.o
>>> referenced by libraries/integer-gmp/gmp/objs/gcd_1.o:(__gmpn_gcd_1)
ld.lld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmpn_invert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libraries/integer-gmp/gmp/objs/invert_limb_table.o
>>> referenced by libraries/integer-gmp/gmp/objs/invert_limb.o:(__gmpn_invert_limb)
ld.lld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libraries/integer-gmp/gmp/objs/mp_minv_tab.o
>>> referenced by libraries/integer-gmp/gmp/objs/mode1o.o:(__gmpn_modexact_1_odd)
collect2: erreur: ld a retourné le statut de sortie 1
`cc' failed in phase `Linker'. (Exit code: 1)
make[1]: *** [libraries/integer-gmp/ghc.mk:4: libraries/integer-gmp/dist-install/build/libHSinteger-gmp-1.0.2.0-ghc8.11.0.20200205.so] Error 1
make[1]: *** Attente des tâches non terminées....
make: *** [Makefile:128: all] Error 2
```
Related: #4366 #8156 and #4022.
## Environment
* GHC version used: HEAD
* Operating System: ArchLinux
* System Architecture: x86-64Sylvain HenrySylvain Henryhttps://gitlab.haskell.org/ghc/ghc/-/issues/17756hadrian does not correctly implement in tree gmp support2020-02-19T10:49:36ZCarter Schonwaldhadrian does not correctly implement in tree gmp support## Summary
Hadrian's intree gmp build logic only works if theres a GMP header file in one of the default search paths of the C compiler
## Steps to reproduce
build ghc using hadrian with the intree-gmp configuration, without GMP...## Summary
Hadrian's intree gmp build logic only works if theres a GMP header file in one of the default search paths of the C compiler
## Steps to reproduce
build ghc using hadrian with the intree-gmp configuration, without GMP headers in any of the default header include paths used by your GCC/CLANG/CC.
on OSX you can reproduce as follows (directions follow assume you're using brew to install libraries)
```shell
brew unlink gmp
git clean -fdx
make maintainer-clean
perl boot
./configure --with-intree-gmp # you may also add CC=(which clang) or gcc or whatever
hadrian/build.sh --flavour=quickest -j
```
## Expected behavior
ghc should build! instead we get this
```
| Run Ghc FindHsDependencies Stage1: libraries/integer-gmp/src/GHC/Integer.hs (and 4 more) => _build/stage1/libraries/integer-gmp/.dependencies.mk
libraries/integer-gmp/cbits/wrappers.c:30:3: error: #error __GNU_MP_VERSION not defined
30 | # error __GNU_MP_VERSION not defined
| ^~~~~
libraries/integer-gmp/cbits/wrappers.c:42:3: error: #error WORD_SIZE_IN_BITS != GMP_LIMB_BITS not supported
42 | # error WORD_SIZE_IN_BITS != GMP_LIMB_BITS not supported
| ^~~~~
Error when running Shake build system:
at action, called at src/Rules.hs:71:19 in main:Rules
at need, called at src/Rules.hs:93:5 in main:Rules
* Depends on: _build/stage1/lib/package.conf.d/integer-gmp-1.0.2.0.conf
at need, called at src/Rules/Register.hs:113:5 in main:Rules.Register
* Depends on: _build/stage1/libraries/integer-gmp/build/HSinteger-gmp-1.0.2.0.o
at need, called at src/Rules/Library.hs:102:5 in main:Rules.Library
* Depends on: _build/stage1/libraries/integer-gmp/build/c/cbits/wrappers.o
* Raised the exception:
user error (Development.Shake.cmd, system command failed
Command line: /usr/local/bin/gcc-9 -std=c99 -Wall -E -MM -MG -MF _build/stage1/libraries/integer-gmp/build/c/cbits/wrappers.o.d -MT _build/stage1/libraries/integer-gmp/build/c/cbits/wrappers.o -Iincludes -I_build/stage1/lib -I_build/stage1/libraries/integer-gmp/build -I_build/stage1/libraries/integer-gmp/build/include -Ilibraries/integer-gmp/include -I/Users/carter/Desktop/reposcratcher/triage-gcc-plz/_build/stage1/lib/x86_64-osx-ghc-8.11.0.20200127/rts-1.0/include -x c libraries/integer-gmp/cbits/wrappers.c -I_build/stage1/gmp/include
Exit code: 1
Stderr:
libraries/integer-gmp/cbits/wrappers.c:30:3: error: #error __GNU_MP_VERSION not defined
30 | # error __GNU_MP_VERSION not defined
| ^~~~~
libraries/integer-gmp/cbits/wrappers.c:42:3: error: #error WORD_SIZE_IN_BITS != GMP_LIMB_BITS not supported
42 | # error WORD_SIZE_IN_BITS != GMP_LIMB_BITS not supported
| ^~~~~
)
```
## Environment
* GHC version used: 8.8.1 or 8.6.5
Optional:
* Operating System: OSX
* System Architecture: AMD64
i originally reported this as https://gitlab.haskell.org/ghc/ghc/issues/17741 and friends, incorrectly :)https://gitlab.haskell.org/ghc/ghc/-/issues/8156amd64 + in-tree gmp build broken2020-02-07T13:07:19Zerrgeamd64 + in-tree gmp build brokenCurrently, 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 o...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?
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Build System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"amd64 + in-tree gmp build broken","status":"New","operating_system":"","component":"Build System","related":[],"milestone":"7.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Currently, the GHC build system has an in-tree GMP. This GMP seems to\r\nbe used only if there is no usable GMP found on the system and the\r\nuser didn't provide one using configure flags.\r\n\r\nWhen we build GHC using an external shared version of GMP, the\r\nresulting GHC is dynamically linked against GMP and also the\r\ngenerated programs are linked dynamically against GMP.\r\n\r\nWhen the in-tree GMP is used, it is built statically, even if the GHC\r\nwe are building is shared GHC on GNU/Linux. This feature is currently\r\nbroken on amd64 (#4366, #4022), but is working currently\r\nvery well on Linux i686.\r\n\r\nApart from the breakage this setting is very flexible and I'd be very\r\nhappy if it were possible to keep it, in spite of removeal requests\r\nlike #4374.\r\n\r\nWhen there is a system GMP, nothing would change, this is the most\r\ntypical usage, e.g. distributions are all building this way.\r\n\r\nOn the other hand, if the user removes his GMP (maybe we should\r\nprovide an option to explicity trigger this in ./configure, instead of\r\nhaving to remove GMP); she can build a GHC that is not linked\r\ndynamically against GMP and the resulting programs are not linked\r\neither. This makes it possible to generate binaries that link\r\ndynamically against libc (no -static) which is quite compatible\r\namongst versions, but doesn't require a libgmp.so to run. For binary\r\ndeployments this seems to be the best kind of setup nowadays.\r\n\r\nNow, if we were only able to fix this for amd64. See this:\r\nhttps://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3\r\n\r\nOn amd64 we can continue to compile GMP statically and link into the\r\nbinary library, we just have to compile GMP with the fPIC. I attached\r\nthe patch to fix this. Previously a similar patch has been rejected\r\nin #4022 because \"this shouldn't\r\nbe platform specific\", but this is clearly not the case, this is\r\nspecific to amd64.\r\n\r\nTadaaaam:\r\n{{{\r\nerrge@sid64:~/ghc/inplace/bin$ cat test.hs\r\nmain = print (2^100)\r\nerrge@sid64:~/ghc/inplace/bin$ ./ghc-stage2 test.hs\r\n[1 of 1] Compiling Main ( test.hs, test.o )\r\nLinking test ...\r\nerrge@sid64:~/ghc/inplace/bin$ ./test\r\n1267650600228229401496703205376\r\nerrge@sid64:~/ghc/inplace/bin$ ldd ./test\r\n linux-vdso.so.1 (0x00007fff79962000)\r\n libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe4b9a83000)\r\n librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe4b987a000)\r\n libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe4b9676000)\r\n libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe4b92c6000)\r\n libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe4b90a6000)\r\n /lib64/ld-linux-x86-64.so.2 (0x00007fe4b9d83000)\r\n}}}\r\n\r\nNo GMP!\r\n\r\nI attach the build file patch to the bugreport.\r\n\r\nSo, can we please apply this patch and just keep the in-tree GMP?\r\n","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1https://gitlab.haskell.org/ghc/ghc/-/issues/4366in-tree GMP build problem with shared libraries2020-02-07T13:07:19ZSimon Marlowin-tree GMP build problem with shared librariesReported by Vivian McPhail \<haskell.vivian.mcphail\@gmail.com\> on glasgow-haskell-users:
```
Trying to build rc1 from source
linux x86_64
BuildFlavour = perf
It seems that the -fPIC flag is set, but an error still occurs (
/usr/bin/...Reported by Vivian McPhail \<haskell.vivian.mcphail\@gmail.com\> on glasgow-haskell-users:
```
Trying to build rc1 from source
linux x86_64
BuildFlavour = perf
It seems that the -fPIC flag is set, but an error still occurs (
/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
)
"inplace/bin/ghc-stage1" -fPIC -dynamic -O -H64m -package-name base-4.3.0.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/autogen -Ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build/autogen -Ilibraries/base/include -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.2.0.0 -package integer-gmp-0.2.0.2 -package rts-1.0 -package-name base -XMagicHash -XExistentialQuantification -XRank2Types -XScopedTypeVariables -XUnboxedTuples -XForeignFunctionInterface -XUnliftedFFITypes -XDeriveDataTypeable -XGeneralizedNewtypeDeriving -XFlexibleInstances -XStandaloneDeriving -XPatternGuards -XEmptyDataDecls -XNoImplicitPrelude -XCPP -no-user-package-conf -rtsopts -O2 -XGenerics -fno-warn-deprecated-flags -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -c libraries/base/./Data/Typeable.hs-boot -o libraries/base/dist-install/build/Data/Typeable.dyn_o-boot
/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
libraries/integer-gmp/gmp/objs/abs.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.2-ghc7.0.0.20100924.so] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.13 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Build System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"in-tree GMP build problem with shared libraries","status":"New","operating_system":"","component":"Build System","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.13","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Reported by Vivian McPhail <haskell.vivian.mcphail@gmail.com> on glasgow-haskell-users:\r\n\r\n{{{\r\nTrying to build rc1 from source\r\n\r\nlinux x86_64\r\nBuildFlavour = perf\r\n\r\nIt seems that the -fPIC flag is set, but an error still occurs (\r\n/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC\r\n)\r\n\r\n\"inplace/bin/ghc-stage1\" -fPIC -dynamic -O -H64m -package-name base-4.3.0.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/autogen -Ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build/autogen -Ilibraries/base/include -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.2.0.0 -package integer-gmp-0.2.0.2 -package rts-1.0 -package-name base -XMagicHash -XExistentialQuantification -XRank2Types -XScopedTypeVariables -XUnboxedTuples -XForeignFunctionInterface -XUnliftedFFITypes -XDeriveDataTypeable -XGeneralizedNewtypeDeriving -XFlexibleInstances -XStandaloneDeriving -XPatternGuards -XEmptyDataDecls -XNoImplicitPrelude -XCPP -no-user-package-conf -rtsopts -O2 -XGenerics -fno-warn-deprecated-flags -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -c libraries/base/./Data/Typeable.hs-boot -o libraries/base/dist-install/build/Data/Typeable.dyn_o-boot\r\n/usr/bin/ld: libraries/integer-gmp/gmp/objs/abs.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC\r\nlibraries/integer-gmp/gmp/objs/abs.o: could not read symbols: Bad value\r\ncollect2: ld returned 1 exit status\r\nmake[1]: *** [libraries/integer-gmp/dist-install/build/libHSinteger-gmp-0.2.0.2-ghc7.0.0.20100924.so] Error 1\r\nmake[1]: *** Waiting for unfinished jobs....\r\nmake: *** [all] Error 2\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/17046Hadrian doesn't seem to handle integer-simple properly2019-11-27T15:23:10ZJavier SagredoHadrian doesn't seem to handle integer-simple properly## Summary
When trying to build ghc-8.8.1-rc1 branch using Hadrian and requesting to use the `integer-simple` library, the flags don't get properly propagated. To be precise, the library `text` can't build because it gets `-optP-DINTEGE...## Summary
When trying to build ghc-8.8.1-rc1 branch using Hadrian and requesting to use the `integer-simple` library, the flags don't get properly propagated. To be precise, the library `text` can't build because it gets `-optP-DINTEGER_GMP` as a flag.
## Steps to reproduce
Redefine `userFlavour` in `hadrian/src/UserSettings.hs`:
```
userFlavour :: Flavour
userFlavour = defaultFlavour { name = "simple", integerLibrary = pure integerSimple }
```
and then:
```
./hadrian/build.sh -c -j --flavour=simple
```
And while building, this error arises:
```
Command line: /usr/local/bin/ghc -M -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db _build/stage0/lib/package.conf.d' '-this-unit-id text-1.2.3.1' '-package-id array-0.5.3.0' '-package-id base-4.12.0.0' '-package-id binary-0.8.7.0' '-package-id bytestring-0.10.8.2' '-package-id deepseq-1.4.4.0' '-package-id ghc-prim-0.5.3' '-package-id integer-simple-0.1.1.1' -i -i_build/stage0/libraries/text/build -i_build/stage0/libraries/text/build/autogen -ilibraries/text/. -I_build/generated -I_build/stage0/libraries/text/build -I_build/stage0/libraries/text/build/include -Ilibraries/text/include -I/usr/local/lib/ghc-8.6.5/bytestring-0.10.8.2/include -I/usr/local/lib/ghc-8.6.5/base-4.12.0.0/include -I/usr/local/lib/ghc-8.6.5/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage0/libraries/text/build/autogen/cabal_macros.h -optP-DINTEGER_GMP -outputdir _build/stage0/libraries/text/build -include-pkg-deps -dep-makefile _build/stage0/libraries/text/.dependencies.mk -dep-suffix '' libraries/text/Data/Text.hs libraries/text/Data/Text/Array.hs libraries/text/Data/Text/Encoding.hs libraries/text/Data/Text/Encoding/Error.hs libraries/text/Data/Text/Foreign.hs libraries/text/Data/Text/IO.hs libraries/text/Data/Text/Internal.hs libraries/text/Data/Text/Internal/Builder.hs libraries/text/Data/Text/Internal/Builder/Functions.hs libraries/text/Data/Text/Internal/Builder/Int/Digits.hs libraries/text/Data/Text/Internal/Builder/RealFloat/Functions.hs libraries/text/Data/Text/Internal/Encoding/Fusion.hs libraries/text/Data/Text/Internal/Encoding/Fusion/Common.hs libraries/text/Data/Text/Internal/Encoding/Utf16.hs libraries/text/Data/Text/Internal/Encoding/Utf32.hs libraries/text/Data/Text/Internal/Encoding/Utf8.hs libraries/text/Data/Text/Internal/Functions.hs libraries/text/Data/Text/Internal/Fusion.hs libraries/text/Data/Text/Internal/Fusion/CaseMapping.hs libraries/text/Data/Text/Internal/Fusion/Common.hs libraries/text/Data/Text/Internal/Fusion/Size.hs libraries/text/Data/Text/Internal/Fusion/Types.hs libraries/text/Data/Text/Internal/IO.hs libraries/text/Data/Text/Internal/Lazy.hs libraries/text/Data/Text/Internal/Lazy/Encoding/Fusion.hs libraries/text/Data/Text/Internal/Lazy/Fusion.hs libraries/text/Data/Text/Internal/Lazy/Search.hs libraries/text/Data/Text/Internal/Private.hs libraries/text/Data/Text/Internal/Read.hs libraries/text/Data/Text/Internal/Search.hs libraries/text/Data/Text/Internal/Unsafe.hs libraries/text/Data/Text/Internal/Unsafe/Char.hs libraries/text/Data/Text/Internal/Unsafe/Shift.hs libraries/text/Data/Text/Lazy.hs libraries/text/Data/Text/Lazy/Builder.hs libraries/text/Data/Text/Lazy/Builder/Int.hs libraries/text/Data/Text/Lazy/Builder/RealFloat.hs libraries/text/Data/Text/Lazy/Encoding.hs libraries/text/Data/Text/Lazy/IO.hs libraries/text/Data/Text/Lazy/Internal.hs libraries/text/Data/Text/Lazy/Read.hs libraries/text/Data/Text/Read.hs libraries/text/Data/Text/Show.hs libraries/text/Data/Text/Unsafe.hs -O -H32m -Wall -fwarn-tabs -funbox-strict-fields -O2 -XHaskell98 -fno-warn-deprecated-flags
Exit code: 1
Stderr:
libraries/text/Data/Text/Lazy/Builder/Int.hs:40:8: error:
Could not find module ‘GHC.Integer.GMP.Internals’
Perhaps you meant
GHC.Integer.Simple.Internals (from integer-simple-0.1.1.1)
Use -v to see a list of the files searched for.
|
40 | import GHC.Integer.GMP.Internals (Integer(S#))
| ^^^^^^^^^^^^^^^^^^^^^^^^^
```
The flag `-optP-DINTEGER_GMP` is being passed to the library and this shouldn't be the case.
## Expected behavior
I would expect the libraries to build without issues.
## Environment
* GHC version used:
```
> cabal --version
cabal-install version 2.4.0.0
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
```
* Operating System: Ubuntu 19.048.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/1605hppa port -- gmp handed misaligned memory2019-07-07T19:12:39Zguesthppa port -- gmp handed misaligned memoryGMP compiled for hppa 2.0n uses 8 byte data by default. hppa \*requires\* that 8 byte data be aligned on an 8 byte boundary. However GHC only aligns allocated memory to a 4 byte boundary. This causes GHC to crash. Currently the workaroun...GMP compiled for hppa 2.0n uses 8 byte data by default. hppa \*requires\* that 8 byte data be aligned on an 8 byte boundary. However GHC only aligns allocated memory to a 4 byte boundary. This causes GHC to crash. Currently the workaround is to recompile GMP to use 32 bit data, but this is probably a performance hit.
Joe Buehler
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------- |
| Version | 6.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"hppa port -- gmp handed misaligned memory","status":"New","operating_system":"","component":"Runtime System","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.6.1","keywords":["GMP"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"GMP compiled for hppa 2.0n uses 8 byte data by default. hppa *requires* that 8 byte data be aligned on an 8 byte boundary. However GHC only aligns allocated memory to a 4 byte boundary. This causes GHC to crash. Currently the workaround is to recompile GMP to use 32 bit data, but this is probably a performance hit.\r\n\r\nJoe Buehler","type_of_failure":"OtherFailure","blocking":[]} -->7.6.2https://gitlab.haskell.org/ghc/ghc/-/issues/1848Binary distributions don't install gmp2019-07-07T19:11:27ZSimon MarlowBinary distributions don't install gmpManuel Chakravarty writes:
Unfortunately, make binary-dist is broken in the HEAD and the 6.8 branch for systems without a pre-installed gmp library. The reason is that distrib/Makefile lacks code that installs the embedded gmp. For the ...Manuel Chakravarty writes:
Unfortunately, make binary-dist is broken in the HEAD and the 6.8 branch for systems without a pre-installed gmp library. The reason is that distrib/Makefile lacks code that installs the embedded gmp. For the Mac OS X 10.5 binary distribution that I just announced on the GHC users list, I patched the Makefile with the attached patch. However, I am not sure whether that's the best/intended way of doing this. (Just invoking `gmp/Makefile` doesn't work, but it might be nice to fix that instead of inlining the GMP install in the toplevel Makefile.)
What's the Right Thing to do here?
Manuel
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Build System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Binary distributions don't install gmp","status":"New","operating_system":"Unknown","component":"Build System","related":[],"milestone":"6.8.2","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.1","keywords":["gmp"],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"Manuel Chakravarty writes:\r\n\r\nUnfortunately, make binary-dist is broken in the HEAD and the 6.8 branch for systems without a pre-installed gmp library. The reason is that distrib/Makefile lacks code that installs the embedded gmp. For the Mac OS X 10.5 binary distribution that I just announced on the GHC users list, I patched the Makefile with the attached patch. However, I am not sure whether that's the best/intended way of doing this. (Just invoking `gmp/Makefile` doesn't work, but it might be nice to fix that instead of inlining the GMP install in the toplevel Makefile.)\r\n\r\nWhat's the Right Thing to do here?\r\n\r\nManuel","type_of_failure":"OtherFailure","blocking":[]} -->6.8.2Ian Lynagh <igloo@earth.li>Ian Lynagh <igloo@earth.li>https://gitlab.haskell.org/ghc/ghc/-/issues/3350GHC doesn't compile on Mac OS X 10.4 (Tiger) via MacPorts2019-07-07T19:04:17ZindilGHC doesn't compile on Mac OS X 10.4 (Tiger) via MacPortsExecuted "sudo port install ghc". Began installing version 6.10.3. Got this error:
```
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: can't locate file for: -lgmp
collect2: ld returned 1 exit status
linking dist-stage1/build/Fingerprint_...Executed "sudo port install ghc". Began installing version 6.10.3. Got this error:
```
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: can't locate file for: -lgmp
collect2: ld returned 1 exit status
linking dist-stage1/build/Fingerprint_hsc_make.o failed
command was: /usr/bin/gcc -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-bootstrap/lib/ghc-6.6 -lHSunix_cbits -ldl -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-6.10.3/libraries/hpc/dist-bootstrapping/build -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-bootstrap/lib/ghc-6.6 -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-6.10.3/libraries/extensible-exceptions/dist-bootstrapping/build -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-6.10.3/libraries/Cabal/dist-bootstrapping/build -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-6.10.3/libraries/filepath/dist-bootstrapping/build -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-bootstrap/lib/ghc-6.6 -lHSbase_cbits -L/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_ghc/work/ghc-bootstrap/lib/ghc-6.6 -lm -lgmp -ldl dist-stage1/build/Fingerprint_hsc_make.o -o dist-stage1/build/Fingerprint_hsc_make
make[1]: *** [boot.stage.1] Error 1
make: *** [stage1] Error 1
```
I checked, and gmp is installed. I tried uninstalling it, cleaning it, and reinstalling it, and I also tried cleaning ghc, but I get the same error when trying to install ghc again.6.12.1