changeset 77:278470dc420d

Provide a "pypy3"-plugin project and make the PyPy-plugin compile properly on FreeBSD. Because pypy_setup.py needs to be properly included within the plugin binary the corresponding binary linking step has been changed to include an "-m" flag because on FreeBSD the current LLVM linker (ld.lld) obviously has no default setting. Per default it is derived from the first object file. But in the binary linking step there is no such .o file. It needs to be included within the uwsgi binary because it is neede to build the plugins when using the uwsgi binary with the "--build-plugin" option.
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 14 Jun 2020 20:03:33 +0200
parents 8711f048ba1c
children 2b8606346ec7 e3249546c992
files uwsginl-plugin-lang-pypy3/Makefile uwsginl-plugin-lang-pypy3/distinfo uwsginl-plugin-lang-pypy3/pkg-descr uwsginl/files/patch-uwsgiconfig.py
diffstat 4 files changed, 91 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uwsginl-plugin-lang-pypy3/Makefile	Sun Jun 14 20:03:33 2020 +0200
@@ -0,0 +1,53 @@
+# Created by: Franz Glasner <freebsd-dev@dom66.de>
+# $FreeBSD$
+
+PORTNAME=	${UWSGI_NAME}-plugin-lang-pypy3
+DISTVERSION=	2.0.18
+CATEGORIES=	www python
+MASTER_SITES=	https://projects.unbit.it/downloads/
+DISTNAME=	uwsgi-${DISTVERSION}
+
+MAINTAINER=	freebsd-dev@dom66.de
+COMMENT=	Language plugin for PyPy 3
+
+LICENSE=	GPLv2-WITH-LINKING-EXCEPTION
+LICENSE_GROUPS=	FSF GPL OSI
+LICENSE_NAME=	GPLv2 with linking exception
+LICENSE_FILE=	${WRKSRC}/LICENSE
+LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+BUILD_DEPENDS+=	${UWSGI_NAME}==${PORTVERSION}:www/uwsginl
+BUILD_DEPENDS+=	pypy3>=6:lang/pypy3
+RUN_DEPENDS+=	${UWSGI_NAME}==${PORTVERSION}:www/uwsginl
+RUN_DEPENDS+=	pypy3>=6:lang/pypy3
+
+USES=		gettext-runtime pkgconfig
+
+PLIST_FILES=	${PLUGIN_DIR}/${PLUGIN_FILENAME}
+
+MAKE_ENV+=	UWSGI_PROFILE_OVERRIDE="plugin_build_dir=${STAGEDIR}${PREFIX}/${PLUGIN_DIR};plugin_dir=${PREFIX}/${PLUGIN_DIR}" PYTHON=/usr/local/bin/pypy3
+
+DESCR=		pkg-descr
+
+UWSGI_NAME=	uwsginl
+UWSGI_PATH=	${LOCALBASE}/bin/${UWSGI_NAME}
+PLUGIN_DIR=	lib/${UWSGI_NAME}/plugins
+
+# The name of the plugin to be created (to eventually  distingush py2 and py3)
+PLUGIN_NAME=	pypy3
+# Where to find the sources for the plugin (defaults to plugins/${PLUGIN_NAME})
+PLUGIN_SOURCE=	plugins/pypy
+# The complete basename of the plugin
+PLUGIN_FILENAME=	${PLUGIN_NAME}_plugin.so
+
+do-configure:
+	@${DO_NADA}
+
+do-build:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${PLUGIN_DIR}
+	@(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${UWSGI_PATH} --build-plugin "${PLUGIN_SOURCE} ${PLUGIN_NAME}")
+
+do-install:
+	${INSTALL_LIB} ${BUILD_WRKSRC}/${PLUGIN_FILENAME} ${STAGEDIR}${PREFIX}/${PLUGIN_DIR}
+
+.include <bsd.port.mk>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uwsginl-plugin-lang-pypy3/distinfo	Sun Jun 14 20:03:33 2020 +0200
@@ -0,0 +1,3 @@
+TIMESTAMP = 1552136313
+SHA256 (uwsgi-2.0.18.tar.gz) = 4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583
+SIZE (uwsgi-2.0.18.tar.gz) = 801555
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uwsginl-plugin-lang-pypy3/pkg-descr	Sun Jun 14 20:03:33 2020 +0200
@@ -0,0 +1,5 @@
+PyPy3 language plugin for uwsginl.
+Dynymically Links to the default PyPy version on the system by default.
+Use --pypy-lib to link to libpypy3-c.so.
+
+WWW: https://projects.unbit.it/uwsgi/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uwsginl/files/patch-uwsgiconfig.py	Sun Jun 14 20:03:33 2020 +0200
@@ -0,0 +1,30 @@
+--- uwsgiconfig.py.orig	2019-02-09 14:48:07 UTC
++++ uwsgiconfig.py
+@@ -1457,7 +1457,8 @@ def build_plugin(path, uc, cflags, ldflags, libs, name
+             gcc_list.append(path + '/' + cfile)
+     for bfile in up.get('BINARY_LIST', []):
+         try:
+-            binary_link_cmd = "ld -r -b binary -o %s/%s.o %s/%s" % (path, bfile[1], path, bfile[1])
++            # See https://svnweb.freebsd.org/base/vendor/lld/dist-release_80/ELF/Driver.cpp?revision=344173&view=markup
++            binary_link_cmd = "ld -r -b binary %s -o %s/%s.o %s/%s" % (get_default_target_emulation(), path, bfile[1], path, bfile[1])
+             print(binary_link_cmd)
+             if os.system(binary_link_cmd) != 0:
+                 raise Exception('unable to link binary file')
+@@ -1550,6 +1551,17 @@ def build_plugin(path, uc, cflags, ldflags, libs, name
+ 
+     print("build time: %d seconds" % (time.time() - plugin_started_at))
+     print("*** %s plugin built and available in %s ***" % (name, plugin_dest + '.so'))
++
++def get_default_target_emulation():
++    """Need a target emulation on FreeBSD (ld, ld.lld when linking binary/raw"""
++    emul = ""
++    if uwsgi_cpu in ("amd64", "x86-64", "x86_64"):
++        emul = "elf_amd64"
++    elif uwsgi_cpu in ("i386", "x86"):
++        emul = "elf_i386"
++    if emul:
++        return "-m %s" % emul
++    return ""
+ 
+ def vararg_callback(option, opt_str, value, parser):
+     assert value is None