devel/swig: update to 4.1.0.

- remove patches for php8 support that were previously backported
- add node, go & boost to TDEP so that most tests can run (most of them pass)
- switch to pcre2

ran all tests on i386, amd64 & arm64 (thanks stsp@ for providing access)
also tested on arm64 by tb@ and riscv64 by jca@
went in an amd64 bulk build by tb@
This commit is contained in:
landry 2022-11-02 16:37:58 +00:00
parent b078a440de
commit dca1b3fa0d
12 changed files with 390 additions and 397 deletions

View File

@ -1,8 +1,7 @@
COMMENT = simplified wrapper and interface generator
SUBST_VARS = VERSION
VERSION = 4.0.2
REVISION = 4
VERSION = 4.1.0
DISTNAME = swig-${VERSION}
CATEGORIES = devel
@ -12,7 +11,7 @@ HOMEPAGE = http://www.swig.org/
# BSD
PERMIT_PACKAGE = Yes
WANTLIB = c m pcre ${COMPILER_LIBCXX} z
WANTLIB = c m pcre2-8 ${COMPILER_LIBCXX} z
COMPILER = base-clang ports-gcc base-gcc
@ -29,7 +28,13 @@ MODPHP_BUILDDEP = Yes
BUILD_DEPENDS = ${MODTCL_BUILD_DEPENDS} \
lang/guile
LIB_DEPENDS = devel/pcre
LIB_DEPENDS = devel/pcre2
# dont run update-plist after make test
TEST_DEPENDS = lang/go \
lang/node \
devel/boost
USE_GMAKE = Yes
CONFIGURE_STYLE = gnu
@ -48,6 +53,11 @@ ALL_TARGET = swig
SWIG_EXAMPLES = ${PREFIX}/share/examples/swig
SWIG_DOCS = ${PREFIX}/share/doc/swig
PORTHOME = ${WRKDIR}
pre-test:
ln -sf ${MODTCL_BIN} ${WRKDIR}/bin/tclsh
post-install:
${INSTALL_DATA_DIR} ${SWIG_EXAMPLES}
${INSTALL_DATA_DIR} ${SWIG_DOCS}

View File

@ -1,2 +1,2 @@
SHA256 (swig-4.0.2.tar.gz) = 1Tvpcw2NWKFr8MvR+KwMDD4QkFcxaL+hUbAetH+pBvw=
SIZE (swig-4.0.2.tar.gz) = 8097014
SHA256 (swig-4.1.0.tar.gz) = 1qmoCU5498+2+ApzzCceH+OIyGOO0iZoYiwsZG31uz0=
SIZE (swig-4.1.0.tar.gz) = 8600226

View File

@ -1,12 +1,12 @@
Index: CCache/configure
--- CCache/configure.orig
+++ CCache/configure
@@ -3759,15 +3759,7 @@ else
@@ -4093,15 +4093,7 @@ else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
-int
-main ()
-main (void)
-{
-
void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }
@ -15,5 +15,5 @@ Index: CCache/configure
- return 0;
-}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ccache_cv_COMPAR_FN_T=yes
if ac_fn_c_try_compile "$LINENO"
then :

View File

@ -0,0 +1,23 @@
adapt for our pthread_set_name_np which returns void.
Index: Examples/test-suite/director_thread.i
--- Examples/test-suite/director_thread.i.orig
+++ Examples/test-suite/director_thread.i
@@ -22,6 +22,7 @@
#include <process.h>
#else
#include <pthread.h>
+#include <pthread_np.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
@@ -112,7 +113,8 @@ extern "C" {
%#ifdef __APPLE__
int setname = pthread_setname_np("MyThreadName");
%#else
- int setname = pthread_setname_np(pthread_self(), "MyThreadName");
+ int setname = 0;
+ pthread_set_name_np(pthread_self(), "MyThreadName");
%#endif
if (setname != 0) {

View File

@ -1,16 +0,0 @@
backport php 8 support from upstream
https://github.com/swig/swig/pull/1978 via
https://src.fedoraproject.org/rpms/swig/c/62dded8bacb09398b03d1352820636182d2494ab
Index: Lib/cdata.i
--- Lib/cdata.i.orig
+++ Lib/cdata.i
@@ -21,7 +21,7 @@ typedef struct SWIGCDATA {
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
-#elif SWIGPHP7
+#elif SWIGPHP
%typemap(out) SWIGCDATA {
ZVAL_STRINGL($result, $1.data, $1.len);

View File

@ -1,16 +0,0 @@
backport php 8 support from upstream
https://github.com/swig/swig/pull/1978 via
https://src.fedoraproject.org/rpms/swig/c/62dded8bacb09398b03d1352820636182d2494ab
Index: Lib/exception.i
--- Lib/exception.i.orig
+++ Lib/exception.i
@@ -12,7 +12,7 @@
%insert("runtime") "swigerrors.swg"
-#ifdef SWIGPHP7
+#ifdef SWIGPHP
%{
#include "zend_exceptions.h"
#define SWIG_exception(code, msg) do { zend_throw_exception(NULL, (char*)msg, code); goto thrown; } while (0)

View File

@ -1,19 +0,0 @@
backport php 8 support from upstream
https://github.com/swig/swig/pull/1978 via
https://src.fedoraproject.org/rpms/swig/c/62dded8bacb09398b03d1352820636182d2494ab
Index: Lib/php/php.swg
--- Lib/php/php.swg.orig
+++ Lib/php/php.swg
@@ -465,7 +465,10 @@
%php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE)
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
-%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
+%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&
+ " $1 = (Z_TYPE($input) == IS_STRING || Z_TYPE($input) == IS_NULL); "
+
+%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char []
" $1 = (Z_TYPE($input) == IS_STRING); "
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE

View File

@ -1,30 +0,0 @@
backport php 8 support from upstream
https://github.com/swig/swig/pull/1978 via
https://src.fedoraproject.org/rpms/swig/c/62dded8bacb09398b03d1352820636182d2494ab
Index: Lib/php/phprun.swg
--- Lib/php/phprun.swg.orig
+++ Lib/php/phprun.swg
@@ -12,8 +12,8 @@ extern "C" {
#include "zend_exceptions.h"
#include "php.h"
-#if PHP_MAJOR_VERSION != 7
-# error These bindings need PHP7 - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
+#if PHP_MAJOR_VERSION < 7
+# error These bindings need PHP 7 or later - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#endif
#include "ext/standard/php_string.h"
@@ -204,7 +204,11 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *t
switch (Z_TYPE_P(z)) {
case IS_OBJECT: {
+#if PHP_MAJOR_VERSION < 8
HashTable * ht = Z_OBJ_HT_P(z)->get_properties(z);
+#else
+ HashTable * ht = Z_OBJ_HT_P(z)->get_properties(Z_OBJ_P(z));
+#endif
if (ht) {
zval * _cPtr = zend_hash_str_find(ht, "_cPtr", sizeof("_cPtr") - 1);
if (_cPtr) {

View File

@ -1,93 +0,0 @@
backport php 8 support from upstream via
https://src.fedoraproject.org/rpms/swig/c/62dded8bacb09398b03d1352820636182d2494ab
Index: Source/Modules/php.cxx
--- Source/Modules/php.cxx.orig
+++ Source/Modules/php.cxx
@@ -473,6 +473,20 @@ class PHP : public Language { (public)
s_arginfo = NewString("/* arginfo subsection */\n");
arginfo_used = NewHash();
+ // Add arginfo we'll definitely need for *_alter_newobject and *_get_newobject.
+ SetFlag(arginfo_used, "1");
+ Append(s_arginfo,
+ "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_1, 0, 0, 0)\n"
+ " ZEND_ARG_INFO(0,arg1)\n"
+ "ZEND_END_ARG_INFO()\n");
+
+ SetFlag(arginfo_used, "2");
+ Append(s_arginfo,
+ "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_2, 0, 0, 0)\n"
+ " ZEND_ARG_INFO(0,arg1)\n"
+ " ZEND_ARG_INFO(0,arg2)\n"
+ "ZEND_END_ARG_INFO()\n");
+
/* start the function entry section */
s_entry = NewString("/* entry subsection */\n");
@@ -653,8 +667,8 @@ class PHP : public Language { (public)
}
Printv(f_begin, s_vdecl, s_wrappers, NIL);
Printv(f_begin, all_cs_entry, "\n\n", s_arginfo, "\n\n", s_entry,
- " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n"
- " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n"
+ " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,swig_arginfo_2)\n"
+ " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,swig_arginfo_1)\n"
" ZEND_FE_END\n};\n\n", NIL);
Printv(f_begin, s_init, NIL);
Delete(s_header);
@@ -689,25 +703,46 @@ class PHP : public Language { (public)
// We want to only emit each different arginfo once, as that reduces the
// size of both the generated source code and the compiled extension
- // module. To do this, we name the arginfo to encode the number of
- // parameters and which (if any) are passed by reference by using a
- // sequence of 0s (for non-reference) and 1s (for by references).
+ // module. The parameters at this level are just named arg1, arg2, etc
+ // so we generate an arginfo name with the number of parameters and a
+ // bitmap value saying which (if any) are passed by reference.
ParmList *l = Getattr(n, "parms");
- String * arginfo_code = NewStringEmpty();
+ unsigned long bitmap = 0, bit = 1;
+ int n_params = 0;
+ bool overflowed = false;
for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) {
/* Ignored parameters */
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
- Append(arginfo_code, GetFlag(p, "tmap:in:byref") ? "1" : "0");
+ ++n_params;
+ if (GetFlag(p, "tmap:in:byref")) {
+ bitmap |= bit;
+ if (bit == 0) overflowed = true;
+ }
+ bit <<= 1;
}
+ String * arginfo_code;
+ if (overflowed) {
+ // We overflowed the bitmap so just generate a unique name - this only
+ // happens for a function with more parameters than bits in a long
+ // where a high numbered parameter is passed by reference, so should be
+ // rare in practice.
+ static int overflowed_counter = 0;
+ arginfo_code = NewStringf("z%d", ++overflowed_counter);
+ } else if (bitmap == 0) {
+ // No parameters passed by reference.
+ arginfo_code = NewStringf("%d", n_params);
+ } else {
+ arginfo_code = NewStringf("%d_%lx", n_params, bitmap);
+ }
if (!GetFlag(arginfo_used, arginfo_code)) {
- // Not had this one before, so emit it.
+ // Not had this one before so emit it.
SetFlag(arginfo_used, arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code);
- for (const char * p = Char(arginfo_code); *p; ++p) {
- Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p);
+ for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) {
+ Printf(s_arginfo, " ZEND_ARG_INFO(%d,%s)\n", GetFlag(p, "tmap:in:byref"), Getattr(p, "lname"));
}
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
}

View File

@ -1,7 +1,7 @@
Index: Source/Swig/include.c
--- Source/Swig/include.c.orig
+++ Source/Swig/include.c
@@ -291,7 +291,6 @@ int Swig_insert_file(const_String_or_char_ptr filename
@@ -287,7 +287,6 @@ int Swig_insert_file(const_String_or_char_ptr filename
while ((nbytes = Read(f, buffer, 4096)) > 0) {
Write(outfile, buffer, nbytes);
}

View File

@ -1,23 +1,19 @@
find our php-config-${PHP_VERSION}
fix Examples/guile/multivalue & multimap regress tests
ld: error: unknown argument '-I/usr/local/include'
ld: error: unknown argument '-pthread'
ld: error: unknown argument '-pthread'
ld: error: unable to find library -lm
Index: configure
--- configure.orig
+++ configure
@@ -9924,14 +9924,14 @@ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PHP header files" >&5
$as_echo_n "checking for PHP header files... " >&6; }
case $PHP in
- *7.*)
- PHPCONFIG=`echo "$PHP"|sed 's/7\...*$/-config&/'` ;;
+ *8.*)
+ PHPCONFIG=`echo "$PHP"|sed 's/\(-8\..\)/-config\1/'` ;;
*)
PHPCONFIG=$PHP-config ;;
esac
php_version=`$PHPCONFIG --version 2>/dev/null`
case $php_version in
- 7.*)
+ 8.*)
PHPINC=`$PHPCONFIG --includes 2>/dev/null`
if test -n "$PHPINC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PHPINC" >&5
@@ -6648,7 +6648,7 @@ then
*-*-linux*) LDSHARED="\$(CC) -shared";;
*-*-dgux*) LDSHARED="ld -G";;
*-*-freebsd3*) LDSHARED="\$(CC) -shared";;
- *-*-freebsd* | *-*-openbsd*) LDSHARED="ld -Bshareable";;
+ *-*-freebsd* | *-*-openbsd*) LDSHARED="cc -shared";;
*-*-netbsd*)
if [ "`\$(CC) -dM -E - </dev/null | grep __ELF__`" != "" ]
then

File diff suppressed because it is too large Load Diff