Thread

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

    The Post Office <noreply@postgresql.org> — 2025-03-13T00:52:51Z

    The following bug has been logged on the website:
    
    Bug reference:      18841
    Logged by:          Laurence Tews
    Email address:      laurence.tews@gmail.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.