'h2ph' Tweaks for macOS 13 Ventura
In the spirit of, "Just Because You Can't Do Everything Doesn't Mean You Can't Do *ANYthing*..."
I've updated utils/h2ph.PL to work under recent versions of MacOS/Xcode:
- Track
typedef,struct, anduniondefinitions and add them to%isatypeso we can eliminate them later - Strip/quote
#if __has_include(<ptrcheck.h>)angle brackets - Generate a stub
%sizeoffrom the default%isatypeentries
FWIW, this was the Simplest Thing That Could Possibly Work™ to let me run:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
sudo h2ph -r -l .
perl -e 'require "sys/ioctl.ph"; ioctl(STDIN, TIOCSTI(), $_) for split "", "Hello, World!"'
If it's at all useful, hooray! 🤩
This p.r. had a failure in a test file specifically intended to exercise h2ph.
https://github.com/Perl/perl5/actions/runs/5590197642/job/15538527359?pr=21261
@DabeDotCom, could you respond to these comments on your pull request? Thanks.
@DabeDotCom, could you respond to these comments on your pull request? Thanks.
Hey, sorry for the delay... Once I got it working for myself, I had forgotten all about it! «sheepish grin»
This could be
length(pack("f", 0.0))
Would it make things even more bulletproof (i.e., provide more of a "belt and suspenders" solution) to include such a fallback for everything — including the missing charsize that got us into this situation in the first place?
### I debated using `||` since nothing *should* ever be `0`...
### but if `%Config` defines it as such, maybe there's a reason? «shrug»
char => $Config{charsize} // length(pack("c", 0)),
uchar => $Config{charsize} // length(pack("C", 0)),
u_char => $Config{charsize} // length(pack("C", 0)),
### I'm guessing we want `!` native sizes... [See `long`, below]
short => $Config{shortsize} // length(pack("s!", 0)),
ushort => $Config{shortsize} // length(pack("S!", 0)),
u_short => $Config{shortsize} // length(pack("S!", 0)),
int => $Config{intsize} // length(pack("i!", 0)),
uint => $Config{intsize} // length(pack("I!", 0)),
u_int => $Config{intsize} // length(pack("I!", 0)),
### On my 64-bit machines, `l` and `L` return 4, but `longsize` is 8 (Like `l!`)
long => $Config{longsize} // length(pack("l!", 0)),
ulong => $Config{longsize} // length(pack("L!", 0)),
u_long => $Config{longsize} // length(pack("L!", 0)),
FILE => $Config{ptrsize} // length(pack("p", 0)),
key_t => $Config{ptrsize} // length(pack("p", 0)),
caddr_t => $Config{ptrsize} // length(pack("p", 0)),
size_t => $Config{sizesize} // length(pack("p", 0)), # Is this the best default for `size_t`?
float => $Config{floatsize} // length(pack("f", 0.0)),
double => $Config{doublesize} // length(pack("d", 0.0)),
I don't think there's any need to fallback everything.
charsize also isn't defined in perl 5.10, 5.8.9:
$ ~/perl/5.8.8-nothread/bin/perl -V:charsize
charsize='1';
$ ~/perl/5.8.9-thr/bin/perl -V:charsize
charsize='UNKNOWN';
$ ~/perl/5.10.0-debug/bin/perl -V:charsize
charsize='UNKNOWN';
$ ~/perl/5.12.0/bin/perl -V:charsize
charsize='1';
(charsize was removed in 0ab0821a75 from Configure and everywhere and it appears to have been accidentally(?) added back to Configure in c193ef60f and then modified to always be 1 in Configure in 89c1d9143a.
This could be
length(pack("f", 0.0))
Okay, next question...
My fallbacks, as written, wouldn't have worked anyway because this is all in a print PREAMBLE <<SIZEOF heredoc:
print PREAMBLE <<SIZEOF;
%sizeof = (
...
float => $Config{floatsize} // length(pack("f", 0.0)),
double => $Config{doublesize} // length(pack("d", 0.0)),
So, I see now, $Config{foo} is evaluated by the .PL script and hardcoded into the resulting output — of course...
In that case, should float => length(pack("f", 0.0)) be evaluated and inserted the same way? (Not that it's wrong to re-calculate it again; it's just .0000001% less efficient. «grin»)
float => @{[ length(pack("f", 0.0)) ]},
double => $Config{doublesize},
There's also this, which @jkeenan pointed out in the workflows:
lib/Getopt/Std ................................................... ok
# Failed test 6 - output free of warnings at ../lib/h2ph.t line 55
# got "Deep recursion on subroutine \"main::__has_include\" at _h2ph_pre.ph line 671.\nCompilation failed in require at -e line 1.\n"
# expected ""
# diff at 0
# after ""
# have "Deep recursion on subroutine \"main::__ha"
# want ""
lib/h2ph ......................................................... FAILED at test 6
I haven't been able to reproduce it outside of CI, but it does seem to happen reliably there.
There has been no discussion in this p.r. in nearly 6 months. The branch does rebase cleanly on blead and an unthreaded build of that branch on Ubuntu Linux does PASS make test_harness for me.
Nevertheless, I am not convinced we should consider merging this code into the core. The amount of code changes in what, IMO, are these days quite obscure parts of the codebase do not seem to be warranted by any significant volume of complaints from macOS 13+ users.
There has been no discussion in this p.r. in nearly 6 months. The branch does rebase cleanly on blead and an unthreaded build of that branch on Ubuntu Linux does PASS
make test_harnessfor me.Nevertheless, I am not convinced we should consider merging this code into the core. The amount of code changes in what, IMO, are these days quite obscure parts of the codebase do not seem to be warranted by any significant volume of complaints from macOS 13+ users.
I am self-assigning this ticket for the purpose of closing it within 7 days unless someone else wants to take it over and steer it to completion.
I am self-assigning this ticket for the purpose of closing it within 7 days unless someone else wants to take it over and steer it to completion.
No takers; closing ticket.