Skip to content

Fix macOS posix_spawn_file_actions_addchdir availability handling#21722

Open
arshidkv12 wants to merge 6 commits intophp:masterfrom
arshidkv12:mac
Open

Fix macOS posix_spawn_file_actions_addchdir availability handling#21722
arshidkv12 wants to merge 6 commits intophp:masterfrom
arshidkv12:mac

Conversation

@arshidkv12
Copy link
Copy Markdown
Contributor

/* The non-_np variant is in macOS 26 (and _np deprecated) */
#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir
static inline int php_spawn_addchdir(
Copy link
Copy Markdown
Member

@NattyNarwhal NattyNarwhal Apr 13, 2026

Choose a reason for hiding this comment

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

I think this might be able to be simplified by checking __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__/__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ instead, since we don't need any real runtime differences, it's just a symbol name, and the old one is unlikely to go away right now even if it's deprecated. It should respect -mmacosx-version-min as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you

@NattyNarwhal
Copy link
Copy Markdown
Member

Still triggers the deprecation on 26;

/Users/calvin/src/php-src/ext/standard/proc_open.c:1409:7: error: 'posix_spawn_file_actions_addchdir_np' is deprecated: first deprecated in macOS
      26.0 - posix_spawn_file_actions_addchdir(3) has replaced posix_spawn_file_actions_addchdir_np(3) [-Werror,-Wdeprecated-declarations]
 1409 |                 r = POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(&factions, cwd);
      |                     ^
/Users/calvin/src/php-src/ext/standard/proc_open.c:53:44: note: expanded from macro 'POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR'
   53 |         #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np
      |                                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/spawn.h:182:9: note: 
      'posix_spawn_file_actions_addchdir_np' has been explicitly marked deprecated here
  182 | int     posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *,
      |         ^

I think you need the AvailabilityMacros.h header to use the unembellished macro names:

calvin@anika-5 php-src % echo | cc -dM -E -mmacosx-version-min=10.15 - | grep MAC_OS_X_VERSION_MIN_REQUIRED
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101500
calvin@anika-5 php-src % echo "#include <AvailabilityMacros.h>" | cc -dM -E -mmacosx-version-min=10.15 - | grep MAC_OS_X_VERSION_MIN_REQUIRED
#define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 101500
#define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__

@NattyNarwhal
Copy link
Copy Markdown
Member

Builds with -enable-werror for me on 26 (well, and -Wno-unterminated-string-initialization, but that's a lexbor thing).

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