From 0373bb02d5c011c084471021fa90cc255326118f Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 29 Jul 2026 19:39:12 +0000 Subject: [PATCH] Use _NSGetEnviron() instead of extern environ on Apple diff --git a/eden/common/utils/SpawnedProcess.cpp b/eden/common/utils/SpawnedProcess.cpp index d108e98..cbde73e 100644 --- eden/common/utils/SpawnedProcess.cpp +++ eden/common/utils/SpawnedProcess.cpp @@ -35,12 +35,20 @@ using folly::checkPosixError; using namespace std::chrono_literals; #ifndef _WIN32 +#ifdef __APPLE__ +// On Darwin, `environ` is only reliably populated in the main executable by +// crt1.o; a dylib must instead go through _NSGetEnviron() to reach the +// process's real environment. +#include +#define environ (*_NSGetEnviron()) +#else // POSIX doesn't appear to specify which header defines this, // so we just extern it. extern "C" { extern char** environ; } #endif +#endif namespace facebook::eden {