lang/python: stop leaking python build LDFLAGS/CFLAGS to python extensions build

right now the installed python retains paths to the python build objdir,
and also enforces -L/usr/local/lib when linking python shared extensions
(which might not be desired):

$python3 -m sysconfig|grep LDSH
        BLDSHARED = "cc -pthread -shared -fPIC -L/usr/local/lib/ -L/usr/obj/ports/Python-3.8.12/Python-3.8.12 -L/usr/local/lib/"
        LDSHARED = "cc -pthread -shared -fPIC -L/usr/local/lib/ -L/usr/obj/ports/Python-3.8.12/Python-3.8.12 -L/usr/local/lib/"

python 3.x provides LDFLAGS_NODIST/CFLAGS_NODIST to avoid that (cf
https://docs.python.org/3/using/configure.html#envvar-CONFIGURE_LDFLAGS_NODIST),
but sadly if we only use it (and remove CPPFLAGS/LDFLAGS pointing at
/usr/local from CONFIGURE_ENV), libintl/textdomain detection during
configure fails.

So, taking inspiration from freebsd PR181721, dont add
CONFIGURE_LDFLAGS/CONFIGURE_CPPFLAGS to PY_LDFLAGS/PY_CPPFLAGS.

extend CHANGES.OpenBSD to explain the change (reminded by sthen@).

went in a bulk build (thanks ajacoutot@!) with a single fallout
(devel/gdb) that will get fixed shortly.
This commit is contained in:
landry 2021-11-01 07:43:39 +00:00
parent e09ade2ced
commit 89cd0faf06
8 changed files with 44 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.70 2021/09/01 17:41:48 kmos Exp $
# $OpenBSD: Makefile,v 1.71 2021/11/01 07:43:39 landry Exp $
# IMPORTANT! If you make any changes to the Python ports, be sure
# to also update files/CHANGES.OpenBSD for your change. This is a
@ -10,7 +10,7 @@ PATCHLEVEL = .18
SHARED_LIBS = python2.7 0.0
VERSION_SPEC = >=2.7,<2.8
REVISION-main = 3
REVISION-main = 4
REVISION-idle = 1
REVISION-tests = 1
REVISION-bsddb = 0

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.19 2021/10/26 23:30:08 kmos Exp $
# $OpenBSD: Makefile,v 1.20 2021/11/01 07:43:39 landry Exp $
# IMPORTANT! If you make any changes to the Python ports, be sure
# to also update files/CHANGES.OpenBSD for your change. This is a
@ -10,7 +10,7 @@ PATCHLEVEL = .12
SHARED_LIBS = python3.8 0.0
VERSION_SPEC = >=3.8,<3.9
REVISION-main = 0
REVISION-main = 1
CONFIGURE_ARGS += --with-ensurepip=no
CONFIGURE_ARGS += --enable-loadable-sqlite-extensions

View File

@ -1,4 +1,4 @@
$OpenBSD: CHANGES.OpenBSD,v 1.5 2021/10/26 23:30:08 kmos Exp $
$OpenBSD: CHANGES.OpenBSD,v 1.6 2021/11/01 07:43:39 landry Exp $
As required by item 3 of the PSF license, here is a brief summary
of changes made to this version of Python for the OpenBSD package.
@ -14,5 +14,8 @@ functions.
4. Disable MULTIARCH check in configure.ac since OpenBSD is not a
multi-arch platform and it causes build problems.
5. Make sure CPPFLAGS/LDFLAGS passed to ./configure don't end up
in PY_CPPFLAGS/PY_LDFLAGS and thus leaking to python extensions.
These changes are available in the OpenBSD CVS repository
<http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.8.

View File

@ -1,8 +1,23 @@
$OpenBSD: patch-Makefile_pre_in,v 1.2 2021/06/12 04:03:23 kmos Exp $
$OpenBSD: patch-Makefile_pre_in,v 1.3 2021/11/01 07:43:39 landry Exp $
chunk 1 is inspired by https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=181721
make sure that CONFIGURE_{LD,C}FLAGS dont leak to python extensions build
Index: Makefile.pre.in
--- Makefile.pre.in.orig
+++ Makefile.pre.in
@@ -99,8 +99,8 @@ PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_N
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
-PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
-PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
+PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CPPFLAGS)
+PY_LDFLAGS= $(LDFLAGS)
PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
NO_AS_NEEDED= @NO_AS_NEEDED@
SGI_ABI= @SGI_ABI@
@@ -646,7 +646,7 @@ gdbhooks: $(BUILDPYTHON)-gdb.py
SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.10 2021/10/30 00:24:16 kmos Exp $
# $OpenBSD: Makefile,v 1.11 2021/11/01 07:43:39 landry Exp $
# IMPORTANT! If you make any changes to the Python ports, be sure
# to also update files/CHANGES.OpenBSD for your change. This is a
@ -11,7 +11,7 @@ SHARED_LIBS = python3.9 0.0
VERSION_SPEC = >=3.9,<3.10
#PSUBDIR = python/3.9.0
REVISION-main = 0
REVISION-main = 1
CONFIGURE_ARGS += --with-ensurepip=no

View File

@ -1,4 +1,4 @@
$OpenBSD: CHANGES.OpenBSD,v 1.5 2021/10/30 00:24:16 kmos Exp $
$OpenBSD: CHANGES.OpenBSD,v 1.6 2021/11/01 07:43:39 landry Exp $
As required by item 3 of the PSF license, here is a brief summary
of changes made to this version of Python for the OpenBSD package.
@ -14,5 +14,8 @@ functions.
4. Disable MULTIARCH check in configure.ac since OpenBSD is not a
multi-arch platform and it causes build problems.
5. Make sure CPPFLAGS/LDFLAGS passed to ./configure don't end up
in PY_CPPFLAGS/PY_LDFLAGS and thus leaking to python extensions.
These changes are available in the OpenBSD CVS repository
<http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.9.

View File

@ -1,8 +1,19 @@
$OpenBSD: patch-Makefile_pre_in,v 1.2 2021/06/12 04:00:22 kmos Exp $
$OpenBSD: patch-Makefile_pre_in,v 1.3 2021/11/01 07:43:39 landry Exp $
Index: Makefile.pre.in
--- Makefile.pre.in.orig
+++ Makefile.pre.in
@@ -99,8 +99,8 @@ PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_N
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
-PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
-PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
+PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CPPFLAGS)
+PY_LDFLAGS= $(LDFLAGS)
PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
NO_AS_NEEDED= @NO_AS_NEEDED@
SGI_ABI= @SGI_ABI@
@@ -674,7 +674,7 @@ gdbhooks: $(BUILDPYTHON)-gdb.py
SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.139 2021/09/01 17:41:47 kmos Exp $
# $OpenBSD: Makefile.inc,v 1.140 2021/11/01 07:43:39 landry Exp $
# IMPORTANT! If you make any changes to the Python ports, be sure
# to also update files/CHANGES.OpenBSD for your change. This is a
@ -121,7 +121,7 @@ CONFIGURE_ENV += OPT='${CFLAGS} -fPIC' CPPFLAGS='-I${LOCALBASE}/include' \
LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
MAKE_ENV += LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
MAKE_FLAGS += LD_LIBRARY_PATH=${WRKSRC} PATH="${WRKDIST}:${PORTPATH}"
MAKE_FLAGS += LDFLAGS='-L${WRKSRC} -L${LOCALBASE}/lib/'
MAKE_FLAGS += CFLAGS_NODIST='-I${LOCALBASE}/include' LDFLAGS_NODIST='-L${WRKSRC} -L${LOCALBASE}/lib/'
FAKE_FLAGS += RANLIB=:
PY_PLATFORM = openbsd${OSMAJOR}