Skip to content

Fix C++ build - #24786

Merged
arnaud-lb merged 1 commit into
php:masterfrom
arnaud-lb:fix-cpp-build
Oct 27, 2026
Merged

arnaud-lb merged 1 commit into
php:masterfrom
arnaud-lb:fix-cpp-build

Conversation

@arnaud-lb

@arnaud-lb arnaud-lb commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Broke the build while merging #24585 up, as I didn't anticipate that the header needs to be C++ compatible when building intl.

I'm wondering if we should eventually re-introduce a smaller zend_atomics.h header for C++ compat.

For now I would like to fix the build.

cc @henderkes @devnexen

Comment thread Zend/zend_types.h Outdated
{
static_assert(sizeof(_Atomic uint32_t) == sizeof(uint32_t), "atomic size");
static_assert(alignof(_Atomic uint32_t) == alignof(uint32_t), "atomic align");
#ifdef __cplusplus

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#ifdef __cplusplus
#ifdef __cplusplus
static_assert(sizeof(std::atomic<uint32_t>) == sizeof(uint32_t), "atomic size");
static_assert(alignof(std::atomic<uint32_t>) == alignof(uint32_t), "atomic align");
static_assert(ATOMIC_INT_LOCK_FREE == 2, "not always lock-free");
uint32_t type_info = reinterpret_cast<const std::atomic<uint32_t> *>(&GC_TYPE_INFO(s))->load(std::memory_order_acquire);
#else
static_assert(sizeof(_Atomic uint32_t) == sizeof(uint32_t), "atomic size");
static_assert(alignof(_Atomic uint32_t) == alignof(uint32_t), "atomic align");
static_assert(ATOMIC_INT_LOCK_FREE == 2, "not always lock-free");
uint32_t type_info = atomic_load_explicit((_Atomic uint32_t *)&GC_TYPE_INFO(s), memory_order_acquire);
#endif

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you. I've pushed a simplified version before seeing this comment because MSVC also doesn't have ATOMIC_INT_LOCK_FREE == 2 in C.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks ok per see.

@henderkes

Copy link
Copy Markdown
Contributor

I'm wondering if we should eventually re-introduce a smaller zend_atomics.h header for C++ compat.

I think a file just for atomics because of C++ is overkill, perhaps a typedef (#ifdef cplusplus) in zend_portability.h would do?

@arnaud-lb
arnaud-lb marked this pull request as ready for review October 27, 2026 14:42
@arnaud-lb
arnaud-lb requested a review from dstogov as a code owner October 27, 2026 14:42
@arnaud-lb

Copy link
Copy Markdown
Member Author

@henderkes that would be ideal indeed

@arnaud-lb

Copy link
Copy Markdown
Member Author

I'm going to merge this to fix the build for now

@arnaud-lb
arnaud-lb merged commit 7155662 into php:master Oct 27, 2026
18 checks passed
@LamentXU123

Copy link
Copy Markdown
Member

@arnaud-lb I think you should also backport this to 8.6?

@arnaud-lb

Copy link
Copy Markdown
Member Author

@LamentXU123 is 8.6 broken too?

@LamentXU123

Copy link
Copy Markdown
Member

Oh my bad. I look into the wrong branch. Sry :)

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.

4 participants