Use clonefile instead of copyfile on macOS. (#10020)