Skip to content
Snippets Groups Projects
Commit fcef9a17 authored by Ben Gamari's avatar Ben Gamari
Browse files

configure: Make environ decl check more robust

Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`,
not `<unistd.h>`
parent 9eeaeca4
No related branches found
No related tags found
No related merge requests found
...@@ -253,3 +253,19 @@ AS_IF([test "$ac_res" != no], ...@@ -253,3 +253,19 @@ AS_IF([test "$ac_res" != no],
[$6])dnl [$6])dnl
AS_VAR_POPDEF([ac_Search])dnl AS_VAR_POPDEF([ac_Search])dnl
]) ])
AC_DEFUN([FP_CHECK_ENVIRON],
[
dnl--------------------------------------------------------------------
dnl * Check whether the libc headers provide a declaration for the
dnl environ symbol. If not then we will provide one in RtsSymbols.c.
dnl See #20512, #20577, #20861.
dnl
dnl N.B. Windows declares environ in <stdlib.h>; most others declare it
dnl in <unistd.h>.
dnl--------------------------------------------------------------------
AC_CHECK_DECLS([environ], [], [], [
#include <stdlib.h>
#include <unistd.h>
])
])
...@@ -189,6 +189,8 @@ FP_CHECK_CONSTS([SIGINT], [ ...@@ -189,6 +189,8 @@ FP_CHECK_CONSTS([SIGINT], [
dnl ** can we open files in binary mode? dnl ** can we open files in binary mode?
FP_CHECK_CONST([O_BINARY], [#include <fcntl.h>], [0]) FP_CHECK_CONST([O_BINARY], [#include <fcntl.h>], [0])
FP_CHECK_ENVIRON
# We don't use iconv or libcharset on Windows, but if configure finds # We don't use iconv or libcharset on Windows, but if configure finds
# them then it can cause problems. So we don't even try looking if # them then it can cause problems. So we don't even try looking if
# we are on Windows. # we are on Windows.
......
...@@ -552,9 +552,9 @@ INLINE int __hscore_open(char *file, int how, mode_t mode) { ...@@ -552,9 +552,9 @@ INLINE int __hscore_open(char *file, int how, mode_t mode) {
#include <crt_externs.h> #include <crt_externs.h>
INLINE char **__hscore_environ(void) { return *(_NSGetEnviron()); } INLINE char **__hscore_environ(void) { return *(_NSGetEnviron()); }
#else #else
/* ToDo: write a feature test that doesn't assume 'environ' to #if !HAVE_DECL_ENVIRON
* be in scope at link-time. */
extern char** environ; extern char** environ;
#endif
INLINE char **__hscore_environ(void) { return environ; } INLINE char **__hscore_environ(void) { return environ; }
#endif #endif
......
...@@ -4,11 +4,14 @@ AC_DEFUN([FP_CHECK_ENVIRON], ...@@ -4,11 +4,14 @@ AC_DEFUN([FP_CHECK_ENVIRON],
[ [
dnl-------------------------------------------------------------------- dnl--------------------------------------------------------------------
dnl * Check whether the libc headers provide a declaration for the dnl * Check whether the libc headers provide a declaration for the
dnl environ symbol. If not then we will provide one in RtsSymbols.c. dnl environ symbol. If not then we will provide one in RtsSymbols.c.
dnl See #20512, #20577, #20861. dnl See #20512, #20577, #20861.
dnl
dnl N.B. Windows declares environ in <stdlib.h>; most others declare it
dnl in <unistd.h>.
dnl-------------------------------------------------------------------- dnl--------------------------------------------------------------------
AC_CHECK_DECLS([environ], [], [], [ AC_CHECK_DECLS([environ], [], [], [
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
]) ])
]) ])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment