idris_support: fix environ for macOS (#3324)

* idris_support: fix environ for macOS

* Add test that touches the new implementation of environ

---------

Co-authored-by: Sergey Fedorov <barracuda@macos-powerpc.org>
Co-authored-by: Mathew Polzin <matt.polzin@gmail.com>
This commit is contained in:
Sergey Fedorov 2024-07-04 01:04:22 +08:00 committed by GitHub
parent efce152178
commit 1931509c92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 0 deletions

View File

@ -23,6 +23,9 @@ char **_argv;
extern char **_environ;
#include "windows/win_utils.h"
#define environ _environ
#elif defined(__APPLE__)
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif

View File

@ -0,0 +1,8 @@
import System
main : IO ()
main = do
env <- getEnvironment
-- it better be non-empty because we set a variable before starting this test
printLn $ null env

View File

@ -0,0 +1 @@
False

View File

@ -0,0 +1,4 @@
. ../../testutils.sh
idris2 --cg chez -o test Test.idr
HELLO=hi ./build/exec/test