Skip to content

Refactor ext/mbstring/libmbfl/config.h usage#13713

Open
petk wants to merge 1 commit intophp:masterfrom
petk:patch-mbstring-config
Open

Refactor ext/mbstring/libmbfl/config.h usage#13713
petk wants to merge 1 commit intophp:masterfrom
petk:patch-mbstring-config

Conversation

@petk
Copy link
Member

@petk petk commented Mar 14, 2024

This simplifies the libmbfl/config.h usage and removes duplicate compile definitions on Windows (HAVE_STRICMP).

The _WIN32 symbol is always defined when compiling on Windows with any current compiler, the HAVE_CONFIG_H symbol is defined only when doing phpize build inside mbstring extension (an edge case but if that is used by someone perhaps), otherwise the regular main/php_config.h is used.

This is sort of an addition to make it managing changes in #13516 easier. The include style of angle brackets is based on the linked PR. Perhaps we don't even need phpize build for the mbstring extension since it is part of the php-src core. But I'm not sure what is the accepted usage for this so I've added it like it was previously in the config.m4 file (the config.h included with absolute path).

I'm adding also @arnaud-lb in the PR to have an overview a bit and when @alexdowad has time for checking this a bit.

Regarding Windows, I have another change planned there with this HAVE_STRICMP but that is beyond the scope here and can be done in the future.

@alexdowad
Copy link
Contributor

@petk Thanks for working on this. I don't know enough about this part of the build system to know if this PR is a good idea or not. 😆

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

The change looks good to me. This causes ext/mbstring/libmbfl/ to diverge a bit more from the upstream, but as it's officially not kept in sync, I guess it's fine.

@arnaud-lb
Copy link
Member

Perhaps we don't even need phpize build for the mbstring extension since it is part of the php-src core

It can be sometimes useful to be able to build a single extension from php-src

@alexdowad
Copy link
Contributor

The change looks good to me. This causes ext/mbstring/libmbfl/ to diverge a bit more from the upstream, but as it's officially not kept in sync, I guess it's fine.

😄 PHP's vendored copy of libmbfl has diverged so much from upstream that it hardly makes sense to call it "libmbfl" any more. (Well, maybe that's an exaggeration, but not a big one.)

@petk
Copy link
Member Author

petk commented Mar 15, 2024

Yes, I agree. I'll change this differently without hardcoding the config.h... The built-in config.h file is kind of weird. Like something done in half. Even if it is completely forked library only used in php-src now. It's still good to separate these things as much as possible.

@petk petk force-pushed the patch-mbstring-config branch from 35ed3c5 to f97e8d5 Compare September 8, 2024 20:26
@petk petk requested a review from youkidearitai as a code owner September 8, 2024 20:26
@petk
Copy link
Member Author

petk commented Sep 8, 2024

Ok, in the appended new commit there is now only the main/php_config.h file included. I think that when building with phpize the extension's config.h is a bit redundant and misses few CPP macros. So the new appended commit is targeted here.

@petk petk force-pushed the patch-mbstring-config branch from f97e8d5 to 078f9de Compare December 5, 2024 12:24
@petk
Copy link
Member Author

petk commented Dec 5, 2024

I've now added more changes here. Details in the commit.

Probably the #include "libmbfl/config.h" should be also changed to #include <libmbfl/config.h> and this configuration header removed from being installed as it is used only in C files (I think).

@petk petk force-pushed the patch-mbstring-config branch 2 times, most recently from d1e7800 to ab53468 Compare March 6, 2026 13:19
@petk petk requested a review from TimWolla as a code owner March 6, 2026 13:19
This moves libmbfl configuration to mbstring extension level and syncs
the include style used as of PHP-8.4 to be able to do simultaneous
in-source and out-of-source builds. The HAVE_CONFIG_H file is when doing
phpize build using Autotools.

Checks for strcasecmp and strings.h are also moved to mbstring extension
only.

The libmbfl/config.h header is now also NOT installed anymore as it is a
private header used only in C files as part of the build interface
(during build phase only).

The libmbfl/config.h is included with angled style so the include flags
take precedence and simultaneous php-src building in-source and
out-of-source can be performed.
@petk petk force-pushed the patch-mbstring-config branch from ab53468 to 1601eed Compare March 6, 2026 13:42
@petk
Copy link
Member Author

petk commented Mar 6, 2026

For the time being, I've rebased this PR against current master branch and also removed the libmbfl/config.h from being installed as it was not meant to be a public header. Yes, this is "fun". Having libraries bundled in php-src and diverging them from being standalone is quite messy but no other way is possible here. I'll check more later on.

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.

3 participants