Please add a `-l` flag to `cp`

Number:rdar://FB8957277 Date Originated:2020 Dec 30
Status: Resolved:
Product:macOS Product Version:
Classification:feature request Reproducible:
On Linux and FreeBSD, `cp` has a `-l` flag that makes it create hardlinks instead of copies of files.

This is useful for example for a custom build system that links a binary in one place and then wants to copy it into a framework directory structure. The linked binary might be large, so doing a physical copy is slow. macOS `cp` has a `-c` flag that makes a copy-on-write clone. This makes the copy fast, but on the next build the linker will overwrite the original file, which then causes all the data to be copy-on-write at that point -- only to have all that data be overwritten when the link output is copied into the framework later in the build. With `cp -l`, things would Just Work.

See also for some background around this feature request.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!