[llvm] [flang][runtime] Use dlsym to access char** environ on FreeBSD (PR #158477)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 29 08:04:52 PDT 2025


================
@@ -104,6 +108,8 @@ void ExecutionEnvironment::Configure(int ac, const char *av[],
 
 #ifdef _WIN32
   envp = _environ;
+#elif defined(__FreeBSD__)
+  envp = *reinterpret_cast<char ***>(dlsym(RTLD_DEFAULT, "environ"));
----------------
Meinersbur wrote:

Could you add a check of the return value of `dlsym` before dereferencing it?

https://github.com/llvm/llvm-project/pull/158477


More information about the llvm-commits mailing list