summaryrefslogtreecommitdiff
path: root/dev-lang/ghc
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/ghc')
-rw-r--r--dev-lang/ghc/Manifest8
-rw-r--r--dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch12
-rw-r--r--dev-lang/ghc/files/ghc-9.2.6-fix-alignment-of-capability.patch249
-rw-r--r--dev-lang/ghc/files/ghc-9.2.7-modorigin-semigroup.patch33
-rw-r--r--dev-lang/ghc/ghc-9.2.8.ebuild975
5 files changed, 1277 insertions, 0 deletions
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
index a6f5615dda70..4fd880427dd1 100644
--- a/dev-lang/ghc/Manifest
+++ b/dev-lang/ghc/Manifest
@@ -9,17 +9,25 @@ AUX ghc-9.0.2-llvm-13.patch 988 BLAKE2B dee0a02ffb7b79981981615e7933f5ba3348f700
AUX ghc-9.0.2-llvm-14.patch 487 BLAKE2B 884dc20e80bd5a0ec9c85833253ca48816e3cf719854ddb58d67cc11fb2eb4583d7b76f93977ccaa28dcbb3fa5ca416122b92f1e486f17529f7c46ac8e659ea0 SHA512 8cf67272181f507ed4263fdb4fb26bf5f1f1b9359ab4e1158af50ab89a82d37cc632873124700034805ae62eaa12efcfbe74a99ee16cbc1b5c653025b8333a8c
AUX ghc-9.0.2-modorigin-semigroup.patch 1210 BLAKE2B e29917dd740bded98257366ca37d3ac8fdc8ffd0e988e6286b8cf21fb9f0232ce1584a1a22665f4afad36e5585c29091040cac16b1204022f5a5f3328420c4ff SHA512 dc54fb02dfed55f5a9309c61ec23859ad4f80fd271fe0ccb41b786fc7d44bc0d9722069e2f56731c6af5ad1703c5081ba9e4b4e683911af4ad9b498f53b67a5e
AUX ghc-9.0.2-sphinx-6.patch 1560 BLAKE2B 60cf463ecd2b0b3677b6f9b171c2b71b59d31d563c70461ed96b276bd831ca722419ad802a6c58851c3cc83eb4e229bbb53dee02e227c41751985834597b08a4 SHA512 89ed630b3d35d4f6fe73e66ff622c63bac35688cdcae4b82e8ff1c1bc069df0897d0744dec9f57a386ca07b8b1fcbdc38b8ad7773f8629718473479afd61eec0
+AUX ghc-9.0.2-verbose-modunusable.patch 572 BLAKE2B 425b5cea58690a8856ee8f7054263dc65c40badedc88c819e7de0b466cac4e87246e03555b39823e5886a5ca28ac26f64d56cec1bf0b0654294ff61c9679bb2d SHA512 b84e459b12815d7fd42b87ecca95514e0f2f8132c53299f6e289efc4c47d618e49f19795249e1a9a328baa270a92b018184e6e9eb05062c01355ce06fd76b9e9
+AUX ghc-9.2.6-fix-alignment-of-capability.patch 8129 BLAKE2B 9e4aad6586736fbe4967a01b386c1bc4fc6361406b457bfe40eb93bce7831ad2992967b3072f1452b569a71ab0b2b234a20e7c71d6d193eadd66acbc0629fdcd SHA512 b1ca93d1e92edfccd64c1a3c04a2fd0157a02bf2cbbf80abf9230dd7dd7d45c4c2c6ceab23d0b1b74c04d55ce4afd090db9d3e2c1f16340271eaeb321f0445b8
+AUX ghc-9.2.7-modorigin-semigroup.patch 1283 BLAKE2B 55f6d1f134bd7c502780af3036dfbe525c6e7b720323e0d2404318cff7d39ca5ac8da20d7d715fea5f40594fe43588004145deda9ce1e24154e791be7ef6569c SHA512 7278526611ec45d6ba0048e713565ef68aff3730bb7274ce9f6b8c6cc9095bbba0416100fb5567dee49861abd55b52b8d0084b89494acc69de3cd12a5cfe95d2
AUX ghc-bash-completion 6496 BLAKE2B dc94a1979e886026a2fbe04bf7b45718ffa3e025a0e8945262e21a1243bfce6517fa1794f2ba6cd54cc853e93ad5d80472b9019b95762f10b5be83634a479955 SHA512 ede79ccf23555f60f48297d29bd98e3ccfd67d2cf27462153e00beb930398cb497e34ba8316e91df44c577ed11fdbe5606f7c6a2777e35d5e783590e49ccfeb5
AUX latomic-subword 2886 BLAKE2B 97c6fb8d055e2ae4abf366f9f0e255588ca2f61f189d9356c5d0e6ff0dd7e7f10676469c72c02d1bd1bc10e5329bc31056670d2ddf03d6e65ae3ff1a5b4cb561 SHA512 8e7e261211ce4cc9baf855ca7b9a289b07fdda27b9738434c42374f9381429fa5798fd15f9cfeb50cc17839a8b8d3634653b72dc8ae9bb5970cf88d35553516c
DIST ghc-9.0.2-riscv64-llvm.patch.xz 7148 BLAKE2B 01a0d4036b649f663aebebab06990ac041533e7462d3ee9e143444f1119b736f2f8f2dfc293d61da1fac9f0d3ef12e98bab5b0c9fe8440ed1eab22a1d45fb9d7 SHA512 8afb62d5363d8a1a8f63e85335f3c8fa35b7d22899ebe334218a60ce9519852325c8ce93bb0be794c36cbc3c1cc031b7b1e2f4d7665d71f49e95f737bd91ba1a
DIST ghc-9.0.2-src.tar.xz 27270396 BLAKE2B 0a73d910d3ef11161f895849025fe37ce231932f7cde441fdf620cf8c51678060a804467879eb0ee5c0a30413604c56e28e2aa1cde01e45c620b76987d9c0c0e SHA512 32994c7d2b8f47bae604cd825bfcf9c788d79ce26d1d5f58bd73a7093e11ae6c3c17b31dc0c9e454dbf67ca169b942f92213c388d615768cae86055bf6094dee
DIST ghc-9.0.2-testsuite.tar.xz 2403564 BLAKE2B 0e7f6fefb9c972f94073aca8b15147913ffa8d3cd3ff7fc63ef7e20b4efd8b443cf21f12e1ab0f5044790f6d8af6cf7788bda85a21b2f356ddface86eb896670 SHA512 b2375500ae837d74af8085d099899b5a7a589c59bdcc033ca0bd6e00f33c4f8d90b481e0c7c3de113e607fcfafdfe8edde4713e6d242b2d4ee87df2eb960c9c7
+DIST ghc-9.2.8-src.tar.xz 24661260 BLAKE2B 5011eed2a86fea607d2f47d92c5884fcd0850037158659273af07ca1b65ad78d500f0cfbfff8f412d4e1f8f5de8e89e0b6146797a7ca0696cc42d71ddc75ef56 SHA512 c1159741725deaa00be7c230b38d43aed0fd456621fb4bc434434f13b03b74da1f91c09ce5dad553cf535f14038d8568fce7f21ea068680211b8bd35eafacf49
+DIST ghc-9.2.8-testsuite.tar.xz 3213812 BLAKE2B 2607ffa0f7b0bc3d0cbcba6726f016c43b79ac9c7479c71a94ae9f7adb3f1b913df30a35ff093777a52ba9213390bf4f9f40fc366f3be9acc48c4ef2b47ca172 SHA512 7ae455b009191167d73ca0990edd0b45d162de3c43d0e43cbb7008c673ddbfc1aa252ff8589af45026508941ea144138d3b2a0436e8bf64417e64b34fb272997
DIST ghc-bin-9.0.2-r4-aarch64-unknown-linux-gnu.tar.gz 221699967 BLAKE2B c6e34b23a9664b6dc7d13f939063c34665c558b2596e3446abd9a8f90e9ad586f515e1703c36d269f7fb4a36a85f497e9f4d356f01ede7a7a614b3cd4fbf0dbe SHA512 d9f381b417ee740c9bba9508d5ccca2a6bffdd32c6262d76f254a21cf7505d2aaa5695c0354ee9e8fb672b90ae67af6205cdd2fe6ad6aa5d610c760d59392b62
DIST ghc-bin-9.0.2-r4-i686-pc-linux-gnu.gpkg.tar 81059840 BLAKE2B 655405cd402cc7af424baf5b715f64af3ce97d474c883c618cd8e6fae40274dc6f584872c607cbe3553141a199729df98ddbdb5947a50520b67f53946f20d25a SHA512 401ab9ae646e18519ba1b06705944862d3f802068c4eae19fc019899eb14ceef95fa57e51b5527e5c5314c2433aff7e418e1d35c2de425c142c34e8fa21a5f46
DIST ghc-bin-9.0.2-r4-powerpc64-unknown-linux-gnu.tar.gz 233834058 BLAKE2B 32ee779c4567472799f985102cdf0a6a5dfb3984795b6efafe6a6326933e1d0128260012cbe5e0e20c71becd4d2e589e32f43882e66b479ef4c34358d7bd8e93 SHA512 be56a92c2f5f00f1f0b22f02745d836ac3706fc207932c71277c1076515ed4fd1875372844b4cbb0996afec5fc122255103ac03c65c99d087615005f1aa63732
DIST ghc-bin-9.0.2-r4-powerpc64le-unknown-linux-gnu.tar.gz 210668658 BLAKE2B fe33a43ea38e5fe17a003e60f29458f0dc5115f92db311dff11b2ce3fa1a9fc0304ad93c76535fb8e4ce44bb703f8a18638149f36b076c84f5c44385486722bd SHA512 12e04c29873ddd80ff259998121b3ce4b9dcdd1157cbb38ce8ac0234c6aaa0c156b0cc78f95af86288e6f595f9e010a1db88ba737e27773b404ed6129e58044f
DIST ghc-bin-9.0.2-r4-riscv64-unknown-linux-gnu.tar.gz 315182159 BLAKE2B 95ee2f82eb706b42a0a3303038cf28166ac1e766a5f38402f833830c311f02773881b5341d6d7a1772fdc616522b1448a740caf34e4e534b5d00fedeb23604de SHA512 dd143f8b379e8ca04ab6254aa19978a3a8caf61322e2e3b2bae7488025949845aa5d5fc0e3124ff360172c2b47e4a33df4d1d55c8a976c96b552cd3c930b2fad
DIST ghc-bin-9.0.2-r4-x86_64-pc-linux-gnu.gpkg.tar 123955200 BLAKE2B b1f45eea658f496997e63c21e3ef190749c122ee3a058d5f25fd90a2e2c33841817c540b9bf87e27e6981d9fb28d9201454217fa8ba9c1d9fc4ccf3d20652158 SHA512 06a240f7117f30179073e075634510d9ffe880010de16c93a001dce7b3020666b0b26d51c2c08cdaee7fc6513d9ffc7082f20b233d62b9149419abba2b4bd4ee
+DIST ghc-bin-9.2.8-i686-pc-linux-gnu.gpkg.tar 105441280 BLAKE2B 76d5fdb846d91d37b0b5706f1efbdd2833aac2d926fb4036845e36470fcfc6ad0143c492908c6cc5190dc3951c647e0584956395fca51b8f357b365ad23b496a SHA512 c19819bc4d8f1208fa28acc054cbb2d490b2b1c55bf55f8d4069474b4d58c931ff1999b593000b7f0b5b7169e6b71ad26d5d0d3480d8ecdbcc5e2c58116ec3d5
+DIST ghc-bin-9.2.8-x86_64-pc-linux-gnu.gpkg.tar 85432320 BLAKE2B ab649a6da5120720fc388dc98685a796415f7e2d664de17887f5bdadf5c9fe6192c4a6ac1bdbbe6e635ebf77b56e1f195367444e6febe01db32e38897dad5cb9 SHA512 fb868c87714aae791b4c19eaf3780707000ff61b240daebbfe2331d5e992dd20376060239df9aaf3daa54266eb10ad7a365804a09a5f6e9b1f5ee80717a16a17
DIST process-1.6.16.0.tar.gz 87354 BLAKE2B 8c2977d6801faef8825ed35f058a6207a518f72eb87ac3144f630bc028f4753cefb9ed4d3fc29185438bcb4f38d33f5a45aebec6a8101e4cdc1b3570ada2e5dc SHA512 1663f2746a05a5a4c29d249db54eaa49edbbadfe8d189eab02276c3f6f3d6b84c81cc4333318c42c7a7265638402cb13276f08aeea134a7f5dd98da050a34341
EBUILD ghc-9.0.2-r4.ebuild 30923 BLAKE2B 3c14d5e3911bb7c2dc23bc8759b55b6131a486ace796eaa7695f60eb8b31dd61334c5ee8f616e2ecb67f114becfb9126b547d251a7d7695161e88321b9c12c28 SHA512 b74b690bf17e7ed765ec606771f967ac62f93311b380ad602f52fdae18c2ebc7b88f2a7b8186d32ca9e74f39f025ae4764b5e5ddd7b2e240f69f16660648cdc2
+EBUILD ghc-9.2.8.ebuild 32019 BLAKE2B c1810f5913e1c3c1ed9d2c00082f03af75d1e01c509e3181162322a5e4d36cd6780eeb88dbb49049f03e62e5d50a85f1c1e943945ac9ff5484ab574cb17d6ac6 SHA512 c026aa11bb1dc93d3801a8087b7ff2efa4f24923f6d39269f69b2ac5b240d13f7ef5a831bb069d8070656003b33665257a51761b73638d39cb7f44d128272d1f
MISC metadata.xml 1172 BLAKE2B 88b5e4af0e8c0e3335185f2c5469837a43ee87e6fc598242f29aced9bb8a3c330139978c564eb4ca503101934917e8406e9400dffd2eeaf7cd9983e8dc96105e SHA512 b03bb932efa54be0d55be591850064fcc967c8d77afdded255be91794544d47bdbbbd2959103cb739f6ec57b8571a955352e965ee1540a9854235a963b218bd3
diff --git a/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch b/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch
new file mode 100644
index 000000000000..13d12efdc0ec
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.0.2-verbose-modunusable.patch
@@ -0,0 +1,12 @@
+diff -urN ghc-9.0.2/compiler/GHC/Unit/State.hs ghc-9.0.2-r1/compiler/GHC/Unit/State.hs
+--- ghc-9.0.2/compiler/GHC/Unit/State.hs 2021-10-19 05:20:00.000000000 -0600
++++ ghc-9.0.2-r1/compiler/GHC/Unit/State.hs 2022-02-17 01:04:05.117930250 -0700
+@@ -194,7 +194,7 @@
+
+ instance Outputable ModuleOrigin where
+ ppr ModHidden = text "hidden module"
+- ppr (ModUnusable _) = text "unusable module"
++ ppr (ModUnusable reason) = text "unusable module" $$ ppr reason
+ ppr (ModOrigin e res rhs f) = sep (punctuate comma (
+ (case e of
+ Nothing -> []
diff --git a/dev-lang/ghc/files/ghc-9.2.6-fix-alignment-of-capability.patch b/dev-lang/ghc/files/ghc-9.2.6-fix-alignment-of-capability.patch
new file mode 100644
index 000000000000..88fdac8d7eb8
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.2.6-fix-alignment-of-capability.patch
@@ -0,0 +1,249 @@
+From 406d485eb5b055ec428fc189a2724c010ff90a8c Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@well-typed.com>
+Date: Tue, 17 Jan 2023 19:45:34 +0000
+Subject: [PATCH 1/5] rts: Use C11-compliant static assertion syntax
+
+Previously we used `static_assert` which is only available in C23. By
+contrast, C11 only provides `_Static_assert`.
+
+Fixes #22777
+---
+ includes/Rts.h | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/includes/Rts.h b/includes/Rts.h
+index b2c74fcfc17..096da7e5139 100644
+--- a/includes/Rts.h
++++ b/includes/Rts.h
+@@ -29,6 +29,9 @@ extern "C" {
+ #include <windows.h>
+ #endif
+
++/* For _Static_assert */
++#include <assert.h>
++
+ #if !defined(IN_STG_CODE)
+ #define IN_STG_CODE 0
+ #endif
+@@ -147,9 +150,17 @@ void _warnFail(const char *filename, unsigned int linenum);
+ #define ASSERTM(predicate,msg,...) CHECKM(predicate,msg,##__VA_ARGS__)
+ #define WARN(predicate) CHECKWARN(predicate)
+ #undef ASSERTS_ENABLED
+-
+ #endif /* DEBUG */
+
++#if __STDC_VERSION__ >= 201112L
++// `_Static_assert` is provided by C11 but is deprecated and replaced by
++// `static_assert` in C23. Perhaps some day we should instead use the latter.
++// See #22777.
++#define GHC_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
++#else
++#define GHC_STATIC_ASSERT(x, msg)
++#endif
++
+ /*
+ * Use this on the RHS of macros which expand to nothing
+ * to make sure that the macro can be used in a context which
+--
+GitLab
+
+
+From 489215f094ac077619bd13fb6e2a756c26648a34 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Mon, 13 Feb 2023 13:13:05 -0500
+Subject: [PATCH 2/5] rts: Statically assert alignment of Capability
+
+In #22965 we noticed that changes in the size of `Capability` can result
+in unsound behavior due to the `align` pragma claiming an alignment
+which we don't in practice observe. Avoid this by statically asserting
+that the size is a multiple of the alignment.
+
+(cherry picked from commit b585225be9670de1a83e0bb17034d2fb821cb8a3)
+---
+ rts/Capability.h | 24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/rts/Capability.h b/rts/Capability.h
+index d7c1916ad7d..34695b0b13e 100644
+--- a/rts/Capability.h
++++ b/rts/Capability.h
+@@ -27,6 +27,16 @@
+
+ #include "BeginPrivate.h"
+
++// We never want a Capability to overlap a cache line with
++// anything else, so round it up to a cache line size:
++#if defined(s390x_HOST_ARCH)
++#define CAPABILITY_ALIGNMENT 256
++#elif !defined(mingw32_HOST_OS)
++#define CAPABILITY_ALIGNMENT 64
++#else
++#define CAPABILITY_ALIGNMENT 1
++#endif
++
+ /* N.B. This must be consistent with CapabilityPublic in RtsAPI.h */
+ struct Capability_ {
+ // State required by the STG virtual machine when running Haskell
+@@ -172,14 +182,12 @@ struct Capability_ {
+ StgTRecHeader *free_trec_headers;
+ uint32_t transaction_tokens;
+ } // typedef Capability is defined in RtsAPI.h
+- // We never want a Capability to overlap a cache line with anything
+- // else, so round it up to a cache line size:
+-#if defined(s390x_HOST_ARCH)
+- ATTRIBUTE_ALIGNED(256)
+-#elif !defined(mingw32_HOST_OS)
+- ATTRIBUTE_ALIGNED(64)
+-#endif
+- ;
++ ATTRIBUTE_ALIGNED(CAPABILITY_ALIGNMENT)
++;
++
++// We allocate arrays of Capabilities therefore we must ensure that the size is
++// a multiple of the claimed alignment
++GHC_STATIC_ASSERT(sizeof(struct Capability_) % CAPABILITY_ALIGNMENT == 0, "Capability size does not match cache size");
+
+ #if defined(THREADED_RTS)
+ #define ASSERT_TASK_ID(task) ASSERT(task->id == osThreadId())
+--
+GitLab
+
+
+From 66f7ee57ce17d2fd96d74c6c4498d4f558815a0d Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Mon, 13 Feb 2023 13:21:11 -0500
+Subject: [PATCH 3/5] rts: Fix alignment of Capability
+
+---
+ rts/Capability.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/rts/Capability.h b/rts/Capability.h
+index 34695b0b13e..c0a058a3e71 100644
+--- a/rts/Capability.h
++++ b/rts/Capability.h
+@@ -181,6 +181,9 @@ struct Capability_ {
+ StgTRecChunk *free_trec_chunks;
+ StgTRecHeader *free_trec_headers;
+ uint32_t transaction_tokens;
++
++ // To ensure that size is multiple of CAPABILITY_ALIGNMENT.
++ StgWord _padding[0];
+ } // typedef Capability is defined in RtsAPI.h
+ ATTRIBUTE_ALIGNED(CAPABILITY_ALIGNMENT)
+ ;
+--
+GitLab
+
+
+From 1332f1f428e71cec02feb39b714b37c3ad0aa857 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Mon, 13 Feb 2023 14:46:24 -0500
+Subject: [PATCH 4/5] rts: Introduce stgMallocAlignedBytes
+
+(cherry picked from commit 04336d2f11e49f7d00392f05d4fd48abdd231fc0)
+---
+ rts/RtsUtils.c | 37 ++++++++++++++++++++++++++++++++++++-
+ rts/RtsUtils.h | 2 ++
+ 2 files changed, 38 insertions(+), 1 deletion(-)
+
+diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
+index ca01bdb6e0c..439e54e2d7a 100644
+--- a/rts/RtsUtils.c
++++ b/rts/RtsUtils.c
+@@ -58,10 +58,45 @@ extern char *ctime_r(const time_t *, char *);
+
+ void *
+ stgMallocBytes (size_t n, char *msg)
++{
++ void *space = malloc(n);
++
++ if (space == NULL) {
++ /* Quoting POSIX.1-2008 (which says more or less the same as ISO C99):
++ *
++ * "Upon successful completion with size not equal to 0, malloc() shall
++ * return a pointer to the allocated space. If size is 0, either a null
++ * pointer or a unique pointer that can be successfully passed to free()
++ * shall be returned. Otherwise, it shall return a null pointer and set
++ * errno to indicate the error."
++ *
++ * Consequently, a NULL pointer being returned by `malloc()` for a 0-size
++ * allocation is *not* to be considered an error.
++ */
++ if (n == 0) return NULL;
++
++ /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
++ rtsConfig.mallocFailHook((W_) n, msg);
++ stg_exit(EXIT_INTERNAL_ERROR);
++ }
++ IF_DEBUG(zero_on_gc, memset(space, 0xbb, n));
++ return space;
++}
++
++void *
++stgMallocAlignedBytes (size_t n, size_t align, char *msg)
+ {
+ void *space;
+
+- if ((space = malloc(n)) == NULL) {
++#if defined(mingw32_HOST_OS)
++ space = _aligned_malloc(n, align);
++#else
++ if (posix_memalign(&space, align, n)) {
++ space = NULL; // Allocation failed
++ }
++#endif
++
++ if (space == NULL) {
+ /* Quoting POSIX.1-2008 (which says more or less the same as ISO C99):
+ *
+ * "Upon successful completion with size not equal to 0, malloc() shall
+diff --git a/rts/RtsUtils.h b/rts/RtsUtils.h
+index c87aedb3a74..3f4b558651c 100644
+--- a/rts/RtsUtils.h
++++ b/rts/RtsUtils.h
+@@ -20,6 +20,8 @@ void shutdownAllocator(void);
+ void *stgMallocBytes(size_t n, char *msg)
+ GNUC3_ATTRIBUTE(__malloc__);
+
++void *stgMallocAlignedBytes(size_t n, size_t align, char *msg);
++
+ void *stgReallocBytes(void *p, size_t n, char *msg);
+
+ void *stgCallocBytes(size_t count, size_t size, char *msg)
+--
+GitLab
+
+
+From 1741fd255842706a9f15c95cd8c1c6b7784c50ce Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Mon, 13 Feb 2023 14:49:52 -0500
+Subject: [PATCH 5/5] rts: Correctly align Capability allocations
+
+Previously we failed to tell the C allocator that `Capability`s needed
+to be aligned, resulting in #22965.
+
+(cherry picked from commit 4af27feabf482cf6b611951443e05ee7e53acb39)
+---
+ rts/Capability.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/rts/Capability.c b/rts/Capability.c
+index edf6a926902..971c1cef834 100644
+--- a/rts/Capability.c
++++ b/rts/Capability.c
+@@ -439,8 +439,9 @@ moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS)
+ if (i < from) {
+ new_capabilities[i] = capabilities[i];
+ } else {
+- new_capabilities[i] = stgMallocBytes(sizeof(Capability),
+- "moreCapabilities");
++ new_capabilities[i] = stgMallocAlignedBytes(sizeof(Capability),
++ CAPABILITY_ALIGNMENT,
++ "moreCapabilities");
+ initCapability(new_capabilities[i], i);
+ }
+ }
+--
+GitLab
+
diff --git a/dev-lang/ghc/files/ghc-9.2.7-modorigin-semigroup.patch b/dev-lang/ghc/files/ghc-9.2.7-modorigin-semigroup.patch
new file mode 100644
index 000000000000..8028ab39cc9c
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.2.7-modorigin-semigroup.patch
@@ -0,0 +1,33 @@
+From 46b7ac7b8aca68d143eec5837ef1ff24d3d1f422 Mon Sep 17 00:00:00 2001
+From: Sylvain Henry <sylvain@haskus.fr>
+Date: Fri, 18 Feb 2022 11:01:04 +0100
+Subject: [PATCH] Quick and dirty fix for ModuleOrigin SemiGroup instance
+
+Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/1250#issuecomment-1044257595
+Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/21097
+Signed-off-by: hololeap <hololeap@users.noreply.github.com>
+---
+ compiler/GHC/Unit/State.hs | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
+index 9a95447e73..08ea0f3eb3 100644
+--- a/compiler/GHC/Unit/State.hs
++++ b/compiler/GHC/Unit/State.hs
+@@ -235,6 +235,13 @@ instance Semigroup ModuleOrigin where
+ text "x: " <> ppr x $$ text "y: " <> ppr y
+ g Nothing x = x
+ g x Nothing = x
++ ModHidden <> ModHidden = ModHidden
++ ModUnusable x <> ModUnusable _y = ModUnusable x
++
++ ModUnusable _ <> ModHidden = ModHidden
++ ModHidden <> ModUnusable _ = ModHidden
++ ModUnusable _x <> y@ModOrigin{} = y
++ x@ModOrigin{} <> ModUnusable _y = x
+ x <> y = pprPanic "ModOrigin: hidden module redefined" $
+ text "x: " <> ppr x $$ text "y: " <> ppr y
+
+--
+2.39.2
+
diff --git a/dev-lang/ghc/ghc-9.2.8.ebuild b/dev-lang/ghc/ghc-9.2.8.ebuild
new file mode 100644
index 000000000000..8fffbe2cca4b
--- /dev/null
+++ b/dev-lang/ghc/ghc-9.2.8.ebuild
@@ -0,0 +1,975 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# to make make a crosscompiler use crossdev and symlink ghc tree into
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+
+PYTHON_COMPAT=( python3_{9..12} )
+inherit python-any-r1
+inherit autotools bash-completion-r1 flag-o-matic ghc-package
+inherit multiprocessing pax-utils toolchain-funcs prefix
+inherit check-reqs llvm unpacker
+DESCRIPTION="The Glasgow Haskell Compiler"
+HOMEPAGE="https://www.haskell.org/ghc/"
+
+BIN_PV=${PV}
+[[ $PR != r0 ]] && BIN_REV=${PR}
+BIN_PVR="${BIN_PV}${BIN_REV:+-${BIN_REV}}"
+
+# >=ghc-9.2 can only be built with <=ghc-9.0 until hadrian is supported
+BUILD_BIN_PV=9.0.2
+BUILD_BIN_REV=r4
+BUILD_BIN_PVR="${BUILD_BIN_PV}${BUILD_BIN_REV:+-${BUILD_BIN_REV}}"
+
+DEFAULT_SRC_HOST="https://eidetic.codes"
+
+ghc_binaries() {
+ echo "
+ binary? ( ${DEFAULT_SRC_HOST}/${PN}-bin-${BIN_PVR}-${1}.gpkg.tar )
+ !binary? ( ${DEFAULT_SRC_HOST}/${PN}-bin-${BUILD_BIN_PVR}-${1}.gpkg.tar )
+ "
+}
+
+# Differentiate glibc/musl
+
+#glibc_binaries="$glibc_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+glibc_binaries+=" amd64? ( $(ghc_binaries x86_64-pc-linux-gnu) )"
+#glibc_binaries="$glibc_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
+#glibc_binaries+=" arm64? ( $(ghc_binaries_gz_build_bin aarch64-unknown-linux-gnu) )"
+#glibc_binaries="$glibc_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#glibc_binaries="$glibc_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#glibc_binaries+=" ppc64? (
+# big-endian? ( $(ghc_binaries_gz_build_bin powerpc64-unknown-linux-gnu) )
+# !big-endian? ( $(ghc_binaries_gz_build_bin powerpc64le-unknown-linux-gnu) )
+#)"
+#glibc_binaries+=" riscv? ( $(ghc_binaries_gz_build_bin riscv64-unknown-linux-gnu) )"
+#glibc_binaries="$glibc_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+glibc_binaries+=" x86? ( $(ghc_binaries i686-pc-linux-gnu) )"
+
+#musl_binaries="$musl_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )"
+#musl_binaries="$musl_binaries amd64? ( https://eidetic.codes/ghc-bin-${PV}-x86_64-pc-linux-musl.tbz2 )"
+#musl_binaries="$musl_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-musl.tbz2 )"
+#musl_binaries="$musl_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-musl.tbz2 )"
+#musl_binaries="$musl_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
+#musl_binaries="$musl_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )"
+#musl_binaries="$musl_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )"
+#musl_binaries="$musl_binaries ppc64? ( !big-endian? ( https://github.com/matoro/ghc/releases/download/${PV}/ghc-bin-${PV}-powerpc64le-unknown-linux-musl.tar.gz ) )"
+#musl_binaries="$musl_binaries riscv? ( https://github.com/matoro/ghc/releases/download/${PV}/ghc-bin-${PV}-riscv64-unknown-linux-musl.tar.gz )"
+#musl_binaries="$musl_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )"
+#musl_binaries="$musl_binaries x86? ( https://eidetic.codes/ghc-bin-${PV}-i686-pc-linux-musl.tbz2 )"
+
+[[ -n $glibc_binaries ]] && arch_binaries+=" elibc_glibc? ( $glibc_binaries )"
+[[ -n $musl_binaries ]] && arch_binaries+=" elibc_musl? ( $musl_binaries )"
+
+# various ports:
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )"
+
+# 0 - yet
+yet_binary() {
+ case "${ELIBC}" in
+ glibc)
+ case "${ARCH}" in
+ #alpha) return 0 ;;
+ #arm64) return 0 ;;
+ #arm) return 0 ;;
+ amd64) return 0 ;;
+ #ia64) return 0 ;;
+ #ppc) return 0 ;;
+ #ppc64) return 0 ;;
+ #riscv) return 0 ;;
+ #sparc) return 0 ;;
+ x86) return 0 ;;
+ *) return 1 ;;
+ esac
+ ;;
+ musl)
+ case "${ARCH}" in
+ #alpha) return 0 ;;
+ #arm64) return 0 ;;
+ #arm) return 0 ;;
+ #amd64) return 0 ;;
+ #ia64) return 0 ;;
+ #ppc) return 0 ;;
+ #ppc64)
+ # use big-endian || return 0
+ # ;;
+ #riscv) return 0 ;;
+ #sparc) return 0 ;;
+ #x86) return 0 ;;
+ *) return 1 ;;
+ esac
+ ;;
+ *) return 1 ;;
+ esac
+}
+
+GHC_PV=${PV}
+#GHC_PV=8.10.0.20200123 # uncomment only for -alpha, -beta, -rc ebuilds
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
+
+SRC_URI="!binary? (
+ https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-src.tar.xz
+ test? ( https://downloads.haskell.org/ghc/${PV/_/-}/${GHC_P}-testsuite.tar.xz )
+)"
+S="${WORKDIR}"/${GHC_P}
+
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
+
+BUMP_LIBRARIES=(
+ # "hackage-name hackage-version"
+)
+
+LICENSE="BSD"
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~x86"
+IUSE="big-endian doc elfutils ghcbootstrap ghcmakebinary +gmp llvm numa profile test unregisterised"
+IUSE+=" binary"
+RESTRICT="!test? ( test )"
+
+LLVM_MAX_SLOT="14"
+RDEPEND="
+ >=dev-lang/perl-5.6.1
+ dev-libs/gmp:0=
+ sys-libs/ncurses:=[unicode(+)]
+ elfutils? ( dev-libs/elfutils )
+ !ghcmakebinary? ( dev-libs/libffi:= )
+ numa? ( sys-process/numactl )
+ llvm? (
+ <sys-devel/llvm-$((${LLVM_MAX_SLOT} + 1)):=
+ || (
+ sys-devel/llvm:14
+ )
+ )
+"
+
+# This set of dependencies is needed to run
+# prebuilt ghc. We specifically avoid ncurses
+# dependency with:
+# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
+PREBUILT_BINARY_DEPENDS="
+ !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
+"
+# This set of dependencies is needed to install
+# ghc[binary] in system. terminfo package is linked
+# against ncurses.
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
+ sys-libs/ncurses:0/6
+"
+
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
+
+DEPEND="${RDEPEND}"
+BDEPEND="
+ virtual/pkgconfig
+ doc? ( app-text/docbook-xml-dtd:4.2
+ app-text/docbook-xml-dtd:4.5
+ app-text/docbook-xsl-stylesheets
+ dev-python/sphinx
+ dev-python/sphinx-rtd-theme
+ >=dev-libs/libxslt-1.1.2 )
+ !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )
+ test? ( ${PYTHON_DEPS} )
+"
+
+needs_python() {
+ # test driver is written in python
+ use test && return 0
+ return 1
+}
+
+# we build binaries without profiling support
+REQUIRED_USE="
+ ?? ( ghcbootstrap binary )
+ ?? ( profile binary )
+ ?? ( llvm unregisterised )
+"
+
+# haskell libraries built with cabal in configure mode, #515354
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
+
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+
+is_native() {
+ [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
+}
+
+if ! is_crosscompile; then
+ PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )"
+fi
+
+# returns tool prefix for crosscompiler.
+# Example:
+# CTARGET=armv7a-unknown-linux-gnueabi
+# CHOST=x86_64-pc-linux-gnu
+# "armv7a-unknown-linux-gnueabi-"
+# CTARGET=${CHOST}
+# ""
+# Used in tools and library prefix:
+# "${ED}"/usr/bin/$(cross)haddock
+# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+
+cross() {
+ if is_crosscompile; then
+ echo "${CTARGET}-"
+ else
+ echo ""
+ fi
+}
+
+append-ghc-cflags() {
+ local persistent compile assemble link
+ local flag ghcflag
+
+ for flag in $*; do
+ case ${flag} in
+ persistent) persistent="yes";;
+ compile) compile="yes";;
+ assemble) assemble="yes";;
+ link) link="yes";;
+ *)
+ [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+ [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+ [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
+ ;;
+ esac
+ done
+}
+
+# $1 - lib name (under libraries/)
+# $2 - lib version
+# example: bump_lib "transformers" "0.4.2.0"
+bump_lib() {
+ local pn=$1 pv=$2
+ local p=${pn}-${pv}
+ local f
+
+ einfo "Bumping ${pn} up to ${pv}"
+
+ for f in ghc.mk GNUmakefile; do
+ mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
+ done
+ mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
+ mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
+}
+
+update_SRC_URI() {
+ local p pn pv
+ for p in "${BUMP_LIBRARIES[@]}"; do
+ set -- $p
+ pn=$1 pv=$2
+
+ SRC_URI+=" https://hackage.haskell.org/package/${pn}-${pv}/${pn}-${pv}.tar.gz"
+ done
+}
+
+update_SRC_URI
+
+bump_libs() {
+ local p pn pv
+ for p in "${BUMP_LIBRARIES[@]}"; do
+ set -- $p
+ pn=$1 pv=$2
+
+ bump_lib "${pn}" "${pv}"
+ done
+}
+
+ghc_setup_cflags() {
+ # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
+ if ! is_native; then
+ export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
+ export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
+ einfo "Crosscompiling mode:"
+ einfo " CHOST: ${CHOST}"
+ einfo " CTARGET: ${CTARGET}"
+ einfo " CFLAGS: ${CFLAGS}"
+ einfo " LDFLAGS: ${LDFLAGS}"
+ einfo " prefix: $(cross)"
+ return
+ fi
+ # We need to be very careful with the CFLAGS we ask ghc to pass through to
+ # gcc. There are plenty of flags which will make gcc produce output that
+ # breaks ghc in various ways. The main ones we want to pass through are
+ # -mcpu / -march flags. These are important for arches like alpha & sparc.
+ # We also use these CFLAGS for building the C parts of ghc, ie the rts.
+ strip-flags
+ strip-unsupported-flags
+
+ # Cmm can't parse line numbers #482086
+ replace-flags -ggdb[3-9] -ggdb2
+
+ GHC_FLAGS=""
+ GHC_PERSISTENT_FLAGS=""
+ for flag in ${CFLAGS}; do
+ case ${flag} in
+
+ # Ignore extra optimisation (ghc passes -O to gcc anyway)
+ # -O2 and above break on too many systems
+ -O*) ;;
+
+ # Arch and ABI flags are what we're really after
+ -m*) append-ghc-cflags compile assemble ${flag};;
+
+ # Sometimes it's handy to see backtrace of RTS
+ # to get an idea what happens there
+ -g*) append-ghc-cflags compile ${flag};;
+
+ # Ignore all other flags, including all -f* flags
+ esac
+ done
+
+ for flag in ${LDFLAGS}; do
+ append-ghc-cflags link ${flag}
+ done
+}
+
+# substitutes string $1 to $2 in files $3 $4 ...
+relocate_path() {
+ local from=$1
+ local to=$2
+ shift 2
+ local file=
+ for file in "$@"
+ do
+ sed -i -e "s|$from|$to|g" \
+ "$file" || die "path relocation failed for '$file'"
+ done
+}
+
+# changes hardcoded ghc paths and updates package index
+# $1 - new absolute root path
+# $2 - ghc version unpacked in ${WORKDIR}
+relocate_ghc() {
+ local to=$1 ghc_v=$2
+
+ # libdir for prebuilt binary and for current system may mismatch
+ # It does for prefix installation for example: bug #476998
+ local bin_ghc_prefix=${WORKDIR}/usr
+ local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
+ local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
+
+ # backup original script to use it later after relocation
+ local gp_back="${T}/ghc-pkg-${ghc_v}-orig"
+ cp "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
+
+ if [[ ${bin_libdir} != $(get_libdir) ]]; then
+ einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
+ # moving the dir itself is not strictly needed
+ # but then USE=binary would result in installing
+ # in '${bin_libdir}'
+ mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
+
+ relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
+ "${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+ "${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+ "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+ "${WORKDIR}/usr/bin/hsc2hs" \
+ "${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+ "$gp_back" \
+ "${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+ fi
+
+ # Relocate from /usr to ${EPREFIX}/usr
+ relocate_path "/usr" "${to}/usr" \
+ "${WORKDIR}/usr/bin/ghc-${ghc_v}" \
+ "${WORKDIR}/usr/bin/ghci-${ghc_v}" \
+ "${WORKDIR}/usr/bin/ghc-pkg-${ghc_v}" \
+ "${WORKDIR}/usr/bin/haddock-ghc-${ghc_v}" \
+ "${WORKDIR}/usr/bin/hp2ps" \
+ "${WORKDIR}/usr/bin/hpc" \
+ "${WORKDIR}/usr/bin/hsc2hs" \
+ "${WORKDIR}/usr/bin/runghc-${ghc_v}" \
+ "${WORKDIR}/usr/$(get_libdir)/${PN}-${ghc_v}/package.conf.d/"*
+
+ # this one we will use to regenerate cache
+ # so it should point to current tree location
+ relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
+
+ if use prefix; then
+ hprefixify "${bin_libpath}"/${PN}*/settings
+ fi
+
+ # regenerate the binary package cache
+ "$gp_back" recache || die "failed to update cache after relocation"
+ rm "$gp_back"
+}
+
+ghc-check-reqs() {
+ # These are pessimistic values (slightly bigger than worst-case)
+ # Worst case is UNREG USE=profile ia64. See bug #611866 for some
+ # numbers on various arches.
+ CHECKREQS_DISK_BUILD=8G
+ CHECKREQS_DISK_USR=2G
+ # USE=binary roughly takes
+ use binary && CHECKREQS_DISK_BUILD=4G
+
+ "$@"
+}
+
+llvmize() {
+ [[ -z "${1}" ]] && return
+ ( find "${1}" -type f \
+ | file -if- \
+ | grep "text/x-shellscript" \
+ | awk -F: '{print $1}' \
+ | xargs sed -i "s#^exec #PATH=\"$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin:\${PATH}\" exec #") || die
+}
+
+ghc-check-bootstrap-version () {
+ local diemsg version python_output
+ ebegin "Checking for appropriate installed GHC version for bootstrapping"
+ if version=$(ghc-version); then
+ if ver_test "${version}" -lt "9.1.0"; then
+ eend 0
+ return 0
+ else
+ diemsg="Inappropriate GHC version for bootstrapping: ${version}"
+ fi
+ else
+ diemsg="Could not find installed GHC for bootstrapping"
+ fi
+
+ eend 1
+ eerror "USE=ghcbootstrap _requires_ an existing GHC already installed on the system."
+ eerror "Furthermore, current technical limitations require that ghc-9.2.* _must_ be"
+ eerror "bootstrapped by ghc-9.0.* or earlier. This may be changed in a later update."
+ die "$diemsg"
+}
+
+pkg_pretend() {
+ [[ ${MERGE_TYPE} != binary ]] && use ghcbootstrap && ghc-check-bootstrap-version
+ ghc-check-reqs check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+ ghc-check-reqs check-reqs_pkg_setup
+
+ # quiet portage about prebuilt binaries
+ use binary && QA_PREBUILT="*"
+
+ [[ ${MERGE_TYPE} == binary ]] && return
+
+ if use ghcbootstrap; then
+ ewarn "You requested ghc bootstrapping, this is usually only used"
+ ewarn "by Gentoo developers to make binary .tbz2 packages."
+
+ [[ -z $(type -P ghc) ]] && \
+ die "Could not find a ghc to bootstrap with."
+ else
+ if ! yet_binary; then
+ eerror "Please try emerging with USE=ghcbootstrap and report build"
+ eerror "success or failure to the haskell team (haskell@gentoo.org)"
+ die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
+ fi
+ fi
+
+ if needs_python; then
+ python-any-r1_pkg_setup
+ fi
+
+ use llvm && llvm_pkg_setup
+}
+
+src_unpack() {
+ # Create the ${S} dir if we're using the binary version
+ use binary && mkdir "${S}"
+
+ # the Solaris and Darwin binaries from ghc (maeder) need to be
+ # unpacked separately, so prevent them from being unpacked
+ local ONLYA=${A}
+ case ${CHOST} in
+ *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;;
+ esac
+ unpacker ${ONLYA}
+}
+
+src_prepare() {
+ # Force the use of C.utf8 locale
+ # <https://github.com/gentoo-haskell/gentoo-haskell/issues/1287>
+ # <https://github.com/gentoo-haskell/gentoo-haskell/issues/1289>
+ export LC_ALL=C.utf8
+
+ if use binary; then
+ local bin_pv="${BIN_PV}"
+ local bin_pvr="${BIN_PVR}"
+ else
+ local bin_pv="${BUILD_BIN_PV}"
+ local bin_pvr="${BUILD_BIN_PVR}"
+ fi
+
+ ghc_setup_cflags
+
+ if ! use ghcbootstrap; then
+ # The switch to gpkg binaries means that they are unpacked in the wrong
+ # location. They are now unnpacked in the $orig_bindir and need to be
+ # moved so that usr/ is in $WORKDIR.
+ local orig_bindir="${WORKDIR}/${PN}-${bin_pvr}"
+ mv -v "${orig_bindir}/image/usr" "${WORKDIR}" || die
+
+ if [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
+ # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
+ # See bug #313635.
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+ "${WORKDIR}/usr/bin/ghc-${bin_pv}"
+
+ # allow hardened users use vanilla binary to bootstrap ghc
+ # ghci uses mmap with rwx protection at it implements dynamic
+ # linking on it's own (bug #299709)
+ pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${PN}-${bin_pv}/bin/ghc"
+ fi
+ fi
+
+ use llvm && ! use ghcbootstrap && llvmize "${WORKDIR}/usr/bin"
+
+ # binpkg may have been built with FEATURES=splitdebug
+ if [[ -d "${WORKDIR}/usr/lib/debug" ]] ; then
+ rm -rf "${WORKDIR}/usr/lib/debug" || die
+ fi
+ find "${WORKDIR}/usr/lib" -type d -empty -delete 2>/dev/null # do not die on failure here
+
+ # ffi headers don't get included in the binpkg for some reason
+ for f in "${WORKDIR}/usr/$(get_libdir)/${PN}-${bin_pv}/include/"{ffi.h,ffitarget.h}
+ do
+ mkdir -p "$(dirname "${f}")"
+ [[ -e "${f}" ]] || ln -sf "$($(tc-getPKG_CONFIG) --cflags-only-I libffi | sed "s/-I//g" | tr -d " ")/$(basename "${f}")" "${f}" || die
+ done
+
+ if use binary; then
+ if use prefix; then
+ relocate_ghc "${EPREFIX}" "${bin_pv}"
+ fi
+
+ # Move unpacked files to the expected place
+ mv "${WORKDIR}/usr" "${S}"
+ eapply_user
+ else
+ if ! use ghcbootstrap; then
+ case ${CHOST} in
+ *-darwin* | *-solaris*)
+ # UPDATE ME for ghc-7
+ mkdir "${WORKDIR}"/ghc-bin-installer || die
+ pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
+ use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
+ use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
+ use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
+ use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
+ popd > /dev/null
+
+ pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
+ # fix the binaries so they run, on Solaris we need an
+ # LD_LIBRARY_PATH which has our prefix libdirs, on
+ # Darwin we need to replace the frameworks with our libs
+ # from the prefix fix before installation, because some
+ # of the tools are actually used during configure/make
+ if [[ ${CHOST} == *-solaris* ]] ; then
+ export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
+ elif [[ ${CHOST} == *-darwin* ]] ; then
+ local readline_framework=GNUreadline.framework/GNUreadline
+ local gmp_framework=/opt/local/lib/libgmp.10.dylib
+ local ncurses_file=/opt/local/lib/libncurses.5.dylib
+ for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
+ install_name_tool -change \
+ ${readline_framework} \
+ "${EPREFIX}"/lib/libreadline.dylib \
+ ${binary} || die
+ install_name_tool -change \
+ ${gmp_framework} \
+ "${EPREFIX}"/usr/lib/libgmp.dylib \
+ ${binary} || die
+ install_name_tool -change \
+ ${ncurses_file} \
+ "${EPREFIX}"/usr/lib/libncurses.dylib \
+ ${binary} || die
+ done
+ # we don't do frameworks!
+ sed -i \
+ -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
+ -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
+ rts/package.conf.in || die
+ fi
+
+ # it is autoconf, but we really don't want to give it too
+ # many arguments, in fact we do the make in-place anyway
+ ./configure --prefix="${WORKDIR}"/usr || die
+ make install || die
+ popd > /dev/null
+ ;;
+ *)
+ relocate_ghc "${WORKDIR}" "${bin_pv}"
+ ;;
+ esac
+ fi
+
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
+ "${S}/ghc/ghc.wrapper"
+
+ cd "${S}" # otherwise eapply will break
+
+ #eapply "${FILESDIR}"/${PN}-9.0.2-CHOST-prefix.patch
+ #eapply "${FILESDIR}"/${PN}-9.0.2-darwin.patch
+
+ # ModUnusable pretty-printing should include the reason
+ eapply "${FILESDIR}/${PN}-9.0.2-verbose-modunusable.patch"
+
+ # Fixes panic when compiling some packages
+ # https://github.com/gentoo-haskell/gentoo-haskell/issues/1250#issuecomment-1044257595
+ # https://gitlab.haskell.org/ghc/ghc/-/issues/21097
+ eapply "${FILESDIR}/${PN}-9.2.7-modorigin-semigroup.patch"
+
+ # Needed for testing with python-3.10
+ #use test && eapply "${FILESDIR}/${PN}-9.0.2-fix-tests-python310.patch"
+
+ #needs a port?
+ #eapply "${FILESDIR}"/${PN}-8.8.1-revert-CPP.patch
+ eapply "${FILESDIR}"/${PN}-8.10.1-allow-cross-bootstrap.patch
+ #eapply "${FILESDIR}"/${PN}-8.10.3-C99-typo-ac270.patch
+ eapply "${FILESDIR}"/${PN}-9.0.2-disable-unboxed-arrays.patch
+ eapply "${FILESDIR}"/${PN}-9.0.2-llvm-13.patch
+ eapply "${FILESDIR}"/${PN}-9.0.2-llvm-14.patch
+
+ # a bunch of crosscompiler patches
+ # needs newer version:
+ #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
+
+ # https://gitlab.haskell.org/ghc/ghc/-/issues/22965
+ #eapply "${FILESDIR}/${PN}-9.2.6-fix-alignment-of-capability.patch"
+ eapply "${FILESDIR}"/${PN}-9.0.2-sphinx-6.patch
+
+ # FIXME: A hack that allows dev-python/sphinx-7 to build the docs
+ #
+ # GHC has updated the bundled version here:
+ # <https://gitlab.haskell.org/ghc/ghc/-/commit/70526f5bd8886126f49833ef20604a2c6477780a>
+ # However, the patch is difficult to apply and our versions of GHC don't
+ # have the update, so we symlink to the system version instead.
+ if use doc; then
+ local rtd_theme_dir="$(dirname $(python -c "import sphinx_rtd_theme; print(sphinx_rtd_theme.__file__)"))"
+ local orig_rtd_theme_dir="${S}/docs/users_guide/rtd-theme"
+
+ ebegin "Replacing bundled rtd-theme with dev-python/sphinx-rtd-theme"
+ rm -r "${orig_rtd_theme_dir}" || die
+ ln -s "${rtd_theme_dir}" "${orig_rtd_theme_dir}" || die
+ eend 0
+ fi
+
+ # mingw32 target
+ pushd "${S}/libraries/Win32"
+ eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
+ popd
+
+ bump_libs
+
+ eapply_user
+ # as we have changed the build system
+ eautoreconf
+ fi
+}
+
+src_configure() {
+ if ! use binary; then
+ # initialize build.mk
+ echo '# Gentoo changes' > mk/build.mk
+
+ # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
+ echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+ echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${PF}" >> mk/build.mk
+
+ # We also need to use the GHC_FLAGS flags when building ghc itself
+ echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
+ echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
+ echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
+ # Speed up initial Cabal bootstrap
+ echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
+
+ # We can't depend on haddock except when bootstrapping when we
+ # must build docs and include them into the binary .tbz2 package
+ # app-text/dblatex is not in portage, can not build PDF or PS
+ echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk
+ echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
+ echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
+
+ # this controls presence on 'xhtml' and 'haddock' in final install
+ echo "HADDOCK_DOCS = YES" >> mk/build.mk
+
+ # not used outside of ghc's test
+ if [[ -n ${GHC_BUILD_DPH} ]]; then
+ echo "BUILD_DPH = YES" >> mk/build.mk
+ else
+ echo "BUILD_DPH = NO" >> mk/build.mk
+ fi
+
+ # Any non-native build has to skip as it needs
+ # target haddock binary to be runnabine.
+ if ! is_native; then
+ # disable docs generation as it requires running stage2
+ echo "HADDOCK_DOCS=NO" >> mk/build.mk
+ echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
+ echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
+ fi
+
+ if is_crosscompile; then
+ # Install ghc-stage1 crosscompiler instead of
+ # ghc-stage2 cross-built compiler.
+ echo "Stage1Only=YES" >> mk/build.mk
+ fi
+
+ # allows overriding build flavours for libraries:
+ # v - vanilla (static libs)
+ # p - profiled
+ # dyn - shared libraries
+ # example: GHC_LIBRARY_WAYS="v dyn"
+ if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
+ echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
+ fi
+ echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
+
+ # Get ghc from the unpacked binary .tbz2
+ # except when bootstrapping we just pick ghc up off the path
+ if ! use ghcbootstrap; then
+ export PATH="${WORKDIR}/usr/bin:${PATH}"
+ fi
+
+ echo "BIGNUM_BACKEND = $(usex gmp gmp native)" >> mk/build.mk
+
+ # don't strip anything. Very useful when stage2 SIGSEGVs on you
+ echo "STRIP_CMD = :" >> mk/build.mk
+
+ local econf_args=()
+
+ # GHC embeds toolchain it was built by and uses it later.
+ # Don't allow things like ccache or versioned binary slip.
+ # We use stable thing across gcc upgrades.
+ # User can use EXTRA_ECONF=CC=... to override this default.
+ econf_args+=(
+ AR=${CTARGET}-ar
+ CC=${CTARGET}-gcc
+ # these should be inferred by GHC but ghc defaults
+ # to using bundled tools on windows.
+ Windres=${CTARGET}-windres
+ DllWrap=${CTARGET}-dllwrap
+ # we set the linker explicitly below
+ --disable-ld-override
+ )
+ case ${CTARGET} in
+ arm*)
+ # ld.bfd-2.28 does not work for ghc. Force ld.gold
+ # instead. This should be removed once gentoo gets
+ # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
+ econf_args+=(LD=${CTARGET}-ld.gold)
+ ;;
+ sparc*)
+ # ld.gold-2.28 does not work for ghc. Force ld.bfd
+ # instead. This should be removed once gentoo gets
+ # a fix for missing --no-relax support bug:
+ # https://sourceware.org/ml/binutils/2017-07/msg00183.html
+ econf_args+=(LD=${CTARGET}-ld.bfd)
+ ;;
+ *)
+ econf_args+=(LD=${CTARGET}-ld)
+ esac
+
+ if [[ ${CBUILD} != ${CHOST} ]]; then
+ # GHC bug: ghc claims not to support cross-building.
+ # It does, but does not distinct --host= value
+ # for stage1 and stage2 compiler.
+ econf_args+=(--host=${CBUILD})
+ fi
+
+ if use ghcmakebinary; then
+ # When building booting library we are trying to
+ # bundle or restrict most of external depends
+ # with unstable ABI:
+ # - embed libffi (default GHC behaviour)
+ # - disable ncurses support for ghci (via haskeline)
+ # https://bugs.gentoo.org/557478
+ # - disable ncurses support for ghc-pkg
+ echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+ echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+ elif is_native; then
+ # using ${GTARGET}'s libffi is not supported yet:
+ # GHC embeds full path for ffi includes without /usr/${CTARGET} account.
+ econf_args+=(--with-system-libffi)
+ econf_args+=(--with-ffi-includes=$($(tc-getPKG_CONFIG) libffi --cflags-only-I | sed -e 's@^-I@@'))
+ fi
+
+ einfo "Final mk/build.mk:"
+ cat mk/build.mk || die
+
+ econf ${econf_args[@]} \
+ --enable-bootstrap-with-devel-snapshot \
+ $(use_enable elfutils dwarf-unwind) \
+ $(use_enable numa) \
+ $(use_enable unregisterised)
+
+ if [[ ${PV} == *9999* ]]; then
+ GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
+ GHC_P=${PN}-${GHC_PV}
+ fi
+ fi # ! use binary
+}
+
+src_compile() {
+ if ! use binary; then
+ # Stage1Only crosscompiler does not build stage2
+ if ! is_crosscompile; then
+ # 1. build/pax-mark compiler binary first
+ emake ghc/stage2/build/tmp/ghc-stage2
+ # 2. pax-mark (bug #516430)
+ pax-mark -m ghc/stage2/build/tmp/ghc-stage2
+ # 2. build/pax-mark haddock using ghc-stage2
+ if is_native; then
+ # non-native build does not build haddock
+ # due to HADDOCK_DOCS=NO, but it could.
+ emake utils/haddock/dist/build/tmp/haddock
+ pax-mark -m utils/haddock/dist/build/tmp/haddock
+ fi
+ fi
+ # 3. and then all the rest
+ emake all
+ fi # ! use binary
+}
+
+src_test() {
+ # TODO: deal with:
+ # - sandbox (pollutes environment)
+ # - extra packages (to extend testsuite coverage)
+ # bits are taken from 'validate'
+ local make_test_target='test' # can be fulltest
+ # not 'emake' as testsuite uses '$MAKE' without jobserver available
+ make $make_test_target stage=2 THREADS=$(makeopts_jobs)
+}
+
+src_install() {
+ if use binary; then
+ use prefix && mkdir -p "${ED}"
+ mv "${S}/usr" "${ED}"
+ else
+ [[ -f VERSION ]] || emake VERSION
+
+ # -j1 due to a rare race in install script:
+ # make --no-print-directory -f ghc.mk phase=final install
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
+ # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \
+ # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
+ # /usr/bin/install: cannot create regular file \
+ # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
+ emake -j1 install DESTDIR="${D}"
+
+ use llvm && llvmize "${ED}/usr/bin"
+
+ # Skip for cross-targets as they all share target location:
+ # /usr/share/doc/ghc-9999/
+ if ! is_crosscompile; then
+ dodoc "distrib/README" "LICENSE" "VERSION"
+ fi
+
+ # rename ghc-shipped files to avoid collision
+ # of external packages. Motivating example:
+ # user had installed:
+ # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
+ # dev-haskell/transformers-0.4.2.0
+ # then user tried to update to
+ # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
+ # this will lead to single .conf file collision.
+ local shipped_conf renamed_conf
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+ for shipped_conf in "${package_confdir}"/*.conf; do
+ # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
+ renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
+ mv "${shipped_conf}" "${renamed_conf}" || die
+ done
+
+ # remove link, but leave 'haddock-${GHC_P}'
+ rm -f "${ED}"/usr/bin/$(cross)haddock
+
+ if ! is_crosscompile; then
+ newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
+ newbashcomp utils/completion/ghc.bash ghc
+ fi
+ fi
+
+ # path to the package.cache
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
+ PKGCACHE="${package_confdir}"/package.cache
+ # copy the package.conf.d, including timestamp, save it so we can help
+ # users that have a broken package.conf.d
+ cp -pR "${package_confdir}"{,.initial} || die "failed to backup initial package.conf.d"
+
+ # copy the package.conf, including timestamp, save it so we later can put it
+ # back before uninstalling, or when upgrading.
+ cp -p "${PKGCACHE}"{,.shipped} \
+ || die "failed to copy package.conf.d/package.cache"
+
+ if is_crosscompile; then
+ # When we build a cross-compiler the layout is the following:
+ # usr/lib/${CTARGET}-ghc-${VER}/ contains target libraries
+ # but
+ # usr/lib/${CTARGET}-ghc-${VER}/bin/ directory
+ # containst host binaries (modulo bugs).
+
+ # Portage's stripping mechanism does not skip stripping
+ # foreign binaries. This frequently causes binaries to be
+ # broken.
+ #
+ # Thus below we disable stripping of target libraries and allow
+ # stripping hosts executables.
+ dostrip -x "/usr/$(get_libdir)/$(cross)${GHC_P}"
+ dostrip "/usr/$(get_libdir)/$(cross)${GHC_P}/bin"
+ fi
+}
+
+pkg_preinst() {
+ # have we got an earlier version of ghc installed?
+ if has_version "<${CATEGORY}/${PF}"; then
+ haskell_updater_warn="1"
+ fi
+}
+
+pkg_postinst() {
+ ghc-reregister
+
+ # path to the package.cache
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+
+ # give the cache a new timestamp, it must be as recent as
+ # the package.conf.d directory.
+ touch "${PKGCACHE}"
+
+ if [[ "${haskell_updater_warn}" == "1" ]]; then
+ ewarn
+ ewarn "\e[1;31m************************************************************************\e[0m"
+ ewarn
+ ewarn "You have just upgraded from an older version of GHC."
+ ewarn "You may have to run"
+ ewarn " 'haskell-updater'"
+ ewarn "to rebuild all ghc-based Haskell libraries."
+ ewarn
+ ewarn "\e[1;31m************************************************************************\e[0m"
+ ewarn
+ fi
+}
+
+pkg_prerm() {
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
+ rm -rf "${PKGCACHE}"
+
+ cp -p "${PKGCACHE}"{.shipped,}
+}
+
+pkg_postrm() {
+ ghc-package_pkg_postrm
+}