On Thu, Aug 31, 2023 at 03:25:09PM -0400, Bruce Momjian wrote:
> 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
This might be simpler for people to modify since it abstracts out the
version checking.
---------------------------------------------------------------------------
# gmake per-file options: https://stackoverflow.com/questions/6546162/how-to-add-different-rules-for-specific-files
for FILE in configure.in configure.ac
do if [ -e "$FILE" ]
then VERSION=$(sed -n 's/^AC_INIT(\[PostgreSQL\], \[\([0-9]\+\).*$/\1/p' "$FILE")
break
fi
done
[ -z "$VERSION" ] && echo 'Could not find Postgres version' 1>&2 && exit 1
if [ "$VERSION" -eq 11 ]
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
postgres.o: CFLAGS+=-Wdangling-pointer=0
END
fi
if [ "$VERSION" -ge 13 ]
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/ZOz3cBySkbEA5RN+@momjian.us
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111240
clauses.o: CFLAGS+=-O2
END
fi
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Only you can decide what is important to you.