External Issue: build failure with gcc 10.2.0 / glibc 2.32-0ubuntu3, getcwd write_only attribute

17160, "cassella", "build failure with gcc 10.2.0 / glibc 2.32-0ubuntu3, getcwd write_only attribute", "2021-02-13T03:41:07Z"

Summary of Problem

I'm getting a build failure in compiler/util/files.cpp after a recent system update.

g++ -c  -MMD -MP -g   -Wall -Werror -Wpointer-arith -Wwrite-strings -Wno-strict-aliasing -Wno-comment -Wsuggest-override -Walloc-size-larger-than=18446744073709551615 -Wno-stringop-truncation -Wmissing-declarations -I. -I../include/linux64 -I../include  -I../../build/compiler/linux64/gnu/x86_64/llvm-none/none -I../../runtime/include/encoding -I/home/fortytwo/src/chapel/third-party/utf8-decoder   -DCOMPILER_SUBDIR=util -o ../../build/compiler/linux64/gnu/x86_64/llvm-none/none/util/files.o files.cpp
files.cpp: In function ‘const char* getCwd()’:
files.cpp:1118:30: error: argument 1 is null but the corresponding size argument 2 value is 4096 [-Werror=nonnull]
 1118 |   const char* result = getcwd(NULL, PATH_MAX);
      >                        ~~~~~~^~~~~~~~~~~~~~~~
In file included from ../include/chpl.h:35,
                 from ../include/driver.h:24,
                 from files.cpp:34:
/usr/include/unistd.h:520:14: note: in a call to function ‘char* getcwd(char*, size_t)’ declared with attribute ‘write_only (1, 2)’
  520 | extern char *getcwd (char *__buf, size_t __size) __THROW __wur
      >              ^~~~~~
cc1plus: all warnings being treated as errors

The write_only attribute requires the buf arg to be able to hold PATH_MAX bytes, despite the getcwd man page noting that NULL is allowed. There's discussion in this bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96832

but I can't tell what the resolution was.

Configuration Information

This is as of master tonight, 4b494edf4a0

CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native *
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
  CHPL_COMM_SUBSTRATE: udp
  CHPL_GASNET_SEGMENT: everything
CHPL_TASKS: qthreads
CHPL_LAUNCHER: amudprun
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
  CHPL_NETWORK_ATOMICS: none
CHPL_GMP: none
CHPL_HWLOC: bundled
CHPL_REGEXP: none
CHPL_LLVM: none
CHPL_AUX_FILESYS: none

gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0