9.4.6: bytestring fails to compile due to missing clockid_t type
Summary
When compiling GHC 9.4.6 against glibc 2.37-8 in nixpkgs, the following failure occurs when compiling bytestring:
In file included from /build/ghc-9.4.6/rts/include/Rts.h:235,[39;49;00m
from libraries/bytestring/cbits/is-valid-utf8.c:54:0: error:
/build/ghc-9.4.6/rts/include/rts/OSThreads.h:38:5: error:
error: unknown type name ‘clockid_t’
38 | clockid_t timeout_clk;
| ^~~~~~~~~
|
38 | clockid_t timeout_clk;
| ^
`cc' failed in phase `C Compiler'. (Exit code: 1)
make[1]: *** [libraries/bytestring/ghc.mk:4: libraries/bytestring/dist-install/build/cbits/is-valid-utf8.p_o] Error 1
The following patch can be used to solve this problem, so it seems that this is a feature macro problem.
diff --git a/cbits/is-valid-utf8.c b/cbits/is-valid-utf8.c
index 01b3b41..c69596a 100644
--- a/libraries/bytestring/cbits/is-valid-utf8.c
+++ b/libraries/bytestring/cbits/is-valid-utf8.c
@@ -29,6 +29,7 @@ SUCH DAMAGE.
*/
#pragma GCC push_options
#pragma GCC optimize("-O2")
+#include "rts/PosixSource.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
This issue probably also affects master
, but I haven't tested it yet.
Steps to reproduce
Check out 5021675026f3ead6f01342a982988db6caeb930f in my nixpkgs fork, nix-build -A haskell.compiler.ghc946
.
Expected behavior
GHC builds successfully
Environment
- GHC version used: 9.4.6
Optional:
- Operating System: linux
- System Architecture: x86_64