summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Support/Unix/Program.inc12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 2ed5597e4ad..baf2767ad58 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -42,10 +42,18 @@
#define _RESTRICT_KYWD
#endif
#include <spawn.h>
+
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
-#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
+
+#if defined(__APPLE__) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
+#define USE_NSGETENVIRON 1
+#else
+#define USE_NSGETENVIRON 0
+#endif
+
+#if !USE_NSGETENVIRON
extern char **environ;
#else
#include <crt_externs.h> // _NSGetEnviron
@@ -220,7 +228,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
}
if (!envp)
-#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
+#if !USE_NSGETENVIRON
envp = const_cast<const char **>(environ);
#else
// environ is missing in dylibs.
OpenPOWER on IntegriCloud