The testcase has GDB call my_getenv in the inferior, and that fails
with Clang, because Clang optimizes out my_getenv completely, since it
isn't called anywhere (in the program).
This commit fixes it.
gdb/testsuite/ChangeLog:
	* gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
	instead of getenv.
+2020-09-13  Pedro Alves  <pedro@palves.net>
+
+       * gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
+       instead of getenv.
+
 2020-09-13  Pedro Alves  <pedro@palves.net>
 
        * gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn
 
 {
   /* Call malloc to ensure it is linked in.  */
   char *tmp = malloc (1);
-  const char *myvar = getenv ("GDB_TEST_VAR");
+  /* Similarly call my_getenv instead of getenv directly to make sure
+     the former isn't optimized out.  my_getenv is called by GDB.  */
+  const char *myvar = my_getenv ("GDB_TEST_VAR");
 
   if (myvar != NULL)
     printf ("It worked!  myvar = '%s'\n", myvar);