[Bug 263353] lang/python38: fix excessive ld.lld memory use with LTO in port options

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 16 Apr 2022 21:58:20 UTC

            Bug ID: 263353
           Summary: lang/python38: fix excessive ld.lld memory use with
                    LTO in port options
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch, regression
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: python@FreeBSD.org
          Reporter: mandree@FreeBSD.org
                CC: python@FreeBSD.org
          Assignee: python@FreeBSD.org
             Flags: maintainer-feedback?(python@FreeBSD.org)
 Attachment #233259 maintainer-approval?(python@FreeBSD.org)
                CC: python@FreeBSD.org

Created attachment 233259
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=233259&action=edit
remove -g from the CFLAGS/LDFLAGS unless WITH_DEBUG is set not empty and not

I can no longer build Python 3.8 on a FreeBSD 13.0-RELEASE amd64 computer with
1.6 GB available memory (1 GB physical, 1 GB encrypted swap file on UFS).

The upstream configure.ac file in Python 3.8.13 as of 0058eede0ebf adds "-flto
-g" to the build (through CFLAGS and LDFLAGS). This happens even without

This considerably increases the memory that my FreeBSD 13.0-RELEASE ld.lld
requires, and the kernel kills it with "out of swap space". 

I used to be able to build Python 3.8 on that machine earlier, and reviewing
port history, I surmise that * 9a31e1b6d3bf 2022-03-09 | lang/python3*: add LTO
option and enable by default everywhere except powerpc64 and riscv64 [Piotr
caused the increase in memory consumption from the desired LTO.

Chopping out the -g from CFLAGS and LDFLAGS fixes this for me, reducing linker
memory consumption to below 400 MB VMEM, and lets my low-on-RAM computer
complete the build. (It is a single Xeon core I rented out for a virtual

I am proposing the attached patch. I have not investigated yet whether Pythons
3.7 3.9 3.10 3.11 need an analogue patch, for lack of time. In Python 3.8 you
will see "-flto -g" in the ${WRKSRC}/Makefile that results from a "make
configure" with LTO option enabled, because the upstream configure.ac is
written that way.

You are receiving this mail because:
You are the assignee for the bug.