BUG #18841: pgflex fails during build when Flex uses dynamic m4

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: laurence(dot)tews(at)gmail(dot)com
Subject: BUG #18841: pgflex fails during build when Flex uses dynamic m4
Date: 2025-03-13 00:52:51
Message-ID: 18841-19af9c81fe3ae298@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18841
Logged by: Laurence Tews
Email address: laurence(dot)tews(at)gmail(dot)com
PostgreSQL version: 17.4
Operating system: Ubuntu x86_64
Description:

When building PostgreSQL from source, using a flex binary that is built with
./configure m4=m4 (a common configuration for hermetic build systems, or
where remote execution is used e.g. bazel) pgflex fails due to being unable
to locate an m4 executable.

FAILED: src/fe_utils/psqlscan.c
/usr/bin/python3 ../src/tools/pgflex --builddir . --srcdir .. --privatedir
src/fe_utils/psqlscan.c.p --flex /home/user/build_home/bin/flex --perl
/usr/bin/perl -i ../src/fe_utils/psqlscan.l -o src/fe_utils/psqlscan.c
--no-backup --fix-warnings -- -Cfe -p -p
flex: fatal internal error, exec of m4 failed

This appears to be due to the fact when m4=m4 is provided, flex uses the
PATH env to locate an m4 executable. Within src/tools/pgflex, the env is
replaced in the subprocess call, so any existing PATH env is not passed to
the subprocess. One possible fix is to create a copy of the existing env,
append FLEX_TMP_DIR, and pass the whole environment to the flex subprocess.

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-03-13 01:13:34 Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE
Previous Message Tom Lane 2025-03-13 00:08:53 Re: Attribute of type record has wrong type error with MERGE ... WHEN NOT MATCHED BY SOURCE THEN DELETE