Subject: Suppressing compiler warning on Debian 12/gcc 12.2.0

From: Bruce Momjian <[email-masked]>
Date: Thu, 31 Aug 2023 15:25:09 -0400

Being a new user of Debian 12/gcc 12.2.0, I wrote the following shell
script to conditionally add gmake rules with compiler flags to
src/Makefile.custom to suppress warnings for certain files.  This allows
me to compile all supported Postgres releases without warnings.

I actually didn't how simple it was to add per-file compile flags until
I read:

	https://stackoverflow.com/questions/6546162/how-to-add-different-rules-for-specific-files

---------------------------------------------------------------------------

# PG 14+ uses configure.ac
if [ ! -e configure.in ] || grep -q 'AC_INIT(\[PostgreSQL\], \[13\.' configure.in
then    cat >> src/Makefile.custom <<END
# work around gcc -O1 bug found in PG 13-current, not -O[023], 2023-08-28
# https://www.postgresql.org/message-id/[email-masked]
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111240
# gmake fix:  https://stackoverflow.com/questions/6546162/how-to-add-different-rules-for-specific-files
clauses.o: CFLAGS+=-O2
END
fi

if [ -e configure.in ] && grep -q 'AC_INIT(\[PostgreSQL\], \[11\.' configure.in
then    cat >> src/Makefile.custom <<END
# new warning in Debian 12, gcc (Debian 12.2.0-14) 12.2.0, 2023-08-14
# Fix for valid macro using stack_base_ptr, warning only in PG 11
postgres.o: CFLAGS+=-Wdangling-pointer=0
END
fi

-- 
  Bruce Momjian  <[email-masked]>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Only you can decide what is important to you.