Skip to content

Autotools: Add PHP_EXTRA_CFLAGS environment variable #15707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petk
Copy link
Member

@petk petk commented Sep 1, 2024

This adds a new configure-phase environment variable PHP_EXTRA_CFLAGS which are appended to the CFLAGS in the Makefile rules. It sets the already present undocumented EXTRA_CFLAGS Makefile variable to not introduce issues with EXTRA_CFLAGS usage in the existing PECL extensions.

This enables setting configure-and-build-phase CFLAGS and build-phase PHP_EXTRA_CFLAGS separately to not affect configure checks:

./configure CFLAGS=... PHP_EXTRA_CFLAGS=...

Follow-up of #12050

This adds a new configure-phase environment variable PHP_EXTRA_CFLAGS
which are appended to the CFLAGS in the Makefile rules. It sets the
already present undocumented EXTRA_CFLAGS Makefile variable to not
introduce issues with EXTRA_CFLAGS usage in the existing PECL
extensions.

This enables setting configure-and-build-phase CFLAGS and build-phase
PHP_EXTRA_CFLAGS separately to not affect configure checks:

    ./configure CFLAGS=... PHP_EXTRA_CFLAGS=...
@petk
Copy link
Member Author

petk commented Sep 1, 2024

I'm still rechecking if this can be done differently a bit by modifying CFLAGS manually in the configure.ac directly. Because other Autotools based projects don't normally set such variable these days anymore. But Autoconf approach is otherwise to still set it separately from the CFLAGS... 🤔

@petk
Copy link
Member Author

petk commented Sep 3, 2024

@iluuu1994 sorry for pinging you here. Do you remember perhaps again why would it be necessary to add extra compile options to the build through the variable? Is there still any case where using CFLAGS is cumbersome for that? Or was that issue only the override of the default Autoconf flags because that -g -O2 got removed doing that (for example, ./configure CFLAGS=-DFOOBAR=1). Basically, the EXTRA_CFLAGS shouldn't be necessary or they would somewhere?

@petk petk marked this pull request as draft September 3, 2024 00:39
@iluuu1994
Copy link
Member

Or was that issue only the override of the default Autoconf flags because that -g -O2 got removed doing that (for example, ./configure CFLAGS=-DFOOBAR=1).

That was the primary one, but you also made this comment:
#12050 (comment)

The Clang+Cpp+Asan issue still exists. The build system will add the -fsanitize= flags not only to CFLAGS but also CXXFLAGS (as it should). However, Clang requires linking with clang++ when compiling C++ files with -fsanitize= for some reason. Do you reckon we can fix this? I'm not sure what the best approach would be.

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