develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #78502] ext/XS-APItest/t/call_checker.t fails under Cygwin

From:
Tony Cook via RT
Date:
June 1, 2012 19:41
Subject:
[perl #78502] ext/XS-APItest/t/call_checker.t fails under Cygwin
Message ID:
rt-3.6.HEAD-5009-1338604911-241.78502-15-0@perl.org
On Mon Apr 11 03:02:36 2011, zefram@fysh.org wrote:
> For the use of modules (such as D-CC) that export C functions, it would
> be useful to have this logic available more openly.  PERL_CALLCONV has
> the right specifiers for core functions, but the right specifiers for
> a module's functions may be different (they're different when building
> the module itself).  We should probably have something like:
> 
> 	#define PERL_BASE_CALLCONV EXTERN_C
> 	#define PERL_EXPORT_CALLCONV PERL_BASE_CALLCONV
> 	#if defined(WIN32) || defined(__CYGWIN__)
> 	# define PERL_IMPORT_CALLCONV PERL_BASE_CALLCONV __declspec(dllimport)
> 	#else
> 	# define PERL_IMPORT_CALLCONV PERL_BASE_CALLCONV
> 	#endif
> 	#ifdef PERL_CORE
> 	# define PERL_CALLCONV PERL_EXPORT_CALLCONV
> 	#else
> 	# define PERL_CALLCONV PERL_IMPORT_CALLCONV
> 	#endif
> 
> Adding PERL_{EX,IM}PORT_CALLCONV to the API should, of course, wait
> until 5.15.  For now, I suggest just extending the current Windows logic
> to Cygwin.

I tried the following change:

diff --git a/perl.h b/perl.h
index 798e7b7..ba9f540 100644
--- a/perl.h
+++ b/perl.h
@@ -5019,15 +5019,26 @@ struct tempsym; /* defined in pp_pack.c */

 #ifndef PERL_CALLCONV
 #  ifdef __cplusplus
-#    define PERL_CALLCONV extern "C"
+#    define PERL_BASE_CALLCONV extern "C"
 #  else
-#    define PERL_CALLCONV
+#    define PERL_BASE_CALLCONV
 #  endif
+#define PERL_EXPORT_CALLCONV PERL_BASE_CALLCONV
+#if defined(WIN32) || defined(__CYGWIN__)
+#  define PERL_IMPORT_CALLCONV PERL_BASE_CALLCONV __declspec(dllimport)
+#else
+#  define PERL_IMPORT_CALLCONV PERL_BASE_CALLCONV
 #endif
 #undef PERL_CKDEF
 #undef PERL_PPDEF
 #define PERL_CKDEF(s)  PERL_CALLCONV OP *s (pTHX_ OP *o);
 #define PERL_PPDEF(s)  PERL_CALLCONV OP *s (pTHX);
+#if defined(PERL_CORE)
+# define PERL_CALLCONV PERL_EXPORT_CALLCONV
+#else
+# define PERL_CALLCONV PERL_IMPORT_CALLCONV
+#endif
+#endif

 #ifdef MYMALLOC
 #  include "malloc_ctl.h"

This failed linking perl itself in Dynaloader, since it sees
__declspec(dllimport) but isn't provided the appropriate
__imp__Foo symbols for perl APIs.  I'd expect similar failures
linking any other extension statically.

I modified sub cflags in EU::MM_Unix to add a -DPERL_STATIC_EXT
define when building a static extension, and modified the final
conditional above to check for PERL_STATIC_EXT as well as
PERL_CORE.

This time it failed linking the re extension, since Perl_regprop
aka my_regprop is declared as dllimport, but isn't an import to
the the other objects linked into re.dll.  I fiddled with this a
bit (removing E from the entry in embed.fnc to start) but haven't
managed to get it to work yet.

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=78502



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About