Skip to content

Conversation

khwilliamson
Copy link
Contributor

This option has been broken for a long time, but this p.r. goes a long way to fixing that.

It works by creating a new file long_names.c that is automatically generated by regen/embed.pl. This file contains the API elements that normally are macros that don't have a separate long name. when NO_SHORT_NAMES is defined, those macros are suppressed, and instead the long-name functions in this file get compiled

The next yak (maybe the only one) needing to be shaved after this is inline functions that use short names. Since they currently are included in the user space, those short names need to be defined, but we're compiling without short names, so it doesn't work.

We could require inline functions to use long names, but I don't like that, and I suspect you don't either.

To me, the easiest other option is to just not have inline functions outside the core when short names are forbidden. We could easily convert them from being inline, and only include them from long_names.c. Thus they would become like any other function in the file.

  • This set of changes requires a perldelta entry

This simple change makes the perl core compile even with this flag.
Prior to this commit, a commented-out prototype was created for all
macros that we have argument and return type information for.  This
might be useful information for a reader of proto.h.

This commits stops doing this for private macros.  It makes a future
commit slightly easier, and I'm unsure of the usefulness of this anyway.
But I could be persuaded otherwise.
Where 'weird' is defined as meaning something that the normal rules
don't apply, so something we generate is unlikely to be correct.

This only affects one element, and it uses aTHX in a way that is
incompatible with it being automated.
This option has been broken for a long time, but this commit goes a long
way to fixing that.

It works by creating a new file long_names.c that is automatically
generated by regen/embed.pl.  This file contains the API elements that
normally are macros that don't have a separate long name.  when
NO_SHORT_NAMES is defined, those macros are suppressed, and instead the
long-name functions in this file get compiled

The next yak (maybe the only one) needing to be shaved after this is
inline functions that use short names.  Since they currently are
included in the user space, those short names need to be defined, but
we'rev compiling without short names, so it doesn't work.

We could require inline functions to use long names, but I don't like
that, and I suspect you don't either.

To me, the easiest other option is to just not have inline functions
outside the core when short names are forbidden.  We could easily
convert them from being inline, and only include them from long_names.c.
Thus they would become like any other function in the file.
@Leont
Copy link
Contributor

Leont commented Oct 7, 2025

I like the idea of this, I'm not sure the details are right.

In particular, it seems to be treating PERL_NO_SHORT_NAMES as something set at perl's compile-time, which it never should be. It only ever should be set by programs embedding perl (and maybe extending if someone it ever silly enough to write an XS alternative).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants