On Sat, Aug 06, 2022 at 11:59:33PM -0400, George Koehler wrote:
> We recently added --enable-optimizations in lang/python/3.* for PGO
> (Profile Guided Optimization), on all platforms where the linker is
> lld. Turns out, this breaks on macppc (powerpc). The build segfaults
> as soon as it tries to run the linked python binary,
> cc -pthread -L/usr/local/lib/ -flto -g
> -L/usr/obj/ports/Python-3.9.13/Python-3.
> 9.13 -L/usr/local/lib/ -fprofile-instr-generate -Wl,--export-dynamic -o
> python P
> rograms/python.o -L. -lpython3.9 -lintl -lpthread -lutil -lm -lm
> LD_LIBRARY_PATH=/usr/obj/ports/Python-3.9.13/Python-3.9.13 ./python -E -S -m
> sys
> config --generate-posix-vars ; if test $? -ne 0 ; then echo
> "generate-posix-var
> s failed" ; rm -f ./pybuilddir.txt ; exit 1 ; fi
> Segmentation fault (core dumped)
> *** Error 139 in . (Makefile:623 'pybuilddir.txt')
> There is no problem on powerpc64; this seems to be a bug in clang or
> lld specific to 32-bit powerpc. I don't know how to reproduce this
> bug outside of python. All of python 3.8, 3.9, 3.10 are broken; they
> all get packaged after I remove --enable-optimizations.
> May I commit this diff, which removes --enable-optimizations on
> powerpc? --George
Looks reasonable. ok kmos@
--Kurt
> Index: Makefile.inc
> ===================================================================
> RCS file: /cvs/ports/lang/python/Makefile.inc,v
> retrieving revision 1.149
> diff -u -p -r1.149 Makefile.inc
> --- Makefile.inc 27 Jul 2022 06:20:10 -0000 1.149
> +++ Makefile.inc 6 Aug 2022 21:35:35 -0000
> @@ -122,7 +122,11 @@ CONFIGURE_ARGS += --with-fpectl \
> .if ${VERSION} != "2.7"
> CONFIGURE_ARGS += --enable-loadable-sqlite-extensions
> . if ${PROPERTIES:Mlld}
> -CONFIGURE_ARGS += --with-lto --enable-optimizations
> +CONFIGURE_ARGS += --with-lto
> +. if ${MACHINE_ARCH} != "powerpc"
> +# On powerpc, the python binary would crash by "Segmentation fault".
> +CONFIGURE_ARGS += --enable-optimizations
> +. endif
> . endif
> TEST_IS_INTERACTIVE = Yes
> .endif