Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the ExtUtils-ParseXS CPAN distribution.

Report information
The Basics
Id: 42574
Status: resolved
Priority: 0/
Queue: ExtUtils-ParseXS

People
Owner: Nobody in particular
Requestors: kaffeetisch [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Make it possible to have xsubs declared as 'static'
For extensions with a lot of xsubs (like the Gtk2 family), it would be beneficial to have the xsubs declared as 'static' so that they don't need to be relocated at startup. Since I don't think this can be the default behavior (due to backwards compatibility), an new option for xsubpp would probably be needed. See <http://markmail.org/message/vvdx56sghtlplcp2> for some discussion.
Hi, I know that this is a WAAAY late response to your ticket, but I only now took a look. On Tue Jan 20 14:05:36 2009, TSCH wrote: Show quoted text
> For extensions with a lot of xsubs (like the Gtk2 family), it would be > beneficial to have the xsubs declared as 'static' so that they don't > need to be relocated at startup. Since I don't think this can be the > default behavior (due to backwards compatibility), an new option for > xsubpp would probably be needed. > > See <http://markmail.org/message/vvdx56sghtlplcp2> for some
discussion. I don't think this is easily and safely possible by patching ExtUtils::ParseXS only. Note that I am certainly not the most clueful person in these matters, so feel free to prove me wrong! Here's why: EU::ParseXS uses the XS() macro defined in XSUB.h to declare XSUBs. That marco can expand to different things depending on platform and compiler. I believe the "static" (or "STATIC" in perl terms) would have to be injected into the code generated by the XS() macro and can't be slapped in front of it. XS is *currently*: #define XSPROTO(name) void name(pTHX_ CV* cv) #undef XS #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) # define XS(name) __declspec(dllexport) XSPROTO(name) #endif #if defined(__SYMBIAN32__) # define XS(name) EXPORT_C XSPROTO(name) #endif #ifndef XS # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) # define XS(name) void name(pTHX_ CV* cv __attribute__unused__) # else # ifdef __cplusplus # define XS(name) extern "C" XSPROTO(name) # else # define XS(name) XSPROTO(name) # endif # endif #endif We might get away with something ugly such as: #define XSPROTO(name) STATIC void name(pTHX_ CV* cv) #if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) # define XS(name) STATIC void name(pTHX_ CV* cv __attribute__unused__) #endif But then, this would be valid only for all versions of perl which ship with the above XS() definition. I didn't do the archeology to find out which versions that would be. Probably goes way back, but what if this gets modified in the future? So maybe we need an XS_STATIC macro in XSUB.h instead? That, we could probably backport with Devel::PPPort. What do you think? Best regards, Steffen
Just a note for the record: I discussed this with Zefram on #p5p. We think it might be acceptable to make XSUBs static by default and allow a special XS verb to mark an XSUB as requiring external linkage. I tested a "dirty" implementation of the static-ness in ExtUtils::ParseXS with a few tens of CPAN modules just to see if this is entirely crazy. No failures so far. Will do better testing later but the train is arriving now. --Steffen
I have just pushed a change to the core perl repository that adds the XS_INTERNAL and XS_EXTERNAL macros that correspond to "static" and exported XSUB symbols respectively. People seem to be fine with this change, but there may, of course, still be a public outcry. Right now, XS is still defined to be XS_EXTERNAL, but if in the C section of your XS file, you add something like the following (last three lines matter most, the rest is just a perl version guad), you can choose to have static XSUBs. #define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) #define PERL_DECIMAL_VERSION \ PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) #define PERL_VERSION_GE(r,v,s) \ (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) #if PERL_VERSION_GE(5, 15, 2) #define XS(name) XS_INTERNAL(name) #endif (WARNING: blead perl is still versioned as 5.15.1!) There may or may not be an ExtUtils::ParseXS feature that backports this to older versions of perl. The XS(name) definition in XSUB.h hasn't changed significantly since 5.10.0, so having an XS option akin to PROTOTYPES that works as far back as that is almost trivial. (Patches welcome). I'd like to hear whether using the above version-guarded redefinition makes a difference in Gtk2/etc load time! Best regards, Steffen
On Thu Aug 11 08:02:21 2011, SMUELLER wrote: Show quoted text
> I have just pushed a change to the core perl repository that adds the > XS_INTERNAL and XS_EXTERNAL macros that correspond to "static" and > exported XSUB symbols respectively. People seem to be fine with this > change, but there may, of course, still be a public outcry.
Just for the record: XS_INTERNAL and XS_EXTERNAL are part of the perl API and are free to use. Redefining XS(name) to force ExtUtils::ParseXS is a bit of a hack, but seems almost acceptable to me as I expect that we'll move to the static-by-default solution, so that virtually nobody has to use it.
It's been more or less decided that 5.16 to be will ONLY do static XSUBs and EU::ParseXS doesn't even have to know about it. For older versions of Perl, you'll have to redefine XS(name) to include a "STATIC" yourself. As mentioned earlier, this should work as far back as 5.10.0 at least since that part of XSUB.h had not been touched since then. I'm marking this as resolved even if it's not a solution within EU::ParseXS. Cheers, Steffen