It seems passing /Debug:FastLink
to the linker does the job for the final executable (I tested on MSVC 19.43.34808), but it only solves half the problem, because the compiler still produces nondeterministic object files, so it doesn't help for caching the object files etc.
If anyone has a complete solution, please post it.