-
Notifications
You must be signed in to change notification settings - Fork 268
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
Fixing Build Regression [BISON] #892
Conversation
Hm. I was trying to test this but
I reviewed the project README and I'm not seeing any obvious missing dependency. Clearing out |
Interestingly, I removed |
Ran some smoke tests and everything seemed to be working across various PHP versions. The |
packages/php-wasm/compile/build.js
Outdated
@@ -167,7 +167,10 @@ if (!requestedVersion || requestedVersion === 'undefined') { | |||
const sourceDir = path.dirname(new URL(import.meta.url).pathname); | |||
|
|||
// Build the base image | |||
await asyncSpawn('make', ['base-image'], { cwd: sourceDir, stdio: 'inherit' }); | |||
await asyncSpawn('make', ['all', 'base-image'], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the base-image
depend on the all
target or is that incidental here?
otherwise it seems like the Makefile
would be the place to list dependencies, wouldn't it? why aren't we putting it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmsnell The base-image
target does not depend on the all
target.
wordpress-playground/packages/php-wasm/compile/Makefile
Lines 1 to 2 in db34c27
base-image: base-image/.ready | |
base-image/.ready: |
(Its generally poor practice to use a PHONY
target as a dependency because that means anything downstream from that target would be rebuilt on every invocation.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmsnell Actually its fine so long as phony targets are used as dependencies ONLY of other phony targets:
wordpress-playground/packages/php-wasm/compile/Makefile
Lines 9 to 13 in c4cfd1e
.PHONY: all libz libzip libpng16 libxml2 libopenssl libsqlite3 libiconv libncurses libedit bison2.7 oniguruma base-image clean | |
all: libz libzip libpng16 libxml2 libopenssl libsqlite3 libiconv libncurses libedit bison2.7 oniguruma base-image | |
clean: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanmorris I think we might have jumped a little too quickly here. I wasn't asking if base-image
currently is encoded as depending on all
, but rather was asking about your change, which seemed to be encoding a dependency outside of the Makefile
. previously we asked for base-image
, but with your change we were also asking for all
. this communicated to me that all
is necessary to build base-image
, and if that were actually true then I think it would be best to leave the dependencies inside make
where they are handled robustly.
as for .PHONY
I think there may also be some misunderstandings. we should use them wherever they are part of a dependency hierarchy, whether or not they are a dependency of another .PHONY
or not. the distinction is purely whether the .PHONY
targets need to be rebuilt every time make
runs. for example, it could be that some build target needs to download a configuration from the internet. that download would be a candidate .PHONY
target, but that doesn't force other targets to rebuild because we could make those other targets depend on the downloaded configuration file directly, and simply not update it if the download is the same as it previously was.
.PHONY: fetch-config
fetch-config:
curl https://my.site/config.json -o /tmp/config.json
diff -q -s /tmp/config.json ./config.json
if [ $? -ne 0 ]; then mv /tmp/config.json ./config.json; fi
libsomething: ./config.json
build-lib-something
making all
a .PHONY
target is common because people generally don't want to put sub-dependencies on the all
target, and even if all
is .PHONY
and runs every time, if the dependencies of the dependencies haven't changed than nothing much will run.
so we want to be judicious and thoughtful when applying .PHONY
, but it's also not something we want to try and avoid; we only want to understand its purpose and value and use it where appropriate.
I can see that we have a number of ways we could improve the Makefile
, but those don't need to occur in this PR.
packages/php-wasm/compile/Makefile
Outdated
|
||
# If you write a rule whose recipe will not create the target file, | ||
# the recipe will be executed every time the target comes up for remaking. | ||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I love comments like this, but I also think it's okay if we don't add it, because .PHONY
is a pretty standard feature of Makefile syntax and there should be ample documentation available for someone to understand it. We don't document the other parts of the Makefile syntax here, and it's probably okay to let the PHONY exist as is.
# If you write a rule whose recipe will not create the target file, | ||
# the recipe will be executed every time the target comes up for remaking. | ||
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html | ||
.PHONY: all libz libzip libpng16 libxml2 libopenssl libsqlite3 libiconv libncurses libedit bison2.7 oniguruma base-image clean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do all of these need to be .PHONY
? I wouldn't ask other than it seems like this patch is now adding that property to the targets, and it wasn't there before.
of course, adding .PHONY
will ensure they're built every time we run make
, but particularly for the libraries like libpng16
and libzip
it seems like we could be more efficient in general if we based the build on some deterministic element like a version number, build architecture, or source files, etc…
I guess the important question is whether you found something in this PR that was broken because dependencies didn't get rebuilt when they should have. if that's the case then .PHONY
seems like a fair addition; if not, maybe we let it stay the way it was and address that separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Makefile should have originally listed these targets as .PHONY
because the names being used are the same as the directories in which the actual artifacts lie. Unintentionally, if that directory has a modification date newer than its dependencies, it would then INCORRECTLY be marked as cached and skipped. Adding the .PHONY
target instructs Make to skip looking at the directory modification time and instead look at the listed dependencies only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. This makes more sense now, as I didn't realize that the directories of the same name as the phony targets existed (because I hadn't looked that deeply outside of the diff).
Let's make sure to add this in the commit description, that this fixes a bug we already had, wherein the .PHONY
should have always been there.
packages/php-wasm/compile/Makefile
Outdated
rm -rf ./libedit/dist | ||
rm -rf ./bison2.7/dist | ||
rm -rf ./oniguruma/dist | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these don't need to appear first. without any arguments, make
will run the first target, which is why all
is a common first target. clean
doesn't need to move unless there's a reason to do it.
packages/php-wasm/compile/build.js
Outdated
@@ -167,7 +167,10 @@ if (!requestedVersion || requestedVersion === 'undefined') { | |||
const sourceDir = path.dirname(new URL(import.meta.url).pathname); | |||
|
|||
// Build the base image | |||
await asyncSpawn('make', ['base-image'], { cwd: sourceDir, stdio: 'inherit' }); | |||
await asyncSpawn('make', [], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice here to leave some explicit intention in the code. although it happens to work with the changes you made to the Makefile
, we've lost the linkage between asking for what we want (with the pre-existing base-image
) and running make
and hoping it does what we need (because no more target is listed).
adding base-image
here would be helpful, or all
, or anything to communicate to our future selves what our purupose was in running make
.
packages/php-wasm/compile/build.js
Outdated
@@ -167,7 +167,10 @@ if (!requestedVersion || requestedVersion === 'undefined') { | |||
const sourceDir = path.dirname(new URL(import.meta.url).pathname); | |||
|
|||
// Build the base image | |||
await asyncSpawn('make', ['base-image'], { cwd: sourceDir, stdio: 'inherit' }); | |||
await asyncSpawn('make', ['all', 'base-image'], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanmorris I think we might have jumped a little too quickly here. I wasn't asking if base-image
currently is encoded as depending on all
, but rather was asking about your change, which seemed to be encoding a dependency outside of the Makefile
. previously we asked for base-image
, but with your change we were also asking for all
. this communicated to me that all
is necessary to build base-image
, and if that were actually true then I think it would be best to leave the dependencies inside make
where they are handled robustly.
as for .PHONY
I think there may also be some misunderstandings. we should use them wherever they are part of a dependency hierarchy, whether or not they are a dependency of another .PHONY
or not. the distinction is purely whether the .PHONY
targets need to be rebuilt every time make
runs. for example, it could be that some build target needs to download a configuration from the internet. that download would be a candidate .PHONY
target, but that doesn't force other targets to rebuild because we could make those other targets depend on the downloaded configuration file directly, and simply not update it if the download is the same as it previously was.
.PHONY: fetch-config
fetch-config:
curl https://my.site/config.json -o /tmp/config.json
diff -q -s /tmp/config.json ./config.json
if [ $? -ne 0 ]; then mv /tmp/config.json ./config.json; fi
libsomething: ./config.json
build-lib-something
making all
a .PHONY
target is common because people generally don't want to put sub-dependencies on the all
target, and even if all
is .PHONY
and runs every time, if the dependencies of the dependencies haven't changed than nothing much will run.
so we want to be judicious and thoughtful when applying .PHONY
, but it's also not something we want to try and avoid; we only want to understand its purpose and value and use it where appropriate.
I can see that we have a number of ways we could improve the Makefile
, but those don't need to occur in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @seanmorris - looks good in the merge.
Just to confirm — does this PR:
Or does it always trigger a full rebuild? It’s not apparent to me from the description and I’d like to avoid a full rebuild each time. if this Pr only rebuilds bison, we’re good. However, if it does trigger a full rebuild, let’s revert and explore what I suggested in the other PR: #871 (comment) |
sorry @adamziel for missing the comment you linked; I may have misunderstood this PR's goal, which I took from the PR's description and chats with @seanmorris. as he and I discussed, I think there definitely are mislabeled or missing dependencies, and it sounds like your suggestion would address that more directly. if there's a problem occurring because we're not building bison, this PR fixes that problem bluntly by making sure it's built while building the base image. I'll let @seanmorris share his thoughts before I do any reverts, as I think we can still move the two ideas together first by making the build slow but reliable (if this does that) and then by optimizing the Makefile. |
Reverts #892 Context: #892 (comment)
What is this PR doing?
This PR corrects the same Bison2.7 issue as #871, in a much simpler fashion.
What problem is it solving?
Bison2.7 will not be built in some cases, blocking the build of PHP <= 7.3.
How is the problem addressed?
This invokes dependency builds before building PHP.
Testing Instructions
Checkout the branch & install the dependencies:
In a separate terminal, clear the artifacts:
docker system prune -af cd packages/php-wasm/compile make clean
Run the build and ensure it succeeds:
Start the dev server:
Then, navigate to:
... and ensure that wordpress works as-expected in each environment.