diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 2f3616e73a1..7fdf3872dd9 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -32,6 +32,9 @@ #endif #ifdef HAVE_POSIX_SPAWN #include +#if !defined(__APPLE__) + extern char **environ; +#endif #endif namespace llvm { @@ -199,6 +202,10 @@ Program::Execute(const Path &path, const char **args, const char **envp, } } +#if !defined(__APPLE__) + if (!envp) envp = (const char**)environ; +#endif + pid_t PID; int Err = posix_spawn(&PID, path.c_str(), &FileActions, /*attrp*/0, (char**)args, (char**)envp);