Skip to content

Conversation

@petk
Copy link
Member

@petk petk commented Mar 1, 2024

The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled using AC_LIBOBJ in case stat.st_blocks is missing on some system. This can be simplified with the usual AC_CHECK_MEMBERS since PHP is using the stat.st_blocks (and stat.st_blksize) conditionally.

This also removes the obsolete HAVE_ST_BLOCKS symbol.

https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055

@petk
Copy link
Member Author

petk commented Mar 1, 2024

Hm, I guess, PHP needs more adjustments then if these are missing...

php-src/ext/phar/stream.c: In function ‘phar_dostat’:
php-src/ext/phar/stream.c:535:17: error: ‘zend_stat_t’ {aka ‘struct stat’} has no member named ‘st_blksize’; did you mean ‘st_size’?
  535 |         ssb->sb.st_blksize = -1;
      |                 ^~~~~~~~~~
      |                 st_size
php-src/ext/phar/stream.c:536:16: error: ‘zend_stat_t’ {aka ‘struct stat’} has no member named ‘st_blocks’
  536 |         ssb->sb.st_blocks = -1;
      |                ^
make: *** [Makefile:1592: ext/phar/stream.lo] Error 1
make: *** Waiting for unfinished jobs....
php-src/ext/phar/func_interceptors.c: In function ‘phar_file_stat’:
php-src/ext/phar/func_interceptors.c:642:28: error: ‘zend_stat_t’ {aka ‘struct stat’} has no member named ‘st_blksize’; did you mean ‘st_size’?
  642 |                         sb.st_blksize = -1;
      |                            ^~~~~~~~~~
      |                            st_size
php-src/ext/phar/func_interceptors.c:643:27: error: ‘zend_stat_t’ {aka ‘struct stat’} has no member named ‘st_blocks’
  643 |                         sb.st_blocks = -1;
      |                           ^
make: *** [Makefile:1595: ext/phar/func_interceptors.lo] Error 1

@petk petk marked this pull request as draft March 1, 2024 08:07
The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with
AC_LIBOBJ if stat.st_blocks is missing on the system. This can be
simplified with the usual AC_CHECK_MEMBERS since PHP is using the
stat.st_blocks (and stat.st_blksize) conditionally.

These members are mostly present on all POSIX-based systems except on
Windows these days.

This also removes the obsolete HAVE_ST_BLOCKS symbol:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055

Additionally, the st_blksize and st_blocks members are checked
conditionally with HAVE_ preprocessor macros. Instead of filtering
Windows specifically here, the preprocessor macros
HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
@petk
Copy link
Member Author

petk commented Sep 1, 2024

Patch updated a bit further and branch rebased. It seems that there was a plan here to implement the missing st_blksize and st_blocks stat members on Windows at some point also. I'll wait with this PR a bit further as isn't critical. It only makes it a bit clearer how the usage should be done at this point. Also those above errors are not relevant in PHP as these two members are used conditionally in the code.

@petk petk marked this pull request as ready for review September 1, 2024 22:45
@petk petk requested a review from bukka as a code owner September 1, 2024 22:45
Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can probably wait after creating PHP-8.5 branch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants