-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add dependency tracking for header files #6693
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
Conversation
Huh, this is a lot simpler than I expected. Works fine for me with both in-tree and out-of-tree builds. This doesn't work for out-of-tree extension builds, because |
With this patch, this hack can be removed as well: Lines 159 to 161 in 549235d
|
This ensures all .c files which include a header file directly or indirectly are rebuilt whenever the header file is changed.
323a763
to
581f718
Compare
Thank you very much for the feedback. I removed the feature check. I don't know of any compiler which does not support those flags. So I think this should be safe. I also removed the rule from the |
I've landed this in master. If it doesn't cause issues for anyone, we should probably backport it to earlier versions, as the change is so simple. |
So here is a use case that no longer works due to this change. Imagine you want to build PHP for distributing it in some way, and you're installing it into So you do this for PHP:
Now, a PECL extension:
The problem is that step 7 no longer works - the
This results in the
Building extensions for 8.0 or lower doesn't generate such a Is this side effect for extensions intentional? The previous behavior was very useful for quickly and cleanly packaging extensions. The workaround is to
and archive that instead, although I wish that instead of Any thoughts, @rioderelfte and @nikic ? |
That side effect was not intentional, no. Thanks for bringing it up. I think this can be worked around by adding |
Will check @rioderelfte ! |
The idea is to If so, then that doesn't help: $ ./configure --prefix=$PHPBASEDIR
…
$ make CPPFLAGS=-MP -s -j 9
…
cc -I. -I/tmp/bob-ST2z9k/pcov-1.0.10 -I/tmp/bob-ST2z9k/pcov-1.0.10/include -I/tmp/bob-ST2z9k/pcov-1.0.10/main -I/tmp/bob-ST2z9k/pcov-1.0.10 -I/app/.heroku/php/include/php -I/app/.heroku/php/include/php/main -I/app/.heroku/php/include/php/TSRM -I/app/.heroku/php/include/php/Zend -I/app/.heroku/php/include/php/ext -I/app/.heroku/php/include/php/ext/date/lib -MP -g -O2 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /tmp/bob-ST2z9k/pcov-1.0.10/pcov.c -MMD -MF pcov.dep -MT pcov.lo -fPIC -DPIC -o .libs/pcov.o
cc -shared .libs/pcov.o -Wl,-soname -Wl,pcov.so -o .libs/pcov.so
creating pcov.la
(cd .libs && rm -f pcov.la && ln -s ../pcov.la pcov.la)
cp ./.libs/pcov.so /tmp/bob-ST2z9k/pcov-1.0.10/modules/pcov.so
cp ./.libs/pcov.lai /tmp/bob-ST2z9k/pcov-1.0.10/modules/pcov.la
PATH="$PATH:/sbin" ldconfig -n /tmp/bob-ST2z9k/pcov-1.0.10/modules
----------------------------------------------------------------------
Libraries have been installed in:
/tmp/bob-ST2z9k/pcov-1.0.10/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'. $ rm -rf $PHPBASEDIR/* $ make install -s
cc -I. -I/tmp/bob-ST2z9k/pcov-1.0.10 -I/tmp/bob-ST2z9k/pcov-1.0.10/include -I/tmp/bob-ST2z9k/pcov-1.0.10/main -I/tmp/bob-ST2z9k/pcov-1.0.10 -I/app/.heroku/php/include/php -I/app/.heroku/php/include/php/main -I/app/.heroku/php/include/php/TSRM -I/app/.heroku/php/include/php/Zend -I/app/.heroku/php/include/php/ext -I/app/.heroku/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /tmp/bob-ST2z9k/pcov-1.0.10/pcov.c -MMD -MF pcov.dep -MT pcov.lo -fPIC -DPIC -o .libs/pcov.o
/tmp/bob-ST2z9k/pcov-1.0.10/pcov.c:23:10: fatal error: php.h: No such file or directory
#include "php.h"
^~~~~~~
compilation terminated.
Makefile:201: recipe for target 'pcov.lo' failed
make: *** [pcov.lo] Error 1 FWIW, this is different from the previous output of $ make install -s
make: *** No rule to make target '/app/.heroku/php/include/php/main/php.h', needed by 'pcov.lo'. Stop. |
Or did I misunderstand you, @rioderelfte ? |
No, you did not misunderstand me – that was exactly what I had in mind. But it makes sense that it does not work, now that I think about it. The newly generated targets for the header files result in the compile target being considered outdated by make. So make tries to recompile the code during install and this fails with the headers missing. I can't think of any obvious fixes then, unfortunately. Why does using An alternative would be to add a configure flag to disable the dependency tracking. |
Yes, exactly. The objective is to have an archive of only the built extension, without any build-time dependencies that might be sharing parts of the path. It's not really a huge issue; I can just use I think An alternative might be to have a cleanup task that only removes the |
This ensures all .c files which include a header file directly or indirectly are rebuilt whenever the header file is changed.
By adding the flags to
PHP_ADD_SOURCES_X
this change should also work for out of tree extensions, though this was not tested.I used the
.dep
extension instead of the default extension.d
since there are already some dtrace files with extension.d
which would clash with the dependency files.At least the change to the
.gitignore
should probably be ported to the other branches as well. Otherwise there will be a lot of untracked files after building master and changing to a different branch.