Michael -
> Hmm, just to be sure: you run Emacs 27.1 with the patched compile.el,
> and you run Tramp 2.5.0.1 from GNU ELPA, with the patch in
> tramp-integration.el?
Actually, I was running Emacs 27.1 with the patched compile.el, and tramp *as it comes in 27.1* with the patch applied to tramp-integration.el.
Prompted by your question, I downloaded Tramp 2.5.0.1 from GNU ELPA and copied those .el files over the tramp files in .../lisp/net, applied the patch in tramp-integration.el and recompiled the macos application. I have the patched compile.el included as well, just to be clear.
I checked in run time, tramp-compile-advice-add and compilation-start-hook are defined as we'd wish.
Unfortunately, I see no change in behaviour. If I click on a syntax error message while compiling test.cpp in the autotools project via tramp, the compile hangs until I ctrl-g out.
Not sure why the difference vs. your setup, sorry.
Best regards,
Duncan.