Skip to content

rts/RtsSymbols.c: conflicting types for ‘environ’ with glibc-2.34

Summary

Compilation failure while compiling RtsSymbols.c

Steps to reproduce

build ghc from source (GHC HEAD as of October 13 2021) on opensuse-riscv64 platform. The issue manifest as:

"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Irts/include -optc-Irts/include/dist -optc-Irts/include/dist-derivedconstants/header -optc-Irts/include/dist-ghcconstants/header -optc-Irts/include/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static  -O0 -H64m -Wall  -Irts/include -Irts/include/dist -Irts/include/dist-derivedconstants/header -Irts/include/dist-ghcconstants/header -Irts/include/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint     -package-env - -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen            -O2 -Wcpp-undef   -Wnoncanonical-monad-instances  -c rts/RtsSymbols.c -o rts/dist/build/RtsSymbols.o

rts/RtsSymbols.c:64:27: error:
     error: conflicting types for ‘environ’; have ‘StgWord[]’ {aka ‘long unsigned int[]’}
       64 |       SymI_NeedsDataProto(environ)              \
          |                           ^~~~~~~
   |
64 |       SymI_NeedsDataProto(environ)              \
   |                           ^

rts/RtsSymbols.c:1076:50: error:
     note: in definition of macro ‘SymI_NeedsDataProto’
     1076 | #define SymI_NeedsDataProto(vvv)  extern StgWord vvv[];
          |                                                  ^~~
     |
1076 | #define SymI_NeedsDataProto(vvv)  extern StgWord vvv[];
     |                                                  ^

rts/RtsSymbols.c:1096:1: error:
     note: in expansion of macro ‘RTS_POSIX_ONLY_SYMBOLS’
     1096 | RTS_POSIX_ONLY_SYMBOLS
          | ^~~~~~~~~~~~~~~~~~~~~~
     |
1096 | RTS_POSIX_ONLY_SYMBOLS
     | ^
In file included from /usr/include/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from rts/posix/Signals.h:12,

                 from rts/RtsSymbols.c:22:0: error: 

/usr/include/unistd.h:567:15: error:
     note: previous declaration of ‘environ’ with type ‘char **’
      567 | extern char **environ;
          |               ^~~~~~~
    |
567 | extern char **environ;
    |               ^
`cc' failed in phase `C Compiler'. (Exit code: 1)
make[1]: *** [rts/ghc.mk:345: rts/dist/build/RtsSymbols.o] Error 1
make: *** [Makefile:128: all] Error 2

and is caused by following commit:

commit 9ebda74ec5331911881d734b21fbb31c00a0a22f
Author: Ben Gamari <bgamari.foss@gmail.com>
Date:   Thu Sep 9 19:08:46 2021 -0400

    rts/RtsSymbols: Add environ

diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 2782d3632f..e8c60d2c07 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -61,6 +61,7 @@
       SymI_HasProto(stg_sig_install)            \
       SymI_HasProto(rtsTimerSignal)             \
       SymI_HasProto(atexit)                     \
+      SymI_NeedsDataProto(environ)              \
       SymI_NeedsDataProto(nocldstop)
 #endif
 

Expected behavior

things to compile well.

Environment

  • GHC version used: GHC HEAD

Optional:

  • Operating System: openSuSE Thumbleweed
  • System Architecture: RISC-V 64
Edited by Jens Petersen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information