This is horrible. Split the difference, and declare 'environ' on all non-Darwin
authorNick Lewycky <nicholas@mxc.ca>
Sun, 18 Apr 2010 07:07:48 +0000 (07:07 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sun, 18 Apr 2010 07:07:48 +0000 (07:07 +0000)
platforms to unbreak the darwin and linux builds. The BSD folks should feel
free to change the #if, if this breaks them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Unix/Program.inc

index 2f3616e73a1018a405fb12299d735966f6c3e95d..7fdf3872dd9bfc94f5b31e9a79dc1a91582c0a86 100644 (file)
@@ -32,6 +32,9 @@
 #endif
 #ifdef HAVE_POSIX_SPAWN
 #include <spawn.h>
+#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);