Unlike project-shell-command, project-compile first prompts for a
command, then binds default-directory and calls compile. Binding
default-directory first makes completion work from the project root,
which is useful for completing on filenames relative to the root, on
targets from the toplevel Makefile, etc.
I see three ways to achieve this:
(1) Rewrite project-compile with call-interactively, the way
project-shell-command is written (see patch #1).
(2) Set COMMAND to nil in the interactive spec, then prompt for it after
binding default-directory (see patch #2).
(3) Let-binding default-directory once in the interactive spec, and
again before calling compile.
I'm assuming (1) is out of the question, given 2020-06-02
"* lisp/progmodes/project.el (project-vc-dir, project-shell): New
commands." (2c1e5b9e77). I'm CC'ing Juri to get his opinion though;
project-compile is new in Emacs 28.1, so its argument list is not yet
set in stone.