iOS doesn't have crt_externs.h available, so we fall back to the posix method.
[oota-llvm.git] / lib / Support / Unix / Program.inc
index 0f45df1a0da0e20fd9bd12dfbeed03c0a979f070..2ed5597e4ad99784bde7468f25c90767ef3569c5 100644 (file)
 #define  _RESTRICT_KYWD
 #endif
 #include <spawn.h>
-#if !defined(__APPLE__)
+#if defined(__APPLE__)
+#include <TargetConditionals.h>
+#endif
+#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
   extern char **environ;
 #else
 #include <crt_externs.h> // _NSGetEnviron
@@ -217,7 +220,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args,
     }
 
     if (!envp)
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
       envp = const_cast<const char **>(environ);
 #else
       // environ is missing in dylibs.