1 Use dlsym to access environ. This avoids undefined references during linking
2 with -Wl,-no-undefined.
3 
4 See https://reviews.freebsd.org/D30842
5 
6 --- src/3rdparty/chromium/base/process/launch_posix.cc.orig	2025-08-18 00:53:11 UTC
7 +++ src/3rdparty/chromium/base/process/launch_posix.cc
8 @@ -67,7 +67,9 @@
9  #error "macOS should use launch_mac.cc"
10  #endif
11 
12 +#if !defined(OS_FREEBSD)
13  extern char** environ;
14 +#endif
15 
16  namespace base {
17 
18 @@ -88,13 +90,27 @@ char** GetEnvironment() {
19  // Get the process's "environment" (i.e. the thing that setenv/getenv
20  // work with).
21  char** GetEnvironment() {
22 +#if !defined(OS_FREEBSD)
23    return environ;
24 +#else
25 +  static char* nullenv = nullptr;
26 +  char ***environ_p = reinterpret_cast<char***>(dlsym(RTLD_DEFAULT, "environ"));
27 +  char **environ = environ_p ? *environ_p : &nullenv;
28 +  return environ;
29 +#endif
30  }
31 
32  // Set the process's "environment" (i.e. the thing that setenv/getenv
33  // work with).
34  void SetEnvironment(char** env) {
35 +#if !defined(OS_FREEBSD)
36    environ = env;
37 +#else
38 +  char ***environ_p = reinterpret_cast<char***>(dlsym(RTLD_DEFAULT, "environ"));
39 +  if (!environ_p)
40 +    return;
41 +  *environ_p = env;
42 +#endif
43  }
44 
45  // Set the calling thread's signal mask to new_sigmask and return
46