Properly inherit the environment on darwin where environ is not available for shared libraries.
llvm-svn: 101710
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 7fdf387..b7b4e9e 100644
--- a/llvm/lib/System/Unix/Program.inc
+++ b/llvm/lib/System/Unix/Program.inc
@@ -34,6 +34,8 @@
#include <spawn.h>
#if !defined(__APPLE__)
extern char **environ;
+#else
+#include <crt_externs.h> // _NSGetEnviron
#endif
#endif
@@ -202,8 +204,11 @@
}
}
+ if (!envp)
#if !defined(__APPLE__)
- if (!envp) envp = (const char**)environ;
+ envp = (const char**)environ;
+#else
+ envp = (const char**)*_NSGetEnviron(); // environ is missing in dylibs.
#endif
pid_t PID;