summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 09:16:04 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 09:16:04 +0000
commit1360e9e270bcabb75551b7f5d9161493a66cfcaa (patch)
treec502e54a910be72db69fce4a76f60654310c0845 /llvm/lib/System/Unix
parentf93df19496cb1389a6e809d52e6eb05e9211d319 (diff)
downloadbcm5719-llvm-1360e9e270bcabb75551b7f5d9161493a66cfcaa.tar.gz
bcm5719-llvm-1360e9e270bcabb75551b7f5d9161493a66cfcaa.zip
Properly inherit the environment on darwin where environ is not available for shared libraries.
llvm-svn: 101710
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Program.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 7fdf3872dd9..b7b4e9eb469 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 @@ Program::Execute(const Path &path, const char **args, const char **envp,
}
}
+ 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;
OpenPOWER on IntegriCloud