g++ doesn't allow including Rts.h from HEAD
Summary
If you try to compile ghc-debug-stub
with HEAD, you get the following message from g++:
GNU C++17 (GCC) version 9.3.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.17.1-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (GCC) version 9.3.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.17.1-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a73d4a62d7cd30907d3cbd101fc2954b
In file included from /nix/store/av9j7zva8s012nsm3y9hgb7kdf41pw7c-ghc-9.3.0/lib/ghc-9.3.20210803/lib/../lib/x86_64-linux-ghc-9.3.20210803/rts-1.0.2/include/Rts.h:224,
from cbits/socket.cpp:3:0: error:
/nix/store/av9j7zva8s012nsm3y9hgb7kdf41pw7c-ghc-9.3.0/lib/ghc-9.3.20210803/lib/../lib/x86_64-linux-ghc-9.3.20210803/rts-1.0.2/include/rts/storage/Heap.h:27:73: error:
error: expected ‘,’ or ‘...’ before ‘ptrs’
27 | StgWord collect_pointers(StgClosure *closure, StgWord size, StgClosure *ptrs[size]);
| ^~~~
|
27 | StgWord collect_pointers(StgClosure *closure, StgWord size, StgClosure *ptrs[size]);
| ^
`cc' failed in phase `C Compiler'. (Exit code: 1)
Link to socket.cpp: https://gitlab.haskell.org/ghc/ghc-debug/-/blob/master/stub/cbits/socket.cpp
The error seems to be due to importing Rts.h
rather than anything in socket.cpp
I think this is caused by !6235 (closed) @bgamari
It looks like this use of variable length arrays is valid in C but not in C++. ghc-debug-common
, which uses Rts.h
within a C file compiles fine.
Steps to reproduce
- Create a c++ file that includes
Rts.h
- Try to compile that file with
g++
- You will get an error similar to above
Expected behaviour
Rts.h
should be compatible with c++
Environment
- GHC version used: The Glorious Glasgow Haskell Compilation System, version 9.3.20210803
Optional:
- Operating System: Linux
- System Architecture: x86_64